From patchwork Tue May 14 12:52:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13664064 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 79CA3C04FFE for ; Tue, 14 May 2024 12:53:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 658496B027E; Tue, 14 May 2024 08:53:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 513106B031A; Tue, 14 May 2024 08:53:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1E2746B027C; Tue, 14 May 2024 08:53:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id EAF6C6B031E for ; Tue, 14 May 2024 08:53:36 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id D97BB121246 for ; Tue, 14 May 2024 12:53:35 +0000 (UTC) X-FDA: 82116992790.14.CD80184 Received: from dggsgout12.his.huawei.com (unknown [45.249.212.56]) by imf04.hostedemail.com (Postfix) with ESMTP id 482A140011 for ; Tue, 14 May 2024 12:53:32 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=none; spf=none (imf04.hostedemail.com: domain of shikemeng@huaweicloud.com has no SPF policy when checking 45.249.212.56) 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=1715691214; 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=0EhsKrW/Sp6dPIJFD2cCoXmFIaalgzDjYH4iMS4P2Uo=; b=YXZV1+5dvNe9A/qnIs62d82Y44nhnhBYE+YTdmhYnkgalO5W2Fl1Ta8PznvHxildiV1t3S 6x6m8BfoDzeY8+I6NgjmLoqCH/3drsjr5lUbvz0go8RuLcpQVZ6SyMjT7Jf/TDIm4C3+6o glZqrqAdLcYrZ4vHy3E0ocwDWhkh+v8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1715691214; a=rsa-sha256; cv=none; b=7l4q4DDkXnllFRAWeslQ6F5VcBu265NJRuhKKqLok6zUhMFx4WCVFSr0S3FPBWWyUtU3O4 b9VPxq3d8awlxq+hL0aMK5qyHZkNxgvUNs8rlGTc34DfySUzFjsRgbJ+sQN52Ar2mTCIt/ 2yDPfSKN3nnyD8hT8OaQ+jD7YBzczPo= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=none; spf=none (imf04.hostedemail.com: domain of shikemeng@huaweicloud.com has no SPF policy when checking 45.249.212.56) smtp.mailfrom=shikemeng@huaweicloud.com; dmarc=none Received: from mail.maildlp.com (unknown [172.19.163.235]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4Vdx9W6RDbz4f3jcq for ; Tue, 14 May 2024 20:53:19 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 842BF1A0AD6 for ; Tue, 14 May 2024 20:53:28 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.101.6]) by APP4 (Coremail) with SMTP id gCh0CgDHzG7EXkNmCyyLMw--.6596S10; Tue, 14 May 2024 20:53:28 +0800 (CST) From: Kemeng Shi To: willy@infradead.org, akpm@linux-foundation.org, tj@kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 8/8] writeback: factor out balance_wb_limits to remove repeated code Date: Tue, 14 May 2024 20:52:54 +0800 Message-Id: <20240514125254.142203-9-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20240514125254.142203-1-shikemeng@huaweicloud.com> References: <20240514125254.142203-1-shikemeng@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: gCh0CgDHzG7EXkNmCyyLMw--.6596S10 X-Coremail-Antispam: 1UD129KBjvJXoWxJryxXr4rXFW8CrW8Jr1DJrb_yoW8AFyrpF Z2kw40yr1kJF1IqanayFZF9rWaqrs3tFWfJ348Gws3tF4fKr12gFy2vry0qr17ArnrGrW5 Zr4DtF97Gw1rCFJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU90b4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUAV Cq3wA2048vs2IY020Ec7CjxVAFwI0_Xr0E3s1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0 rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVW7JVWDJwA2z4x0Y4vE2Ix0cI8IcVCY1x0267 AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E 14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7 xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Y z7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7 v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF 1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_JFI_Gr1lIx AIcVC0I7IYx2IY6xkF7I0E14v26F4j6r4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4l IxAIcVC2z280aVAFwI0_Gr0_Cr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIda VFxhVjvjDU0xZFpf9x07UZo7tUUUUU= X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 482A140011 X-Rspam-User: X-Stat-Signature: u9gk4nw84xjp5a1ybhp599itkhx8nqhf X-HE-Tag: 1715691212-335918 X-HE-Meta: U2FsdGVkX1+Lgce1IjYNdymp76QJaEf3cV/ZJgtB5DDPF3PGjBuhSMHH50bknDFbsAPI+JWbL0etx1v8UEpODx6V/qvEHYJS+f1h4dSMUpCk+CcdnzFkktSTlUPzsWJr5mxPmKLBiIScd3LOkWHxsKtLkh/nTgrIbdU8ZpVmDfLsmaCwSEGElW8zalD+ICWWmFY1NtTdaNR35P2uT/TyQhbvklzf4IEOd88rV93z+G8BVIIRsqTtuHrz5+ErSRBbDGqE22jQAUOPB/DJi7JVAhG/i1mrQaXo8ETBsifRQXBVwpLaJXFnpCW1W834pXki8JfM1o6lbSE3WfkJxLlnc8owM6aCate53vq8BdEQr4v0CCRovh9J6tfsm15HCvma52sqa4a74pEO/KgrVz87JEgmxbar3ExipsZjDFn+UtnKQbd1cDBSkX5I6z30D4ceEaQ6a6KHCwFF3v14PaJHTXTFiwJeXoPS0d/cF/9jHriYxycfSPl+8mVWh7IeYrKgxDzs4UdeyPA+piq9dQqp5bO791aQWEBkpcRojMQkoCnEerwph9jUa8yFjLKXJ8N7CNImjG5SEOHD6nTzar1jDBPQ9A8g+nQAzxs0fB/ubbGfU8nllteRZclkyiGrjCnsn0OuuACcXCAYiGli7IfkhuLUo0NbksV2zA9UXWyXSOB3gXqYdk9p/Jtv3caemuLEdo60TGToZV8Z3091pVAVWouUH0e6AAt6xz7CqDFr4g09qQwiortorfohnzCt4jin/sgb0uKeTMHpMV6FV0IvFIGslM75NhYok+lvLn5rRjd62lSAEGyUzndDJ9GUsCHnLSSqq5biJh1BU24dD/RonQ6yNwOyuLpHbCK9iaCEBYQotXQfu2LpboxKaUpjHQk3R2+kjBWAZUp+lNDnrrOhE80JXUaWBjeoFjykEwqusxDb2TysmFHW9m98cV4xwkjBcC/ZQlpTJiWmdGDdKsY zORF6BpB 3UKYBkDw9Rihr5QLBMJ9IZ9hJeJE5XZE8+dYJX6IJ08MZnQDAgLaKHqpYZHR7t2f38gNcxPbbdlV4ycS0J5gZ3nATKh/wUgurQvqZsd920XCEpO0r2VRcbBQrd8fJLZNfbD7qSjui9wRz5oUp5toaSxXbcDb+QLcCwJrnA9r/kzjSRh7fV4YdqZfnPLdr7lcIpa1EpyxZB1UyLcUA/tjDL4qvLTFqrT39cFMeKBl/V9FOpdxTxk6Mhl+zwzxv95eUSDGrLiq1NJqc3rrZra0HJZ2WRA== 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 0f1f3e179be2..d1d385373c5b 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -1783,6 +1783,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 @@ -1869,12 +1880,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) { @@ -1884,12 +1892,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; }