From owner-freebsd-hackers@freebsd.org Wed May 22 16:09:04 2019 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F2E2E15B0149; Wed, 22 May 2019 16:09:03 +0000 (UTC) (envelope-from slw@zxy.spb.ru) Received: from zxy.spb.ru (zxy.spb.ru [195.70.199.98]) (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 BA1498CDF8; Wed, 22 May 2019 16:09:02 +0000 (UTC) (envelope-from slw@zxy.spb.ru) Received: from slw by zxy.spb.ru with local (Exim 4.86 (FreeBSD)) (envelope-from ) id 1hTTnS-0004CW-60; Wed, 22 May 2019 19:08:54 +0300 Date: Wed, 22 May 2019 19:08:54 +0300 From: Slawa Olhovchenkov To: Lev Serebryakov Cc: Alexander Motin , Mark Johnston , freebsd-fs@freebsd.org, freebsd-hackers@freebsd.org Subject: Re: Commit r345200 (new ARC reclamation threads) looks suspicious to me - second potential problem Message-ID: <20190522160854.GD47119@zxy.spb.ru> References: <369cb1e9-f36a-a558-6941-23b9b811825a@FreeBSD.org> <20190520164202.GA2130@spy> <28c7430b-fb7c-6472-5c1b-fa3ff63a9e73@FreeBSD.org> <94d051a3-3427-7a5b-efe7-169cff2265d3@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <94d051a3-3427-7a5b-efe7-169cff2265d3@FreeBSD.org> User-Agent: Mutt/1.5.24 (2015-08-30) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: slw@zxy.spb.ru X-SA-Exim-Scanned: No (on zxy.spb.ru); SAEximRunCond expanded to false X-Rspamd-Queue-Id: BA1498CDF8 X-Spamd-Bar: +++ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [3.66 / 15.00]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_SPAM_SHORT(0.94)[0.941,0]; MIME_GOOD(-0.10)[text/plain]; RCVD_TLS_LAST(0.00)[]; DMARC_NA(0.00)[zxy.spb.ru]; AUTH_NA(1.00)[]; RCPT_COUNT_FIVE(0.00)[5]; NEURAL_SPAM_MEDIUM(0.91)[0.910,0]; IP_SCORE(0.00)[country: RU(0.01)]; MX_GOOD(-0.01)[zxy.spb.ru]; NEURAL_SPAM_LONG(0.92)[0.918,0]; R_SPF_NA(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:5495, ipnet:195.70.192.0/19, country:RU]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 May 2019 16:09:04 -0000 On Wed, May 22, 2019 at 06:50:10PM +0300, Lev Serebryakov wrote: > On 22.05.2019 18:19, Alexander Motin wrote: > > >>> But looks like `arc_kmem_reap_soon()` is synchronous on FreeBSD! So, > >>> this `delay()` looks very wrong. Am I right? > > > > Why is it wrong? > One second pause after synchronous operation to wait it completion? > > There one more questionable piece of code: > > 6936 static void > 6937 arc_lowmem(void *arg __unused, int howto __unused) > 6938 { > .... > 6947 arc_reduce_target_size(to_free); > 6948 > 6949 mutex_enter(&arc_adjust_lock); > 6950 arc_adjust_needed = B_TRUE; > 6951 zthr_wakeup(arc_adjust_zthr); > > > 4587 static void > 4588 arc_reduce_target_size(int64_t to_free) > 4589 { > ... > 4612 if (asize > arc_c) { > 4613 DTRACE_PROBE2(arc__shrink_adjust, uint64_t, asize, > 4614 uint64_t, arc_c); > 4615 /* See comment in arc_adjust_cb_check() on why > lock+flag */ > 4616 mutex_enter(&arc_adjust_lock); > 4617 arc_adjust_needed = B_TRUE; > 4618 mutex_exit(&arc_adjust_lock); > 4619 zthr_wakeup(arc_adjust_zthr); > 4620 } > 4621 } > > Looks like lock/flag/wakeup sequence (which is now very cheap — mutexes > are not cheap, and this mutex could become contended in low-memory > situation) could be called twice. > > Looks like `arc_reduce_target_size()` should return boolean value and > unconditional signalling in `arc_lowmem()` should become conditional. No, for FreeBSD case arc_lowmem() don't be conditional from this condition in this maner and need completly differnt set of ananlys factors and do different...