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-416085 X-HE-Meta: U2FsdGVkX1/S9iCMkZrynEAnJaJEciEa5gHCJvuhB17xmzXlUyQURXgnbV6qNIJTh10TMymgHQ8gvmX5gnzTcdVKY+ZczJcpz/XzZyyzOmqahQieE9ByFybFfkylkCJtKnBvenVwVYpGLSIbyYtNvLF5+bOZosFc7OrfDWO23JUmY5iQi8IgXOdboD7qzEe+l0+0HN2Qf2BmlOAZAOD8E/RcqRf4qozbfeVNlqUM2/aIMm31sgjgnAvFpaY2RLnymsoZjkkr9mi+oeqV45F8V8yvWMacbOxgBOhsn/K5grzgpk3HSJSlJpKi4d8OiY37vAi7Dmmsyqrd6fUP0WwvfOy1dQjuV8wOv5BllluuDRzy1tCGMc/1iymTw7iSfET75cvqAfd/34wuJAaDsW929O74W8FuqQDEDm1I0W8gs9GPAEG4OmUwb8GuNT3EA/dn0jQPIXmUGjfT+XSX1efkLPnqhSeQ5zZ9vT0FG1raeQCibQRE9jiJV094ilyl60dpSnMAXFVtU2BotgeZkcDXGcDYqv2GLYKr6Er0jvRi62EbD3ltrbc9Z/zFdyednrvY5GXTnI4DzAVGduU4ZHC0sTMQPtwuhZBBqXJYH6CsEv4IVRExzzgWq914CBXmcIezSBMtqSQNY2mh73YJJZ7Su/51mGm5vLynolo04XAH7MWlMT08gCC+NDttf73jD1rQI1pIWfsehqizM+5zMCsxLHN2AH5rojJ7gZnf9DVgzu1GWIgGAAwSgJ++/FtXUqeff40kEupZ/iQyQp/YFzC49OWrnxYtGl6yiM4a1tZ/mcf7yKtbfS/AHMbvH9Jjz8dv1LguVgLXXT1VmSg+hqugkUG+jA4V8wJpaEuparnikQg5w5aIdHTaBQwfHvsX2hg/0lsaCbrwgBCaFibRRiCwd+MpCkZCUkbKWIbd7JpeFhfvtTB98bcJBZPLOF3l3/3YWVE2pnDtnxSGvNCTVdh P/eGlFQt 6Fd16qZRbtlqsNots7EOPaZXi7PtEZAnmhK4NRH237v0+TbPqs5IMDN6mJUScaD8BxPYx0PDpE0pGyCz1VvTP6xRtiLAwEKgL8t39D839QXsj7SR463hgnkc+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)) {