From patchwork Tue Dec 12 03:26:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bixuan Cui X-Patchwork-Id: 13488472 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com header.b="MmoRfFBd" Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01on2122.outbound.protection.outlook.com [40.107.117.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10F9C8F; Mon, 11 Dec 2023 19:27:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A6RVKUPbsuPjpW3Yve+G4cxLgqCcRraIi2LMQ9tcneTmb+IAbTn6Vfek1aftmiYJG64Ui4qgLDSPl4VkuCnyrKs9AniZK9A6lJwjKyRMJ9hS/TElbYHIPW6v5i9SpNIng0FilXJaWlBYNSlEwPnbMZ+RMhp5TyXiCN8W7vGd84GyLtjYaHU2mWb7VRRGCfKZZZgqrnicnuv4/IHLw8Oas2XfotaxfqZ9D8j3zoMnb9FGmZvvLZ0qXnL6Z4mD3+8lujoYw9KeElBnBxLYzGN6ttDYknFFibTELk4TovNF47pIQAbsfw+dZUw1giYCqkYLFiuG54b88aulv1ggLnx3lQ== 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=g7oIIAqbzcDOZgSBWU+sOxLWScBOIz8KQyrhRsF24hA=; b=PItkxf7EAKVb1XKG5PhU3N4h4WDA41tSA6eZAe3qiy4aGAhymLDlgT8hwUDB+6ror7qxS+sa5H11h/dZCsmPfe6WAF9FXOLXu0gbCCJp6EZyDkVfkfwWvQ7OU8auFUwmsGf+BcZT2SPpo7UpVfkh7kgVllFTPzgY87F/LxL2Ydo08GgTy18fqHnwxnkOdFEWPmmK/l7YdH7aJCxK58vfhpR7QWbZb91+fXAsOSdRDo3d0F6x55hhwXor6RNHmpWFmqEwq+Br9zomxaayGLg8UFG+LO5wVj1n8W7T7zNFE+jzgl5dqFDUM0/xmqOCAVEIncia/ZDQOJhtLgoNuwNk7w== 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=g7oIIAqbzcDOZgSBWU+sOxLWScBOIz8KQyrhRsF24hA=; b=MmoRfFBdL4JCkbsfa2iyasY1gKDIxTvG7oTh0YkDIbsSQnQsuk8ARATTZil3mDFXXhUm7F++NnMO6QBrx0L8uXc3021bWsTuKUslm+cWw+BmC2RqHxHfQ2iQ9dwfrOkFzaKUMVHaMMx3HkIzCFepzItEdqZtsIZMtVBxs+G3y+ciHmCQYQedCYXxFn05dKmNFTV3WWsTr27lByjjS5l+ZzWJqzeNGtUCJl/Q85+2sCJbD7IrlXRdFlwMeVi8I9sWQZ+/t+G7bsaOqYDmTRNkGy2IbnNzHNdYCKAAZmgtMLRj23qsS7I6s6BzCtJ0EwfE4vWjus8TSVp0E+0F3++70A== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from TYZPR06MB4045.apcprd06.prod.outlook.com (2603:1096:400:21::8) by TY0PR06MB6839.apcprd06.prod.outlook.com (2603:1096:405:10::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.32; Tue, 12 Dec 2023 03:27:02 +0000 Received: from TYZPR06MB4045.apcprd06.prod.outlook.com ([fe80::9925:32d7:c818:3c5]) by TYZPR06MB4045.apcprd06.prod.outlook.com ([fe80::9925:32d7:c818:3c5%7]) with mapi id 15.20.7068.033; Tue, 12 Dec 2023 03:27:02 +0000 From: Bixuan Cui To: rostedt@goodmis.org, mhiramat@kernel.org, mathieu.desnoyers@efficios.com, akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-mm@kvack.org, cuibixuan@vivo.com, opensource.kernel@vivo.com Subject: [PATCH -next 1/2] mm: shrinker: add new event to trace shrink count Date: Mon, 11 Dec 2023 19:26:39 -0800 Message-Id: <20231212032640.6968-2-cuibixuan@vivo.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20231212032640.6968-1-cuibixuan@vivo.com> References: <20231212032640.6968-1-cuibixuan@vivo.com> X-ClientProxiedBy: SGBP274CA0012.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b0::24) To TYZPR06MB4045.apcprd06.prod.outlook.com (2603:1096:400:21::8) Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYZPR06MB4045:EE_|TY0PR06MB6839:EE_ X-MS-Office365-Filtering-Correlation-Id: 67714e02-9049-49e3-7021-08dbfac234ec X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6OPrY0Ju4iZDA/QpvEYw4bOJHF2nupxUDom1gLrJ67jhrXGLfjFMMCtTISpp/TqmKLHIDH2iCOvm4Fh0pdW0MFIQNYuXSHNCtiwz1Tx0JfhhRVkc15itAofxxkRy0czi9nLIursovLKOIdNNX/xAfp54UtomW3cqAmrwvqRJ36CzsnfziLn4+Nu0o4eu4Ske8nA3dSHN6u4ehtLheKHae/uYjcX+uHfMo1Pj7Kea5h6n/yjImY/1pqU33/3G4yIfy3IDmdRI8V/PTQ34RWId4FvmBAQSIysW87EZE+FPr6vvb0nrkf7yCLEQZUQqepPxy3yAFUPFsuVIEHUQ53JqqPaWXya0PsWjwXPeOePebwxjntBE3kcjQWvauoDZ3i04MxPdsTo+/LaCtC2U5MKgIZ6A2tugwFFsScZ0ZdZeFX1UbdQcOdRZZFQjwYLfLweQfDVXUaqwParDFByBErA8aDwjwPb4XVlA1hMGC04l9W77aE3VmtjmWS9sIc4ohhvLCWmo1G4FE/WbpFGD8emLILmjLMG8UVvl4JSFOmDS6NLEjkq8S5TouoCzMencBwKUsAkuPSviL4Ml+0/yUQ+BCpagudlsmWnrhT0X974tfNfBidfv+8o9lBF5dSyPWZ3x X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:TYZPR06MB4045.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376002)(346002)(136003)(396003)(39860400002)(366004)(230922051799003)(186009)(451199024)(1800799012)(64100799003)(2616005)(26005)(1076003)(107886003)(40140700001)(316002)(38350700005)(86362001)(36756003)(38100700002)(83380400001)(5660300002)(52116002)(6512007)(6506007)(6666004)(66556008)(66946007)(8936002)(8676002)(6486002)(66476007)(4326008)(2906002)(41300700001)(478600001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KFt6CF92Hmsh74MOyXHdEFV85MyYSlnoCQ7QIoCdfDA8a9ZcmjfjV7694Ltu15QGwWXi8yCnkouBg88mk5Cd+da3Jhs0cUqRwokT2F2FKGA1pxvRaUds+HvO/y/zk+OvEyH/bUs1icyE9kLtgWwcjelR70QaUS0/y50nv/4PQYBX7S5EmPU2WKb9NMIMRUnX8U4npf5FR15XowowwwC9f+tKafpjjGTu0oc+Dp5/CZN2HZcyclo2w2qMYKl+fGaruwAHKqHRmBLluaMA+AVDEOK5dOnulXAWVgiI7N5d6uEQ2DVhxYO3zy6wulGEgGI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QOuaKlYBaTUn9zXgwC6ZvIYyUg9YmMG+yS7bvZdOTYiszEDgo0P1bR96Ah+F7hGQU7xEpUoLV87pBwkN7Ar/DqzYp/T4c3htojp/d5Xm0xYCjkeCzq05uQdgM/g/aVsr4hITjMVFXbx++tv9Gk++e0F9it2j58UEkoFyjKq5khCvez8JlnzoUMQOd49a/cPDdFDK71fF75ZMmIakW1sc4b9N X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 67714e02-9049-49e3-7021-08dbfac234ec X-MS-Exchange-CrossTenant-AuthSource: TYZPR06MB4045.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Dec 2023 03:27:02.3035 (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: I8KcoMiux6zmidmHyrPsPNrFJxv6bsN7aaT06Yr9BlHXXYk5l6GIDVAptjfiubrwNfy3vqAYU9h5JGr9pLvLjg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY0PR06MB6839 From: cuibixuan do_shrink_slab() calculates the freeable memory through shrinker->count_objects(), and then reclaims the memory through shrinker->scan_objects(). When reclaiming memory, shrinker->count_objects() takes a certain amount of time: Fun spend(us) ext4_es_count 4302 ext4_es_scan 12 super_cache_count 4195 super_cache_scan 2103 Therefore, adding the trace event to count_objects() can more accurately obtain the time taken for slab memory recycling. Example of output: kswapd0-103 [003] ..... 1098.317942: mm_shrink_count_start: kfree_rcu_shrink_count.cfi_jt+0x0/0x8 00000000c540ff51: nid: 0 kswapd0-103 [003] ..... 1098.317951: mm_shrink_count_end: kfree_rcu_shrink_count.cfi_jt+0x0/0x8 00000000c540ff51: nid: 0 freeable:36 Signed-off-by: Bixuan Cui --- include/trace/events/vmscan.h | 49 +++++++++++++++++++++++++++++++++++ mm/shrinker.c | 4 +++ 2 files changed, 53 insertions(+) diff --git a/include/trace/events/vmscan.h b/include/trace/events/vmscan.h index 1a488c30afa5..406faa5591c1 100644 --- a/include/trace/events/vmscan.h +++ b/include/trace/events/vmscan.h @@ -196,6 +196,55 @@ DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template, mm_vmscan_memcg_softlimit_re ); #endif /* CONFIG_MEMCG */ +TRACE_EVENT(mm_shrink_count_start, + TP_PROTO(struct shrinker *shr, struct shrink_control *sc), + + TP_ARGS(shr, sc), + + TP_STRUCT__entry( + __field(struct shrinker *, shr) + __field(void *, shrink) + __field(int, nid) + ), + + TP_fast_assign( + __entry->shr = shr; + __entry->shrink = shr->count_objects; + __entry->nid = sc->nid; + ), + + TP_printk("%pS %p: nid: %d", + __entry->shrink, + __entry->shr, + __entry->nid) +); + +TRACE_EVENT(mm_shrink_count_end, + TP_PROTO(struct shrinker *shr, struct shrink_control *sc, long freeable), + + TP_ARGS(shr, sc, freeable), + + TP_STRUCT__entry( + __field(struct shrinker *, shr) + __field(void *, shrink) + __field(int, nid) + __field(long, freeable) + ), + + TP_fast_assign( + __entry->shr = shr; + __entry->shrink = shr->count_objects; + __entry->nid = sc->nid; + __entry->freeable = freeable; + ), + + TP_printk("%pS %p: nid: %d freeable:%ld", + __entry->shrink, + __entry->shr, + __entry->nid, + __entry->freeable) +); + TRACE_EVENT(mm_shrink_slab_start, TP_PROTO(struct shrinker *shr, struct shrink_control *sc, long nr_objects_to_shrink, unsigned long cache_items, diff --git a/mm/shrinker.c b/mm/shrinker.c index dd91eab43ed3..d0c7bf61db61 100644 --- a/mm/shrinker.c +++ b/mm/shrinker.c @@ -379,7 +379,11 @@ static unsigned long do_shrink_slab(struct shrink_control *shrinkctl, : SHRINK_BATCH; long scanned = 0, next_deferred; + trace_mm_shrink_count_start(shrinker, shrinkctl); + freeable = shrinker->count_objects(shrinker, shrinkctl); + + trace_mm_shrink_count_end(shrinker, shrinkctl, freeable); if (freeable == 0 || freeable == SHRINK_EMPTY) return freeable; From patchwork Tue Dec 12 03:26:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bixuan Cui X-Patchwork-Id: 13488473 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com header.b="J9X7aQGS" Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01on2097.outbound.protection.outlook.com [40.107.117.97]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B6B5DC; Mon, 11 Dec 2023 19:27:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EgsA3zu7+/XPZm7Uq0q/G58moKo1+rWsywJu1zVIak+XYQ38KdvrFUDv6qv/rf5nMshfFhFOUY2x8HEJnO19HjeSjtp5eQDYtJz6i10XnyiYR5240lJRB2IY4xgvCHLlVlwN82DuaEulIpfpt2b+m+m3E8ygG1ZUlW+nCXarDnf8NflJYZZqZgDZOCJS4iruJavat54NE/gqmbzlTabNTJbAHeRbbIV6GM2/BBfSyny5xighHCt7O6yltEHaklYAyPjLH7dsMSBh2+wC7Asb+g7LZtbkMEd1UakmmOQaWJ+78+p3PxHhL+pOiU0zZSheu3ln1NDdondBeUtDTTwYsQ== 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=eeU/QXyDeRMtTGN6We1+pgz8pJ6zXq2mwd5p00JEds8=; b=RqVfzRZc0i74qSXsnwl8aK9hDvPor9/UePVZP1jDqSmFqnfoSh9VYBuvDZMfkpgQda5nOWKlJeVqTTQOqzIss+uX3opFpe2fggiDBf5WuEqNKMavl4UsGop0dFhO0SGFUae/svv3njCRJv6had+hCGMQCTZz6DlfQpVC2CL2m7gT7PLSsydLKBX9acKYyydS3huI4S+sxlTV4vIascihACEFbA4wmDSCluXJZJco2gscMspz54zSg4MnhvD09v5lGlzeD4L4XSGCswfZrO+TWv4BQzIAMKQkr7WGlMUnRsdmUHmBRinGA7ExP9oC+EGjBAOOxZM7a9QHe1LdADNaKQ== 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=eeU/QXyDeRMtTGN6We1+pgz8pJ6zXq2mwd5p00JEds8=; b=J9X7aQGSKmXRXJ7SXgZRacfplpoOVxLVcuydxihUgFxf/5yW6BpihemZjtXNIoVYlTfeFxjpX82HKgkzuuSbGZdztMlM/FwbO0kXZajglol4GuXrnNh1R/GbGcSQFE6g1eNEaxAfkDQAiYIKs3jgKHUwHWnOefzgiNI8knc2Bd896XCtTcd2dDgdvxa/AfhVqHDq0QFPoTUcAdEOWw+d+N+BhckKQo9vvUVtf92sAV8z/yxEaYN6cUWZZUiGdIVZIHABjNgDCx4adcOuXR/pKCiWcKGmJsx+k7CB2kqUhvw5d6uj5w6WilQBrXvw1WWuk7ypY0tD7WpLrFlsxSJCWw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from TYZPR06MB4045.apcprd06.prod.outlook.com (2603:1096:400:21::8) by TY0PR06MB6839.apcprd06.prod.outlook.com (2603:1096:405:10::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.32; Tue, 12 Dec 2023 03:27:09 +0000 Received: from TYZPR06MB4045.apcprd06.prod.outlook.com ([fe80::9925:32d7:c818:3c5]) by TYZPR06MB4045.apcprd06.prod.outlook.com ([fe80::9925:32d7:c818:3c5%7]) with mapi id 15.20.7068.033; Tue, 12 Dec 2023 03:27:09 +0000 From: Bixuan Cui To: rostedt@goodmis.org, mhiramat@kernel.org, mathieu.desnoyers@efficios.com, akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-mm@kvack.org, cuibixuan@vivo.com, opensource.kernel@vivo.com Subject: [PATCH -next 2/2] mm: vmscan: add new event to trace shrink lru Date: Mon, 11 Dec 2023 19:26:40 -0800 Message-Id: <20231212032640.6968-3-cuibixuan@vivo.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20231212032640.6968-1-cuibixuan@vivo.com> References: <20231212032640.6968-1-cuibixuan@vivo.com> X-ClientProxiedBy: SGBP274CA0012.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b0::24) To TYZPR06MB4045.apcprd06.prod.outlook.com (2603:1096:400:21::8) Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYZPR06MB4045:EE_|TY0PR06MB6839:EE_ X-MS-Office365-Filtering-Correlation-Id: 28db6b3f-c615-4b86-2d69-08dbfac23935 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EggoWrBAtUTj4YEV8eT7BMOkVby2Btc/8TRhdnQ9PmUN2mTJvzU3BBLKmQdH1QCPGykHvOO+RRpu83nsdEdHJFeUdHxDTo1UWmbIqkXQzTVzhiuMcnrqNFKu8DOvb6RGoFZtao6hgiISq6sOyyYmbCqE2miw+ON3BefrMhG/nJ5rB769eSXhZg7J/twNFv5jfc/PUt5UkkK+al5uH+5lr0Ja+wFZ0k+lhwy0KOxxAWgCZk3NSU7uUV+QGWtdCiSA7WnZ83J/wVjFOM/jObq9+niW8upwuIJ0EXB2jp9zKJMp5dh7of28TqrBPiGnkE2oTr1jJ6GFrNIo+U9XXLJ2kAQy1d2GWBxCjEEucfgrkE4ot5Xq42mYRRF/cdQzyCitK58QWuQn8kWy9En3nf/WDv6bWqyvFVJH2oPl3nSwX5KgL034D/zu/ooxOUsuqiylnwDzoE+AsS05NCzipwamLSdO3uI2XVC67ZqqNztObJH9QTAwYRepbMsLo+KoAm6r4lpb6vvfYAb9XVuS7TWBqnZNJ6PNL3PsedoTf2x1InVDOaN16v1A1Ver7tlhTq9WRf0raCiQIIrqexzeED8VwDo5+Uw6y0CifDJmmCBpHro6RW2NxfyF8tiRpMbkb7Bf X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:TYZPR06MB4045.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376002)(346002)(136003)(396003)(39860400002)(366004)(230922051799003)(186009)(451199024)(1800799012)(64100799003)(2616005)(26005)(1076003)(107886003)(40140700001)(316002)(38350700005)(86362001)(36756003)(38100700002)(83380400001)(5660300002)(52116002)(6512007)(6506007)(6666004)(66556008)(66946007)(8936002)(8676002)(6486002)(66476007)(4326008)(2906002)(41300700001)(478600001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RSPQMdvNdFuqsHbr/s3uTn46IL39h/0PR8anaPFuO1ZsyeRLnTOCYITNoqFAaSr0sZLIHKNA5VpjG7LrUts9shnGcdJ7vcV/8bUlj0UC7jitu/+v63309lhlQGeoq4HJX64p0p9D61McrfAE2+Jf+fcpl7K8NMfEcrxEj6xm7PW+lS5HuBHZlAUWlkNCGOH5YZP5VhS/rtE7+tcOHiUHL/HODub61soU0QvHhPU5+oCbKgtTNLtTZr1aiJRHS55GVYXoaVQivefoFeX0AAzfiJKj5zH+Z0leGNDmhhqLtJ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uMUbFJkVTnQzusryxDbTfIQeigXBSq6UnDpRFnsFrVrlE77tSO8iu8YbAGDeGtMoDvEiAndcw3asIlVSme8Ga/+TUhikFufHM9cBi5DXrZ5OYzLPpjecbCZSUmjyncUN2ENN0HxtJKgqqVKPNsGc6MQP4Z9PO/Vx53JkeBYOHUGsEBmwboUEVZ/0IV9Ry7wmtixnJBOizurgjELWLmvvDCOLPgdLZ9A2/U3amtLcgzP2 X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 28db6b3f-c615-4b86-2d69-08dbfac23935 X-MS-Exchange-CrossTenant-AuthSource: TYZPR06MB4045.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Dec 2023 03:27:09.4828 (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: mn24X+UvLKKnAlxmw4bEDG2JbJ1jQV2q3RgtmDAFtdF+zHGPiHGVWKTX4MxS37z/SyKfSGli8goJWjBGNszJyw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY0PR06MB6839 From: cuibixuan Add a new event to calculate the shrink_inactive_list()/shrink_active_list() execution time. Example of output: kswapd0-103 [007] ..... 1098.353020: mm_vmscan_lru_shrink_active_start: nid=0 kswapd0-103 [007] ..... 1098.353040: mm_vmscan_lru_shrink_active_end: nid=0 nr_taken=32 nr_active=0 nr_deactivated=32 nr_referenced=0 priority=6 flags=RECLAIM_WB_FILE|RECLAIM_WB_ASYNC kswapd0-103 [007] ..... 1098.353040: mm_vmscan_lru_shrink_inactive_start: nid=0 kswapd0-103 [007] ..... 1098.353094: mm_vmscan_lru_shrink_inactive_end: nid=0 nr_scanned=32 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=32 nr_unmap_fail=0 priority=6 flags=RECLAIM_WB_ANON|RECLAIM_WB_ASYNC kswapd0-103 [007] ..... 1098.353094: mm_vmscan_lru_shrink_inactive_start: nid=0 kswapd0-103 [007] ..... 1098.353162: mm_vmscan_lru_shrink_inactive_end: nid=0 nr_scanned=32 nr_reclaimed=21 nr_dirty=0 nr_writeback=0 nr_congested=0 nr_immediate=0 nr_activate_anon=0 nr_activate_file=0 nr_ref_keep=11 nr_unmap_fail=0 priority=6 flags=RECLAIM_WB_FILE|RECLAIM_WB_ASYNC Signed-off-by: Bixuan Cui --- include/trace/events/vmscan.h | 38 +++++++++++++++++++++++++++++++++-- mm/vmscan.c | 8 ++++++-- 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/include/trace/events/vmscan.h b/include/trace/events/vmscan.h index 406faa5591c1..9809d158f968 100644 --- a/include/trace/events/vmscan.h +++ b/include/trace/events/vmscan.h @@ -395,7 +395,24 @@ TRACE_EVENT(mm_vmscan_write_folio, show_reclaim_flags(__entry->reclaim_flags)) ); -TRACE_EVENT(mm_vmscan_lru_shrink_inactive, +TRACE_EVENT(mm_vmscan_lru_shrink_inactive_start, + + TP_PROTO(int nid), + + TP_ARGS(nid), + + TP_STRUCT__entry( + __field(int, nid) + ), + + TP_fast_assign( + __entry->nid = nid; + ), + + TP_printk("nid=%d", __entry->nid) +); + +TRACE_EVENT(mm_vmscan_lru_shrink_inactive_end, TP_PROTO(int nid, unsigned long nr_scanned, unsigned long nr_reclaimed, @@ -446,7 +463,24 @@ TRACE_EVENT(mm_vmscan_lru_shrink_inactive, show_reclaim_flags(__entry->reclaim_flags)) ); -TRACE_EVENT(mm_vmscan_lru_shrink_active, +TRACE_EVENT(mm_vmscan_lru_shrink_active_start, + + TP_PROTO(int nid), + + TP_ARGS(nid), + + TP_STRUCT__entry( + __field(int, nid) + ), + + TP_fast_assign( + __entry->nid = nid; + ), + + TP_printk("nid=%d", __entry->nid) +); + +TRACE_EVENT(mm_vmscan_lru_shrink_active_end, TP_PROTO(int nid, unsigned long nr_taken, unsigned long nr_active, unsigned long nr_deactivated, diff --git a/mm/vmscan.c b/mm/vmscan.c index 4e3b835c6b4a..73e690b3ce68 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1906,6 +1906,8 @@ static unsigned long shrink_inactive_list(unsigned long nr_to_scan, struct pglist_data *pgdat = lruvec_pgdat(lruvec); bool stalled = false; + trace_mm_vmscan_lru_shrink_inactive_start(pgdat->node_id); + while (unlikely(too_many_isolated(pgdat, file, sc))) { if (stalled) return 0; @@ -1990,7 +1992,7 @@ static unsigned long shrink_inactive_list(unsigned long nr_to_scan, if (file) sc->nr.file_taken += nr_taken; - trace_mm_vmscan_lru_shrink_inactive(pgdat->node_id, + trace_mm_vmscan_lru_shrink_inactive_end(pgdat->node_id, nr_scanned, nr_reclaimed, &stat, sc->priority, file); return nr_reclaimed; } @@ -2028,6 +2030,8 @@ static void shrink_active_list(unsigned long nr_to_scan, int file = is_file_lru(lru); struct pglist_data *pgdat = lruvec_pgdat(lruvec); + trace_mm_vmscan_lru_shrink_active_start(pgdat->node_id); + lru_add_drain(); spin_lock_irq(&lruvec->lru_lock); @@ -2107,7 +2111,7 @@ static void shrink_active_list(unsigned long nr_to_scan, lru_note_cost(lruvec, file, 0, nr_rotated); mem_cgroup_uncharge_list(&l_active); free_unref_page_list(&l_active); - trace_mm_vmscan_lru_shrink_active(pgdat->node_id, nr_taken, nr_activate, + trace_mm_vmscan_lru_shrink_active_end(pgdat->node_id, nr_taken, nr_activate, nr_deactivate, nr_rotated, sc->priority, file); }