Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1122813lqa; Sun, 28 Apr 2024 20:50:36 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWFPTeBN2YNiI9bwcJMuCtiEcCAQJl/u8jFIDJtGk6U5nksOF9KjWeUMl2G6daSO1zMGMsEm9gztMLGVlO/UqX4bvpg2baZ+dn8ilPxlg== X-Google-Smtp-Source: AGHT+IEAkPwRTVTyfKQs/+Bx0cpoo6jO1ei1tavrzFYmD8vn8XSByq03Ps7ce1rt0PccezJ+IAks X-Received: by 2002:a17:906:f18d:b0:a58:7298:fdfe with SMTP id gs13-20020a170906f18d00b00a587298fdfemr7469659ejb.53.1714362636633; Sun, 28 Apr 2024 20:50:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714362636; cv=pass; d=google.com; s=arc-20160816; b=gsfE7hqT9Oh8IwCnJaJ3hZNxvOohoaG4vKLmt5W/b4SFVIOKv5EqFEsjY5mZeJXmZt agFNiKIAmennenyFcL8KcsJ/G9dJijvW6Gbz7cKtof7J9Qxu9ePvS18kBAvYy+tFL+Uh aA+PEkCxW5PcRMWqK/CsuJLLzs/qwr3jDQ3RNw2oab13tVVDCLQiKPB4UEaC1In44Ij9 EgiBqIL9fgFgAMGeQpLUUxe3Edwm2XWyuKhWcEyksCAsdtqrHWndJmb+R06JuJiVS97d MvH82mO7gREIdeIeT7W9O/TQ4hIeP061mhPCJ4647iQz6bwgwkB3o1SUQo7io6zwBjK2 3mRQ== 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=PRoGGQa3+cfB1Xvy9AzB8/U1nu1FrK/5u20rEcWlP/g=; fh=JvXjDH40Qny8SV6dd2VRD5pFxo0ZkXWBhEYiilPYRjw=; b=QiQo/0K5lHDrvlHak8TQ/kQt5HR3FiNVBcvsomoe4uBfOYkfPxR8IulbZc4nxipo9Z URFg8kR95IMpILTxeXnDA5rRasU1IxgQ9vX3PPjOQGPes7mlKSExe3Gj428sX25kqqZ9 jVWEVoOHsNq7MlQOM+w/vfVb1wB+lk0/Q3PDNtxJ+3asIowvRkURsDYccmCbGmsQ0PMD 3LgF4mzCcOMsvDRyt3A33bXRTujIqXfqlskPeTRkyox79hye3aF46lvTe93+4AoxV9kK BlDdJnqL90JmEoZX6q8HD/9o+99IiB2z+7TAQC8+hOtS3L6s8bGGUJ5gkLSZ4klgW0wV YOww==; 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-161715-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-161715-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id d16-20020a170906041000b00a524ecb5d87si13596034eja.736.2024.04.28.20.50.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Apr 2024 20:50:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-161715-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-161715-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-161715-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 5F4EB1F21137 for ; Mon, 29 Apr 2024 03:50:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A927623778; Mon, 29 Apr 2024 03:48:01 +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 9B0B5200CD; 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=MBmPSg7a+DPBcSfQZANJjxB4nTppjEA1Gm+9kMgvF4dpXHjwCUlK/pu5nyGeFYUh/dbiU18sebuDlD5mZkiSt7L83jm+ro/Q3aIGUgc3kY9D61H8T3m+ppiLUu4mtoR2oPTpVGWRNhr/frdMUwBbjv0LRqj6H2xI7/N736TNDXk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714362481; c=relaxed/simple; bh=/rNwyfdAP8bbQElnR2CpvbW8upwOIeYxWG9L1OnsP2A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=c4+uw69aNPi4lDVk6J2eGo0XGFz9/m43T2j7ybbdCIAGGPzon0H7ss3B251UDB5EO3FdM3Dw0/6cwwXAXKJJIDeR/JzPl7Cd8aCUhBjbgpJL5mhRyCan6yp95BuhRE61gLzduI8bWdJWxHREmYpx1NVY7E8vamVEfFODyKNgDFo= 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.163.235]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4VSTmq2pG7z4f3nJw; 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 C89951A0568; 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> 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--.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/ 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); -- 2.30.0