Lines Matching defs:vmd
124 static void vm_pageout_mightbe_oom(struct vm_domain *vmd, int page_shortage,
206 static int vm_pageout_launder(struct vm_domain *vmd, int launder,
692 vm_pageout_launder(struct vm_domain *vmd, int launder, bool in_shortfall)
722 marker = &vmd->vmd_markers[queue];
723 pq = &vmd->vmd_pagequeues[queue];
959 struct vm_domain *vmd;
966 vmd = VM_DOMAIN(domain);
967 pq = &vmd->vmd_pagequeues[PQ_LAUNDRY];
968 KASSERT(vmd->vmd_segs != 0, ("domain without segments"));
979 (void)EVENTHANDLER_REGISTER(swapon, vm_pageout_swapon, vmd,
981 (void)EVENTHANDLER_REGISTER(swapoff, vm_pageout_swapoff, vmd,
1003 else if (shortfall_cycle == 0 || vm_laundry_target(vmd) <= 0) {
1037 nclean = vmd->vmd_free_count +
1038 vmd->vmd_pagequeues[PQ_INACTIVE].pq_cnt;
1039 ndirty = vmd->vmd_pagequeues[PQ_LAUNDRY].pq_cnt;
1041 vmd->vmd_free_target - vmd->vmd_free_min)) >= nclean) {
1042 target = vmd->vmd_background_launder_target;
1074 target -= min(vm_pageout_launder(vmd, launder,
1085 if (target == 0 && vmd->vmd_laundry_request == VM_LAUNDRY_IDLE)
1086 (void)mtx_sleep(&vmd->vmd_laundry_request,
1094 if (vmd->vmd_laundry_request == VM_LAUNDRY_SHORTFALL &&
1096 shortfall = vm_laundry_target(vmd) +
1097 vmd->vmd_pageout_deficit;
1103 vmd->vmd_laundry_request = VM_LAUNDRY_IDLE;
1104 nfreed += vmd->vmd_clean_pages_freed;
1105 vmd->vmd_clean_pages_freed = 0;
1123 vm_pageout_active_target(struct vm_domain *vmd)
1127 shortage = vmd->vmd_inactive_target + vm_paging_target(vmd) -
1128 (vmd->vmd_pagequeues[PQ_INACTIVE].pq_cnt +
1129 vmd->vmd_pagequeues[PQ_LAUNDRY].pq_cnt / act_scan_laundry_weight);
1139 vm_pageout_scan_active(struct vm_domain *vmd, int page_shortage)
1150 marker = &vmd->vmd_markers[PQ_ACTIVE];
1151 pq = &vmd->vmd_pagequeues[PQ_ACTIVE];
1161 min_scan *= scan_tick - vmd->vmd_last_active_scan;
1166 vmd->vmd_last_active_scan = scan_tick;
1183 vm_pageout_init_scan(&ss, pq, marker, &vmd->vmd_clock[0], max_scan);
1185 if (__predict_false(m == &vmd->vmd_clock[1])) {
1187 TAILQ_REMOVE(&pq->pq_pl, &vmd->vmd_clock[0], plinks.q);
1188 TAILQ_REMOVE(&pq->pq_pl, &vmd->vmd_clock[1], plinks.q);
1189 TAILQ_INSERT_HEAD(&pq->pq_pl, &vmd->vmd_clock[0],
1191 TAILQ_INSERT_TAIL(&pq->pq_pl, &vmd->vmd_clock[1],
1338 TAILQ_REMOVE(&pq->pq_pl, &vmd->vmd_clock[0], plinks.q);
1339 TAILQ_INSERT_AFTER(&pq->pq_pl, marker, &vmd->vmd_clock[0], plinks.q);
1393 vm_pageout_scan_inactive(struct vm_domain *vmd, int page_shortage)
1426 pq = &vmd->vmd_pagequeues[PQ_INACTIVE];
1622 atomic_add_int(&vmd->vmd_addl_shortage, addl_page_shortage);
1625 atomic_add_int(&vmd->vmd_inactive_us,
1627 atomic_add_int(&vmd->vmd_inactive_freed,
1636 vm_pageout_inactive_dispatch(struct vm_domain *vmd, int shortage)
1640 vmd->vmd_inactive_shortage = shortage;
1647 if ((threads = vmd->vmd_inactive_threads) > 1 &&
1648 vmd->vmd_helper_threads_enabled &&
1649 vmd->vmd_inactive_pps != 0 &&
1650 shortage > vmd->vmd_inactive_pps / VM_INACT_SCAN_RATE / 4) {
1651 vmd->vmd_inactive_shortage /= threads;
1653 vm_domain_pageout_lock(vmd);
1654 blockcount_acquire(&vmd->vmd_inactive_starting, threads - 1);
1655 blockcount_acquire(&vmd->vmd_inactive_running, threads - 1);
1656 wakeup(&vmd->vmd_inactive_shortage);
1657 vm_domain_pageout_unlock(vmd);
1661 vm_pageout_scan_inactive(vmd, vmd->vmd_inactive_shortage + slop);
1667 blockcount_wait(&vmd->vmd_inactive_running, NULL, "vmpoid", PVM);
1668 freed = atomic_readandclear_int(&vmd->vmd_inactive_freed);
1676 us = max(atomic_readandclear_int(&vmd->vmd_inactive_us), 1);
1682 vmd->vmd_inactive_pps = (vmd->vmd_inactive_pps / 2) + (pps / 2);
1692 vm_pageout_inactive(struct vm_domain *vmd, int shortage, int *addl_shortage)
1704 deficit = atomic_readandclear_int(&vmd->vmd_pageout_deficit);
1710 page_shortage = vm_pageout_inactive_dispatch(vmd, starting_page_shortage);
1711 addl_page_shortage = atomic_readandclear_int(&vmd->vmd_addl_shortage);
1725 pq = &vmd->vmd_pagequeues[PQ_LAUNDRY];
1727 if (vmd->vmd_laundry_request == VM_LAUNDRY_IDLE &&
1730 vmd->vmd_laundry_request = VM_LAUNDRY_SHORTFALL;
1732 } else if (vmd->vmd_laundry_request !=
1734 vmd->vmd_laundry_request =
1736 wakeup(&vmd->vmd_laundry_request);
1738 vmd->vmd_clean_pages_freed +=
1747 vm_pageout_mightbe_oom(vmd, page_shortage, starting_page_shortage);
1765 vm_pageout_mightbe_oom(struct vm_domain *vmd, int page_shortage,
1772 vmd->vmd_oom_seq = 0;
1774 vmd->vmd_oom_seq++;
1775 if (vmd->vmd_oom_seq < vm_pageout_oom_seq) {
1776 if (vmd->vmd_oom) {
1777 vmd->vmd_oom = false;
1787 vmd->vmd_oom_seq = 0;
1789 if (vmd->vmd_oom)
1792 vmd->vmd_oom = true;
1810 vmd->vmd_oom = false;
2067 struct vm_domain *vmd;
2073 vmd = VM_DOMAIN(domain);
2083 KASSERT(vmd->vmd_segs != 0, ("domain without segments"));
2084 vmd->vmd_last_active_scan = ticks;
2090 vm_domain_pageout_lock(vmd);
2097 atomic_store_int(&vmd->vmd_pageout_wanted, 0);
2102 if (vm_paging_needed(vmd, vmd->vmd_free_count)) {
2108 vm_domain_pageout_unlock(vmd);
2116 if (mtx_sleep(&vmd->vmd_pageout_wanted,
2117 vm_domain_pageout_lockptr(vmd), PDROP | PVM,
2123 atomic_store_int(&vmd->vmd_pageout_wanted, 1);
2131 shortage = pidctrl_daemon(&vmd->vmd_pid, vmd->vmd_free_count);
2133 ofree = vmd->vmd_free_count;
2134 if (vm_pageout_lowmem() && vmd->vmd_free_count > ofree)
2135 shortage -= min(vmd->vmd_free_count - ofree,
2137 target_met = vm_pageout_inactive(vmd, shortage,
2147 shortage = vm_pageout_active_target(vmd) + addl_shortage;
2148 vm_pageout_scan_active(vmd, shortage);
2159 struct vm_domain *vmd;
2163 vmd = VM_DOMAIN(domain);
2165 vm_domain_pageout_lock(vmd);
2167 msleep(&vmd->vmd_inactive_shortage,
2168 vm_domain_pageout_lockptr(vmd), PVM, "psleep", 0);
2169 blockcount_release(&vmd->vmd_inactive_starting, 1);
2171 vm_domain_pageout_unlock(vmd);
2172 vm_pageout_scan_inactive(vmd, vmd->vmd_inactive_shortage);
2173 vm_domain_pageout_lock(vmd);
2179 blockcount_release(&vmd->vmd_inactive_running, 1);
2184 get_pageout_threads_per_domain(const struct vm_domain *vmd)
2188 if (VM_DOMAIN_EMPTY(vmd->vmd_domain))
2201 domain_cpus = CPU_COUNT(&cpuset_domain[vmd->vmd_domain]);
2226 struct vm_domain *vmd;
2229 vmd = VM_DOMAIN(domain);
2230 vmd->vmd_interrupt_free_min = 2;
2237 vmd->vmd_pageout_free_min = 2 * MAXBSIZE / PAGE_SIZE +
2238 vmd->vmd_interrupt_free_min;
2239 vmd->vmd_free_reserved = vm_pageout_page_count +
2240 vmd->vmd_pageout_free_min + vmd->vmd_page_count / 768;
2241 vmd->vmd_free_min = vmd->vmd_page_count / 200;
2242 vmd->vmd_free_severe = vmd->vmd_free_min / 2;
2243 vmd->vmd_free_target = 4 * vmd->vmd_free_min + vmd->vmd_free_reserved;
2244 vmd->vmd_free_min += vmd->vmd_free_reserved;
2245 vmd->vmd_free_severe += vmd->vmd_free_reserved;
2246 vmd->vmd_inactive_target = (3 * vmd->vmd_free_target) / 2;
2247 if (vmd->vmd_inactive_target > vmd->vmd_free_count / 3)
2248 vmd->vmd_inactive_target = vmd->vmd_free_count / 3;
2254 vmd->vmd_pageout_wakeup_thresh = (vmd->vmd_free_target / 10) * 9;
2261 vmd->vmd_background_launder_target = (vmd->vmd_free_target -
2262 vmd->vmd_free_min) / 10;
2265 pidctrl_init(&vmd->vmd_pid, hz / VM_INACT_SCAN_RATE,
2266 vmd->vmd_free_target, PIDCTRL_BOUND,
2268 oid = SYSCTL_ADD_NODE(NULL, SYSCTL_CHILDREN(vmd->vmd_oid), OID_AUTO,
2270 pidctrl_init_sysctl(&vmd->vmd_pid, SYSCTL_CHILDREN(oid));
2272 vmd->vmd_inactive_threads = get_pageout_threads_per_domain(vmd);
2273 SYSCTL_ADD_BOOL(NULL, SYSCTL_CHILDREN(vmd->vmd_oid), OID_AUTO,
2275 &vmd->vmd_helper_threads_enabled, 0,
2290 struct vm_domain *vmd;
2293 vmd = VM_DOMAIN(i);
2294 vm_cnt.v_free_reserved += vmd->vmd_free_reserved;
2295 vm_cnt.v_free_target += vmd->vmd_free_target;
2296 vm_cnt.v_free_min += vmd->vmd_free_min;
2297 vm_cnt.v_inactive_target += vmd->vmd_inactive_target;
2298 vm_cnt.v_pageout_free_min += vmd->vmd_pageout_free_min;
2299 vm_cnt.v_interrupt_free_min += vmd->vmd_interrupt_free_min;
2300 vm_cnt.v_free_severe += vmd->vmd_free_severe;
2301 freecount += vmd->vmd_free_count;
2380 struct vm_domain *vmd;
2382 vmd = VM_DOMAIN(domain);
2383 vm_domain_pageout_assert_unlocked(vmd);
2387 if (atomic_fetchadd_int(&vmd->vmd_pageout_wanted, 1) == 0) {
2388 vm_domain_pageout_lock(vmd);
2389 atomic_store_int(&vmd->vmd_pageout_wanted, 1);
2390 wakeup(&vmd->vmd_pageout_wanted);
2391 vm_domain_pageout_unlock(vmd);