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

Function vm_pageout_worker

freebsd/vm/vm_pageout.c:2085–2171  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2083}
2084
2085static void
2086vm_pageout_worker(void *arg)
2087{
2088 struct vm_domain *vmd;
2089 u_int ofree;
2090 int addl_shortage, domain, shortage;
2091 bool target_met;
2092
2093 domain = (uintptr_t)arg;
2094 vmd = VM_DOMAIN(domain);
2095 shortage = 0;
2096 target_met = true;
2097
2098 /*
2099 * XXXKIB It could be useful to bind pageout daemon threads to
2100 * the cores belonging to the domain, from which vm_page_array
2101 * is allocated.
2102 */
2103
2104 KASSERT(vmd->vmd_segs != 0, ("domain without segments"));
2105 vmd->vmd_last_active_scan = ticks;
2106
2107 /*
2108 * The pageout daemon worker is never done, so loop forever.
2109 */
2110 while (TRUE) {
2111 vm_domain_pageout_lock(vmd);
2112
2113 /*
2114 * We need to clear wanted before we check the limits. This
2115 * prevents races with wakers who will check wanted after they
2116 * reach the limit.
2117 */
2118 atomic_store_int(&vmd->vmd_pageout_wanted, 0);
2119
2120 /*
2121 * Might the page daemon need to run again?
2122 */
2123 if (vm_paging_needed(vmd, vmd->vmd_free_count)) {
2124 /*
2125 * Yes. If the scan failed to produce enough free
2126 * pages, sleep uninterruptibly for some time in the
2127 * hope that the laundry thread will clean some pages.
2128 */
2129 vm_domain_pageout_unlock(vmd);
2130 if (!target_met)
2131 pause("pwait", hz / VM_INACT_SCAN_RATE);
2132 } else {
2133 /*
2134 * No, sleep until the next wakeup or until pages
2135 * need to have their reference stats updated.
2136 */
2137 if (mtx_sleep(&vmd->vmd_pageout_wanted,
2138 vm_domain_pageout_lockptr(vmd), PDROP | PVM,
2139 "psleep", hz / VM_INACT_SCAN_RATE) == 0)
2140 VM_CNT_INC(v_pdwakeups);
2141 }
2142

Callers 1

vm_pageoutFunction · 0.85

Calls 7

vm_paging_neededFunction · 0.85
pidctrl_daemonFunction · 0.85
vm_pageout_lowmemFunction · 0.85
minFunction · 0.85
vm_pageout_inactiveFunction · 0.85
vm_pageout_active_targetFunction · 0.85
vm_pageout_scan_activeFunction · 0.85

Tested by

no test coverage detected