From owner-freebsd-hackers@freebsd.org Mon May 20 16:20:50 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 66D3915B1A62 for ; Mon, 20 May 2019 16:20:50 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from outbound3d.ore.mailhop.org (outbound3d.ore.mailhop.org [54.186.57.195]) (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 D81578553E for ; Mon, 20 May 2019 16:20:49 +0000 (UTC) (envelope-from ian@freebsd.org) ARC-Seal: i=1; a=rsa-sha256; t=1558369248; cv=none; d=outbound.mailhop.org; s=arc-outbound20181012; b=Q9C2yE1DEzEvavTiBes2JrWahNX0QLReE2+opnzWhvabcjqsA74tfyXOvCjZCRWuZ2H0ypcJx9C6+ YcJ7qNT+rqFla7FN6mAWUqBtiC97KvHumZLgwtOLM3KxuAfzN5kkjsOHScRt/8yeJLfNF2u8QIpCNA jbqrl/KCzNgICN14mZPQUomGYLEXTeFxCrKlJI24ehngyTxveWo2+oi0wPLHEMglDc5T874A3vH8vk IiWoF5e4ObnfG6tKZYdvKJFoeGgRF+eCzr6V9KAh1dCLUaOUA+BKVCfv01GhJs7YnxNNlgQ1NKZOXw iUwoJ2LoqM7CVbG84eKpBzh/bjiQsPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=arc-outbound20181012; h=content-transfer-encoding:mime-version:content-type:references:in-reply-to: date:to:from:subject:message-id:dkim-signature:from; bh=14WWBiocjAfZezhw4SrVUMCriDCHv4r+HKSo15KGdrU=; b=eCTrHMq0E/LtUYHSn6LxMtQiMtM08MFqk4WO4exec+ZRmtDyPPTt2OR5V+4giEpHo9g4EasGfg+Tw 4rHEtuaX+FIDMXj5UDe7WXy66SYd1tc3rn4n+B7cDisIj37que2TBB0H3laGrX4gE3D0xSbHhtDx7F A9UO/Ry1Cy6joEnuV+GvD3Yq88dGn99jJAWGFtJsW1XZpbXDnFRgsLRHLDT++2fst8jZtWVmgU6FsE E04dpdlIeh+DqTzBEZaTeabr1scHniIzg+IKWtmWRbMYkiejjRiRMy+0tjmeHSpKY/w6d88wipzRR5 iwvVvOmbDj80Ng9WYzJkpCRyvfwMYIw== ARC-Authentication-Results: i=1; outbound3.ore.mailhop.org; spf=softfail smtp.mailfrom=freebsd.org smtp.remote-ip=67.177.211.60; dmarc=none header.from=freebsd.org; arc=none header.oldest-pass=0; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=dkim-high; h=content-transfer-encoding:mime-version:content-type:references:in-reply-to: date:to:from:subject:message-id:from; bh=14WWBiocjAfZezhw4SrVUMCriDCHv4r+HKSo15KGdrU=; b=ivBKPH9aqOmJMPFFMPcI8Io7zf7sgyitKeU07IiLIIxN1j4aah9/1WllZynxeXSRZNAFEwwJCkDlq d5PzJLPJGvtjS3UKFoPkXmre60XkPwIu9AeQSY36WzcpvWtaQL49zQcesirU/wT1n8yfJpXLIJObaI gPpsuVlJsuPphe8z4P6MIy7zZqF2ZIfZ4V/nt+GmGhLUCkEMkHGB1I2bUCctdq1UItsaJatgnVL+m/ 7Mg59qDwn0M5jWd9QdHV9kL0b1nZ24y2/JD14HqPGV5tY05sGUMOx62UqTrUHap+OU/8O2LrQlXNGs VBX+YlZDxTxqaGxuIhl1LD5mvUtXFqw== X-MHO-RoutePath: aGlwcGll X-MHO-User: 38f03783-7b1b-11e9-990f-673a89bc4518 X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Originating-IP: 67.177.211.60 X-Mail-Handler: DuoCircle Outbound SMTP Received: from ilsoft.org (unknown [67.177.211.60]) by outbound3.ore.mailhop.org (Halon) with ESMTPSA id 38f03783-7b1b-11e9-990f-673a89bc4518; Mon, 20 May 2019 16:20:46 +0000 (UTC) Received: from rev (rev [172.22.42.240]) by ilsoft.org (8.15.2/8.15.2) with ESMTP id x4KGKjFw024929; Mon, 20 May 2019 10:20:45 -0600 (MDT) (envelope-from ian@freebsd.org) Message-ID: <8160c9149c04d2b622292abf582bcbb9a541d2ed.camel@freebsd.org> Subject: Re: Commit r345200 (new ARC reclamation threads) looks suspicious to me - second potential problem From: Ian Lepore To: lev@FreeBSD.org, freebsd-fs@freebsd.org, freebsd-hackers@FreeBSD.org, Alexander Motin Date: Mon, 20 May 2019 10:20:45 -0600 In-Reply-To: <369cb1e9-f36a-a558-6941-23b9b811825a@FreeBSD.org> References: <369cb1e9-f36a-a558-6941-23b9b811825a@FreeBSD.org> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5 FreeBSD GNOME Team Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: D81578553E X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.99 / 15.00]; local_wl_from(0.00)[freebsd.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.99)[-0.990,0]; ASN(0.00)[asn:16509, ipnet:54.186.0.0/15, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] 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: Mon, 20 May 2019 16:20:50 -0000 On Mon, 2019-05-20 at 19:05 +0300, Lev Serebryakov wrote: > I'm looking at last commit to > 'sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c' (r345200) and > have another question. > > Here are such code: > > 4960 /* > 4961 * Kick off asynchronous kmem_reap()'s of all our > caches. > 4962 */ > 4963 arc_kmem_reap_soon(); > 4964 > 4965 /* > 4966 * Wait at least arc_kmem_cache_reap_retry_ms between > 4967 * arc_kmem_reap_soon() calls. Without this check it is > possible to > 4968 * end up in a situation where we spend lots of time > reaping > 4969 * caches, while we're near arc_c_min. Waiting here > also > gives the > 4970 * subsequent free memory check a chance of finding > that the > 4971 * asynchronous reap has already freed enough memory, > and > we don't > 4972 * need to call arc_reduce_target_size(). > 4973 */ > 4974 delay((hz * arc_kmem_cache_reap_retry_ms + 999) / > 1000); > 4975 > > But looks like `arc_kmem_reap_soon()` is synchronous on FreeBSD! So, > this `delay()` looks very wrong. Am I right? > > Looks like it should be `#ifdef illumos`. > One of the things arc_kmem_reap_soon() does is call dnlc_reduce_cache(), and that sets a variable and does a condition variable broadcast, presumably causing other threads to wake up and do some work. So, presumably the delay (which appears to really be a call to pause(9) on freebsd) allows time for that async work to happen before calling arc_available_memory(). -- Ian