From patchwork Mon Apr 29 03:47:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13646249 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 A1CC4C19F4F for ; Mon, 29 Apr 2024 03:47:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A0C266B007B; Sun, 28 Apr 2024 23:47:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8167D6B0095; 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 5CC246B0096; Sun, 28 Apr 2024 23:47:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 2237A6B0085 for ; Sun, 28 Apr 2024 23:47:55 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id CC40B14100D for ; Mon, 29 Apr 2024 03:47:54 +0000 (UTC) X-FDA: 82061185668.18.B9F69BF Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by imf03.hostedemail.com (Postfix) with ESMTP id 3FA6E20006 for ; Mon, 29 Apr 2024 03:47:51 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=none; spf=pass (imf03.hostedemail.com: domain of shikemeng@huaweicloud.com designates 45.249.212.51 as permitted sender) smtp.mailfrom=shikemeng@huaweicloud.com; dmarc=none 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=PRoGGQa3+cfB1Xvy9AzB8/U1nu1FrK/5u20rEcWlP/g=; b=FF+nvZ8lkrkex3z7JTfxiafDdBkz06JKBDesRqnVXCC6/aBZ4kj5SQiroKvNUFYqnCNuXP t2sBkPdsyFlewuAzKaixPECFIqUwtcNhdbwV+d9PG5UrNgAP/P331+fKHTynOyVanDAbnY x7XYoMZlpKVwCaqtG9xfrIlKEOcU+X0= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=none; spf=pass (imf03.hostedemail.com: domain of shikemeng@huaweicloud.com designates 45.249.212.51 as permitted sender) smtp.mailfrom=shikemeng@huaweicloud.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714362473; a=rsa-sha256; cv=none; b=e6YWowZ6t9kfrmK9g3SCUoPT15klI1R7tdb3dZDn0sV5ZuEsc+/LBv9dhq8KXZDfKrgbyv WPWuhf/iSJNV+cmGMTfdNP3BAr5BNfiv1BmboNGpLGIUnaliwOm1RcAnsUbAI9fNtWuJEZ UJHReqLK5TxdEsCZfbiue2zwmXvrnTY= Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4VSTmq2JSyz4f3nJq for ; Mon, 29 Apr 2024 11:47:39 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id B98571A0B98 for ; Mon, 29 Apr 2024 11:47:48 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.101.6]) by APP1 (Coremail) with SMTP id cCh0CgA3UwxgGC9m24__LA--.38879S11; Mon, 29 Apr 2024 11:47:48 +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 09/10] writeback: factor out wb_dirty_exceeded to remove repeated code Date: Mon, 29 Apr 2024 11:47:37 +0800 Message-Id: <20240429034738.138609-10-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--.38879S11 X-Coremail-Antispam: 1UD129KBjvJXoW7Cw45Jr4Dtr17ur4fXr45GFg_yoW8KF17pF ZrJw12krWUJa1Sg3ZxJFWDur43trsrArWxJ34UWw15ta13KF12gr92qFWFvr17ArZxJFs0 yrW5t34xGw18Kr7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9jb4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUAV Cq3wA2048vs2IY020Ec7CjxVAFwI0_Xr0E3s1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0 rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVWDJVCq3wA2z4x0Y4vE2Ix0cI8IcVCY1x0267 AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E 14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7 xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Y z7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7 v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF 1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_JFI_Gr1lIx AIcVC0I7IYx2IY6xkF7I0E14v26F4j6r4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4l IxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvf C2KfnxnUUI43ZEXa7IU13l1DUUUUU== X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-Rspam-User: X-Rspamd-Queue-Id: 3FA6E20006 X-Rspamd-Server: rspam06 X-Stat-Signature: z1gcqrswno91o7wc7dxmndw9wjopner3 X-HE-Tag: 1714362471-823782 X-HE-Meta: U2FsdGVkX1+DJ+czupeWnunacLrETrA7bcrgot+NzwrjnobC/PMr6qhu2uU3gufw5QKx10ZmW+GcpiZZdW/boSU1o6JslyvsBSWZ3woBtFzcnkueaTgHELsOHK625/t058TMvFHJxhqYi7ivSSbHVaVCeaFCB7LV0VHfddoPUNAA3U7awI0H9r0LQw1+4gJcauQQLKXGkBA9KLkfmBEzhIA0IqQ4FiocZpCWMjbCiZ36V5rNEg/rFs980RY92D8De0rLQdev/FuJgIE9XJbXuExloTo7SpRCmTRo7vPmxoM6vzFy/KuAL39joeHormn7Wps4Pm6hTyoZP/t+0qyb/eFdxjXQmMqFhcM1jIr865PXRQVQS14qSjyanKdHTTEjBHN/J3fVL/XtvtIxCc+oLWFqUiZCWEDgnMD4h2sPQcWyYBkuiy6pPSDlBMOPI2KjvX3SJcWqXbWRFjc0HK1mtwtAo1lKS9XQ360rbFpKVytOU9IwgBxe8EkF90N7SyK+9pJv7Gqt4YUV5AXjIARtLFxoChmOGKF55nnHu97Pb3ZspEGst1S6sm0Uj2uRR+BQsyQvwYf2w/EPfXdnqv3WVnl4raZn6eG20Zi3idBu9MtbV0YvJyRspamRIEDKDxOMtaPvz8NQXxsLXexe6z+kp9SSAM/AQhUDdoLRzS9xTxLAqjZ+xIjBmBLQUVli0gKJiZBT6xMZJzoNFwSZw67y8ZpihkPcHaXXtB2qeB0CJ7MJ9anw4LKKZyGtgPoLWVxc57O9vQ+TGcllFKSzTtnrAVJzjltbEpeTM8dF9q9N1IcLyBnquPDwthZyDhaamgDjS/E6I4dcD5fJpevHzXVwTYO3H1Q/ujVq/Ba9dr/Nf4khBmnF2jfKkgw7LfvYeJneAhphk/AyT85AhkaiOzl41Rxu+4ZlmgxZWDJynwHdaErxTkm3BA1xLJdB+fUjXrVf4/CNDykw49eYwp62mg9 LO+5Lf3D AM6PnbP6FK1rIMlaoLoNIE7Z7lg2BIPTqLG3m4uHaScOfQfMbBFsJmr+VPmcIZE4yDI3dru+pPUHDAOYOKGLsncFwNaY9Q5Oi00J8RvpJ7K32UJBlvRHLDToX+Q9NGYA7wikr4pWkdzcLUfa0tmi557pNuNccI9NgZ4QetSqHVYfyE5OKlwv1ojzNG0kRqivzqhGMcA08ksUp4RLxXCQyKcmTZA== 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 wb_dirty_exceeded to remove repeated code Signed-off-by: Kemeng Shi --- mm/page-writeback.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 68ae4c90ce8b..26b638cc58c5 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -140,6 +140,7 @@ struct dirty_throttle_control { unsigned long pos_ratio; bool freerun; + bool dirty_exceeded; }; /* @@ -1782,6 +1783,13 @@ static void wb_dirty_freerun(struct dirty_throttle_control *dtc, dirty_freerun_ceiling(dtc->wb_thresh, dtc->wb_bg_thresh); } +static inline void wb_dirty_exceeded(struct dirty_throttle_control *dtc, + bool strictlimit) +{ + dtc->dirty_exceeded = (dtc->wb_dirty > dtc->wb_thresh) && + ((dtc->dirty > dtc->thresh) || strictlimit); +} + /* * balance_dirty_pages() must be called by processes which are generating dirty * data. It looks at the number of dirty pages in the machine and will force @@ -1804,7 +1812,6 @@ static int balance_dirty_pages(struct bdi_writeback *wb, long max_pause; long min_pause; int nr_dirtied_pause; - bool dirty_exceeded = false; unsigned long task_ratelimit; unsigned long dirty_ratelimit; struct backing_dev_info *bdi = wb->bdi; @@ -1872,9 +1879,7 @@ static int balance_dirty_pages(struct bdi_writeback *wb, if (gdtc->freerun) goto free_running; - dirty_exceeded = (gdtc->wb_dirty > gdtc->wb_thresh) && - ((gdtc->dirty > gdtc->thresh) || strictlimit); - + wb_dirty_exceeded(gdtc, strictlimit); wb_position_ratio(gdtc); sdtc = gdtc; @@ -1889,17 +1894,13 @@ static int balance_dirty_pages(struct bdi_writeback *wb, if (mdtc->freerun) goto free_running; - dirty_exceeded |= (mdtc->wb_dirty > mdtc->wb_thresh) && - ((mdtc->dirty > mdtc->thresh) || strictlimit); - + wb_dirty_exceeded(mdtc, strictlimit); wb_position_ratio(mdtc); if (mdtc->pos_ratio < gdtc->pos_ratio) sdtc = mdtc; } - if (dirty_exceeded != wb->dirty_exceeded) - wb->dirty_exceeded = dirty_exceeded; - + wb->dirty_exceeded = gdtc->dirty_exceeded || mdtc->dirty_exceeded; if (time_is_before_jiffies(READ_ONCE(wb->bw_time_stamp) + BANDWIDTH_INTERVAL)) __wb_update_bandwidth(gdtc, mdtc, true);