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

Function vm_pageout_mightbe_oom

freebsd/vm/vm_pageout.c:1794–1842  ·  view source on GitHub ↗

* The pagedaemon threads randlomly select one to perform the * OOM. Trying to kill processes before all pagedaemons * failed to reach free target is premature. */

Source from the content-addressed store, hash-verified

1792 * failed to reach free target is premature.
1793 */
1794static void
1795vm_pageout_mightbe_oom(struct vm_domain *vmd, int page_shortage,
1796 int starting_page_shortage)
1797{
1798 int old_vote;
1799
1800 if (starting_page_shortage <= 0 || starting_page_shortage !=
1801 page_shortage)
1802 vmd->vmd_oom_seq = 0;
1803 else
1804 vmd->vmd_oom_seq++;
1805 if (vmd->vmd_oom_seq < vm_pageout_oom_seq) {
1806 if (vmd->vmd_oom) {
1807 vmd->vmd_oom = FALSE;
1808 atomic_subtract_int(&vm_pageout_oom_vote, 1);
1809 }
1810 return;
1811 }
1812
1813 /*
1814 * Do not follow the call sequence until OOM condition is
1815 * cleared.
1816 */
1817 vmd->vmd_oom_seq = 0;
1818
1819 if (vmd->vmd_oom)
1820 return;
1821
1822 vmd->vmd_oom = TRUE;
1823 old_vote = atomic_fetchadd_int(&vm_pageout_oom_vote, 1);
1824 if (old_vote != vm_ndomains - 1)
1825 return;
1826
1827 /*
1828 * The current pagedaemon thread is the last in the quorum to
1829 * start OOM. Initiate the selection and signaling of the
1830 * victim.
1831 */
1832 vm_pageout_oom(VM_OOM_MEM);
1833
1834 /*
1835 * After one round of OOM terror, recall our vote. On the
1836 * next pass, current pagedaemon would vote again if the low
1837 * memory condition is still there, due to vmd_oom being
1838 * false.
1839 */
1840 vmd->vmd_oom = FALSE;
1841 atomic_subtract_int(&vm_pageout_oom_vote, 1);
1842}
1843
1844/*
1845 * The OOM killer is the page daemon's action of last resort when

Callers 1

vm_pageout_inactiveFunction · 0.85

Calls 2

vm_pageout_oomFunction · 0.85
atomic_fetchadd_intFunction · 0.50

Tested by

no test coverage detected