MCPcopy Create free account
hub / github.com/F-Stack/f-stack / vm_thread_swapin

Function vm_thread_swapin

freebsd/vm/vm_swapout.c:555–589  ·  view source on GitHub ↗

* Bring the kernel stack for a specified thread back in. */

Source from the content-addressed store, hash-verified

553 * Bring the kernel stack for a specified thread back in.
554 */
555static void
556vm_thread_swapin(struct thread *td, int oom_alloc)
557{
558 vm_page_t ma[KSTACK_MAX_PAGES];
559 vm_offset_t kaddr;
560 int a, count, i, j, pages, rv;
561
562 kaddr = td->td_kstack;
563 pages = td->td_kstack_pages;
564 vm_thread_stack_back(td->td_domain.dr_policy, kaddr, ma, pages,
565 oom_alloc);
566 for (i = 0; i < pages;) {
567 vm_page_assert_xbusied(ma[i]);
568 if (vm_page_all_valid(ma[i])) {
569 i++;
570 continue;
571 }
572 vm_object_pip_add(kstack_object, 1);
573 for (j = i + 1; j < pages; j++)
574 if (vm_page_all_valid(ma[j]))
575 break;
576 VM_OBJECT_WLOCK(kstack_object);
577 rv = vm_pager_has_page(kstack_object, ma[i]->pindex, NULL, &a);
578 VM_OBJECT_WUNLOCK(kstack_object);
579 KASSERT(rv == 1, ("%s: missing page %p", __func__, ma[i]));
580 count = min(a + 1, j - i);
581 rv = vm_pager_get_pages(kstack_object, ma + i, count, NULL, NULL);
582 KASSERT(rv == VM_PAGER_OK, ("%s: cannot get kstack for proc %d",
583 __func__, td->td_proc->p_pid));
584 vm_object_pip_wakeup(kstack_object);
585 i += count;
586 }
587 pmap_qenter(kaddr, ma, pages);
588 cpu_thread_swapin(td);
589}
590
591void
592faultin(struct proc *p)

Callers 1

faultinFunction · 0.85

Calls 9

vm_thread_stack_backFunction · 0.85
vm_page_all_validFunction · 0.85
vm_object_pip_addFunction · 0.85
vm_pager_has_pageFunction · 0.85
minFunction · 0.85
vm_pager_get_pagesFunction · 0.85
vm_object_pip_wakeupFunction · 0.85
pmap_qenterFunction · 0.50
cpu_thread_swapinFunction · 0.50

Tested by

no test coverage detected