From patchwork Mon Apr 29 03:47:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13646251 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 E73D5C19F4F for ; Mon, 29 Apr 2024 03:48:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1DD836B0087; Sun, 28 Apr 2024 23:47:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BF50F6B0098; 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 7C91D6B0085; Sun, 28 Apr 2024 23:47:55 -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 20D826B0083 for ; Sun, 28 Apr 2024 23:47:55 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id CA378C16CF for ; Mon, 29 Apr 2024 03:47:54 +0000 (UTC) X-FDA: 82061185668.17.5D318E5 Received: from dggsgout12.his.huawei.com (unknown [45.249.212.56]) by imf27.hostedemail.com (Postfix) with ESMTP id 5260640005 for ; Mon, 29 Apr 2024 03:47:50 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf27.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=SQ/JBG66LmbW9o6Seu/f8heP05rH3ongsctM/QThBrk=; b=7HSihje2mkl7fDxgvLOvE5ZQlNfqwW68W583SbfswpnruurJWO7VtfTSTfBjbih7bAGGBl UC7HUCEZdW0G16gyNYqfosd16yiCrElg2Ugax8zAWgJwdHHu89r4lP3LWCo3khnHOa/9wt bQ5ziVISXDmYYzVweZnIfO7vlUNZSiw= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf27.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=P1JAfSBlNwKaKUVSY8DuA70vlHUMgkWNADCnTQsJnujVMs2CjWkIf93fLJHrTSRF3mSDhg AiRMC29cmKw/va8eTGdRjOTmdBJX+6bqgkwr/wgBFsJy9bg5H6hGaNI3KZJAFmmVMGM53s lAPfP2qQOZeVxL3B0PaeRa7yP8QCpJI= Received: from mail.maildlp.com (unknown [172.19.163.235]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4VSTmp2VCTz4f3jHs 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 277071A0568 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--.38879S3; 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 01/10] writeback: factor out wb_bg_dirty_limits to remove repeated code Date: Mon, 29 Apr 2024 11:47:29 +0800 Message-Id: <20240429034738.138609-2-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--.38879S3 X-Coremail-Antispam: 1UD129KBjvJXoWxCw43ZF1rCw18Aw1kuFyDKFg_yoW5GF13pF ZrAw12vrW8Jr13trsxJFWUZr43tan3trW7Xr93CwnIyw17GryYgFyIkFZYvFyfGFW7Ja4f Zw4Yv34xJ34DKr7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvGb4IE77IF4wAFF20E14v26r4j6ryUM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUGw A2048vs2IY020Ec7CjxVAFwI0_JFI_Gr1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxS w2x7M28EF7xvwVC0I7IYx2IY67AKxVWDJVCq3wA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxV W8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMc Ij6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_ Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr 0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY 17CE14v26r126r1DMIIYrxk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bKibxpm+inL0KZQSDpRFqNl45x/etdhu93PWZfBy15EHIY8iVS59pAMvKYrdX3Pabdxs4lLAMkd/UyiBWYE8BIIY/oFDt0K7kr3ahzQJvyO13rTdYOZOYc9Dpi2xRTQK0526+dgOAoWXspkNKQunO9dMwxSCaCS23D3pbyQGVlzdQR+SxV/mfl/SZ8/rM58CMcMfRa/OLoml1s9wkq8amRUDXhetPPkS30o28xI3q1XXjC5Jf7RKjx/CrpAmaf6FVHSvSR+1EgKWq6NC6Lp1WiauRmKP85h EDC4lkRR Inpf/ceHOPefIM6uOmgqLATjbalMVitQYNDUxCoBlegfJLKjTv12atKz6xOS6XXrxWV6Lx9ONwQPPPD0fcixS2HeOa9ApnYBXIABcCBjXt/t0/RBvNnAKNn7d2nhvT5NUd4ey/fdXSijCKRBQPRnNRYA4JGgY4rUWaS4XXXQ0WXjVHEOeC1AH+SEcGLGCvXsTRGcoz8OK0pFcybU905HtUtLOQ7Ewle23oOBAv1DpBbXDE0M+3KiN+iOSUU7AgyQxb/B/Sbws+gi7r3Q= 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: Similar to wb_dirty_limits which calculates dirty and thresh of wb, wb_bg_dirty_limits calculates background dirty and background thresh of wb. With wb_bg_dirty_limits, we could remove repeated code in wb_over_bg_thresh. Signed-off-by: Kemeng Shi Acked-by: Tejun Heo --- mm/page-writeback.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 692c0da04cbd..e1f73643aca1 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2087,6 +2087,21 @@ void balance_dirty_pages_ratelimited(struct address_space *mapping) } EXPORT_SYMBOL(balance_dirty_pages_ratelimited); +/* + * Similar to wb_dirty_limits, wb_bg_dirty_limits also calculates dirty + * and thresh, but it's for background writeback. + */ +static void wb_bg_dirty_limits(struct dirty_throttle_control *dtc) +{ + struct bdi_writeback *wb = dtc->wb; + + dtc->wb_bg_thresh = __wb_calc_thresh(dtc, dtc->bg_thresh); + if (dtc->wb_bg_thresh < 2 * wb_stat_error()) + dtc->wb_dirty = wb_stat_sum(wb, WB_RECLAIMABLE); + else + dtc->wb_dirty = wb_stat(wb, WB_RECLAIMABLE); +} + /** * wb_over_bg_thresh - does @wb need to be written back? * @wb: bdi_writeback of interest @@ -2103,8 +2118,6 @@ bool wb_over_bg_thresh(struct bdi_writeback *wb) struct dirty_throttle_control * const gdtc = &gdtc_stor; struct dirty_throttle_control * const mdtc = mdtc_valid(&mdtc_stor) ? &mdtc_stor : NULL; - unsigned long reclaimable; - unsigned long thresh; /* * Similar to balance_dirty_pages() but ignores pages being written @@ -2117,13 +2130,8 @@ bool wb_over_bg_thresh(struct bdi_writeback *wb) if (gdtc->dirty > gdtc->bg_thresh) return true; - thresh = __wb_calc_thresh(gdtc, gdtc->bg_thresh); - if (thresh < 2 * wb_stat_error()) - reclaimable = wb_stat_sum(wb, WB_RECLAIMABLE); - else - reclaimable = wb_stat(wb, WB_RECLAIMABLE); - - if (reclaimable > thresh) + wb_bg_dirty_limits(gdtc); + if (gdtc->wb_dirty > gdtc->wb_bg_thresh) return true; if (mdtc) { @@ -2137,13 +2145,8 @@ bool wb_over_bg_thresh(struct bdi_writeback *wb) if (mdtc->dirty > mdtc->bg_thresh) return true; - thresh = __wb_calc_thresh(mdtc, mdtc->bg_thresh); - if (thresh < 2 * wb_stat_error()) - reclaimable = wb_stat_sum(wb, WB_RECLAIMABLE); - else - reclaimable = wb_stat(wb, WB_RECLAIMABLE); - - if (reclaimable > thresh) + wb_bg_dirty_limits(mdtc); + if (mdtc->wb_dirty > mdtc->wb_bg_thresh) return true; } From patchwork Mon Apr 29 03:47:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13646257 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 6A1A3C4345F for ; Mon, 29 Apr 2024 03:48:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F06266B0088; Sun, 28 Apr 2024 23:47:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 784B96B0093; Sun, 28 Apr 2024 23:47:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 35BB16B008C; Sun, 28 Apr 2024 23:47:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 595966B0093 for ; Sun, 28 Apr 2024 23:47:55 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 0E323121779 for ; Mon, 29 Apr 2024 03:47:55 +0000 (UTC) X-FDA: 82061185710.07.E1A3920 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by imf04.hostedemail.com (Postfix) with ESMTP id AD59540002 for ; Mon, 29 Apr 2024 03:47:51 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf04.hostedemail.com: domain of shikemeng@huaweicloud.com designates 45.249.212.51 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=rzDhs/JLGc/krFNNQofSHPqT5pI+BJvr+/OC+Nf6FmY=; b=rP7Loq2dQjXMsXkhub8PKBGv2nfbmegXyA03pmHrpHXZm7EyF5mRqUKrYGlmLt53BntaEQ cqQj5FhSzYm5z4UilnRv5veNtKfpjr52kfxDbmpE24A3nuELRPOapbX9vdO28yQHRw9nPI UuK8eGvt8XIA8Qz6bkyDFWRdihdUtfU= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf04.hostedemail.com: domain of shikemeng@huaweicloud.com designates 45.249.212.51 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=f4XjrzkduiPiROO4F9YvwYS4MoGAEOJdXM6m96EJes83SB/2aPAUiIhpZNvFrf4pUFadqi 1gkseLgd22pHx6KR6184l+aaRTgSqKlX4dtfCf1SRrr6UTOc66nzxxupLikQLE9l+Kzgif EElTwKnMitKQkdl2LzsA5PQOy3+RN/E= Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4VSTms3FB3z4f3kpG 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 76CC81A0175 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--.38879S4; 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 02/10] writeback: add general function domain_dirty_avail to calculate dirty and avail of domain Date: Mon, 29 Apr 2024 11:47:30 +0800 Message-Id: <20240429034738.138609-3-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--.38879S4 X-Coremail-Antispam: 1UD129KBjvJXoWxGrWxCF1Uur4UWr4rGr1Utrb_yoW5Xw48pF 43Jw4YkFWUJF42grn3JFWj9rW3K397trWUtryxCa1SvF1fur1UGFy8urykZr17CF97Jrya yrsIyr97Gr48CrJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvGb4IE77IF4wAFF20E14v26ryj6rWUM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUXw A2048vs2IY020Ec7CjxVAFwI0_Gr0_Xr1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxS w2x7M28EF7xvwVC0I7IYx2IY67AKxVWDJVCq3wA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxV W8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMc Ij6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_ Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr 0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY 17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcV C0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY 6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa 73UjIFyTuYvjxU2_MaUUUUU X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: AD59540002 X-Stat-Signature: wcjboiyiuu1gucrqzmsxmomycmyd9t1t X-HE-Tag: 1714362471-835752 X-HE-Meta: U2FsdGVkX19BzgaHsNMewYk0R7+9vKN5684K3mXRZOGoBUxNtKBsx7msrLbVsDYRUf9wbFCEvu4F4E0QTsww2zywMyhgUpwbP9cweODtbIO+H2Ze58ChNic6L4TDGdUnUVpPU4VgeUrgEqrxOmsw5GSs7lfBT2pU5O8eq7OntDCHvTcUj+lMMqlt00rnfK/y5V30EnpVIKvCIwqzeUcj/YqpcKu6Eah6PKn9bGq2b3fva6Kqm//CNbppd2IbSrrNdTJgTw+47I57Ky5Zdc3h44Rf22R8/aRggNAWcFjggYnNSXLt8xe/AEoyBNgdUtNHRo6T4c4iB83qxHippRrZ7WzIi+HG1SzWPir4aRWC4g1/G27AokNtBj2N0g0I3mLX9Kb9nMqHv68snY6usR/OaG0aA5OD3fyk47UGfldtMGCmvaeIIlMV7WYNqAzyIrvFsKrSlwQLnOdQORvCJ/IxIxsyzA+yRh4A7pEriAj8sNi2lujp9sImheCRxKRiI2XjV1r0qs0lJgcP5qHQ92OUEIr5Y78aHXX1m9fXUJMUAid5diAR9rJW2NkK6ejOEDX0iQxMIFKdj9LpoDM/hAD2be6PL0ZStX7qGP/uaWAd2WegQAC8NXf3nGBw4s9QW8zKszS+l9PA95KScPA3Ld4C1hYRh6ab2zpZUhSO8Swsb/4lf3NTIMYu5/2JwJx8CdHWjCoMMrGv+6xmAUZhYYDoXvEO1/TrJDH3kNY6liALvCxeHqb7BoJuHyt8gcU/oDPMBGqiQm18F+r6MfDccfRITeAtJ4yvBofF77F30oq/3m/jopKNU5JGze+Xot3vQXxN+oZs2tIh9yKl4P3F7t+/9v3+70Lt9kMasgH8CvUjrp8K7R/+Tl0JoShuWMf9ohc2qbi11Z25YJ/yfkJ81IXIzcOC/mdlWUm/xrOjoww4CIFly8IiMpGJA38GVQbTuv3av7XmYvjbtGImnCYDGvz bfGuDnx0 uqGM6eiOADmLVWY+7ctiXjCZk/HFQFqBZifMVvnb49v0nAIb5HB1lMhOi0T3PmH9ejIooPIq9bXIQF6/iziKP45cCVqETO7jcXm9xsCOJJ1DkPTJmpE+8rOSvmxyiLKCIvoYsYnN/duKA/wFUurO1MklQtbCGuEpgsjkhIN1sNOntegdmbsEg5Zs4zz0LzcH/T1DhztLxr00+SQuPn27VezCCjg== 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: Add general function domain_dirty_avail to calculate dirty and avail for either dirty limit or background writeback in either global domain or wb domain. Signed-off-by: Kemeng Shi --- mm/page-writeback.c | 50 +++++++++++++++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 13 deletions(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index e1f73643aca1..e4f181d52035 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -837,6 +837,41 @@ static void mdtc_calc_avail(struct dirty_throttle_control *mdtc, mdtc->avail = filepages + min(headroom, other_clean); } +static inline void +global_domain_dirty_avail(struct dirty_throttle_control *dtc, bool bg) +{ + dtc->avail = global_dirtyable_memory(); + dtc->dirty = global_node_page_state(NR_FILE_DIRTY); + if (!bg) + dtc->dirty += global_node_page_state(NR_WRITEBACK); +} + +static inline void +wb_domain_dirty_avail(struct dirty_throttle_control *dtc, bool bg) +{ + unsigned long filepages = 0, headroom = 0, writeback = 0; + + mem_cgroup_wb_stats(dtc->wb, &filepages, &headroom, &dtc->dirty, + &writeback); + if (!bg) + dtc->dirty += writeback; + mdtc_calc_avail(dtc, filepages, headroom); +} + +/* + * Dirty background will ignore pages being written as we're trying to + * decide whether to put more under writeback. + */ +static void domain_dirty_avail(struct dirty_throttle_control *dtc, bool bg) +{ + struct dirty_throttle_control *gdtc = mdtc_gdtc(dtc); + + if (gdtc) + wb_domain_dirty_avail(dtc, bg); + else + global_domain_dirty_avail(dtc, bg); +} + /** * __wb_calc_thresh - @wb's share of dirty threshold * @dtc: dirty_throttle_context of interest @@ -2119,14 +2154,8 @@ bool wb_over_bg_thresh(struct bdi_writeback *wb) struct dirty_throttle_control * const mdtc = mdtc_valid(&mdtc_stor) ? &mdtc_stor : NULL; - /* - * Similar to balance_dirty_pages() but ignores pages being written - * as we're trying to decide whether to put more under writeback. - */ - gdtc->avail = global_dirtyable_memory(); - gdtc->dirty = global_node_page_state(NR_FILE_DIRTY); + domain_dirty_avail(gdtc, true); domain_dirty_limits(gdtc); - if (gdtc->dirty > gdtc->bg_thresh) return true; @@ -2135,13 +2164,8 @@ bool wb_over_bg_thresh(struct bdi_writeback *wb) return true; if (mdtc) { - unsigned long filepages, headroom, writeback; - - mem_cgroup_wb_stats(wb, &filepages, &headroom, &mdtc->dirty, - &writeback); - mdtc_calc_avail(mdtc, filepages, headroom); + domain_dirty_avail(mdtc, true); domain_dirty_limits(mdtc); /* ditto, ignore writeback */ - if (mdtc->dirty > mdtc->bg_thresh) return true; 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 4xAw1a9FWUJanrXrnx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DVpDC3QIMAbpBNuxyoW3qIQ9B/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; } From patchwork Mon Apr 29 03:47:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13646256 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 08CD4C19F4F for ; Mon, 29 Apr 2024 03:48:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D7B3D6B0089; Sun, 28 Apr 2024 23:47:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 46DD96B0088; Sun, 28 Apr 2024 23:47:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1869F6B0083; Sun, 28 Apr 2024 23:47:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 2EA0A6B008C for ; Sun, 28 Apr 2024 23:47:55 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id D8F2C1A170A for ; Mon, 29 Apr 2024 03:47:54 +0000 (UTC) X-FDA: 82061185668.13.A54E870 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by imf30.hostedemail.com (Postfix) with ESMTP id B5FD08000B for ; Mon, 29 Apr 2024 03:47:51 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=none; spf=pass (imf30.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=eVq/sQGD7HOocXKuP7SHgpKjhUrN+VjbwQ5zNNo7vN8=; b=INED8fhNrDam3kO/+0QWkVvTQ9Ra+wym+AFxnRYci6c9T+cEA/wD6tvXPRbtV3SbyDZUrA qd5UDplI4JhfbM6nPXgR4K59+cDE+LfnNHj46vVzo9D0i5fJAgdaECFgYKPwrqLZzUPTC7 KA9xW8i+kFsFUNUfDaBFM91qyo4qmOE= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=none; spf=pass (imf30.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=mIyBoy5aCc4wt2JUrOdRwowV8R4yjFBQ2UO06kl3orm1Y/wHynZYfqRUHzPsQUCqn34Dwg 66htuqFDUFkxsjPDZ5LuyOrnRkV+bK3TN+5jxhFWFtjKhWRMaOa3qfMDLWjW6BWA5yAU3e xJF3/Oz3TA+6GrKK1+72LEcJjQ/ejmo= Received: from mail.maildlp.com (unknown [172.19.163.235]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4VSTmn5DPFz4f3nJd for ; Mon, 29 Apr 2024 11:47:37 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 291C31A0572 for ; Mon, 29 Apr 2024 11:47:47 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.101.6]) by APP1 (Coremail) with SMTP id cCh0CgA3UwxgGC9m24__LA--.38879S6; Mon, 29 Apr 2024 11:47:47 +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 04/10] writeback use [global/wb]_domain_dirty_avail helper in cgwb_calc_thresh Date: Mon, 29 Apr 2024 11:47:32 +0800 Message-Id: <20240429034738.138609-5-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--.38879S6 X-Coremail-Antispam: 1UD129KBjvdXoW7Wr45urWxZr1fWw1rWFyUJrb_yoWktrc_ua yUKrykur9rCF45Gay2v3Z3ZrykKw4ku3WDta1SkF9xCFn29rykXFs7XwsxJry7ZFWUXFy7 GrsrZa1akws7GjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbVAYFVCjjxCrM7AC8VAFwI0_Wr0E3s1l1xkIjI8I6I8E6xAIw20E Y4v20xvaj40_Wr0E3s1l1IIY67AEw4v_Jr0_Jr4l82xGYIkIc2x26280x7IE14v26r126s 0DM28IrcIa0xkI8VCY1x0267AKxVW5JVCq3wA2ocxC64kIII0Yj41l84x0c7CEw4AK67xG Y2AK021l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF7I0E14 v26r4UJVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAF wI0_GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2 WlYx0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkE bVWUJVW8JwACjcxG0xvY0x0EwIxGrwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbV WUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF 67kF1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42 IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF 0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxh VjvjDU0xZFpf9x07UZo7tUUUUU= X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-Rspamd-Queue-Id: B5FD08000B X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 4pdfxfs9r3i1g97ra881ajtcwk6wj3qk X-HE-Tag: 1714362471-981601 X-HE-Meta: U2FsdGVkX18LfhrsKleeSelp0kviZW/zBn59iSOoQY7l/nJU5MPFNfLNVLXQqeHQ9xrG9NgpayHVBnfEAscvPpl+NqLB/6FvLRNnMTtymOiwF3NwzB1x3pwBpcwgZ8uUlUiPN39/MqtNvMblJ9Yqx9hW5GL0ALiSPtu1byvcAuXZHlw1nw9O6mOkW9FslvnCpQQpugt1D+IQ3Zj3S/hY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ter, 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: Use [global/wb]_domain_dirty_avail helper in cgwb_calc_thresh to remove repeated code. Signed-off-by: Kemeng Shi --- mm/page-writeback.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 28a29180fc9f..a1d48e8387ed 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -934,16 +934,9 @@ unsigned long cgwb_calc_thresh(struct bdi_writeback *wb) { struct dirty_throttle_control gdtc = { GDTC_INIT_NO_WB }; struct dirty_throttle_control mdtc = { MDTC_INIT(wb, &gdtc) }; - unsigned long filepages = 0, headroom = 0, writeback = 0; - - gdtc.avail = global_dirtyable_memory(); - gdtc.dirty = global_node_page_state(NR_FILE_DIRTY) + - global_node_page_state(NR_WRITEBACK); - mem_cgroup_wb_stats(wb, &filepages, &headroom, - &mdtc.dirty, &writeback); - mdtc.dirty += writeback; - mdtc_calc_avail(&mdtc, filepages, headroom); + global_domain_dirty_avail(&gdtc, false); + wb_domain_dirty_avail(&mdtc, false); domain_dirty_limits(&mdtc); return __wb_calc_thresh(&mdtc, mdtc.thresh); From patchwork Mon Apr 29 03:47:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13646255 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 DB1C5C4345F for ; Mon, 29 Apr 2024 03:48:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BC54A6B0085; Sun, 28 Apr 2024 23:47:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3FB0E6B0089; Sun, 28 Apr 2024 23:47:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F1B816B0099; 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 262586B0088 for ; Sun, 28 Apr 2024 23:47:55 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id D250A4022D for ; Mon, 29 Apr 2024 03:47:54 +0000 (UTC) X-FDA: 82061185668.15.6D90ABA Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by imf08.hostedemail.com (Postfix) with ESMTP id 5BE4816001E for ; Mon, 29 Apr 2024 03:47:51 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf08.hostedemail.com: domain of shikemeng@huaweicloud.com designates 45.249.212.51 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=cVLmwvM55KKrk98jpFkQK7J4Ub92SCF7GSB0RSV4mFY=; b=mNNdtAyH27IUQmUHjc8ntQqGoTRm+nG8ehS2vTgDCUajgErBW1ETJKj5+pjzA2tsS8I7Kc DzZbhHANwcvUGpk4Bz2A63Ah0c8v2c1zKMQCiqeNv2eFptjBbKdaOLSI++ZXyNw89/ghRa jujto3/lTE/mRgZ+3ZsVqaJN3vkwrXI= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf08.hostedemail.com: domain of shikemeng@huaweicloud.com designates 45.249.212.51 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=bMp9j7Gm8Y3uBfq7OtRa7GKMrrFguKBtGVrWENK97SCRWlgKba0tH4Dxwo41tqaHrPw8FF Ah3ScV0YzqwPa/bn0QE+CBKB/J3DbGnGM8xIdVOKg8UFE9jiFf7poUWPaIuZfu4H/XzziP 4m3wLS/UhMh00JXtPg4EHD6sjOvDkqg= Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4VSTmt3FLSz4f3kpX for ; Mon, 29 Apr 2024 11:47:42 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 769A91A016E for ; Mon, 29 Apr 2024 11:47:47 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.101.6]) by APP1 (Coremail) with SMTP id cCh0CgA3UwxgGC9m24__LA--.38879S7; Mon, 29 Apr 2024 11:47:47 +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 05/10] writeback: call domain_dirty_avail in balance_dirty_pages Date: Mon, 29 Apr 2024 11:47:33 +0800 Message-Id: <20240429034738.138609-6-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--.38879S7 X-Coremail-Antispam: 1UD129KBjvJXoW7uFyrCF1kJw48ZrW8Gr4kWFg_yoW8GFWxpF Z3tan0kayUtF12qrn7Aa9F9rW3Kan7KrWxJryxC3yavF42kF1UKFyI9ryvvr1Ikry3Jr9I v3y2qrykJw10gr7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvEb4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUAV Cq3wA2048vs2IY020Ec7CjxVAFwI0_Xr0E3s1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0 rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVWDJVCq3wA2z4x0Y4vE2Ix0cI8IcVCY1x0267 AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E 14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7 xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Y z7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7 v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF 1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_JFI_Gr1lIx AIcVC0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI 42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWI evJa73UjIFyTuYvjxUFgAwUUUUU X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 5BE4816001E X-Stat-Signature: 5xij6e1scd66kt4pa9fbqoi4iqpu97xe X-Rspam-User: X-HE-Tag: 1714362471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TP6xRtiLAwEKgL8t39D839QXsj7SR463hgnkc+54xJjCdV8WGv44P3GnzDu5hxKxDNbyvRWT0J7UvA4dv4xqFRKYp5R6GHDkmje2ShHEYbORN/peMTMGKufAkkQIBIf89XEZcPZYh5R0pLfDSWgZHfRnIMtUK7c1pUf5e7rJ0LqxlF4sXRj8pwrcCmTbg= 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: Call domain_dirty_avail in balance_dirty_pages to remove repeated code. This is also a preparation to factor out repeated code calculating dirty limits in balance_dirty_pages. Signed-off-by: Kemeng Shi --- mm/page-writeback.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index a1d48e8387ed..c41db87f4e98 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -1747,9 +1747,8 @@ static int balance_dirty_pages(struct bdi_writeback *wb, unsigned long m_bg_thresh = 0; nr_dirty = global_node_page_state(NR_FILE_DIRTY); - gdtc->avail = global_dirtyable_memory(); - gdtc->dirty = nr_dirty + global_node_page_state(NR_WRITEBACK); + domain_dirty_avail(gdtc, false); domain_dirty_limits(gdtc); if (unlikely(strictlimit)) { @@ -1765,17 +1764,11 @@ static int balance_dirty_pages(struct bdi_writeback *wb, } if (mdtc) { - unsigned long filepages, headroom, writeback; - /* * If @wb belongs to !root memcg, repeat the same * basic calculations for the memcg domain. */ - mem_cgroup_wb_stats(wb, &filepages, &headroom, - &mdtc->dirty, &writeback); - mdtc->dirty += writeback; - mdtc_calc_avail(mdtc, filepages, headroom); - + domain_dirty_avail(mdtc, false); domain_dirty_limits(mdtc); if (unlikely(strictlimit)) { From patchwork Mon Apr 29 03:47:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13646252 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 C0E2FC19F53 for ; Mon, 29 Apr 2024 03:48:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4CC966B0098; Sun, 28 Apr 2024 23:47:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D97646B008A; 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 AAEA16B0083; Sun, 28 Apr 2024 23:47:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 27AE36B0089 for ; Sun, 28 Apr 2024 23:47:55 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id C707E12177F for ; Mon, 29 Apr 2024 03:47:54 +0000 (UTC) X-FDA: 82061185668.20.A7ED0E3 Received: from dggsgout12.his.huawei.com (unknown [45.249.212.56]) by imf15.hostedemail.com (Postfix) with ESMTP id E32F1A0004 for ; Mon, 29 Apr 2024 03:47:51 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=none; spf=pass (imf15.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=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=KmjblY363rY1a20QKT/IQxUbZXWoJWRyls9zYaRWvZg=; b=IYa5VYI2YBKTIkVoviIp4fU5gRTr/cxeiw2ae/FdwQXfw3mW0TYk98X59skFPLX2eimd8q D4m2OqNEV0MW5qV7TtRBZDiIno1hHeVNt7kzQsaCA3J5YCG/rS1jIUAYj9E1457vBMv5q3 u5bXa8ypj76j8wCoN0ja4MPsQOhcp2I= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=none; spf=pass (imf15.hostedemail.com: domain of shikemeng@huaweicloud.com designates 45.249.212.56 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=2532cpZdLmnTn5b6aQaXRnqFyCjgvZzeT2OWVFlcc5hAMdotbT4mdMM9M8yVn4oFV6tcJ8 A2uh/0zSh6ZISSts7kFOnOVWCPBD82weIc9nKqazrxrkWouwbArVaVK7z5B7BUa6c+yaCE SEgOqTsdsjObltCWmSN+EZn7FKvv8ew= Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4VSTmq71PMz4f3jcn 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 C3C141A0B98 for ; Mon, 29 Apr 2024 11:47:47 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.101.6]) by APP1 (Coremail) with SMTP id cCh0CgA3UwxgGC9m24__LA--.38879S8; Mon, 29 Apr 2024 11:47:47 +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 06/10] writeback: Factor out code of freerun to remove repeated code Date: Mon, 29 Apr 2024 11:47:34 +0800 Message-Id: <20240429034738.138609-7-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--.38879S8 X-Coremail-Antispam: 1UD129KBjvJXoWxJF1kAw1rAr4fAF1xAr48tFb_yoWrZFW3pF WxJw4Yy3yDXa4IqrZxAF9rXrW3trs7W3y3XasrCw15tr13KF12gFy2kFZ5Ar17CFyxJF15 ZayaqF97J34kKFJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvEb4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUAV Cq3wA2048vs2IY020Ec7CjxVAFwI0_Xr0E3s1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0 rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVWDJVCq3wA2z4x0Y4vE2Ix0cI8IcVCY1x0267 AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E 14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7 xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Y z7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7 v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF 1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_JFI_Gr1lIx AIcVC0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI 42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWI evJa73UjIFyTuYvjxUFgAwUUUUU X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-Rspamd-Queue-Id: E32F1A0004 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 9fr9d68oszkrgm5axsncupg7drib79q6 X-HE-Tag: 1714362471-125332 X-HE-Meta: U2FsdGVkX1/ceqfCScvuWH53X2Dr7GXRN0zbz+CIqNghjn4pFKfwK4t9wgGbofG5ZLYKyhr7udLPNUNUOt3TthsRcXTKWVR4y80LG639t8xFUDjcp9BL8mz+3rgXyuk8klCTz6+eZJMXUF5s70QUlgIf1mtIJENboJqFNfz3rWrnWClcZdU0BE6cs15sfACds3ZMr59qYPLjj3nMIBWXPc3ADtKOvdJh6g5/x/CdCfC7GzWq7ZLOg1QA828TVFW46Fh+82GwlWhJXTxUlh7IrJXM8kaMC/eHGFJSZU7nZ4zfajCcS2XaNuK4ASrO3sm/wnwoPc5j05qCl+cgLWc3zHyRFSONe3L6GzIffQzC1PiHgWK8otOJpecNRUtPPtOSB9uOjIrlym0sNnvr+EnuJQjcB/KjEMlkrXt+CFH77NkDi9Vx3DLrTBdN5wn24Yai93LKe0WnnNIqFEHuFZvSckUMyg7pSf4D/lxMQnBCM+19fJxESKsBgZ+I68hqMRMCPubXyM/IrY9WvskHMJih/q0NahEcaxWpuUsJcE/UMmtYetCDyS4bK4K1M1u3gojN436mq0MbeCWXZZFhHEtSvQckaEHucSiir3OsQfZXbL2RxAvN7cAuarM52jNqg3AI6oPgJrvsP6w5HFCpYfaFT09MY1tmgaV0dxetotpy409n0cj4TVjkVeRniEWzQ+yZh50SKTQmQR0PeiC+A7IdMog3c/8/w1FqmxTzoGuaF5RkMg45BshmvuE5D5Z3e34Zn4XwgAFjowWH1TX+sBnqP9osf0Ebms5jpU7Z5M2bDYQOvBaH8y3jFhfjZcSuKnHaKbWhn49Tod2MctxJAifHx2il+BZO9TObadCum4zs49y7uNK29gagly0uh/YcY5cjEnYisA2WMwrpbV2i4ArV2MZqocX+Tzf5+EZip+DP9Vik+4ypkDk0w8hJ84Kgn1Si7xinENYPxgu7fb8zyI/ CV2Rtn1D cCUHbpxTMkaJElEJ0fb5k/Fos2zvfYhMxuahi8+RBNYsNlnHM5+ApMCBvs/qDet+xwW/6Q84DfjebjdPaG3LXPsBTaMxxRB5l0P4fNYY5diYvBAwT35Q1KVXvjCDM318oxW7EOIcaOBUfflCJvOJk299BFhQH8lnpPO7qKXOOA9ZhZm/mOO8k2gysX2MTkp16H0s7WQF4VaGMRtiVPkwST9vgcQ== 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 code of freerun into new helper functions domain_poll_intv and domain_dirty_freerun to remove repeated code. Signed-off-by: Kemeng Shi Acked-by: Tejun Heo --- mm/page-writeback.c | 89 +++++++++++++++++++++++++-------------------- 1 file changed, 49 insertions(+), 40 deletions(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index c41db87f4e98..b49ca82380a5 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -139,6 +139,7 @@ struct dirty_throttle_control { unsigned long wb_bg_thresh; unsigned long pos_ratio; + bool freerun; }; /* @@ -1709,6 +1710,49 @@ static inline void wb_dirty_limits(struct dirty_throttle_control *dtc) } } +static unsigned long domain_poll_intv(struct dirty_throttle_control *dtc, + bool strictlimit) +{ + unsigned long dirty, thresh; + + if (strictlimit) { + dirty = dtc->wb_dirty; + thresh = dtc->wb_thresh; + } else { + dirty = dtc->dirty; + thresh = dtc->thresh; + } + + return dirty_poll_interval(dirty, thresh); +} + +/* + * Throttle it only when the background writeback cannot + * catch-up. This avoids (excessively) small writeouts + * when the wb limits are ramping up in case of !strictlimit. + * + * In strictlimit case make decision based on the wb counters + * and limits. Small writeouts when the wb limits are ramping + * up are the price we consciously pay for strictlimit-ing. + */ +static void domain_dirty_freerun(struct dirty_throttle_control *dtc, + bool strictlimit) +{ + unsigned long dirty, thresh, bg_thresh; + + if (unlikely(strictlimit)) { + wb_dirty_limits(dtc); + dirty = dtc->wb_dirty; + thresh = dtc->wb_thresh; + bg_thresh = dtc->wb_bg_thresh; + } else { + dirty = dtc->dirty; + thresh = dtc->thresh; + bg_thresh = dtc->bg_thresh; + } + dtc->freerun = dirty <= dirty_freerun_ceiling(thresh, bg_thresh); +} + /* * 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 @@ -1741,27 +1785,12 @@ static int balance_dirty_pages(struct bdi_writeback *wb, for (;;) { unsigned long now = jiffies; - unsigned long dirty, thresh, bg_thresh; - unsigned long m_dirty = 0; /* stop bogus uninit warnings */ - unsigned long m_thresh = 0; - unsigned long m_bg_thresh = 0; nr_dirty = global_node_page_state(NR_FILE_DIRTY); domain_dirty_avail(gdtc, false); domain_dirty_limits(gdtc); - - if (unlikely(strictlimit)) { - wb_dirty_limits(gdtc); - - dirty = gdtc->wb_dirty; - thresh = gdtc->wb_thresh; - bg_thresh = gdtc->wb_bg_thresh; - } else { - dirty = gdtc->dirty; - thresh = gdtc->thresh; - bg_thresh = gdtc->bg_thresh; - } + domain_dirty_freerun(gdtc, strictlimit); if (mdtc) { /* @@ -1770,17 +1799,7 @@ static int balance_dirty_pages(struct bdi_writeback *wb, */ domain_dirty_avail(mdtc, false); domain_dirty_limits(mdtc); - - if (unlikely(strictlimit)) { - wb_dirty_limits(mdtc); - m_dirty = mdtc->wb_dirty; - m_thresh = mdtc->wb_thresh; - m_bg_thresh = mdtc->wb_bg_thresh; - } else { - m_dirty = mdtc->dirty; - m_thresh = mdtc->thresh; - m_bg_thresh = mdtc->bg_thresh; - } + domain_dirty_freerun(mdtc, strictlimit); } /* @@ -1797,31 +1816,21 @@ static int balance_dirty_pages(struct bdi_writeback *wb, wb_start_background_writeback(wb); /* - * Throttle it only when the background writeback cannot - * catch-up. This avoids (excessively) small writeouts - * when the wb limits are ramping up in case of !strictlimit. - * - * In strictlimit case make decision based on the wb counters - * and limits. Small writeouts when the wb limits are ramping - * up are the price we consciously pay for strictlimit-ing. - * * If memcg domain is in effect, @dirty should be under * both global and memcg freerun ceilings. */ - if (dirty <= dirty_freerun_ceiling(thresh, bg_thresh) && - (!mdtc || - m_dirty <= dirty_freerun_ceiling(m_thresh, m_bg_thresh))) { + if (gdtc->freerun && (!mdtc || mdtc->freerun)) { unsigned long intv; unsigned long m_intv; free_running: - intv = dirty_poll_interval(dirty, thresh); + intv = domain_poll_intv(gdtc, strictlimit); m_intv = ULONG_MAX; current->dirty_paused_when = now; current->nr_dirtied = 0; if (mdtc) - m_intv = dirty_poll_interval(m_dirty, m_thresh); + m_intv = domain_poll_intv(mdtc, strictlimit); current->nr_dirtied_pause = min(intv, m_intv); break; } From patchwork Mon Apr 29 03:47:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13646253 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 EBD7DC4345F for ; Mon, 29 Apr 2024 03:48:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7C4626B008A; Sun, 28 Apr 2024 23:47:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 13A5E6B0095; 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 C82B56B0089; Sun, 28 Apr 2024 23:47:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 2DC376B008A for ; Sun, 28 Apr 2024 23:47:55 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id CD28C1604EE for ; Mon, 29 Apr 2024 03:47:54 +0000 (UTC) X-FDA: 82061185668.14.102F3B8 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by imf14.hostedemail.com (Postfix) with ESMTP id 70636100008 for ; Mon, 29 Apr 2024 03:47:52 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=none; spf=pass (imf14.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=4hJMqp0kdzD927iRN9tU+qg9NNfQR5aBN07pmpBydD8=; b=hLo9bfv3Kv6zUjBc5S2FgLdpxWkQs0OmodxMaCYRCMtaGpXdW5p6TjX3AqvH4fAk621FC5 hEW8hnixk3xy9Y7Rzg3w0qzlA/9zhJ0Wcec+Krm+zDaqLmoO0JuSeiXjg2XultuNwnz5iz /3oCJpdfRvnnSltFk4KY4j8XDqCGr/A= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714362473; a=rsa-sha256; cv=none; b=DxZEe3A9cHLH8RtXwSCwspwsLFg7Mu2NKwK17R56oekQia+6uRESgLLONjFNvi0ZAxcyN6 2Cilnyd/WKaBY1ID/0c1cPfHpl6ruvFR1wVMfn7bFz5XiV4L5hjLUFuNeoE2z7FB5Ftcxz R/eSe4I87QQfbE4Lodg9yL1qPNOS2FE= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=none; spf=pass (imf14.hostedemail.com: domain of shikemeng@huaweicloud.com designates 45.249.212.51 as permitted sender) smtp.mailfrom=shikemeng@huaweicloud.com; dmarc=none Received: from mail.maildlp.com (unknown [172.19.163.235]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4VSTmp4xWLz4f3nJk 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 1E5F51A0568 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--.38879S9; 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 07/10] writeback: factor out wb_dirty_freerun to remove more repeated freerun code Date: Mon, 29 Apr 2024 11:47:35 +0800 Message-Id: <20240429034738.138609-8-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--.38879S9 X-Coremail-Antispam: 1UD129KBjvJXoWxWw1xWrWUuryUXF45GrW7Arb_yoW5GFy5pF WSyw43Cr4DJr1IqrsIyF9FvFWftrsavrWfC34Uuwnxtw1Sgr1Igry7tryrZF42kFy7Jrs0 vFs0vF97G34UJFJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 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-Stat-Signature: g13oddq5nbse9t94zr14cdgozf5it6rs X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 70636100008 X-HE-Tag: 1714362472-254747 X-HE-Meta: U2FsdGVkX1/bLacc7iLFthQmT8pFB/wyAc/5wbWNwNJR8r1nO1m6wwSVnWa/TmTrVs1k7F+IgZx30UJvkvMhyijoovlGcHjlJ42lne+CUg0uKn21y/D81HEI3wDzy4dEPHcD+0Uswi6X6j3twemAEY3aYB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W8y7KSy4p79jFDPNSPLZxfUU= 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_freerun to remove more repeated freerun code. Signed-off-by: Kemeng Shi --- mm/page-writeback.c | 55 +++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index b49ca82380a5..e38beb680742 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -1753,6 +1753,27 @@ static void domain_dirty_freerun(struct dirty_throttle_control *dtc, dtc->freerun = dirty <= dirty_freerun_ceiling(thresh, bg_thresh); } +static void wb_dirty_freerun(struct dirty_throttle_control *dtc, + bool strictlimit) +{ + dtc->freerun = false; + + /* was already handled in domain_dirty_freerun */ + if (strictlimit) + return; + + wb_dirty_limits(dtc); + /* + * LOCAL_THROTTLE tasks must not be throttled when below the per-wb + * freerun ceiling. + */ + if (!(current->flags & PF_LOCAL_THROTTLE)) + return; + + dtc->freerun = dtc->wb_dirty < + dirty_freerun_ceiling(dtc->wb_thresh, dtc->wb_bg_thresh); +} + /* * 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 @@ -1845,19 +1866,9 @@ static int balance_dirty_pages(struct bdi_writeback *wb, * Calculate global domain's pos_ratio and select the * global dtc by default. */ - if (!strictlimit) { - wb_dirty_limits(gdtc); - - if ((current->flags & PF_LOCAL_THROTTLE) && - gdtc->wb_dirty < - dirty_freerun_ceiling(gdtc->wb_thresh, - gdtc->wb_bg_thresh)) - /* - * LOCAL_THROTTLE tasks must not be throttled - * when below the per-wb freerun ceiling. - */ - goto free_running; - } + wb_dirty_freerun(gdtc, strictlimit); + if (gdtc->freerun) + goto free_running; dirty_exceeded = (gdtc->wb_dirty > gdtc->wb_thresh) && ((gdtc->dirty > gdtc->thresh) || strictlimit); @@ -1872,20 +1883,10 @@ static int balance_dirty_pages(struct bdi_writeback *wb, * both global and memcg domains. Choose the one * w/ lower pos_ratio. */ - if (!strictlimit) { - wb_dirty_limits(mdtc); - - if ((current->flags & PF_LOCAL_THROTTLE) && - mdtc->wb_dirty < - dirty_freerun_ceiling(mdtc->wb_thresh, - mdtc->wb_bg_thresh)) - /* - * LOCAL_THROTTLE tasks must not be - * throttled when below the per-wb - * freerun ceiling. - */ - goto free_running; - } + wb_dirty_freerun(mdtc, strictlimit); + if (mdtc->freerun) + goto free_running; + dirty_exceeded |= (mdtc->wb_dirty > mdtc->wb_thresh) && ((mdtc->dirty > mdtc->thresh) || strictlimit); From patchwork Mon Apr 29 03:47:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13646254 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 E34D3C04FFE for ; Mon, 29 Apr 2024 03:48:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9D77A6B0083; Sun, 28 Apr 2024 23:47:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1D4AF6B0085; Sun, 28 Apr 2024 23:47:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D1FB06B0085; Sun, 28 Apr 2024 23:47:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 2F5D06B0092 for ; Sun, 28 Apr 2024 23:47:55 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id D0ACBA280A for ; Mon, 29 Apr 2024 03:47:54 +0000 (UTC) X-FDA: 82061185668.16.D7A3CB3 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) by imf02.hostedemail.com (Postfix) with ESMTP id E71A780003 for ; Mon, 29 Apr 2024 03:47:51 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf02.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=vRRn7LNArr1toCzzV2bzQT9bmdj5eXR3/zEb3sZWN2Y=; b=xsxPRhdrT1oeCrTC9pjAdgJrlENa2ylxPcBbLstreXtt6Ia4uWXzBF7whlSnGslSFV5NQe Kk4nCH69X/6HsDY9yr/+5UvrWK23N/yLfLU2FwZ73cdA5xjonJCSW9gwnVlFG9Pd8Yg8jY iba+Wyy9fd09nEDlJvqQzvVi0fLgLHQ= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf02.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=I/MHv9p/UAzN0uZtRMR20/Bid1EsYcMG0p+qAnVpH3Jl6A/jRBofuT3p2CyMMRD7/vSXRA cxWO17p6rml5cCaxD2KPw/Bp3NDc4RbPYXIUb3exq3NtTIutBZ0MNF9ZhV3/QhVPe95PjO wOdO2A0YKc24R8umehUbc7IK4tAKPEk= Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4VSTmr4WMBz4f3jdQ for ; Mon, 29 Apr 2024 11:47:40 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 6D15D1A016E 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--.38879S10; 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 08/10] writeback: factor out balance_domain_limits to remove repeated code Date: Mon, 29 Apr 2024 11:47:36 +0800 Message-Id: <20240429034738.138609-9-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--.38879S10 X-Coremail-Antispam: 1UD129KBjvJXoW7AFW5ZFyDKry5uF1DKF43GFg_yoW8Xw1kpF 4Iyay29r4DJ3WjqrsakFW7u3y3KrZ7ta12q34rCwsIvr1xKr1qgFy7Zry0vF17Ar1fJr90 yFsFqas7Gw48CFJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 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-Server: rspam09 X-Rspamd-Queue-Id: E71A780003 X-Stat-Signature: smd7tiha7no7fist19xjwb7sez5rjutq X-HE-Tag: 1714362471-163904 X-HE-Meta: U2FsdGVkX1/g5XNwa+c43mEN+bvIKK+9mYS8OyCry2jDKszfUl7nH8Is6cWXA8hax9LRj0aJfHEJTj9iHBvJkp0R16ifl1bEA1uZ+VrEvmU5lSb1fdil2+Sqi8zJaxVUZJzpg+kyAkf9rvk0k9Ub/MXUiUwbb6AhsMSIiCN6YtqIR54XXo277J6j3VyioBy1BynzCefyWsnVZnHCCir0sBuB/GvdTHwXm36ZET6/n30TRBuYDfWxv7dgVfg8Vii8hohk+uuGioC+HnJXgqv+pOGjvUb3ZPtxpBJt7mMuRJ9oWPG1Z47ob5RoCVQPCb9jAJI9rWmSTUdrw0MlUwZcTmmm6O98tU5x8xwzuTtPfOZIfT9nYcDoA3Zk/T+HY9EfSfZHQ5YeI3jA/xaUcNi0nmb+T8aefvJ0bMm97pSsDTq81SpyBvYxQi7krC+Sl7ZvqTYN4ge+AkATvI0b6ix1QZCUj49zP2Fc2tZA9xthvj3gRF71lYRD8JpjLkrV4t+1GCteps4lmdjPbWrM61URnZ4aUG7W2c1EQ/QyqKywZQmQUw071DJCE4wCWVmrYU2P5VT+7Voo4FfyM86asGwG4jcf27huwSdOqFYicN+SSTy+seBch9H2V55jVBW+WgueWefenBbDtG2WrR72nO84T6p8Nxpwh7HuNp7Z88ixn8UXxqWf6JXyiCZfLaNpOQuvt5UsXPEpgqxPDT6sH8P5pHsvn/oZr5x+LfP8k3qVRPGBfkaZdwRqOA3Fj+h1cdzlsEejpgqliJxupew3zKe7iTLFpGYEE+FRlRf1LoPp35ZTMa9F4pBSkwS/q13t8pf2cpkiZBy2EK/xXoApxxEn9xV68Bd5JlZAKWmmzhHAG/5rlvyvJtYM1aZIdvewfhhW08KM/uMvOzigsH+CNetaZkP5555tdRWYDi5aRoczLhtTnwTOl5w9L3xMF6MwHFomDMY0rS1BvnqH+FsBoda /gu0Iqui DsCMQ6ThSQIrZGtlYUmB6wzJ0ebTNWhiEUNWTM8wPA+yzBZ9afZ4AmzbeyydawB1+6BgYwvYw++4dlhJXi1AIVXF/rcto0A8RihQrYZdz/j7/Uw5d2yPtKVjvKqdI29bNn9CcNtkb0z0SLYcAvHk+ORZOMVgicVnZGgxi/Deh4CPYRrAy3pxyMprW7JQjP9Y5x25C5604ijZkbhmExxjYA45Yng== 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_domain_limits to remove repeated code. Signed-off-by: Kemeng Shi Acked-by: Tejun Heo --- mm/page-writeback.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index e38beb680742..68ae4c90ce8b 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -1753,6 +1753,14 @@ static void domain_dirty_freerun(struct dirty_throttle_control *dtc, dtc->freerun = dirty <= dirty_freerun_ceiling(thresh, bg_thresh); } +static void balance_domain_limits(struct dirty_throttle_control *dtc, + bool strictlimit) +{ + domain_dirty_avail(dtc, false); + domain_dirty_limits(dtc); + domain_dirty_freerun(dtc, strictlimit); +} + static void wb_dirty_freerun(struct dirty_throttle_control *dtc, bool strictlimit) { @@ -1809,19 +1817,13 @@ static int balance_dirty_pages(struct bdi_writeback *wb, nr_dirty = global_node_page_state(NR_FILE_DIRTY); - domain_dirty_avail(gdtc, false); - domain_dirty_limits(gdtc); - domain_dirty_freerun(gdtc, strictlimit); - - if (mdtc) { + balance_domain_limits(gdtc, strictlimit); + if (mdtc) /* * If @wb belongs to !root memcg, repeat the same * basic calculations for the memcg domain. */ - domain_dirty_avail(mdtc, false); - domain_dirty_limits(mdtc); - domain_dirty_freerun(mdtc, strictlimit); - } + balance_domain_limits(mdtc, strictlimit); /* * In laptop mode, we wait until hitting the higher threshold 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: 1714362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HDAOYOKGLsncFwNaY9Q5Oi00J8RvpJ7K32UJBlvRHLDToX+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); 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; }