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

Function vm_pageout_inactive

freebsd/vm/vm_pageout.c:1709–1785  ·  view source on GitHub ↗

* Attempt to reclaim the requested number of pages from the inactive queue. * Returns true if the shortage was addressed. */

Source from the content-addressed store, hash-verified

1707 * Returns true if the shortage was addressed.
1708 */
1709static int
1710vm_pageout_inactive(struct vm_domain *vmd, int shortage, int *addl_shortage)
1711{
1712 struct vm_pagequeue *pq;
1713 u_int addl_page_shortage, deficit, page_shortage;
1714 u_int starting_page_shortage;
1715
1716 /*
1717 * vmd_pageout_deficit counts the number of pages requested in
1718 * allocations that failed because of a free page shortage. We assume
1719 * that the allocations will be reattempted and thus include the deficit
1720 * in our scan target.
1721 */
1722 deficit = atomic_readandclear_int(&vmd->vmd_pageout_deficit);
1723 starting_page_shortage = shortage + deficit;
1724
1725 /*
1726 * Run the inactive scan on as many threads as is necessary.
1727 */
1728 page_shortage = vm_pageout_inactive_dispatch(vmd, starting_page_shortage);
1729 addl_page_shortage = atomic_readandclear_int(&vmd->vmd_addl_shortage);
1730
1731 /*
1732 * Wake up the laundry thread so that it can perform any needed
1733 * laundering. If we didn't meet our target, we're in shortfall and
1734 * need to launder more aggressively. If PQ_LAUNDRY is empty and no
1735 * swap devices are configured, the laundry thread has no work to do, so
1736 * don't bother waking it up.
1737 *
1738 * The laundry thread uses the number of inactive queue scans elapsed
1739 * since the last laundering to determine whether to launder again, so
1740 * keep count.
1741 */
1742 if (starting_page_shortage > 0) {
1743 pq = &vmd->vmd_pagequeues[PQ_LAUNDRY];
1744 vm_pagequeue_lock(pq);
1745 if (vmd->vmd_laundry_request == VM_LAUNDRY_IDLE &&
1746 (pq->pq_cnt > 0 || atomic_load_acq_int(&swapdev_enabled))) {
1747 if (page_shortage > 0) {
1748 vmd->vmd_laundry_request = VM_LAUNDRY_SHORTFALL;
1749 VM_CNT_INC(v_pdshortfalls);
1750 } else if (vmd->vmd_laundry_request !=
1751 VM_LAUNDRY_SHORTFALL)
1752 vmd->vmd_laundry_request =
1753 VM_LAUNDRY_BACKGROUND;
1754 wakeup(&vmd->vmd_laundry_request);
1755 }
1756 vmd->vmd_clean_pages_freed +=
1757 starting_page_shortage - page_shortage;
1758 vm_pagequeue_unlock(pq);
1759 }
1760
1761 /*
1762 * Wakeup the swapout daemon if we didn't free the targeted number of
1763 * pages.
1764 */
1765 if (page_shortage > 0)
1766 vm_swapout_run();

Callers 1

vm_pageout_workerFunction · 0.85

Calls 5

vm_pageout_mightbe_oomFunction · 0.85
vm_swapout_runFunction · 0.70
vm_swapout_run_idleFunction · 0.70
wakeupFunction · 0.50

Tested by

no test coverage detected