Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1122826lqa; Sun, 28 Apr 2024 20:50:42 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXAGBjW80Zol+5+pE09riDSJpmZTYtrlg4+2K0ADo0iM3O0r5xhTe4Sa88IzTymUH6JUrhpc0S+8cR3cL2i5B3I7S3B2ifvwNfvBYvJLA== X-Google-Smtp-Source: AGHT+IH8EVWlnAc6RmtyVv6OUQ2duJ7K2fZOQp8uaoVXnZYse7zvAwg5enGBdHR/e80q8KbPBzB9 X-Received: by 2002:a05:6808:2917:b0:3c8:6427:5b7 with SMTP id ev23-20020a056808291700b003c8642705b7mr3917199oib.56.1714362642070; Sun, 28 Apr 2024 20:50:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714362642; cv=pass; d=google.com; s=arc-20160816; b=OYAT7Xc5oguFwVvlFsXROHeDyklq3VrnyS4XxblQN08N9finCeXC2nSeooxfD7+oAi +lhFbpsmdFiEAyH2SX3HMtgmjp2mzK2/rX4CYmVSkJqyU0LrSEyX2H6vwixoKtvc2F0I vs+DqNQ91c6sGcKLq05TtAWgml14XuL4KbmBSbxHleBmjAcF9n6JZT9aRKU1CJ6OKkxP cPccjOEeuR9qjCdy99mIG65Egi4j412zTNRxXvySWh09+2J7SdvD55S8Qk2Gfa8N1n5M uB0of0filFjgN425EVJS7edrs6/960orEpDOglhHqXRGI74L/rE3jIy+lVhoYB/FNJG8 zGhw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=vxrjnKI2OiIsLWW5zjc+Vsca5M6fEJCgVCafJICxuZs=; fh=JvXjDH40Qny8SV6dd2VRD5pFxo0ZkXWBhEYiilPYRjw=; b=eqUy8g2+OVFJ3UjKopxyDpzLXHwGupREfLST2IpQp5HmnzbQ6V6DfS/+cXoiOt/yF1 TfDXcS18oenrMebsCh69k6SOaDbrmK+oZ3+YeVfuJJj/A0QYqMnX1G87p1fWHOSoIQiG IuYIYByQCg6WmlnX6RYUcEre/seXjQ9QT2s8TTXggwZmHiRQfsY9kmYmjcXP+RVlJY1m tpU1AoKQMG7HsDbWxQyWEXxJ7OeN4a6za4ADbgT/3IsMJLUoSXqru39lw2WlE2aRCCfi pAfxb1Hgui82Pa5+7n+Jxx4a+C4B0H7QHw38YxEzp1QQQldfgcPVwwyiosBKr7mEeAbx J6pg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-161716-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-161716-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id b189-20020a6334c6000000b005f7fd3a0f26si16959675pga.130.2024.04.28.20.50.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Apr 2024 20:50:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-161716-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-161716-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-161716-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id AF7E52829EA for ; Mon, 29 Apr 2024 03:50:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 02E9B2575A; Mon, 29 Apr 2024 03:48:02 +0000 (UTC) Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E5D8C210E9; Mon, 29 Apr 2024 03:47:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714362481; cv=none; b=ZNZxOdluCMbEPmapAHjkynG3EwfUZEf9lukflHkhZP3+7zkyJ+W2vq4U4axSmmbDUN3Zm8jlkP8HDtLCRw0XmfgmRYYdCIx1YF7lhgR3CEOpb93wUmIsdIzfRLBNh9hAfmF0t2178BzYmOyAX46YIr0OL4otjObJu9YppjVvgsU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714362481; c=relaxed/simple; bh=aMvuzdkorgTSU70l2pwX1IXtuF84vkBsJNWDHJXe1IM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=d8LApUozhd8kvy62jItEF7LB6mJ2MjHpfu/ye3JsN57Gb6zNq/EVn2B7NSM9yjQjTP9RtWIsccXMemTTikViBdI6e5MzzWhjbi7b6RMuyYyiuFmVNE1WfW806FPTu8Vv7nH6UrPAH0YZvcnxiUPHi3PN5nwq4K91UFqtEQerIa8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4VSTmq5BpSz4f3nK5; 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 23A891A0179; 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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/ 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; } -- 2.30.0