vm_lowmem is prevented every 2**31 ticks
Ryan Stone
rysto32 at gmail.com
Wed Aug 5 23:48:14 UTC 2015
Currently vm_pageout_scan() uses a calculation on ticks to rate-limit the
number of vm_lowmem() events. The calculation that it uses is:
if (vmd == &vm_dom[0] && pass > 0 &&
(ticks - lowmem_ticks) / hz >= lowmem_period)
The problem with this code is that there is no guarantee that
vm_pageout_scan() will be called with pass > 0 within any time period.
This can mean that (for example) lowmem_ticks could have been 0 an
arbitrarily long time ago, and if ticks happens to be negative when we are
running low on memory, the result of ticks - lowmem_ticks will be negative
and the condition will not be true until ticks goes positive again.
A coworker suggested casting the result of the subtraction to a u_int.
This narrows the window considerably (down to 2 * lowmem_period seconds),
but it's not possible to eliminate the problem entirely as long as we use
ticks. I am tempted to just call getbintime() instead. Low memory events
should be infrequent enough that calling getbintime() should be ok.
Unless somebody has an objection or an alternate solution, I'll put
together a patch using getbintime() and get that into phabricator.
More information about the freebsd-hackers
mailing list