From owner-freebsd-hackers@freebsd.org Wed Jun 15 13:10:34 2016 Return-Path: Delivered-To: freebsd-hackers@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 2CEFCA1DF51 for ; Wed, 15 Jun 2016 13:10:34 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BB17D12DC for ; Wed, 15 Jun 2016 13:10:33 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id u5FDAOtd076482 (version=TLSv1 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Wed, 15 Jun 2016 16:10:24 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua u5FDAOtd076482 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id u5FDAOD3076479; Wed, 15 Jun 2016 16:10:24 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 15 Jun 2016 16:10:24 +0300 From: Konstantin Belousov To: Fabian Keil Cc: freebsd-hackers@freebsd.org Subject: Re: vnlru_proc() draining unrelated uma zones Message-ID: <20160615131024.GA38613@kib.kiev.ua> References: <20160615140516.3cba6001@fabiankeil.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160615140516.3cba6001@fabiankeil.de> User-Agent: Mutt/1.6.1 (2016-04-27) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Jun 2016 13:10:34 -0000 On Wed, Jun 15, 2016 at 02:05:16PM +0200, Fabian Keil wrote: > While looking into two uma-related issues[0] I noticed that > vnlru_proc() is calling uma_reclaim() even though the intention > seems to be to merely drain the vnode-related zones. > > According to uma.h, uma_reclaim() "should only be called by > the page out daemon", presumably because of the overhead > and side-effects. > > I've been using this patch for a couple of weeks and didn't > notice any regressions: > > diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c > index 2767826..2c65ce1 100644 > --- a/sys/kern/vfs_subr.c > +++ b/sys/kern/vfs_subr.c > @@ -1107,8 +1107,10 @@ vnlru_proc(void) > vfs_unbusy(mp); > } > mtx_unlock(&mountlist_mtx); > - if (onumvnodes > desiredvnodes && numvnodes <= desiredvnodes) > - uma_reclaim(); > + if (onumvnodes > desiredvnodes && numvnodes <= desiredvnodes) { > + zone_drain(vnode_zone); > + zone_drain(vnodepoll_zone); > + } You listed two obvious zones which cache allocations related to vnodes, but there are much more. E.g. on some systems there are FFS inodes attached to most vnodes, on other there are znodes. What about rangelocks, fifos, namecache data etc ? What about malloc zones where some other allocs to handle vnodes are done ? Practically, significant part of the kernel memory allocations is rooted in the vnode handling, and when we shrink the vnode cache due to neccessity, we should shrink that second-level caches as well. Since it is very hard to properly enumerate that items, the shortcut is used. > if (done == 0) { > if (force == 0 || force == 1) { > force = 2; > > It also didn't seem to noticeable affect the issues I was investigating > (the code is rarely executed on my systems), but calling uma_reclaim() > still seems strange to me. > > Am I missing something? > > Fabian > > [0] > "Prevent deadlocks when paging on GELI-encrypted devices": > https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=209759 > "[...] connections time out/ssh results in 'broken pipe'": > https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=209680