Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 05 Aug 2015 17:59:30 -0600
From:      Ian Lepore <ian@freebsd.org>
To:        Ryan Stone <rysto32@gmail.com>
Cc:        "freebsd-hackers@freebsd.org" <freebsd-hackers@freebsd.org>
Subject:   Re: vm_lowmem is prevented every 2**31 ticks
Message-ID:  <1438819170.70393.227.camel@freebsd.org>
In-Reply-To: <CAFMmRNwKd7FpQBdG5C=yynSAN9o59pD-ERhZ5Z0BMykbg_Yy8Q@mail.gmail.com>
References:  <CAFMmRNwKd7FpQBdG5C=yynSAN9o59pD-ERhZ5Z0BMykbg_Yy8Q@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 2015-08-05 at 19:48 -0400, Ryan Stone wrote:
> 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.

If you're measuring elapsed time, please use getbinuptime() rather than
the time of day clock (which can be stepped arbitrarily).

Hey wait a sec... if it's currently some_ticks/hz it's counting seconds,
right?  So no need to mess with bintimes, if whole seconds are good
enough just use the global time_uptime.

-- Ian




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1438819170.70393.227.camel>