From patchwork Wed Oct 18 08:20:59 2023
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Huan Yang
X-Patchwork-Id: 13426606
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 B3283C41513
for ; Wed, 18 Oct 2023 08:22:14 +0000 (UTC)
Received: by kanga.kvack.org (Postfix)
id 378DA8D0143; Wed, 18 Oct 2023 04:22:14 -0400 (EDT)
Received: by kanga.kvack.org (Postfix, from userid 40)
id 327A98D0016; Wed, 18 Oct 2023 04:22:14 -0400 (EDT)
X-Delivered-To: int-list-linux-mm@kvack.org
Received: by kanga.kvack.org (Postfix, from userid 63042)
id 1A28C8D0143; Wed, 18 Oct 2023 04:22:14 -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 0BDD68D0016
for ; Wed, 18 Oct 2023 04:22:14 -0400 (EDT)
Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1])
by unirelay08.hostedemail.com (Postfix) with ESMTP id BAD76141299
for ; Wed, 18 Oct 2023 08:22:13 +0000 (UTC)
X-FDA: 81357889746.09.3F29AA0
Received: from APC01-SG2-obe.outbound.protection.outlook.com
(mail-sgaapc01on2137.outbound.protection.outlook.com [40.107.215.137])
by imf27.hostedemail.com (Postfix) with ESMTP id BDC1140008
for ; Wed, 18 Oct 2023 08:22:10 +0000 (UTC)
Authentication-Results: imf27.hostedemail.com;
dkim=pass header.d=vivo.com header.s=selector2 header.b=laGlQ26D;
spf=pass (imf27.hostedemail.com: domain of link@vivo.com designates
40.107.215.137 as permitted sender) smtp.mailfrom=link@vivo.com;
dmarc=pass (policy=quarantine) header.from=vivo.com;
arc=pass ("microsoft.com:s=arcselector9901:i=1")
ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed;
d=hostedemail.com;
s=arc-20220608; t=1697617331;
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=y/eT6KVcewOpLb+WlLYKCO09cMKS2vKtu5gikp+mGh4=;
b=KlqS1EIG8i+IPe6V+RmTuMXxU1xZS7dLO1Z8vu3dF4Agmm1N3RSK0nWcVwL7nzKs96ZU1V
6TQedj2UYxVxgCJG37i8/zc52N0eieqaKpY0xngeu5yU7Ug8Z4CZjz3ARS/KJT7l2ZNWwd
dazLR0o8hX8+2XVdgtqycTSfVto8up8=
ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1697617331; a=rsa-sha256;
cv=pass;
b=VXKmf61cdqzv5fiuyZxsvHyVKxr22eoiIyGXyLQuQt8FtTlfk0rZRKMPfOkeal95GnAAFK
Vz0BlHKZKj7FDJJ8nKz7LvZzZM0KKsEeDQyDwfVwSmDvWABl6qmGs7voTfmr2StMxtJdZ0
JBm2HHnuxQZh9zEakIriPwUO2yp1nXo=
ARC-Authentication-Results: i=2;
imf27.hostedemail.com;
dkim=pass header.d=vivo.com header.s=selector2 header.b=laGlQ26D;
spf=pass (imf27.hostedemail.com: domain of link@vivo.com designates
40.107.215.137 as permitted sender) smtp.mailfrom=link@vivo.com;
dmarc=pass (policy=quarantine) header.from=vivo.com;
arc=pass ("microsoft.com:s=arcselector9901:i=1")
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
b=aZBj635fOfB3pvM3VEC6KgU22Nepzixrvhqb8A3RL79ZvXV0G9l1WsS9a8r2VR7PJO+essHhfH81x4dgKjneJ2lYZuryuOZeJMYKupPg+xEkCgFtSa7g1OBG9QvtzR6A+3ueGLLtj/+gm+HveEO9wVxe8ZDuUDBlHLFgXOh/NxoFMZyvMR1IyPDf/0muu0V0FOAHRHfwlWshs6CvZ6pvfMVmzDBcg+jJSyyLuF6a5Ro4PtzAydlNjWR45KX1v4M7rSRhb3vN4WK1PFVPuIMHAh9wcDcMU6E9XNNUJ1nIdI/05pZNq+0O51GdlYCgUZzMmMueuiJ6hzC1LGRu5PB/jA==
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=y/eT6KVcewOpLb+WlLYKCO09cMKS2vKtu5gikp+mGh4=;
b=bYK+7Y3dUAYtljh1FeyJHbk+sq2EK4rRE4GILFPPNIHErDhESASMSAp2FUWsAm8SC0DzkfC+aBfwLFGME/Wd4lI2cIeeW9YA+ejCiHOUT+e11FNCRb7sT48mfryiODqcOeO8KXhxSajMfc93R4XcCTn/aHgyE2uSm0mohGxQbvTtf4nWaN5OIaNZK+LBNFNGsu9ftYdQuC3fO8bGx2G7j12aChf6njQDxgKjsAKPo9fUWmMsz2c8d3v5iQn59dnAj/rGvDqP9CjxTU3LHagK1Wh3koGKI+SHSk+hT07XEL3FhGqEnWYsZfljikrlVWn2LFM83+C53ExdLGxD3lmzEg==
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=y/eT6KVcewOpLb+WlLYKCO09cMKS2vKtu5gikp+mGh4=;
b=laGlQ26Db/3Oo5Q6rbxOh0QBdnQzY20bHviAclUVHZzVPRfGbudg0GLr4YhGyNjuG+ZuxpR+/dNvPW7DScsNDEtkZ1+txNEzRyhZWYnMzeBEs5ldkkC4BKXWvwUdKeix556+2+rJVLS9/yMg0R/gQIYGkFroHjh4R9zJXzhPQxyAkm0q4ihErFZWkYsmBxOOoEnObPCa9UuyGekuY+7iyukqd6zVQ4WI/PK94LzfAM7+XdEQXKA3I2Mtl9fuigy0xBuLBLeNL6hPzFdxsCW4FGzXAhY/UEeP2PwIsfB97zNoYPDTwWWOX0TLBCS4P6wiPcnngn9zsOX8SlChvQ76Bw==
Received: from PUZPR06MB5676.apcprd06.prod.outlook.com (2603:1096:301:f8::10)
by PSAPR06MB4391.apcprd06.prod.outlook.com (2603:1096:301:82::8) with
Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.22; Wed, 18 Oct
2023 08:22:02 +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.021; Wed, 18 Oct 2023
08:22:02 +0000
From: Huan Yang
To: Yu Zhao ,
Steven Rostedt ,
Masami Hiramatsu ,
Andrew Morton ,
Suren Baghdasaryan ,
Huan Yang ,
Vlastimil Babka ,
linux-kernel@vger.kernel.org,
linux-trace-kernel@vger.kernel.org,
linux-mm@kvack.org,
bpf@vger.kernel.org
Cc: opensource.kernel@vivo.com
Subject: [PATCH 1/2] tracing: mm: multigen-lru: fix mglru trace
Date: Wed, 18 Oct 2023 16:20:59 +0800
Message-Id: <20231018082104.3918770-2-link@vivo.com>
X-Mailer: git-send-email 2.34.1
In-Reply-To: <20231018082104.3918770-1-link@vivo.com>
References: <20231018082104.3918770-1-link@vivo.com>
X-ClientProxiedBy: SG2PR04CA0185.apcprd04.prod.outlook.com
(2603:1096:4:14::23) To PUZPR06MB5676.apcprd06.prod.outlook.com
(2603:1096:301:f8::10)
MIME-Version: 1.0
X-MS-PublicTrafficType: Email
X-MS-TrafficTypeDiagnostic: PUZPR06MB5676:EE_|PSAPR06MB4391:EE_
X-MS-Office365-Filtering-Correlation-Id: 4bee04ef-c9e2-4559-d701-08dbcfb34e78
X-MS-Exchange-SenderADCheck: 1
X-MS-Exchange-AntiSpam-Relay: 0
X-Microsoft-Antispam: BCL:0;
X-Microsoft-Antispam-Message-Info:
o+3FWqGIOzyLZVowgOupzkXO8oAJTlvnqz5bWKMj8Kg9qBCCIn9nri7dYvSMLwPLEmb3VXMk7xNDfnnLhtIN11Amf6/O0dQGcprcv3FiaC+UQbwHEzTHEQFlk9icw362J4Ne57g1mJ9MGqSiQ+EmgRYbbp5vb/m+Gl0T+CddAypBMgBF75/LpMMAAT7dKlZ1GNZVNB+jGORAoir9RiQUGNGULtkwgCIsxmjw5futbd5eG6Xe9RRDWKYbvOfhCUjV8Qz+ruTIgYYXsRrjl9n/t6IL2CYKXARBbcDWewHdK7BRvyFyyZiwUvTClTWPtKcMYPsjBDjrgIhQhT4briucqPDWJERpzprUEa+gQs4cdU/GSbDB5K8MhioC4XhR5WxJU6+4GvdE31xUd1FXVOf5SGo655RVLVOfjx0CcL8zSaSt0ixvRyfAueWHRkqYINwMUP/0tZ8rtNHwF51VlL31WY9FVyEDRHnh15F55IAMJa9g4wJkPbztvtjgnBinvZcXYTtcGfk6ZNjiB477y4eIQUQbE331aH6uRj1XDkgfQOb3dQ9hm80PSt895ah9taFV39bqgFyCYIMYKRuk+e9mxR3wquhb6QiS4s1wewSOQOwHFpt2UERmeNioKFy44Czo9KQcP/QLhw+z7LgF7pq6nA==
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)(376002)(136003)(366004)(396003)(346002)(39850400004)(230922051799003)(64100799003)(451199024)(186009)(1800799009)(7416002)(4326008)(8676002)(8936002)(5660300002)(2906002)(86362001)(36756003)(41300700001)(38100700002)(6506007)(83380400001)(6666004)(52116002)(6512007)(6486002)(107886003)(316002)(478600001)(1076003)(26005)(921005)(110136005)(38350700005)(66476007)(2616005)(66946007)(66556008);DIR:OUT;SFP:1102;
X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1
X-MS-Exchange-AntiSpam-MessageData-0:
TdHSSxkHxMNJr/kQEBhZL5/r02/l0KTt7Xtv0guRMyGaYBvEhJSv7xUDtbJplMwYUNYyUKHZUEK+4sluBapXAKE5DiKk06h2drfXLAvheXUUJqYNG74twByapol7v9A5LfwWtTtNqCB21gXUQBxfqnVZustVzR0wNHRdSAGB1hUVLOKSwixjnENNyCknfI6mjQGxJ9MtGJdRbp/d9Qz2K4sXQo0Em/AFFFD2L0q5TGcTY0cYYVWcxlwVvrtWGLuRtbEU+an5Xc/IB6kcReV4rRq4q001gum8YLQnG1o1yA9+emTFUGT+8cY7y4l8k8C/rd5kJH1sc03WZ9WgKb2gAqZY68Z7cdsH0aucogLHkoX3TF1epEG5GdBGqZI1qlTAUEuajIx19Yz/VCGNAmAp6rDMIL4fAR6EE6ELUcN2xIZ8xkvRFAQzijyuCZlb8iXhn2Q5LoTEteiGNvQB+Rxi4Kyh6UiqWf56ZKcnXcE8HX3+qnSKDJPI45mhUeh+//itmJDUQxAWKJbmCAbmkWa6wHjtwjbHc/r7EvbuqJDkJxdxR2A9GUirGZmxQ2X9QALthRYyLvBrr2mXc+ozq2jae83JsgpEHrsNQ1fdSXhuxEoi9ebUw1UPyLiqusJYuEV8LZGwnDh9C0OUJUmL+1+K/nmjt+K3C6YV3IXmQOv9cq3lByyhDDPD3ljfkZXGiJ7jLha/6JwrbaDmZGdHGE00ejYCACQP3L2/eWm+l0QyP3UCRtQO0On4L2GAvB/gdfo5s8re6OJddDARRj5xraVxjXQGD4MThMVju5RpkKJGDTocIH/Ew4q1JzwUo/CZYs/22/QB6x9Iu7GLrT4OwS+BR6DFR9iGjx8q1U4HI+/pjnOGBUMgcVz0t1ApIeIX6HS/ZJZmttF4TZcOFe3sjcMcaQNaKr86+vdq9Vsmf+cyX3WhftspZCJtFp3yod7qgy35o2cCN88jcZVaUiX7F2XcJYC2nljFppkd6FdzIbutcYRU0VuqJODdV1xXRx1ZRMOlCdWedMDS8c7vydW8SZDcwsitHnj2wnIehIerdXrdaoH652MUIpByyNQZjc7jhhdZEyeiYXW1JK+njHrhUd9HWK/4i0HeGCOQCxzQmEQf4PypBewb6t7mRsr6pg9ONiFk3ZlXp+903XugciYbZq6ZlWHp/oeTg3AE5mqP5TF9Z7h9hx8RCb7GATVuKwKP+05Rk78XX89DBDsyOvnBEdWSVjJ8eIsECvBBXKUsPG9uAy5AZZdvjLRWevJp9XKpueGt4l0L50w5EaNaBPZfwJdSbI/ecTVnB4jTKQUaxVkBOta86fCFWwK+GfMUCZJUeu9Agv8frzHz8ROyarJjUtlr1rqN1RdQb+hDbslWXHuDd/93FGqVM5njihyzP5d4jn1Up4SKD5RmzoHNpK9TUS2KFwk4yK77+8soqbZoGk3jAq9KNVkriluvCyPbJReTzAo42hOv/+0sCjMHa3KbnWZ1bwnzmEp1tVezbWcT5fp/jcNlADCMcQhZHuOuHrGiOIth4gUmenrahiRozAW9N8ezaha2HoOtNScDrDEh1N5hwc7rNBqziWOtrBtJR6u4sysL
X-OriginatorOrg: vivo.com
X-MS-Exchange-CrossTenant-Network-Message-Id:
4bee04ef-c9e2-4559-d701-08dbcfb34e78
X-MS-Exchange-CrossTenant-AuthSource: PUZPR06MB5676.apcprd06.prod.outlook.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2023 08:22:02.6948
(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:
u/VOtR9oXkT+G4/qSHOzkBvjHozfJmpIXojLB3fT2UVNgTUjzao2ujf/7vYGkiULOU1MmkYA919eAS5GH9WU3A==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: PSAPR06MB4391
X-Rspamd-Queue-Id: BDC1140008
X-Rspam-User:
X-Stat-Signature: 9mak5tdxb4x7zbkqruhpr8rgzaiwbn5r
X-Rspamd-Server: rspam03
X-HE-Tag: 1697617330-853344
X-HE-Meta:
U2FsdGVkX18RERD9iX1ejdM8WhyxW8euihCa3hka+gfmozB6y7cfH+5a60WzikeCiExA+CD/Iw5W327Ti/UjORgzMciZzsVAZ5X6cPJqVG1b3RutG+M/8HtihS+B+HDZI36lveb3oyzT5aI1UP0E8p5pHU9Tn7HK0KbmXrUAoYf9/15VWRmx7hkfxwlZd8UAZSkOqJCjXXO4xIqmdO7OZW+Gq7R+ubRDkdYeMxXy+DXkRuny2+uu7fgGPK4vPVfA0u1Z7aYb42vG4ymjSkghKWtAG38OO0UfSf9VRJAPEyeJxgOfDvNI3cLoV7iv0cD7G0I/bCt43gySs3cCejpb4OzmKIPQ/6iS49+yzkkbbAKvVUO+XNdLn6XqQmTV452dSo9vd/uGY110yO63iq2qcr0S/cAx/MjmSWo+GoQWD2K1ndDsCznRAK+V0xlPb3FW6jogHfKKvuL6YMcbS4gq1yIAPEp2t24kZBNkEaMlWbRfXXGXEV9Zb6TyUs/RWE02MgrtSR1iZyNm3GNRggU4q+cbN39ChBFC52F3OdR92tyYZGR+Q7Ct9dsxU6gtZuwbnOzi8MZyDUaXIYDR6eKpnpzGG1qVVRuhFthTA56UbNJpwIzmjzqBFN2AsVmuQBipewjPWKFFRou4Fsc3Dj1qOW3kPO4m9X3BbV5orLiAKOH/DdVBOnmSPGlAPdPVYhG8FbMDSa3H5PDcvc8M5tYssMAli9X+P03I9eqBrxzrrOhg56SDivap+SyPL/yTkMGrGhamTvAiOdC8O59ET3p5OiqgvI1asXFbUXJ4lmdMFmfvm8YJeZFLG+MRLEK5gNXh1A0p+vCejjIyfjrB4lQpCKmWR8htjmwuaHK9sWz97B1TsU5uf1X0ooLXAEo5vCQNittow1av2gci3sTKu/E/bOmnyNYli080/ClAQkuOIYwugVeOBlQX6hWCwhKnNqMXNb3YJtp6yu30X3r9EMk
i41GMALW
SsqnBBGQBZWG60ETESUIWIrEFb5Pq1EZDEBNJYMUoiezoth3C5mKPkMjv7r321erNOgOMrbj2/AQgmtlAlbYtRo99YI6MhLRnHXWVElXE0jUomX9fS286uX5l6LOnG4awXf8mTCnNIfgj6p7m2WZpr+Vf0PcOokLPGrob2/axB4B0UGiQwxJmZZ4+8TKCXo/4Nr0gfCJye8Iy68j/zaIgHZ0ikOwSOUTfHA0Sq47Wr6LzbST+qf6kK9wncFqHS4mZVHY246sSdwo5tCXj5/XqfiqOgoXzAucI2eVPPk/O+dz+DlDwV5bmnkqpB7w/BWuCRUu3l2YQ7WYsOJqBd8682NLo8w==
X-Bogosity: Ham, tests=bogofilter, spamicity=0.000053, version=1.2.4
Sender: owner-linux-mm@kvack.org
Precedence: bulk
X-Loop: owner-majordomo@kvack.org
List-ID:
This patch add two reclaim stat:
nr_promote: nr_pages shrink before promote by folio_update_gen.
nr_demote: nr_pages NUMA demotion passed.
And then, use correct nr_scanned which evict_folios passed into
trace_mm_vmscan_lru_shrink_inactive.
Mistake info like this:
```
kswapd0-89 [000] 64.887613: 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=0
nr_ref_keep=0 nr_unmap_fail=0 priority=4
flags=RECLAIM_WB_FILE|RECLAIM_WB_ASYNC
```
Correct info like this:
```
<...>-9041 [006] 43.738481: mm_vmscan_lru_shrink_inactive:
nid=0 nr_scanned=13 nr_reclaimed=0 nr_dirty=0 nr_writeback=0
nr_congested=0 nr_immediate=0 nr_activate_anon=9 nr_activate_file=0
nr_ref_keep=0 nr_unmap_fail=0 nr_promote=4 nr_demote=0 priority=12
flags=RECLAIM_WB_ANON|RECLAIM_WB_ASYNC
```
Signed-off-by: Huan Yang
---
include/linux/vmstat.h | 2 ++
include/trace/events/vmscan.h | 8 +++++++-
mm/vmscan.c | 26 +++++++++++++++++++++-----
3 files changed, 30 insertions(+), 6 deletions(-)
diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
index fed855bae6d8..ac2dd9168780 100644
--- a/include/linux/vmstat.h
+++ b/include/linux/vmstat.h
@@ -32,6 +32,8 @@ struct reclaim_stat {
unsigned nr_ref_keep;
unsigned nr_unmap_fail;
unsigned nr_lazyfree_fail;
+ unsigned nr_promote;
+ unsigned nr_demote;
};
enum writeback_stat_item {
diff --git a/include/trace/events/vmscan.h b/include/trace/events/vmscan.h
index 1a488c30afa5..9b403824a293 100644
--- a/include/trace/events/vmscan.h
+++ b/include/trace/events/vmscan.h
@@ -366,6 +366,8 @@ 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(unsigned long, nr_demote)
__field(int, priority)
__field(int, reclaim_flags)
),
@@ -382,17 +384,21 @@ 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->nr_demote = stat->nr_demote;
__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 priority=%d flags=%s",
+ 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 nr_demote=%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->nr_demote,
__entry->priority,
show_reclaim_flags(__entry->reclaim_flags))
);
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 2cc0cb41fb32..21099b9f21e0 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1063,8 +1063,10 @@ static unsigned int shrink_folio_list(struct list_head *folio_list,
/* folio_update_gen() tried to promote this page? */
if (lru_gen_enabled() && !ignore_references &&
- folio_mapped(folio) && folio_test_referenced(folio))
+ 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
@@ -1193,6 +1195,7 @@ static unsigned int shrink_folio_list(struct list_head *folio_list,
(thp_migration_supported() || !folio_test_large(folio))) {
list_add(&folio->lru, &demote_folios);
folio_unlock(folio);
+ stat->nr_demote += nr_pages;
continue;
}
@@ -4495,6 +4498,8 @@ static int evict_folios(struct lruvec *lruvec, struct scan_control *sc, int swap
int type;
int scanned;
int reclaimed;
+ unsigned long nr_taken = sc->nr_scanned;
+ unsigned int total_reclaimed = 0;
LIST_HEAD(list);
LIST_HEAD(clean);
struct folio *folio;
@@ -4521,10 +4526,7 @@ static int evict_folios(struct lruvec *lruvec, struct scan_control *sc, int swap
return scanned;
retry:
reclaimed = shrink_folio_list(&list, pgdat, sc, &stat, false);
- sc->nr_reclaimed += reclaimed;
- trace_mm_vmscan_lru_shrink_inactive(pgdat->node_id,
- scanned, reclaimed, &stat, sc->priority,
- type ? LRU_INACTIVE_FILE : LRU_INACTIVE_ANON);
+ total_reclaimed += reclaimed;
list_for_each_entry_safe_reverse(folio, next, &list, lru) {
if (!folio_evictable(folio)) {
@@ -4582,6 +4584,20 @@ static int evict_folios(struct lruvec *lruvec, struct scan_control *sc, int swap
goto retry;
}
+ /**
+ * MGLRU scan_folios return nr_scanned no only contains
+ * isolated folios. To get actually touched folios in
+ * shrink_folios_list, we can record last nr_scanned which
+ * sc saved, and sc nr_scanned will update for each folios
+ * which we touched. New count sub last can get right nr_taken
+ */
+ nr_taken = sc->nr_scanned - nr_taken;
+
+ sc->nr_reclaimed += total_reclaimed;
+ trace_mm_vmscan_lru_shrink_inactive(pgdat->node_id, nr_taken,
+ total_reclaimed, &stat,
+ sc->priority, type);
+
return scanned;
}