From patchwork Mon Apr 29 03:47:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13646258 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 AA608C04FFE for ; Mon, 29 Apr 2024 03:48:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 72E9B6B008C; Sun, 28 Apr 2024 23:48:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6DD4F6B0093; Sun, 28 Apr 2024 23:48:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 580D06B0095; Sun, 28 Apr 2024 23:48:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 309D66B008C for ; Sun, 28 Apr 2024 23:48:00 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id DDA1A1A1709 for ; Mon, 29 Apr 2024 03:47:59 +0000 (UTC) X-FDA: 82061185878.27.570BA64 Received: from dggsgout12.his.huawei.com (unknown [45.249.212.56]) by imf02.hostedemail.com (Postfix) with ESMTP id 7814680003 for ; Mon, 29 Apr 2024 03:47:57 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=none; spf=pass (imf02.hostedemail.com: domain of shikemeng@huaweicloud.com designates 45.249.212.56 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=1714362478; 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=vxrjnKI2OiIsLWW5zjc+Vsca5M6fEJCgVCafJICxuZs=; b=CljqzOiBcDQoxwOP7k3raH1oKtoIQJPSI/My2+uKMGb17KxK3HhC14ZVN50JgiRNUQR5sq b/E6CSpqY0mUpfVlucBEgQ7izsAgPcLuCRJFHPJp8vRXtXUri7bv6TWOCTcVJ8Oy9p5ryj D0wIECq/i6WXvVh/QbCYdG9EaatnSB8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714362478; a=rsa-sha256; cv=none; b=AZGdCur7zyaNEVAgRj/z/kHU8ejbFnuIidStvuEv+Ad8B3XZRJuDNdtl2rVqfIGhJCQa9Q WD0CL0qu1el4Z9b4ax6O+2O8gBuYqzsk9nh81DD83gsrB2Su7DQyUKfTrewBpMHRAChdjL Oe6hud9JqQuh/Z1nQPHiR2CtJRdhrsc= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=none; spf=pass (imf02.hostedemail.com: domain of shikemeng@huaweicloud.com designates 45.249.212.56 as permitted sender) smtp.mailfrom=shikemeng@huaweicloud.com; dmarc=none Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4VSTms1rSMz4f3jdr for ; Mon, 29 Apr 2024 11:47:41 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 129191A105D for ; Mon, 29 Apr 2024 11:47:49 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.101.6]) by APP1 (Coremail) with SMTP id cCh0CgA3UwxgGC9m24__LA--.38879S12; 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 10/10] writeback: factor out balance_wb_limits to remove repeated code Date: Mon, 29 Apr 2024 11:47:38 +0800 Message-Id: <20240429034738.138609-11-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--.38879S12 X-Coremail-Antispam: 1UD129KBjvJXoW7CF1kKw4kCFWfXr1UCryfWFg_yoW8AFyrpF Z2kw40kr4kJF1Sqa9akFW7urWaqrs3tFWfG348Wws3tF4fKr12gFy2vry0qr17ArnrGrW3 Zr4DtF97Gw1rCFJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9jb4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUAV Cq3wA2048vs2IY020Ec7CjxVAFwI0_Xr0E3s1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0 rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVWDJVCq3wA2z4x0Y4vE2Ix0cI8IcVCY1x0267 AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E 14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7 xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Y z7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7 v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF 1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Gr0_Xr1lIx AIcVC0I7IYx2IY6xkF7I0E14v26F4j6r4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4l IxAIcVC2z280aVAFwI0_Gr0_Cr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvf C2KfnxnUUI43ZEXa7IU13l1DUUUUU== X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-Rspam-User: X-Stat-Signature: k6sbnkyboydkme1akrmuyybncbte98zr X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 7814680003 X-HE-Tag: 1714362477-826904 X-HE-Meta: U2FsdGVkX1+28C3wFu1WyoQ22kcURv2hHnt3A1piFOcxG8uF0ZPQQexgCUgTnvvXGd+stNIp4XsInu6xkDNZt66FgbdQe01ub/ZAauzgtefXHOOD9nLwfuHDZNScqejKTGCK6QSTrZajWtSbEguSBUqelAp83TILCcDz1kN0QbU5uTsSmNg47j+2iWwtkMaSQX1eowKaOeMhE6CDG6PPXMoc7WJ6V7JFe9+Cfv/omQCnx3EEAVPVGvhGnLh2WzTzpHAAOJqlFbPlEp5mOtZ92TUt3Hgpf3wKTNd9PrPTQ0Pr6J7VsT8X7gmJelfrhJ93hTW2Whg7uKfygmVQiscUC3W+h5M+qcAh4Mzzh2Xkn9viKWbhEPonYy5rcryva8CUvJm4xPmzBkw1LVDYAwpyuHMk1RPxNUsKPfUS5FtXdolWny95T1mFKRsWqh/YVxh6Wnp4DL1qcZecnR1OWOEJsx+OyhpFTxGRNE69lMcyb6ief5WxzdCN7rYvAwF2vgkB5ZS0jmHt7nDe1rvzwc+9/VxeXdLhYw3ne0uMXZz/WdedP+wmgMN4HiVFTfLJslxTOdBpxz/mvsE1RxVvBwFAdXMcPgmOoozDnSK5ZGpK7SaDbvaiV3GktKG6odV15s6GgFCczZkZucCJ2n2U2dTBZ/Mm+2MmlcbUvdhgwtrDEJUyNAHmYYNYScDjokE26JZCkaUrJa5X4CdZsqUGJkgVbs29GdI63D0/cMJavbVClphU1IqIbfflYqXaGq7M+wCAdCxCFPCtaAlX+41OP0dVcS0t+rDo7dzsMmBy1Afo79wmsf/cjIiAOxrPLTX0XING+wDJuSOm0NC2/DPj+zDgaYLru56MExIVaLxhKvGYnrGWc5wvWcWJZlEjasOkaqbXvYKCukCdxeGlTejE5D8qz4YMlAJGNNTvE6DERQoPq9vv8hIZDhiPH+C4A1TYI+SxB95Us6S/0F+OutS/Q/z zLYaSk9j 1O8+nrk/g9rrdSDjDMnGO41gwnVe0+u9MYvZO0UYl+Cw/WIcs6u60MKYMd3M5lvOD/sn3tv6dXcpA7q5hcm1PLmpQeOoKbcI5R7ViChKt0QPxo5OK9gRP/pu7aXvXAtzX0KOTy0ry4vmOggdV4zJFYMCYhh6n4o8n+fhS2qd2LxfGO5azzKlESs0E8M/eRylZk36VnewS0HmqG2aZuTn1r8z+v4oo3icPyBLDlOZzfvTHpwz+Gl5legPUEcocGqOnqgdgDroBsU0szLA= 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 balance_wb_limits to remove repeated code Signed-off-by: Kemeng Shi --- mm/page-writeback.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 26b638cc58c5..4949036e6286 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -1790,6 +1790,17 @@ static inline void wb_dirty_exceeded(struct dirty_throttle_control *dtc, ((dtc->dirty > dtc->thresh) || strictlimit); } +static void balance_wb_limits(struct dirty_throttle_control *dtc, + bool strictlimit) +{ + wb_dirty_freerun(dtc, strictlimit); + if (dtc->freerun) + return; + + wb_dirty_exceeded(dtc, strictlimit); + wb_position_ratio(dtc); +} + /* * 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 @@ -1875,12 +1886,9 @@ static int balance_dirty_pages(struct bdi_writeback *wb, * Calculate global domain's pos_ratio and select the * global dtc by default. */ - wb_dirty_freerun(gdtc, strictlimit); + balance_wb_limits(gdtc, strictlimit); if (gdtc->freerun) goto free_running; - - wb_dirty_exceeded(gdtc, strictlimit); - wb_position_ratio(gdtc); sdtc = gdtc; if (mdtc) { @@ -1890,12 +1898,9 @@ static int balance_dirty_pages(struct bdi_writeback *wb, * both global and memcg domains. Choose the one * w/ lower pos_ratio. */ - wb_dirty_freerun(mdtc, strictlimit); + balance_wb_limits(mdtc, strictlimit); if (mdtc->freerun) goto free_running; - - wb_dirty_exceeded(mdtc, strictlimit); - wb_position_ratio(mdtc); if (mdtc->pos_ratio < gdtc->pos_ratio) sdtc = mdtc; }