From patchwork Mon Apr 29 03:47:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13646250 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5172C4345F for ; Mon, 29 Apr 2024 03:47:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DAA6F6B0092; Sun, 28 Apr 2024 23:47:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9554E6B0087; Sun, 28 Apr 2024 23:47:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 642306B007B; Sun, 28 Apr 2024 23:47:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 236E86B0087 for ; Sun, 28 Apr 2024 23:47:55 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id C8D3B1C11BD for ; Mon, 29 Apr 2024 03:47:54 +0000 (UTC) X-FDA: 82061185668.19.CC305D9 Received: from dggsgout12.his.huawei.com (unknown [45.249.212.56]) by imf16.hostedemail.com (Postfix) with ESMTP id C86C818000C for ; Mon, 29 Apr 2024 03:47:51 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf16.hostedemail.com: domain of shikemeng@huaweicloud.com designates 45.249.212.56 as permitted sender) smtp.mailfrom=shikemeng@huaweicloud.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714362473; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Xp1ncWjHGeZ5doQPYrVKdPq4BoeQXyB/Tu5lE/rO7O4=; b=mQ6COAYA/GbybzEPd1S6yuB1WIQ1xEZCdeWk6dRWLKsTRB+CnTcQxLEUgSgxZ7hobk/gkx bqgoc+YmQutA3GvfEsWsS7DD9qubQXMpgeZS8W+tfuiKggMO4+QQYY5F7FN9ux7z8ZnZOU 69C07h9RcUrsfGFrSaKJKoOkl86HEBw= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf16.hostedemail.com: domain of shikemeng@huaweicloud.com designates 45.249.212.56 as permitted sender) smtp.mailfrom=shikemeng@huaweicloud.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714362473; a=rsa-sha256; cv=none; b=FUqpAHBuYs9IMW/wbA2pubKa//lp9GRf7uxCwCtfGSsaeiCqQDgoUPYNkc8mkoqGdjHK0S Fl0A60AQR5fcGqizhg8v7erMTxFrDoHI9GsuandovO4faEXteS4ih3ObNGsgexWB9QhqhJ rusooYdevSzV0OKTozinyXbV8C+f898= Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4VSTmp74ZNz4f3jcp for ; Mon, 29 Apr 2024 11:47:38 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id C55301A1048 for ; Mon, 29 Apr 2024 11:47:46 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.101.6]) by APP1 (Coremail) with SMTP id cCh0CgA3UwxgGC9m24__LA--.38879S5; Mon, 29 Apr 2024 11:47:46 +0800 (CST) From: Kemeng Shi To: willy@infradead.org, akpm@linux-foundation.org, jack@suse.cz, tj@kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 03/10] writeback: factor out domain_over_bg_thresh to remove repeated code Date: Mon, 29 Apr 2024 11:47:31 +0800 Message-Id: <20240429034738.138609-4-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20240429034738.138609-1-shikemeng@huaweicloud.com> References: <20240429034738.138609-1-shikemeng@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: cCh0CgA3UwxgGC9m24__LA--.38879S5 X-Coremail-Antispam: 1UD129KBjvJXoW7WrW8CrW8XryxAFykuw1xZrb_yoW8tr4DpF 4xAw1a9FWUJanrXrnxCFyUur43trZ7t3yUt3srCw1fAw43Cr4UGFy7Ar9YvFy8CFy7Jrya vr4ava4fGF10krJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvGb4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUWw A2048vs2IY020Ec7CjxVAFwI0_Xr0E3s1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxS w2x7M28EF7xvwVC0I7IYx2IY67AKxVWDJVCq3wA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxV W8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMc Ij6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_ Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr 0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY 17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcV C0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY 6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa 73UjIFyTuYvjxUFYFCUUUUU X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-Rspamd-Server: rspam01 X-Stat-Signature: qgg715no3gqhsdwokktupyz8egtf51ao X-Rspam-User: X-Rspamd-Queue-Id: C86C818000C X-HE-Tag: 1714362471-31359 X-HE-Meta: U2FsdGVkX18KxpAbVST7Sv+n3XnRQp8FxTc5UlPQoL2bxTvfI6T0blhhasz8z+IU+2yGuwOYoc34jy693hB1t766RjDEeBJluKtkKqG5CJ1+arJtyPK9toU0eCcZjYCI1X7UTnzMLWrFTm7rp2nhQ7INitrIowLE5SwCx16E+U2rk231nr/U25VKA2FtxuMEMbcfHSuBo3lptBQvueGM0jWxPvybXwS8dvifLozKuIg3SylikA1fEyLg4RN582TGfGP9qw/+tjD7yVscKYYYwoZBDGttL2wVxznd1e43DfR2oMhp75zpNktL3PQZLN9Wx05CgvRDJ/3gK9M8tbKwxWC5/7bhpjyEPKkb1YnGY7nWyy/tpfKnWUOakJVBE0qyVtv1mIYcrD/AcINw1TQjwXkPHac5R3TTqAg0ZmDZsY44ke+mh+8j0ocPmaVFk6NxDmhm6nFL6Qok5nqX9Pea9Gs2IP3hmhS3TtsnURBmBZLHCQcudnJb8rMkXudu9XF6Md/4ZCeKIsKCwrNeLDR0KfAbiL+Z9Bq3CqGR1kpeGfZA3pVQxJv2Qq+gFAIbPu21f6pGNxfR32g0zKJ+UXjyEi+JG3g6D3TCWPwEXfjr6ywlZhcaULHYxf2N6olTKvFmBRMy46RbnBF5W8muOY38mXIPNNBMTivcCxBl+vn1VqbuAM9v1TWRdejhF+0AuHSWf7cbKWeiJr14G6euSSWovyR+Me64V8A6g4IJbQjRQ1JTTTa+I0+2tBqYySCX+NQ8feBezrk5/qij5xghb8CcdJ69TTVmHlgmTyJtKMoxq31FcE4NanYL4jaycX9LZOoAhwNemNLMGugmD4GUr9LzlXwwuAbkKBBrshAhSizvrYIJQQYtgrFlXRoM3mtzq3iZijDtDn1TnQ9Pw8u6Ew80w9NCEHJp060Y5PvUYhk4I/R5GXh6Bjy3GIPZtRL4ZZyFjXQLo+0Gu/qvCKeOhTQ FjLS7Lwt uUsRI6qK8J7r+fL8yA7l3gMGg5UDVpDC3QIMAbpBNuxyoW3qIQ9B/ENf5SGl5Tnd7WpblEqyfgOU378pKTY1TTpyrvKH2/92vy+NIsZKsWDaFIG2KChNMrCTosPrgWpEs92nxOmdqDS1F8Slwhy0VdC+V7GnAYQP9u0nNcm9FQa1eN0SeV94arq/fbCTgoRF+FjWm1JGzqyfgKtDmSdcpkIr5x1ICy+CvGnOdeyqO/tT/m7Y/VHmMKYOfTT5ZZPRilc2Q2kmlpuTFepo= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Factor out domain_over_bg_thresh from wb_over_bg_thresh to remove repeated code. Signed-off-by: Kemeng Shi Acked-by: Tejun Heo --- mm/page-writeback.c | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index e4f181d52035..28a29180fc9f 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2137,6 +2137,20 @@ static void wb_bg_dirty_limits(struct dirty_throttle_control *dtc) dtc->wb_dirty = wb_stat(wb, WB_RECLAIMABLE); } +static bool domain_over_bg_thresh(struct dirty_throttle_control *dtc) +{ + domain_dirty_avail(dtc, true); + domain_dirty_limits(dtc); + if (dtc->dirty > dtc->bg_thresh) + return true; + + wb_bg_dirty_limits(dtc); + if (dtc->wb_dirty > dtc->wb_bg_thresh) + return true; + + return false; +} + /** * wb_over_bg_thresh - does @wb need to be written back? * @wb: bdi_writeback of interest @@ -2148,31 +2162,14 @@ static void wb_bg_dirty_limits(struct dirty_throttle_control *dtc) */ bool wb_over_bg_thresh(struct bdi_writeback *wb) { - struct dirty_throttle_control gdtc_stor = { GDTC_INIT(wb) }; - struct dirty_throttle_control mdtc_stor = { MDTC_INIT(wb, &gdtc_stor) }; - struct dirty_throttle_control * const gdtc = &gdtc_stor; - struct dirty_throttle_control * const mdtc = mdtc_valid(&mdtc_stor) ? - &mdtc_stor : NULL; - - domain_dirty_avail(gdtc, true); - domain_dirty_limits(gdtc); - if (gdtc->dirty > gdtc->bg_thresh) - return true; + struct dirty_throttle_control gdtc = { GDTC_INIT(wb) }; + struct dirty_throttle_control mdtc = { MDTC_INIT(wb, &gdtc) }; - wb_bg_dirty_limits(gdtc); - if (gdtc->wb_dirty > gdtc->wb_bg_thresh) + if (domain_over_bg_thresh(&gdtc)) return true; - if (mdtc) { - domain_dirty_avail(mdtc, true); - domain_dirty_limits(mdtc); /* ditto, ignore writeback */ - if (mdtc->dirty > mdtc->bg_thresh) - return true; - - wb_bg_dirty_limits(mdtc); - if (mdtc->wb_dirty > mdtc->wb_bg_thresh) - return true; - } + if (mdtc_valid(&mdtc)) + return domain_over_bg_thresh(&mdtc); return false; }