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

Function vm_thread_swapout

freebsd/vm/vm_swapout.c:527–550  ·  view source on GitHub ↗

* Allow a thread's kernel stack to be paged out. */

Source from the content-addressed store, hash-verified

525 * Allow a thread's kernel stack to be paged out.
526 */
527static void
528vm_thread_swapout(struct thread *td)
529{
530 vm_page_t m;
531 vm_offset_t kaddr;
532 vm_pindex_t pindex;
533 int i, pages;
534
535 cpu_thread_swapout(td);
536 kaddr = td->td_kstack;
537 pages = td->td_kstack_pages;
538 pindex = atop(kaddr - VM_MIN_KERNEL_ADDRESS);
539 pmap_qremove(kaddr, pages);
540 VM_OBJECT_WLOCK(kstack_object);
541 for (i = 0; i < pages; i++) {
542 m = vm_page_lookup(kstack_object, pindex + i);
543 if (m == NULL)
544 panic("vm_thread_swapout: kstack already missing?");
545 vm_page_dirty(m);
546 vm_page_xunbusy_unchecked(m);
547 vm_page_unwire(m, PQ_LAUNDRY);
548 }
549 VM_OBJECT_WUNLOCK(kstack_object);
550}
551
552/*
553 * Bring the kernel stack for a specified thread back in.

Callers 1

swapoutFunction · 0.85

Calls 6

vm_page_lookupFunction · 0.85
vm_page_dirtyFunction · 0.85
vm_page_unwireFunction · 0.85
cpu_thread_swapoutFunction · 0.50
pmap_qremoveFunction · 0.50
panicFunction · 0.50

Tested by

no test coverage detected