From patchwork Fri Jan 5 01:36:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bixuan Cui X-Patchwork-Id: 13511653 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 350BAC47073 for ; Fri, 5 Jan 2024 01:36:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9A87D6B02F1; Thu, 4 Jan 2024 20:36:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 958E86B02F2; Thu, 4 Jan 2024 20:36:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7D1F16B02F3; Thu, 4 Jan 2024 20:36:55 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 66D8C6B02F1 for ; Thu, 4 Jan 2024 20:36:55 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 46F2AA203A for ; Fri, 5 Jan 2024 01:36:55 +0000 (UTC) X-FDA: 81643543590.11.1999C94 Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01on2118.outbound.protection.outlook.com [40.107.117.118]) by imf19.hostedemail.com (Postfix) with ESMTP id 693EC1A0005 for ; Fri, 5 Jan 2024 01:36:52 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=vivo.com header.s=selector2 header.b=ewSH2B4m; dmarc=pass (policy=quarantine) header.from=vivo.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf19.hostedemail.com: domain of cuibixuan@vivo.com designates 40.107.117.118 as permitted sender) smtp.mailfrom=cuibixuan@vivo.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1704418612; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=/+HFuVXQet26qI0PvwZToEYKyK1hQvB+fF6C3EU4waA=; b=wBPOwP06RWWnW8IIwvbOpkLi2hKR1r/wu2HNwt9SdUxziwPxS5h6lSkC+isG9amRwsJaTR kA5ZeD2U0vCQ1XH7ZGZ7u2Maw1VV1ud8o/5NN3y8zoh5jkogRteg4VxyhArReHezco415C DXfBtoABS7UqSq6dn3A1tISX+30JJTM= ARC-Authentication-Results: i=2; imf19.hostedemail.com; dkim=pass header.d=vivo.com header.s=selector2 header.b=ewSH2B4m; dmarc=pass (policy=quarantine) header.from=vivo.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf19.hostedemail.com: domain of cuibixuan@vivo.com designates 40.107.117.118 as permitted sender) smtp.mailfrom=cuibixuan@vivo.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1704418612; a=rsa-sha256; cv=pass; b=a5/SbyyKcb4IRsFQtI5b0Q5NZwkpobK9H4Fs3mMJensgtIZ0dvlncwzN3F8Keev7bKU6DU cfdpOaM+f+EvDevf8tnIwCahpCISZBqpFDgGScgdoMoD2iOF4tzGGhlbl/cslpN0lq/zAc 8TxoKgo1ElmFHTdWAA6ZBlvI6aAxuqk= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Y08zRpsr+D9yVLbQgyWacusfOpeGjRAOF06dIwvBMmF0RzMWxsYCBrVuaYPuaAVjMsAj8cw+0YBGReu/6TPIe/WtaDsEc0SAr/o1lo2R+YMFSTTzuhx2yWv+SCyvT8grqgVVDr3vUcATVBx3nMy7Uz+MECV6NIFcNbdqpAUHY1c+Aqq7PIalxWCuevQQkINR4emaS6TSbHRYHLXEiXEUfcg2YNXwvYqA+EVQk5ZeFP+O0gjAqcB9YgStP4kpt7SwKTQ1j0pXeiUG4WV5WlS10pysHZGnESvZmCioFXdMHzk8hU/GI/dVl2iOnXYXLIMmkeOEob0XA0P9cf2nzCn1nw== 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=/+HFuVXQet26qI0PvwZToEYKyK1hQvB+fF6C3EU4waA=; b=fnn/+BLo0c5Xs2vGVRCQ1cW6WWGIVYVuM5yrVQbwWFnh6vz9rP4iBgELOgDfc82bz7IweI28rt4tCSHpMC0fcF/vzRH5+sBtvKHcjrU9f3KGxW3p0nrWUqnQ//V5gPzzNRdCZPlyUMZbOUikWy0/amY4kRrUdqNFVT4Apt2pae9ASu/VoHvpmkGZz1EcddLKIHgsV/WdRHjA1dERtBf9bhI+1uPG6Xo1GJMeZpdY+qChlP94ElFm15Af6Surjj14g2fYtuXYFiuSf+Ia1//2eJRttGuUVYeldpGCC2zqqwLdWY9U2vLGVrtcTKGFlCwD1IP056LW/1OpPLelv8Xi2w== 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=/+HFuVXQet26qI0PvwZToEYKyK1hQvB+fF6C3EU4waA=; b=ewSH2B4mjiR/8qBsjVwOxmZfUiYLyok9KqW5wa94fIk/tNCtl10BQQJl9kZWX9thdBcT55NzUz6oyibMiJlLdrwY4qC3Ffv060yJv24s998FNg8EQJ7D8JlGQdQboLNeqJc/kYXcqyYt8N0mg8cfMokwLH1mQ54iVreTt8cUXGGOrhAfBE5JENqL9OhVBB1aZHRHTZW6OxlnyIdqD+GkxiBLib48KrH3jYxt5nKBjPzoM5YO5UoQp40zob6GGOErNnXICgPcKtbaZ6G/6v0U+oDLyDvxPqXi6gh+PP0nXfVj2s1pCU/FFkHabkheqE+CE0G76zZphWH3vT3D4Q0zEQ== Received: from TYZPR06MB4045.apcprd06.prod.outlook.com (2603:1096:400:21::8) by PSAPR06MB4488.apcprd06.prod.outlook.com (2603:1096:301:81::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.16; Fri, 5 Jan 2024 01:36:42 +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.7159.015; Fri, 5 Jan 2024 01:36:42 +0000 From: Bixuan Cui To: akpm@linux-foundation.org, rostedt@goodmis.org, mhiramat@kernel.org, mathieu.desnoyers@efficios.com Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-mm@kvack.org, opensource.kernel@vivo.com, cuibixuan@vivo.com Subject: [PATCH -next v6 1/2] mm: shrinker: add new event to trace shrink count Date: Thu, 4 Jan 2024 17:36:06 -0800 Message-Id: <20240105013607.2868-2-cuibixuan@vivo.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240105013607.2868-1-cuibixuan@vivo.com> References: <20240105013607.2868-1-cuibixuan@vivo.com> X-ClientProxiedBy: SG2PR04CA0169.apcprd04.prod.outlook.com (2603:1096:4::31) To TYZPR06MB4045.apcprd06.prod.outlook.com (2603:1096:400:21::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYZPR06MB4045:EE_|PSAPR06MB4488:EE_ X-MS-Office365-Filtering-Correlation-Id: 93c84b2f-a06c-4b1a-4d20-08dc0d8ec4d2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: W5ib7TSsf151qQdLjOkJH69RCLYWSJKalN8XkBvzYJqabALlDWwPaeWmQyu9suc7bU11RlSlrCYC1k4SKy9zLezW0rYRHYd+FGpnSeaijCSgkggMyLu5TalHjUY1fqZdvdXtBRQxWd2g6U86FrbX1saRAJLA02YJMROZv8mLxB6AztWe+S3lNbaKLhQ1ONi0J999OwqLjQi6segjG2iCc24fsXaWZJGGkCSGhoMzcQy1SEYm6ktVy+M3wUzO+Jx/WHXJaKW78Ny0wrYnVPa1KHqyGZHrA6ojwF++N1ooINRO7Lo/2sTscaN1wyIsyu0dxXbEmpsBGxlgJW4jFyIOCSun1L4iIETCyPVNAi6NE2Ssz5XeflGGbJljoDh4yGDQspAU1bXWMLuygILmegma4LG6STrinMLhlJSpQfV/qXFIRBXVTNk/A2bD0SrSj7wPYhl0h9/b2KwGgn+8G4TlMFEdwCnqzIvBJM4tNidf3XVATC1/6dOatNY9nKx99t47+wuX+Alkku98KPfzrR9/nj51jeeW8pf/D8bY7WFl6DsN08AVNojYBWe2R+WcgHo1ZEhdNypitTgG19igNFszpZkXHoPQKk5RYNCATiL+urt5G1qcbvc2rt+SzTFOKeKk 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)(366004)(136003)(396003)(376002)(39850400004)(346002)(230922051799003)(1800799012)(186009)(64100799003)(451199024)(52116002)(26005)(1076003)(6666004)(6486002)(478600001)(6512007)(6506007)(2616005)(83380400001)(107886003)(5660300002)(2906002)(41300700001)(66556008)(316002)(8676002)(8936002)(66476007)(4326008)(38350700005)(66946007)(38100700002)(40140700001)(36756003)(86362001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9nylH50KXxLXXrOTmteQIVeZhlXKHBJ8VqDr4Nh6wlaMi8Lj0s0Bwo1jAmPmIuBuPvG+xTMk6eZxSYpDXOBRYyrGOTjphVvqwf58rc5nvN0Xh5YzCw+OSD3o+PdTEYzI4CQ8Mvzn7PSDWg9d8Lnm0b0VWbExi9BlBTLXTH9UZ2YBKRpsvA3il6gtcI6aClZOL7wpOkPyAKHKSjjn5br0tWjMrTpoMeV2h2KDN3eEfvGU/4w54mcMaXtkC4bSyqmBmq4AOVL7SAiAf3Ds3AJl/GoCvCkZWa5SU4NEOeQknT+ZUEtO1Wf580rXxqaZpueYfTwL++AEn3VTzTwEkvzA4D0YPdiOWqQiTIQouHVObF2NkZoRq/iBHFQ/l9xmkO6iLg0u8JwkUwPqmvmnHWa/QDpFasih8LYhCIcPCuvwcU9d8Z60thbh4d72s+Kqo7Z0ZSQLAQqvHHbt48QskqdO2rzvrslcYv98IRULEj4LFqiCJedSW4MFYJV43D84VmbRdx3FVhcTzVAKJH5jBgbaWNvp53BLkp8ctvIFbDoNwLD0WnYPWoXzVlugLtZmVkAQvOlLJrPIiw0x1vf7l1AWt0uwCIpP+V2eCazqirfkQ4qccumdkDy3ZfceQklI0vIDOWsL9H3rjDJb7k7O0OFU8ONWb/DGOcu7gfTP7IE/fRWB4zH0pRdoqaCmEBM6nAMHY0+4Ag2f7k/CxrC6Aq0eXvE4QLGSwRhqApRkHAO3mbxj2T6vAX8oaovm96RsYkFlDvbezV6C7gyVwpz7Y9joi9BOCbJdHoxJz/6SkKVaqrsifVDBGTT0tw7Gutl026zISW4f5hZBR5iBiXvWa+MDOsmiH8028oecOK840q8NkUzFdhMEdQ1t13ufSYQZNY+UbYGiwchJGPp3VTzMVo+qoHZj5PbcS5OjWOUDPCaOwyGHAtbiY+X4MYhmXZ7AGiR5y9YNxWdSulNm0AM+PV9HhA5Xk/MaFIrUhyKG/g6WORm2YuGHTeZq71JxpMxpT86PxxXBR85x1ZqdxQMTr6/C1VEsgnolvSWge63JYDwpG6v8hzGqlntjLTTXaI2MjbgUrcTi18OmG5f5dvLQkhCUfEwTqZWb/qrG3pxGsnEAOMG5iXoekW0XAsNmmPLdhVT1hFLf/EShpxiL2ESr5vctcX3V/LIH/gqFJ/S00VCvrZQKOZVodO922srh2PuMmvHdZSiLqmEL1CW5xmUQGOk/8F2osK6iKPO1vNfo+g8jKRuSHOlHRQakg+ANGkr60cUe4iiVRINtFjAng/koOxC/dmqL/C3qky2GljSxd+T7cZ4R+VBU0UvdBBdOmpbHvIdgPDWyoPMCF0vo443FgWT6o5w8aBYVUQBLMxFxcn0Qnhpi3HKoYiv4Yk4dUX03sRzDMEDlmQFoUyRC2rNVAcNg+vKBEXKqh9g/yzwkW7t0YuNZVfg756cXkqDRo9csReQMlBFfV7QpPl2322JR69S0VNC9kM79D4byLZXdx+wNQmlkOBWnuRd9WkIKYqSfmFmkVcpzXsYrd0JnAV2/9/MP7/Y/n5JC/WmW4mvSOK5+zSsB5tAeJ6OpQcNTMmbsT4OK X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 93c84b2f-a06c-4b1a-4d20-08dc0d8ec4d2 X-MS-Exchange-CrossTenant-AuthSource: TYZPR06MB4045.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2024 01:36:41.9742 (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: eQGGnHYvTsxk2ouB6qlH6tOf+tA5pYbqSlBbCrZax6ahRrvJ7fweyl/z+4wHfjCGhpJkFPqAL2KcUSFX2CrxlQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PSAPR06MB4488 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 693EC1A0005 X-Stat-Signature: oaz5gby7iku5yirgm1ru9x7gky98ybyd X-Rspam-User: X-HE-Tag: 1704418612-766816 X-HE-Meta: U2FsdGVkX1+RccFDOlejvmqEggRPV27UnjLa/LD19TcbLa37NjvK/evxY5Oq6p2EQPFQFTAlvjFOW3/qUcQ8G2K0j3z4Nvlimx57P+MZUXJuwLYwReVyziv08MT8C0qVGFWoq5vYGKGpaqvJ5sqxaqzlrRFyVfsTpn+KLsu6FjD2nVbYoAUvSMvK54dSd61e5d+5GT4/EC+pUUXNrXwdzYwQ9a5HnIT2P6JIGTBAKiMq+2L5PXBqXA62t9newPeREfixXDyfzXf6z7799Cgfg8k3cnQi4Y0PoNL3K8EW/K00KxV2rT4aJxz85uihg2lyXB42ieOB9bVrhORRz17Gqc84A4CGEQY6gcx5g8G5Qj2oCTzDwyUYM3onztd+5XCpLFG03iEZrVEhgmNly25i0+q75WQ/79YEkHm1rKzfvI0yMnFBjRdIYUBb9PwIGt4BrLzFXNSoZs63B3IxRT0Wz/n9fc2siUyOxI85Lg9AtJ166MpNaRy2kNERnfp+KblneYvQzu8+k10b0CQaakTTrnFb94DK+sG9u69+FSXbXiX1G4878hLak5yIMsDCTOKtY1O1snVdT+4/4RE/NZRSWO+cjIeZbZjecV7Q2CPi2tCyu3Pdqe/gUWNBHivmXsabi3SH9gEqpMQdfFBo76m45PlqF1hTz9F7Hr24VOvPUA0piOmMkTn27fUduzNtvpU8b9qYNLzxTALted/pTtRs8RTf0gCtT8JuxJj5iGT3IGFCPFgqIDsetkFkGgkPgCG9Awh1B8dPQnXjjcSiDIYLrnhyuI4geFZQCry1BzvwSoS1qN2wF3wqB/Yc1SImmSTVlR2CtqUPxkkilmSeoH2ZMyGM8q3y2grpNc+VWk3eKo+GLt7A50WSpFqaM1JWz6XGTiDBUgEzjTKvF9GKtdlg+c06qOssfV7nE2fq5ga+jvlJoiBtanVZCrDaOOvh97TlEzyjOGROj21F1Sl9dKz 6tcnpDtJ f3qMfzTj5uY2ibSaBz7SCqQfNr7WXXak4xtwUtvCo7Wbr3rdnO2lm4F5s1GU31LEaSMCm06ei1oXrrv+oNoBYaxHJBDGTKYhGb3SUaSllyHBPyVpl0r5bjIEXjgNFoZke2YTR1AVfq25rNqKsUNPn5wpQ18SkVcxi6lahrcXjPtBoYE0oH9Bv1HfDAY3CDjMTkyYTx75qMDlMDV4Sq0T4CwRtEiV68pImnyLugCdjZID//5/oHfmrgl05eGfN8Eh6EvLskOsx7DXipUtbowqlPHvUJQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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 Reviewed-by: Steven Rostedt (Google) --- Changes: v6: * Add Reviewed-by from Steven Rostedt. v5: * Use 'DECLARE_EVENT_CLASS(mm_vmscan_lru_shrink_start_template' to replace 'RACE_EVENT(mm_vmscan_lru_shrink_inactive/active_start' * Add the explanation for adding new shrink lru events into 'mm: vmscan: add new event to trace shrink lru' v4: * Add Reviewed-by and Changlog to every patch. v3: * Swap the positions of 'nid' and 'freeable' to prevent the hole in the trace event. v2: * Modify trace_mm_vmscan_lru_shrink_inactive() in evict_folios() at the same time to fix build error (Andrew pointed out). 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..b99cd28c9815 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(long, freeable) + __field(int, nid) + ), + + TP_fast_assign( + __entry->shr = shr; + __entry->shrink = shr->count_objects; + __entry->freeable = freeable; + __entry->nid = sc->nid; + ), + + 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 Fri Jan 5 01:36:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bixuan Cui X-Patchwork-Id: 13511654 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 6B238C47074 for ; Fri, 5 Jan 2024 01:37:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A92816B02F3; Thu, 4 Jan 2024 20:36:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A43536B02F4; Thu, 4 Jan 2024 20:36:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 852246B02F7; Thu, 4 Jan 2024 20:36:59 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 693206B02F3 for ; Thu, 4 Jan 2024 20:36:59 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 4CBD5A2016 for ; Fri, 5 Jan 2024 01:36:59 +0000 (UTC) X-FDA: 81643543758.18.429756D Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01on2118.outbound.protection.outlook.com [40.107.117.118]) by imf19.hostedemail.com (Postfix) with ESMTP id 8EF051A0005 for ; Fri, 5 Jan 2024 01:36:55 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=vivo.com header.s=selector2 header.b=bvxw5ABN; dmarc=pass (policy=quarantine) header.from=vivo.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf19.hostedemail.com: domain of cuibixuan@vivo.com designates 40.107.117.118 as permitted sender) smtp.mailfrom=cuibixuan@vivo.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1704418615; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=hf2c4QchU4YbB25u2sqDyI9eKLm7nDzoutilL6L5Rhc=; b=zV0Ff/yZFdLZsnzYUTiwrp7Ur9upmGs5ZTckbuCT63MRqajW0BNxXamlBpEujXTkkfu8N7 da+e+x0RH+hzuB804AHBEcCnni9NquMHwz6x3KqLiaL8QHMANzv3riRE9qoxRG1X6DAg6K oU5wE7rdP6tjTNAUe2UZ5FKaOjFaSoM= ARC-Authentication-Results: i=2; imf19.hostedemail.com; dkim=pass header.d=vivo.com header.s=selector2 header.b=bvxw5ABN; dmarc=pass (policy=quarantine) header.from=vivo.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf19.hostedemail.com: domain of cuibixuan@vivo.com designates 40.107.117.118 as permitted sender) smtp.mailfrom=cuibixuan@vivo.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1704418615; a=rsa-sha256; cv=pass; b=BEBSxWWr6vmCXml02PK0o+whJfRc/ytybc9+314f7sgl5OWxIQPJanEpDH4Bd0x++TJ/SZ ABoFm/TLTiJW4UM8HJHY8aK9r6gvP2oO08WpNeit3MbV/tjoqBzdq4GMfGTFswMzmtFALb HmVGD5Nwz8DZ/9VjtOPAgDn8vt5TocI= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ENu5Rj7SbIGDQ4jftH5BGf1apxZOi+jkY6xNXm7QuihIXGqEaOXdsN2x6HUU+rmq4+465yCOrGYqQsBDU5+37mSSEi2eC9xTDaGCbrEg/DghB3R6LTDA66/ZgG4qTkHjYtG59Ul8v4x1BdMPJUlrXZ7mp6qN3qoZkd4DbqrCSZaL4NgFKZOUcloxcoZgl4QnjcxFM/KqRUiS7/JWKM8ImOWwH+n6Yt8BTn727zU5ItGrZKDuo7oPKvzQZ5wIMDqYaEIRWRXNuvIxyOE7dr5ANwP59puHPi7Sszkr0YRce7r8okxqdfiEtkPHR8DgwHW1yDfiVkzSH8voYDdXEKc/pQ== 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=hf2c4QchU4YbB25u2sqDyI9eKLm7nDzoutilL6L5Rhc=; b=YGGKyJsIpjsq1KpdItX7iogMfY7P/KFBU1WbuK0URqOHldnEJIPMuVPGvWH+qB7t8vVJITIttzEgEAYm++uRBMHzvMlcT0tMdIRM/g/1OY8D+22DrqFo02i8mZ5QvKSOH5H4LkZoJ3cMEGa+/wWjZrF7j5coCbfaH8UT6m2kMrJZcwzqA5eWB+g7wwI5NWbW11TVti1Fxc/V2eMz3NdvAGBPEcvtuF+qs/Ee55GDmy41ak0o186mXfM97m1W88aPjQsmVAnzx7p/Ry/mSElUCzhE7wSdpjpm3YQPAF8dOTso9rZicb8LNR2+n4tbeiiFmNpX9QCxjArCLvF/3+Bkrg== 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=hf2c4QchU4YbB25u2sqDyI9eKLm7nDzoutilL6L5Rhc=; b=bvxw5ABN8nOb5hx6KxJ0olyjJhRwUTLpPpD9FkSxKZOCbYO2aL4Y7266nzbrGhaJrsP6mhZn1Fg2HKJyU7fmkJ0A8t0I8XorSqdK9Fk0FzqdlwzGpGUgR3ynlkElIKRUoiqDxrwNqTo72ZkaypOXliGxRhUqcPy3Lgy/4tafDqzq5IzKWhXlS40YSPODFqSnPNpL4X2gmATMZ+N2tNSqMGmzAZOpvzaE+1ehUv8qdryLhLVPuRsTDmAjDWcY8TV/qVQ10Wi3yE09TTBEvRf02rR92tco6+YfZpcVv34bt16x2WAMpfk6wIGdciK7ZelcK7cZBvsQntK1iNfM3xGAtQ== Received: from TYZPR06MB4045.apcprd06.prod.outlook.com (2603:1096:400:21::8) by PSAPR06MB4488.apcprd06.prod.outlook.com (2603:1096:301:81::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.16; Fri, 5 Jan 2024 01:36:46 +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.7159.015; Fri, 5 Jan 2024 01:36:46 +0000 From: Bixuan Cui To: akpm@linux-foundation.org, rostedt@goodmis.org, mhiramat@kernel.org, mathieu.desnoyers@efficios.com Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-mm@kvack.org, opensource.kernel@vivo.com, cuibixuan@vivo.com Subject: [PATCH -next v6 2/2] mm: vmscan: add new event to trace shrink lru Date: Thu, 4 Jan 2024 17:36:07 -0800 Message-Id: <20240105013607.2868-3-cuibixuan@vivo.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240105013607.2868-1-cuibixuan@vivo.com> References: <20240105013607.2868-1-cuibixuan@vivo.com> X-ClientProxiedBy: SG2PR04CA0169.apcprd04.prod.outlook.com (2603:1096:4::31) To TYZPR06MB4045.apcprd06.prod.outlook.com (2603:1096:400:21::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYZPR06MB4045:EE_|PSAPR06MB4488:EE_ X-MS-Office365-Filtering-Correlation-Id: 0b17d349-03dc-44a0-0ffb-08dc0d8ec737 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: s1TieorddW6c14F0tpenRUzRD5ZGDnVlnhvA7S9mVthShH1M4/evgphjMGSsgfk95nqmEG07qml+bRlk9V7I+lbaK9h/EB1vdVs4um8LmLI8GQpfPMRdERHdGRg97Jh9aY5AydG4ZonzMqqAiiK9VpXRT5vsdnH7sFXvhuCihKW8mxSbGQDgzM8pk3nni6HPo+cslf12iWda5F9Ok3IwtHCGtC3KJjLilyLUscUO+30eYsAcHpdgqtUeiGawlSUiVvyDwNHPwo1vFX2ryPLH6RKNEJBQm6oLOBaeL51NkOX4t8rKQy2BhHz7w0uE6bx0AdwD3VXYwzXyJQCsY6FW7EA0c2/nMi/+K5glg6Gbp7jk5GZBmA4VsVeELADbGvEP1oTk34mjnJ0ZVLwc0tGSsXRdiVbYsEyb8DnsaEVxA456Csh8leSDvRorxEpUDmYHoN9oJh/E6DqSSbJZRt9ZKPrb1Z7N5anRUxiA6iShwc8dYRGKzWNbns/YGrV6Vol5w44pFg51cgNIjiGTsBfnKG9CjKoPutWPnxrRmFkCyzXu13Su1MX05Pd/IhidInZgAJ634rnKCjD3KUlJjuJ9Ruu7xbcWshuFauLL7ZzIG6Jav79ZgKYzwXaTLkQIcpSt 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)(366004)(136003)(396003)(376002)(39850400004)(346002)(230922051799003)(1800799012)(186009)(64100799003)(451199024)(52116002)(26005)(1076003)(6666004)(6486002)(478600001)(6512007)(6506007)(2616005)(83380400001)(107886003)(5660300002)(2906002)(41300700001)(66556008)(316002)(8676002)(8936002)(66476007)(4326008)(38350700005)(66946007)(38100700002)(40140700001)(36756003)(86362001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rv8dmPPjuWJ8m1gKvkIMxvbNwqHjw2IzNXEwQ+soK+K0qYo5c+jOE61IDU3ga3BXtQ8PMXRdUp72lmLzl+zBFV7Aw0krZFewCYca8HuN18klEGpTGWWA5OdW2YkAcDSOe4wAqfy5g8qk9y2+ZYou0/yLE7fI7OW/iarWV2LES96i1i80CU56wRHPSDSJS9b9Fhp9iebOds1NL9f9TdYE1QNETfiSSstTyN61RFTDYqdGwYDPCGyMdblMWI4D2lV/kP78c/A83+Wf4YMZ0K0cJXElYEapL4GvtUhId3VIwhCpo0KNFVhEjBOgY63HMq5t528ndfK+iIV/GwOi36AIqXTtE0bsjPNXmTpbcgLojH3swktS9ar5H8juSz0x/7erzfktowV16jkwD61LK5i1DjvG2HCBcn8RRHbpFK+TWnOFcSgxnwM2qq5nIzhmCIBdbuqy4eTsrC5n/L72wX/Fob2Kg1rVuadLxHHD2zTjEr/0d5FDT3OcVO31tqYg7R2RnBJPRyiZAX3yTv250KaqALljMre/N5QjGHUuuGEE2My1xSi+Zccxwvr+73JRtcF9G4U4Jw2NdZW5M58hKamEo5nA+46OjafuiZI6b8kTLEVholMW2weKukE3Q+i0Ufdt5SGXx4IoUaf7GFRzsLfJZl3Dc8PmHQbmd9v60oOol6Umqa06nx6owp9C1nFfIQRKTXbeUunS8ZumVVtlVoHleeMO2hcewgCgzYed4wsE6QBX725nRVLog1obRBDUWCqLvHCkiligc7zC44O9CH9GWM2Rvn6atiXXP/7sgaFFfmcKNLoBzHKbBHiqx/ZnxlT2WSXXfzz8B5toR3WtCkr4tDvomFS0QVxsH4ujz8kS5XVPODLJBsHK07MEgTsaS69v5oATq+ULDC8yGPHRsLQ1dtlRQNhVXvs1oiZWDUPLE0+jIlUwzb3I8VN+jxc++jMBIkMdrEcWwDU9rIRKb0dMsoA6usVq3YAmFK85n4yxEkbauzK0upUWinJ0DeyBm7BoTLoZ3zjohYU5JP2Kv5X4WrBAIJdLM28e6hB+/nIMLVENhKRL1vBQGffSZ1j6SoXEJCsn60rAc5g5HiooZkyX270QFHtXTACyoFuxLrQLkd/+wzeWvUNINHLzeZW/3Q+/qVwb81L+grvLse/1QRBI4AXZjo0gzAVFIdXLmf2ZWBoirHHDwU58U+omQaQ/Iv66evbOc2z2NPCxl9FOYsfvmEBSrMV0640cqZ6XYKSMtghxTWs861OCkbilJGIAiXMtIaqyv2wZty6U8sfQj696ega4nH0GsVHwy4ZlmfQciLpKnBeDD26UfRGOgTyt0zgFqfrVtUK0rHuSf3ldJARopXPJAEcXGCIE9VwexJ+fnQXASTNLUlpJ7wISv6WtrS/tUfOyQYJBw5aZp69S79kuEZweDVNJ11gdvuOsC/Ho2ac+E3OR3G3cXySnSWYlElKWaXNMgqiW0V0WWLziKSabpMwOkKA1FLunEmZ1xfB0NJ0SUNX4hXeWOd8Mfy7v3jzdpYIWdL701b4tH3gpNn0+NbZ8EuZBTd39ItLUE04BBhFgO9b7OrmwlWtv9JpMw6/4 X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0b17d349-03dc-44a0-0ffb-08dc0d8ec737 X-MS-Exchange-CrossTenant-AuthSource: TYZPR06MB4045.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2024 01:36:46.2204 (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: M0IOWpqV3yeNAPdCoeHqb846WnZ/P90Sbu8dWwOYirBoJTsCXQDVqkegbwClsx8c4sasFDnmLuryMhUMKdS5LQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PSAPR06MB4488 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 8EF051A0005 X-Stat-Signature: yaqe9fny97m3yd5magbaxyzwy4j7cgix X-Rspam-User: X-HE-Tag: 1704418615-880111 X-HE-Meta: U2FsdGVkX1/1x4Ui9+YAkGCv2kHriOwRRns/ID5E9q0O7pjMZdKuKdr/MeSvdp5kWdwBYoeuRLCBWyxgdyeo0IxwBRUfjGp3U/jBqsLRn/2mBf9sZXIs5RAA7e3MpFZg3LR09aWXonQ6TLJ0hT/AloaCUiX8+57gF1YpMe8iR9wa/QQfTvmt76/cqsJRbgMcijZA+I5u8bvi/TVKA6qZHbJyG9JbjMmO6BYRBnoRLiNDwlBwfKDrlAmW0VdY3uYogSjWNbgahrjUV7on7xsBebrMH97D5wZA2VQ2NwO/mHIE9lCmNl/Fi8LJpf1UeCHvhNTJtYQGQb3k/zsJMeaZdviEA5k67XjBRBDRabN/+A/utMsfDinD30NRRh8gkkVEvMr+onrRvcpE7Xo6m8V25akcIiZtzSuJIUY30+p0DnEmRJcbxH/OrigeDy0Bv3LarUhqkEFWOjZdL0z7LiiJ4NnC931PfAi8hx/Vw9ln1whB/7pOG+rNt9PuHpZrJhq+8Deggtaz59XfNuQ5El1LRhBYSi1YFHmn0tpIGaOsPD5z8PRa5lV41LHXQWZeSjrfUxOl9rKE54JwZWEeu6SmmfCYSTp1b+5l18p6e3QTXY9v3SajY5PSU0g9Edx6EY/GwjrVrBeGIukip2aCByawPX7ZXKDlMpuInKBKSKvVhNaeut/aghDz7PP9KoJYxHrUGi1f071obRkE8tX3Q/CteriHeyASZMa5Ftrum1byfbSFUArDpDFSPPigqeFgMVIyAtXmsRXZJMekr/PVtwz8IJQeaPeQx39RvFf0TLaxv9ncTpgM8fS76BA/ABnlUgXil2JFFRpxU6GHoRER/XXdp3muqQG341LEgNtXceEMTAoTvhJs+N3vkSSJcHK68fdc0SXFKsFnDbsTIhTFaNJOMWn9dcmxN+Av9vEIW3d7HcQ1XXng2DXhvpGuO3eYbKP5yYXjjvkIGC9UTXfZ05e +bW141C7 jS6m0hyLp9A5k50bgFqWrf3sn6Z4EIxCXB57pvtcCMnFYuc3VFktAbh4oHkZxSNODNR6IQ1sm8Vy7pIQpThvtAGw7b+F7/tO0FERb07SpLOeoM70+6xTXw0evBrPGnxZCOeqpKfoE37zrRW3Oo5+eiWUqSL2zX0brHj0/zIz1rLXZfu6bnAkSDYDGgDHhscI2UGZpSstg3+VKKqbdyKFoyOHgz2mOZSKGGqT2WcUDTSkyGeqiF2Xrig/3ae2UpIhtUsjplDMMUZnwphDebOZ4/XyKRr/Mfql6q+1So3oLA/+8UW90Y2NvIkQ2HIKjxB5QnoPksFF3Zwj9O10= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: cuibixuan Page reclaim is an important part of memory reclaim, including: * shrink_active_list(), moves folios from the active LRU to the inactive LRU * shrink_inactive_list(), shrink lru from inactive LRU list Add the new events to calculate the execution time to better evaluate the entire memory recycling ratio. 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 Reviewed-by: Andrew Morton Reviewed-by: Steven Rostedt (Google) --- Changes: v6: * Add Reviewed-by from Steven Rostedt. v5: * Use 'DECLARE_EVENT_CLASS(mm_vmscan_lru_shrink_start_template' to replace 'RACE_EVENT(mm_vmscan_lru_shrink_inactive/active_start' * Add the explanation for adding new shrink lru events into 'mm: vmscan: add new event to trace shrink lru' v4: * Add Reviewed-by and Changlog to every patch. v3: * Swap the positions of 'nid' and 'freeable' to prevent the hole in the trace event. v2: * Modify trace_mm_vmscan_lru_shrink_inactive() in evict_folios() at the same time to fix build error (Andrew pointed out). include/trace/events/vmscan.h | 31 +++++++++++++++++++++++++++++-- mm/vmscan.c | 11 ++++++++--- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/include/trace/events/vmscan.h b/include/trace/events/vmscan.h index b99cd28c9815..4793d952c248 100644 --- a/include/trace/events/vmscan.h +++ b/include/trace/events/vmscan.h @@ -395,7 +395,34 @@ TRACE_EVENT(mm_vmscan_write_folio, show_reclaim_flags(__entry->reclaim_flags)) ); -TRACE_EVENT(mm_vmscan_lru_shrink_inactive, +DECLARE_EVENT_CLASS(mm_vmscan_lru_shrink_start_template, + + 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) +); + +DEFINE_EVENT(mm_vmscan_lru_shrink_start_template, mm_vmscan_lru_shrink_inactive_start, + TP_PROTO(int nid), + TP_ARGS(nid) +); + +DEFINE_EVENT(mm_vmscan_lru_shrink_start_template, mm_vmscan_lru_shrink_active_start, + TP_PROTO(int nid), + TP_ARGS(nid) +); + +TRACE_EVENT(mm_vmscan_lru_shrink_inactive_end, TP_PROTO(int nid, unsigned long nr_scanned, unsigned long nr_reclaimed, @@ -446,7 +473,7 @@ 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_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..a44d9624d60f 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); } @@ -4524,9 +4528,10 @@ static int evict_folios(struct lruvec *lruvec, struct scan_control *sc, int swap if (list_empty(&list)) return scanned; retry: + trace_mm_vmscan_lru_shrink_inactive_start(pgdat->node_id); reclaimed = shrink_folio_list(&list, pgdat, sc, &stat, false); sc->nr_reclaimed += reclaimed; - trace_mm_vmscan_lru_shrink_inactive(pgdat->node_id, + trace_mm_vmscan_lru_shrink_inactive_end(pgdat->node_id, scanned, reclaimed, &stat, sc->priority, type ? LRU_INACTIVE_FILE : LRU_INACTIVE_ANON);