Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp346333ybl; Wed, 11 Dec 2019 19:49:31 -0800 (PST) X-Google-Smtp-Source: APXvYqzrCL565ppsahIqMkvL+RH+5Quvz231n4FgnoRW1qYBYiRbfmCxginwNVx89f8TU/57IYWe X-Received: by 2002:a9d:73d2:: with SMTP id m18mr5260841otk.150.1576122571443; Wed, 11 Dec 2019 19:49:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576122571; cv=none; d=google.com; s=arc-20160816; b=dHhm5DoVjbvHMDs5f9/pOfPsAtv6lrWAT/o+7EBwKSnC4OrBqqcxwUxEm/KyLeKvOd drgrqjW1XuTTCiHk+ail6eyDigO5ZEBqQ6NwLSzmWQS0ZlQni3h40DyV61fkGV/GyRbm aCXYPSjO2MvqNWrJ3e18wqrgFQla9BD4MOxbZsFelmqx8XBDP1m0rMglThapa01r3nUN 4uPLqxmWqrwxxmxpdXNbyM0MIUhZGDcDNH3sF/+Ut3ElX7qEGSPX8T6CBssmrhGizuyJ WaL18UJptCy7cdxL1JL/9fm2coWLHd6Wo2wsAtbOwDXgVyRqurLVJsXhU+M17gYhkB+7 BDmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:subject:cc:to:from :date:message-id:content-transfer-encoding:mime-version; bh=oT7tSsKmjI76eCaqPkTeTSutloW2WtiO9hPdpXxxKHA=; b=XNMhNfSWq4//Xf3qN2caOwTrPEGlI0TxmtyK7RjHFeTbezihuvv9cmQlRl93QfAibq 2iOtqpE3+wDh9x3m7TzNeLV5oQm9TnRES3jP84uMh1EFioMfIYsdOsEbP0J5nFCpoP59 LP7MKt/w8mzH0cl8BZzYdNsW38K3iMDHuH3TpnTTop2MJ/HHw50j3+O4+25imV+kxFp6 wM+ynXxTz2hx2Q3qnSMco0RKtJOA636sBmydZ0HtCR3bifASM6uRrVK9GUTxQM7C/FhK LCypJulECGQeViswcGWzovsjzs0/7IDUb28xU4dzH3fvvqPMKaU+7Apwx0aya4WBxYzY 1Bwg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=stoffel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z14si2365788oth.15.2019.12.11.19.49.19; Wed, 11 Dec 2019 19:49:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=stoffel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727669AbfLLDsh (ORCPT + 99 others); Wed, 11 Dec 2019 22:48:37 -0500 Received: from li1843-175.members.linode.com ([172.104.24.175]:58314 "EHLO mail.stoffel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726823AbfLLDsg (ORCPT ); Wed, 11 Dec 2019 22:48:36 -0500 Received: from quad.stoffel.org (66-189-75-104.dhcp.oxfr.ma.charter.com [66.189.75.104]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.stoffel.org (Postfix) with ESMTPSA id D8F541EF96; Wed, 11 Dec 2019 22:48:35 -0500 (EST) Received: by quad.stoffel.org (Postfix, from userid 1000) id 561E5A5DFF; Wed, 11 Dec 2019 22:48:35 -0500 (EST) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <24049.47251.286105.88377@quad.stoffel.home> Date: Wed, 11 Dec 2019 22:48:35 -0500 From: "John Stoffel" To: Sasha Levin Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Coly Li , Jens Axboe , linux-bcache@vger.kernel.org, linux-raid@vger.kernel.org Subject: Re: [PATCH AUTOSEL 4.14 32/58] bcache: at least try to shrink 1 node in bch_mca_scan() In-Reply-To: <20191211152831.23507-32-sashal@kernel.org> References: <20191211152831.23507-1-sashal@kernel.org> <20191211152831.23507-32-sashal@kernel.org> X-Mailer: VM 8.2.0b under 25.1.1 (x86_64-pc-linux-gnu) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org >>>>> "Sasha" == Sasha Levin writes: Sasha> From: Coly Li Sasha> [ Upstream commit 9fcc34b1a6dd4b8e5337e2b6ef45e428897eca6b ] Sasha> In bch_mca_scan(), the number of shrinking btree node is calculated Sasha> by code like this, Sasha> unsigned long nr = sc->nr_to_scan; Sasha> nr /= c->btree_pages; Sasha> nr = min_t(unsigned long, nr, mca_can_free(c)); Sasha> variable sc->nr_to_scan is number of objects (here is bcache B+tree Sasha> nodes' number) to shrink, and pointer variable sc is sent from memory Sasha> management code as parametr of a callback. Sasha> If sc->nr_to_scan is smaller than c->btree_pages, after the above Sasha> calculation, variable 'nr' will be 0 and nothing will be shrunk. It is Sasha> frequeently observed that only 1 or 2 is set to sc->nr_to_scan and make Sasha> nr to be zero. Then bch_mca_scan() will do nothing more then acquiring Sasha> and releasing mutex c->bucket_lock. Sasha> This patch checkes whether nr is 0 after the above calculation, if 0 Sasha> is the result then set 1 to variable 'n'. Then at least bch_mca_scan() Sasha> will try to shrink a single B+tree node. Sasha> nr /= c->btree_pages; Sasha> + if (nr == 0) Sasha> + nr = 1; Wouldn't it be even more clear with: nr /= c->bree_pages || 1; instead? John