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 WUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rM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grIQxdBa9/zQuGVQ6EcR89v0qfJWtY36cDoCEumzrO0bUSdXQmuRsO3oYLHXMTxPqR4lPbeaiN+pDFabh6CbdlSjUdpXNf74Lwc014UkoFubyGU9Q15oq9y/xcOAPSjSeej+S1znBxNcd/4t1RWC1nA5rEzSI/kS04UQ40NFrXdMTkjtLyNaIL8tnDtmiXXbcnIbzwjp34TN4zJfLzLhjFrtIVTM0OfEFgyQLFMExhA0vsKnRvv/0xSlSG8JFe+54OOSoaio7wYdTI5ojgLC6VQoIRAC0DKQNjDDkzoywt/PbWm7LbaPPy7z5E6P8kUhEO I/BnJ2SY Zg+HL1nP/ezUfWHQyBBedLZ+90GTRijp3aFdATiEk4qfcwSX9f0TOoiWQZk5YcZo6SfjdBF5FH6a7rcvWZ/Ii7tu0xEiRuyiMjP3f/hbgttQ4btZDTiy++8/VAI/S/xp8ye9cJQRXvl7GCO3/qjjujoboGg4A6hfS4XDx0ZMHMmulefGYAi7CiZ2XOdUFK+TOe6m23DCX8yOOgYQhC631xKEjzRhrMJ5X/ObxgI3YoVA294MOwi2N8wNSN5rv6QxavRMlnQI6MOQTm5s= 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: 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);