Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 1 Apr 2018 12:27:03 -0400
From:      Mark Johnston <markj@FreeBSD.org>
To:        Tijl Coosemans <tijl@FreeBSD.org>
Cc:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   Re: svn commit: r331732 - head/sys/vm
Message-ID:  <20180401162703.GD1440@raichu>
In-Reply-To: <20180401172021.27852803@kalimero.tijl.coosemans.org>
References:  <201803291427.w2TEReA3024929@repo.freebsd.org> <20180331202118.5401ed2a@kalimero.tijl.coosemans.org> <20180331225432.GB1440@raichu> <20180401172021.27852803@kalimero.tijl.coosemans.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Apr 01, 2018 at 05:20:21PM +0200, Tijl Coosemans wrote:
> On Sat, 31 Mar 2018 18:54:32 -0400 Mark Johnston <markj@FreeBSD.org> wrote:
> > On Sat, Mar 31, 2018 at 08:21:18PM +0200, Tijl Coosemans wrote:
> > > On Thu, 29 Mar 2018 14:27:40 +0000 (UTC) Mark Johnston <markj@FreeBSD.org> wrote:  
> > > > Author: markj
> > > > Date: Thu Mar 29 14:27:40 2018
> > > > New Revision: 331732
> > > > URL: https://svnweb.freebsd.org/changeset/base/331732
> > > > 
> > > > Log:
> > > >   Fix the background laundering mechanism after r329882.
> > > >   
> > > >   Rather than using the number of inactive queue scans as a metric for
> > > >   how many clean pages are being freed by the page daemon, have the
> > > >   page daemon keep a running counter of the number of pages it has freed,
> > > >   and have the laundry thread use that when computing the background
> > > >   laundering threshold.
> > > > [...]  
> > > 
> > > I'm seeing big processes being killed with an "out of swap space" message
> > > even though there's still plenty of swap available.  It seems to be fixed
> > > by making this division round upwards:
> > > 
> > > 		if (target == 0 && ndirty * isqrt((nfreed +
> > > 		    (vmd->vmd_free_target - vmd->vmd_free_min) - 1) /
> > > 		    (vmd->vmd_free_target - vmd->vmd_free_min)) >= nclean) {
> > > 
> > > I don't know where this formula comes from, so I don't know if this
> > > change is correct.  
> > 
> > Hm, that's somewhat surprising. This code shouldn't be executing in
> > situations where the OOM kill logic is invoked (i.e., memory pressure
> > plus a shortage of clean pages in the inactive queue).
> > 
> > How much RAM does the system have? Could you collect "sysctl vm" output
> > around the time of an OOM kill?
> 
> 1GiB RAM.  I've sampled sysctl vm every 5s from the moment the process
> starts swapping until it is killed and uploaded that to
> https://people.freebsd.org/~tijl/sysctl/

Thank you. Now I agree with your change. Would you like to commit it?
I can take care of it if you prefer.

There is still a deeper problem here after r329882 in that the shortfall
laundering mechanism is not kicking in before the OOM killer. The
problem is that the PID controller may produce a positive output even
when the error is negative; this is seen in 22.txt, the last capture
before the OOM kill. Because the error is negative (i.e.,
v_free_count > v_free_target), we will not attempt to launder pages in
shortfall mode. The positive output means that the page daemon is
repeatedly scanning the (completely depleted) inactive queue, but since
the laundering mechanism is failing to produce clean pages, there is
nothing to reclaim and so we eventually invoke the OOM killer.

I'm not yet sure how best to address this, but your change is probably
sufficient to mitigate the problem in general and also corrects an
unintentional behaviour change in my commit.



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