From owner-freebsd-arch@freebsd.org Thu Nov 30 17:42:41 2017 Return-Path: Delivered-To: freebsd-arch@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8D1F5E66940 for ; Thu, 30 Nov 2017 17:42:41 +0000 (UTC) (envelope-from lm@mcvoy.com) Received: from mcvoy.com (mcvoy.com [192.169.23.250]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 770996D82F for ; Thu, 30 Nov 2017 17:42:41 +0000 (UTC) (envelope-from lm@mcvoy.com) Received: by mcvoy.com (Postfix, from userid 3546) id AF50335E135; Thu, 30 Nov 2017 09:42:40 -0800 (PST) Date: Thu, 30 Nov 2017 09:42:40 -0800 From: Larry McVoy To: "freebsd-arch@freebsd.org" , scottl@netflix.com, kbowling@llnw.com, gallatin@netflix.com Subject: Re: small patch for pageout. Comments? Message-ID: <20171130174240.GB811@mcvoy.com> References: <20171130173424.GA811@mcvoy.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171130173424.GA811@mcvoy.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Nov 2017 17:42:41 -0000 https://reviews.freebsd.org/D13308 On Thu, Nov 30, 2017 at 09:34:24AM -0800, Larry McVoy wrote: > In a recent numa meeting that Scott called, Jeff suggested a small > patch to the pageout daemon (included below). > > It's rather dramatic the difference it makes for me. If I arrange to > thrash the crap out of memory, without this patch the kernel is so > borked with all the processes in disk wait that I can't kill them, > I can't reboot, my only option is to power off. > > With the patch there is still some borkage, the kernel is randomly > killing processes because of out of mem, it should kill one of my > processes that is causing the problem but it doesn't, it killed > random stuff like dhclient, getty (logged me out), etc. > > But the system is responsive. > > What the patch does is say "if we have more than one core, don't sleep > in pageout, just keep running until we freed enough mem". > > Comments? > > --lm > > diff --git a/sys/vm/vm_pageout.c b/sys/vm/vm_pageout.c > index 4ecae5ad5fd..f59a09e96e2 100644 > --- a/sys/vm/vm_pageout.c > +++ b/sys/vm/vm_pageout.c > @@ -1815,10 +1815,18 @@ vm_pageout_worker(void *arg) > * (page reclamation) scan, then increase the level > * and scan again now. Otherwise, sleep a bit and > * try again later. > + * LM: per discussions with the numa team, don't > + * sleep if we have at least 2 cpus, just keep > + * scanning. This makes a HUGE difference when > + * the system is thrashing on memory, it's the > + * difference between usable and borked. > */ > mtx_unlock(&vm_page_queue_free_mtx); > - if (pass >= 1) > - pause("psleep", hz / VM_INACT_SCAN_RATE); > + if (pass >= 1) { > + if (mp_ncpus < 2) { > + pause("psleep", hz /VM_INACT_SCAN_RATE); > + } > + } > pass++; > } else { > /* -- --- Larry McVoy lm at mcvoy.com http://www.mcvoy.com/lm