From patchwork Fri Oct 20 08:43:51 2023
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Huan Yang
X-Patchwork-Id: 13430268
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 B8A13C001DF
for ; Fri, 20 Oct 2023 08:44:51 +0000 (UTC)
Received: by kanga.kvack.org (Postfix)
id 3C5858D01C4; Fri, 20 Oct 2023 04:44:51 -0400 (EDT)
Received: by kanga.kvack.org (Postfix, from userid 40)
id 342508D0003; Fri, 20 Oct 2023 04:44:51 -0400 (EDT)
X-Delivered-To: int-list-linux-mm@kvack.org
Received: by kanga.kvack.org (Postfix, from userid 63042)
id 146D18D01C4; Fri, 20 Oct 2023 04:44:51 -0400 (EDT)
X-Delivered-To: linux-mm@kvack.org
Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com
[216.40.44.17])
by kanga.kvack.org (Postfix) with ESMTP id EF6AF8D0003
for ; Fri, 20 Oct 2023 04:44:50 -0400 (EDT)
Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1])
by unirelay03.hostedemail.com (Postfix) with ESMTP id C9186A04C9
for ; Fri, 20 Oct 2023 08:44:50 +0000 (UTC)
X-FDA: 81365204340.21.A921E3F
Received: from APC01-PSA-obe.outbound.protection.outlook.com
(mail-psaapc01on2128.outbound.protection.outlook.com [40.107.255.128])
by imf05.hostedemail.com (Postfix) with ESMTP id DFA8E100005
for ; Fri, 20 Oct 2023 08:44:47 +0000 (UTC)
Authentication-Results: imf05.hostedemail.com;
dkim=pass header.d=vivo.com header.s=selector2 header.b=TpLCD03N;
arc=pass ("microsoft.com:s=arcselector9901:i=1");
spf=pass (imf05.hostedemail.com: domain of link@vivo.com designates
40.107.255.128 as permitted sender) smtp.mailfrom=link@vivo.com;
dmarc=pass (policy=quarantine) header.from=vivo.com
ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed;
d=hostedemail.com;
s=arc-20220608; t=1697791488;
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-type:
content-transfer-encoding:content-transfer-encoding:
in-reply-to:in-reply-to:references:references:dkim-signature;
bh=aT41bP8r3trBeh7cRmEwTNlaQyvK5YLUexl8IQTAjVo=;
b=C9AupK9+ZQNmbF9kRUEtWspGMWJSbGfypUhgzrUx9xonH+maAe1eKlVOJHvb1+u/hjr0Q2
zM6R75Gc13fsj4pAgQKhmNGbxK1NvF5CpshOsqth41haHjHcDp25Gzk8d3cgrWIlyP3Z5m
uVr/su8wst4ui5/pEZv9o/73I9ly+V8=
ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1697791488; a=rsa-sha256;
cv=pass;
b=F3eOw6RFYe0drYWVhY1bZvhRXCsouAPT+dlzBuDkVBdAmq+of7TbunfuknwTxt0/DJC8ep
bshKSzDTshu9SFYD1E4kiUero3bZc0bGHTVF4dD/kW0PJi7xiPBrEtpY3IgNErgX5JL5Q+
+CM/7rBEmd5uanHwJu4zE9rFoPbHrek=
ARC-Authentication-Results: i=2;
imf05.hostedemail.com;
dkim=pass header.d=vivo.com header.s=selector2 header.b=TpLCD03N;
arc=pass ("microsoft.com:s=arcselector9901:i=1");
spf=pass (imf05.hostedemail.com: domain of link@vivo.com designates
40.107.255.128 as permitted sender) smtp.mailfrom=link@vivo.com;
dmarc=pass (policy=quarantine) header.from=vivo.com
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
b=WA7mEgLXLyG6XY4kFo1zUrFkFEOoK8CCiJ/R7Z8JaoIGeE2p69jPJ7R2LzAL1vXZZu7GohwZRIjP75lxgtxIkBcg0seY5DZRTjKc79fB2nbhVSw3azE8mT7ZsE9ttlNNXl0mFAfmCO6iEZI6aME5jJDwDfWnjJqkltASO52bVaS/kk/DhLTlAWjrJH1EgU6rMoBff2byIJC0oZ1Mq+vo3JqTSkbZCXMwS2bnlpTW+vJXgzNDTr7BiUIiW0T3u4XaiV04hK4fKhBYyRrt20lpKFKXbOQk/eSwdghVKtwqLJYy6bTW8yI3NRsvjDXIEulLsPoV+L8Vya8lpI1yKU+sgQ==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;
s=arcselector9901;
h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;
bh=aT41bP8r3trBeh7cRmEwTNlaQyvK5YLUexl8IQTAjVo=;
b=JokubdsG+BHAxAbPj8fjkRWDmpyMyApxO/7LNB3DVdI99h9gLOIDYwdCWQkYhNb1Ih1EkCZ5+IJD5iKOw1g+L3av+tmpeveQcZSiZ8Pwt14FDK+b+WFndn7phGIJA3I1RWSsC7qtmc016c4KJV2Cukd0oqbPxGisGFZuDkzEkpKkEWtQFF5gsDZa6J31FAVQOuYtODG2JRO9uou5TyXdh07ZevWO88Fvc0ky7/MocP1xwR65LMNfKwgfaeFFCfg85M2M/K+YlfdK6c6HlMN8TAP+emF5MlWfttX4eLnmV0dOpivRsKq3VWygXfRWkRhSEYgJAUuFCsStpGxKsiqo8Q==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass
smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com;
dkim=pass header.d=vivo.com; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo.com; s=selector2;
h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
bh=aT41bP8r3trBeh7cRmEwTNlaQyvK5YLUexl8IQTAjVo=;
b=TpLCD03NEsT447fCJhlnb/zvV3C/qFd61HnRqkYTOIJrAtKLx0hxykqQPJePOCYbgnHIDtfUojJgwZ70m1CKsKVW4AVX0Gwy0ZRvZWvAEQZcIcwD/HvCWnnq148eibSFJ5kkEPV2hQW0Iv5vPP1tHnT/jxhewbu/UyP96FVFOQhXPaL9zWwihpn5obiKZx4OyI67PVe//tygmrX1gbOpkAciCXpNYecHE6FD7ngIHX/Qou2r23fyMo3I7VXZdSeXaM0w4nMrQZk2sSmE/y6cTTEK4RBEsiRELrWD9zmTvpl7XGkICK6h3vUZgz1/fIMw5Q8xWDFEiCBdL15n5RnCcA==
Received: from PUZPR06MB5676.apcprd06.prod.outlook.com (2603:1096:301:f8::10)
by KL1PR06MB6553.apcprd06.prod.outlook.com (2603:1096:820:f1::9) with
Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.24; Fri, 20 Oct
2023 08:44:40 +0000
Received: from PUZPR06MB5676.apcprd06.prod.outlook.com
([fe80::40ac:5701:4617:f503]) by PUZPR06MB5676.apcprd06.prod.outlook.com
([fe80::40ac:5701:4617:f503%4]) with mapi id 15.20.6907.025; Fri, 20 Oct 2023
08:44:40 +0000
From: Huan Yang
To: Yu Zhao ,
Steven Rostedt ,
Masami Hiramatsu ,
Andrew Morton ,
Huan Yang ,
Suren Baghdasaryan ,
Vlastimil Babka ,
linux-kernel@vger.kernel.org,
linux-trace-kernel@vger.kernel.org,
linux-mm@kvack.org
Cc: opensource.kernel@vivo.com
Subject: [PATCH 2/2] mm: multi-gen LRU: move promoted folio out of lock
Date: Fri, 20 Oct 2023 16:43:51 +0800
Message-Id: <20231020084358.463846-3-link@vivo.com>
X-Mailer: git-send-email 2.34.1
In-Reply-To: <20231020084358.463846-1-link@vivo.com>
References: <20231020084358.463846-1-link@vivo.com>
X-ClientProxiedBy: SG2PR04CA0198.apcprd04.prod.outlook.com
(2603:1096:4:14::36) To PUZPR06MB5676.apcprd06.prod.outlook.com
(2603:1096:301:f8::10)
MIME-Version: 1.0
X-MS-PublicTrafficType: Email
X-MS-TrafficTypeDiagnostic: PUZPR06MB5676:EE_|KL1PR06MB6553:EE_
X-MS-Office365-Filtering-Correlation-Id: a653b177-ffc0-4154-e9d7-08dbd148cc69
X-MS-Exchange-SenderADCheck: 1
X-MS-Exchange-AntiSpam-Relay: 0
X-Microsoft-Antispam: BCL:0;
X-Microsoft-Antispam-Message-Info:
guCoE3hSns7e0lNAgTfd9SDeR4ey4mamtBgAg0RhN2enVJZJVReM2BAmwtD8wavgE3OlpS2FnzEaBCBB/AKn/fb4Ox29l6xxlUHBybrT/NPMGLueymHUzSQZKSKNvk7Q2zdaxsqyHyOlFKtrIi4Ohnjq/+pYH+cWIBdYwp9cMURBHrG8z9x0tvJIoU+kzdwqRMO2ZokgzfWq2d0o48lITlzU4DRia0M1axxC1Ra1MoMBB5NIrgvLOTQRT8uyNpK08ztCHDKgeAAjhEQ9pIiRpcp9VhQIiMug83WvhexcCrgRLDsGMfvBf5ijfEC84oSemn7n+gX4y96CGSj+s5UWB4GcEp8w0BMQje5QNiHKL7bVCs31tc5owVPsI7hUa5QxOJtPktRDFanBPbMH/j/8jbXHs5HqmK5AxVqxbiBv0Nk+kcepUs8Br31qGRGHETnQeOvrfzk8GW/ahX81TnBEwFTcyMJRRiEuqHnQB7LH/2cgqmhHYf8+XuR1eyQ+iQoo6UpxCLw+D4GKvZUQxYDXXEH0nZams4gsl0HrbH+o7YwtwvCPZfGgfO8xol01zq4XfhXU8GZ5zdv/tfl3E2qBUOp04FyAMKvLDVPUAAmVMNeT7PUxa6KptoT/9gELcB2yDb1hBiY1SZTA8yP+RL+nWg==
X-Forefront-Antispam-Report:
CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PUZPR06MB5676.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(39860400002)(396003)(346002)(376002)(136003)(366004)(230922051799003)(186009)(1800799009)(64100799003)(451199024)(36756003)(38350700005)(6512007)(83380400001)(110136005)(66476007)(66556008)(38100700002)(86362001)(52116002)(2906002)(26005)(107886003)(2616005)(1076003)(6506007)(6666004)(4326008)(478600001)(6486002)(66946007)(41300700001)(316002)(8936002)(8676002)(921008)(5660300002);DIR:OUT;SFP:1102;
X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1
X-MS-Exchange-AntiSpam-MessageData-0:
KLCgOQgZfBWg5q7mnELhk9IhFnnUpie7aYMo0Uiq1k0oAhiXYyfH86H1nKiEqZWbYgMua9vzC5TsY9cByJgJtWznkeNu7WdzeVEK0B9zhIeUBb1/dwDe/8zlgwAp9DiC6lLR6+MlNrUgGATyloOjJTtV2TpQ1tHPNoHSnBWZSPdoKg7GqJS3RVcnzzAms/PA34p/5TPQTTi0sGc41eox+gHQ+0ySwSSbHPgN9t+kvDr7uawIMnekgPnu0cx23aT5OVem6t+nO+npOnP28n2XedqPxhykJuyzSUuBgRYMce0HprD3hv0ekgd51ZEgxjiHb7DTjFNoVrgvvj1dPGhbFVbgNxXKFXFoLUnUIOJyOODCCiCwoOlU+Sr9Ym/SXkX4DSew0COIdpDmLbBRonA6XI6W9d2v2RD/S+qdImlPaVi6RQfYBLaNLNBD7flNLbA0jOUOVxv66qg4EB/0oZ2+kV05NY2sm7NNcp4yTlRoiTeYmed9RCpvllLO/jb3qd++rF8jIjwzzeIgdwR4ANEeqrPs99n+n0gWSq25W7IMseVvbe55b3hEF3ADBzeLugYVTdMAqazvX9KCfYa021QQRmBtVSPKpUAHTcr0JxpHWF86W18XO3HmumR8YNqVP0ojMIW6Kp8ETXu0eHf2oypub1Gefphvb3RJOfcOHU+YrUv9rwtL2N/f6x8lVBSwJA6M5F9YPNtTxf/1qgC4rs9+VCATgpGgRG4yHjVMrJmOJRToQcPGAszuJ4HIOLu4E7BlVklfQIq5r6WCsaaLuDznEOMFX5cIwBtHnMp4jN0c7zOQlTfX8Cb88o6+W1nm8ZMplU3djxOKcNcJq4k+Z/c01yVbD+PF4qiXhwM5peWrXtrvpaSAzvobM0veJcF6NMQDnb4hiSvvZtP5CCmvZe8+GhRVdu7EpRpVHGJj98q9pynitcrey/9C5wUBliAq7HRgdZukPTuyOwy1Ul0kcAFMMa0hJMyGTqhcCvKZJw+U+plWta9UOgJglFUCK+QrdNabo5puIn5ACjk4qIRpJlbPfhurKQct+tjXkyZ4RHNy0Pq9KGydEK4twbWAC0S6NBrc7Ja/frfh1zSbIrM/JuT+hxxEPOU3ZJHG8Ofg+KyJIBeuy3WiGw/w5Rg2bPh55JhkjkN3qkUK8RLBD9+QkUL7AU+EVR05apsXD5HuS6WW9Rh3g9lwR5WeXX6edvYNmzwvuz2zPL1efoXoNXIC29VjxLti7IGC0UrJCSKxDTZUVIPgTXN+hHTxm8HeVXC5zUfzIitCSz/VvPDlL1AdZ11qs73mR7KQoXr88XkQhD0HHSNWuLxYyTHtY/DCyMyDMXfXYK7SK7RV7aTGSSD3rfO/1WcvGy1Rc3fCRL3D00VysE151T/idqt1q07oBE1MR/B1q/XweSviXT0WZFBDLfIh45Z75zVVQjJHNdaUSNasZoLoQ3H6KwC+Rq/UPprYvXAZ75Zkb8/Me8W5ccjNCvnjF/jdWrBpuUw7Pm5e+xxdiKg/83+5/SasqjE0pgPETduxMYe2Q9b/H3zxh9hWaZRtnUzPClrlkbRYxzOnzl6Zb2vR7RQgod+ybA6KEpHMdf8U
X-OriginatorOrg: vivo.com
X-MS-Exchange-CrossTenant-Network-Message-Id:
a653b177-ffc0-4154-e9d7-08dbd148cc69
X-MS-Exchange-CrossTenant-AuthSource: PUZPR06MB5676.apcprd06.prod.outlook.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2023 08:44:40.1890
(UTC)
X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted
X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed
X-MS-Exchange-CrossTenant-MailboxType: HOSTED
X-MS-Exchange-CrossTenant-UserPrincipalName:
V031SWY0F5NvOCCL/d6G9/bBUugs7whQJXgptuZBhuqYoohLuQe9+K4ru4lbWLrBf5zkNYexAI27glIv2mc8RQ==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1PR06MB6553
X-Stat-Signature: awfsjgw4xix8cpucyfpn7z6jf34beggz
X-Rspamd-Server: rspam10
X-Rspamd-Queue-Id: DFA8E100005
X-Rspam-User:
X-HE-Tag: 1697791487-148012
X-HE-Meta:
U2FsdGVkX1/cqUcnbl/6FK8+b87a7r/Ch+G0zDMrYf11QpUe3I4H/a3fiomuKOkvG3coPp3gYZ3o/WShEXQP2sapFq1xMGWOt8iX2MZ5xQgquxI6AaFUz+v8s/Z7J6AjJ5W9UPPrmFThtr2iIR6uG2EeQOe/Vzej2oWRUVO7Z9WolQpwayhTJDKYilWFO9VcrHnt2SfWiIkbc4bqcQbbB93mTByIuLrRJgKxYAfvgjWt1Wp0ycZBOSSNjfsCVn9hGqSaHIMONACXEzovqEAfskSM3G92heuvnzbtcoBsMRa9IjncrZBnBpfD6UQd308FIBHOT6QN00gaYCFYGjkFhbaEMqA4IQc+P0IBuzQSvIugW38AaCvsjMEqqQhojRC41L2L0+aDLOE3FjVOzyZ0Nb4peBWIs8E/jGZS76O/3q+qDgeQe5M0U1ZEaS9/bey5jS87LHj3lNQHqWKCSh8iZ8/lUEQDdl9dpycICa82NDOfOFoI0PedXVAOBnm29OLmmThtYgJTiQuZiSeB363a8/g85L56A5vDxma5WqnHx9YcYId28d8jUn2DmQRs/2T8o9tMrqN1deeuguM8Y4jSkKfSrMg+apdIsnSjgfJNINilWfDiUC0AaDpprtMsaxYEeBAaOMYQekBi+7KaF4WN1o7WhvzQtpCeC3tZnfYCxL/IjQz/T4+K1hA09g3A10E2BBICTZcYczzELB9ICJ33ETfbl/xujWqfGuuJxW+hKCsSov04qFAjypNaOAFSv/dz1uIdxT6VUO6j1HDlkIWSIj3RTe/nm6d7mU9mProR8uRObXW+dKBykN6Zozaay72PHNb+iKyj+OLmja/RvqUS6YTS8oAhUdYWF/P+f1dVXRvNBN+C4tJJq+HKe9mBUVZ4YlDfxQp/cfmeKJtG48PrLTle+RE5vYpmwX/4H6TecARxkPZN/MwTznldZdNDe9rIF3IWaGj/tfwCn7LMxYG
uTtQMvXI
nYh42hkbbp+s0LFvjFBE2u3CQrcfyg3FGM8jGB6FfZvsgSAU7NdavL+QMWBKSI0KosrTbzrsafP0kYX5eCEEUWqxNqZkpU9zZ5qg2IRh+/2n6Qt++tWitbX2xchVT9yggWzUm1f+1KxT74B9f9MvsxXfk7bnsAF2xM5ZSaAOJoaXJr4URUe8nV2Wu2wLbu7wJG5+P7AchcPF+SbS2Viym2D3I081d77o5zrCg+PV1Tcg3cfgclkb8H/X3RNOC7Sur7PdGBZ87XtQxraUCp+abxcvGrAWKFaq1fBgJvfd3cvsLeM3onNISD3E5rZqPsFLUvu4uA41anYhxlCMLiVplk4bCUw==
X-Bogosity: Ham, tests=bogofilter, spamicity=0.000747, version=1.2.4
Sender: owner-linux-mm@kvack.org
Precedence: bulk
X-Loop: owner-majordomo@kvack.org
List-ID:
With nr_prmote trace, show that here are many folio
promoted before shrink check.
I just test by below cmd, and grep nr_reclaimed=0:
```
trace-cmd record -e vmscan:mm_vmscan_lru_shrink_inactive\
stressapptest -M 8096 -s 120 -m 1 -W
trace-cmd report | grep "nr_reclaim\=0"
```
Then find many show like below:
```
<...>-9042 [001] 43.290759: mm_vmscan_lru_shrink_inactive:
nid=0 nr_scanned=64 nr_reclaimed=0 nr_dirty=0 nr_writeback=0
nr_congested=0 nr_immediate=0 nr_activate_anon=0 nr_activate_file=1
nr_ref_keep=0 nr_unmap_fail=0 nr_promote=63 flags=RECLAIM_WB_FILE|RECLAIM_WB_ASYNC
```
Many scanned folio is promoted ahead. So, this promoted check better
checked before trylock folio.
And, now that promoted alread checked before touch, no need to trace it
anymore, remove this trace.
Signed-off-by: Huan Yang
---
include/linux/vmstat.h | 1 -
include/trace/events/vmscan.h | 6 ++----
mm/vmscan.c | 12 +++++-------
3 files changed, 7 insertions(+), 12 deletions(-)
diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
index a3710ce08434..fed855bae6d8 100644
--- a/include/linux/vmstat.h
+++ b/include/linux/vmstat.h
@@ -32,7 +32,6 @@ struct reclaim_stat {
unsigned nr_ref_keep;
unsigned nr_unmap_fail;
unsigned nr_lazyfree_fail;
- unsigned nr_promote;
};
enum writeback_stat_item {
diff --git a/include/trace/events/vmscan.h b/include/trace/events/vmscan.h
index ffcf288879e0..41964d6e8dd1 100644
--- a/include/trace/events/vmscan.h
+++ b/include/trace/events/vmscan.h
@@ -366,7 +366,6 @@ TRACE_EVENT(mm_vmscan_lru_shrink_inactive,
__field(unsigned int, nr_activate1)
__field(unsigned long, nr_ref_keep)
__field(unsigned long, nr_unmap_fail)
- __field(unsigned long, nr_promote)
__field(int, priority)
__field(int, reclaim_flags)
),
@@ -383,20 +382,19 @@ TRACE_EVENT(mm_vmscan_lru_shrink_inactive,
__entry->nr_activate1 = stat->nr_activate[1];
__entry->nr_ref_keep = stat->nr_ref_keep;
__entry->nr_unmap_fail = stat->nr_unmap_fail;
- __entry->nr_promote = stat->nr_promote;
__entry->priority = priority;
__entry->reclaim_flags = trace_reclaim_flags(file);
),
TP_printk("nid=%d nr_scanned=%ld nr_reclaimed=%ld nr_dirty=%ld nr_writeback=%ld nr_congested=%ld nr_immediate=%ld nr_activate_anon=%d"
- " nr_activate_file=%d nr_ref_keep=%ld nr_unmap_fail=%ld nr_promote=%ld priority=%d flags=%s",
+ " nr_activate_file=%d nr_ref_keep=%ld nr_unmap_fail=%ld priority=%d flags=%s",
__entry->nid,
__entry->nr_scanned, __entry->nr_reclaimed,
__entry->nr_dirty, __entry->nr_writeback,
__entry->nr_congested, __entry->nr_immediate,
__entry->nr_activate0, __entry->nr_activate1,
__entry->nr_ref_keep, __entry->nr_unmap_fail,
- __entry->nr_promote, __entry->priority,
+ __entry->priority,
show_reclaim_flags(__entry->reclaim_flags))
);
diff --git a/mm/vmscan.c b/mm/vmscan.c
index fb5df298c955..98a7b0f738bd 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1045,6 +1045,11 @@ static unsigned int shrink_folio_list(struct list_head *folio_list,
folio = lru_to_folio(folio_list);
list_del(&folio->lru);
+ /* folio_update_gen() tried to promote this page? */
+ if (lru_gen_enabled() && !ignore_references &&
+ folio_mapped(folio) && folio_test_referenced(folio))
+ goto keep;
+
if (!folio_trylock(folio))
goto keep;
@@ -1061,13 +1066,6 @@ static unsigned int shrink_folio_list(struct list_head *folio_list,
if (!sc->may_unmap && folio_mapped(folio))
goto keep_locked;
- /* folio_update_gen() tried to promote this page? */
- if (lru_gen_enabled() && !ignore_references &&
- folio_mapped(folio) && folio_test_referenced(folio)) {
- stat->nr_promote += nr_pages;
- goto keep_locked;
- }
-
/*
* The number of dirty pages determines if a node is marked
* reclaim_congested. kswapd will stall and start writing