diff options
| author | Mark Johnston <markj@FreeBSD.org> | 2018-08-09 18:25:49 +0000 |
|---|---|---|
| committer | Mark Johnston <markj@FreeBSD.org> | 2018-08-09 18:25:49 +0000 |
| commit | b50a4ea6468ba2ca098a767f6f72d2e0dc9327d8 (patch) | |
| tree | 103965c6a83e58dc81659f7acbcc58ab81e93ca9 /sys/vm/vm_pageout.c | |
| parent | 4c793b68dab5b7470b611fc1e0743e27b2dce090 (diff) | |
Notes
Diffstat (limited to 'sys/vm/vm_pageout.c')
| -rw-r--r-- | sys/vm/vm_pageout.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/sys/vm/vm_pageout.c b/sys/vm/vm_pageout.c index 416c36d9c4bf7..6881319e4d9d6 100644 --- a/sys/vm/vm_pageout.c +++ b/sys/vm/vm_pageout.c @@ -152,7 +152,6 @@ static int vm_pageout_oom_seq = 12; static int vm_pageout_update_period; static int disable_swap_pageouts; static int lowmem_period = 10; -static time_t lowmem_uptime; static int swapdev_enabled; static int vm_panic_on_oom = 0; @@ -1856,12 +1855,17 @@ vm_pageout_oom(int shortage) } } -static void -vm_pageout_lowmem(struct vm_domain *vmd) +static bool +vm_pageout_lowmem(void) { + static int lowmem_ticks = 0; + int last; + + last = atomic_load_int(&lowmem_ticks); + while ((u_int)(ticks - last) / hz >= lowmem_period) { + if (atomic_fcmpset_int(&lowmem_ticks, &last, ticks) == 0) + continue; - if (vmd == VM_DOMAIN(0) && - time_uptime - lowmem_uptime >= lowmem_period) { /* * Decrease registered cache sizes. */ @@ -1873,14 +1877,16 @@ vm_pageout_lowmem(struct vm_domain *vmd) * drained above. */ uma_reclaim(); - lowmem_uptime = time_uptime; + return (true); } + return (false); } static void vm_pageout_worker(void *arg) { struct vm_domain *vmd; + u_int ofree; int addl_shortage, domain, shortage; bool target_met; @@ -1939,11 +1945,16 @@ vm_pageout_worker(void *arg) /* * Use the controller to calculate how many pages to free in - * this interval, and scan the inactive queue. + * this interval, and scan the inactive queue. If the lowmem + * handlers appear to have freed up some pages, subtract the + * difference from the inactive queue scan target. */ shortage = pidctrl_daemon(&vmd->vmd_pid, vmd->vmd_free_count); if (shortage > 0) { - vm_pageout_lowmem(vmd); + ofree = vmd->vmd_free_count; + if (vm_pageout_lowmem() && vmd->vmd_free_count > ofree) + shortage -= min(vmd->vmd_free_count - ofree, + (u_int)shortage); target_met = vm_pageout_scan_inactive(vmd, shortage, &addl_shortage); } else |
