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