Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp861881rdb; Tue, 23 Jan 2024 18:42:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IHuTa4cVIVGSWUETJ8zFCzsqB2hsuHFk0wmBJ6pYrNLUQ7Hb8MsYyilPFGz+m8e2FLFYjZu X-Received: by 2002:a05:620a:2f7:b0:783:8d56:72a7 with SMTP id a23-20020a05620a02f700b007838d5672a7mr729845qko.53.1706064157409; Tue, 23 Jan 2024 18:42:37 -0800 (PST) Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id oq34-20020a05620a612200b00783484f3fedsi9199369qkn.348.2024.01.23.18.42.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 18:42:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-36320-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=FtRaZ7e4; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-36320-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-36320-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=vivo.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 1CCE51C20EF2 for ; Wed, 24 Jan 2024 02:42:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CE14F524C; Wed, 24 Jan 2024 02:42:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com header.b="FtRaZ7e4" Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01on2117.outbound.protection.outlook.com [40.107.215.117]) (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 9E788BA24; Wed, 24 Jan 2024 02:42:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.215.117 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706064141; cv=fail; b=DEdfDGhOcP5llXCdmOY5ljtawn00Q4jfwNAtzmhh0J7ZGf1QUL7DiXevMP7jCqFEoQPDhKlryXIHhGLVCOGH6uXZiIrGSvRktAsvYy+arSVh9xOLtXvKP0Oyv+Rl92+vcqVUVUSv2ZwbS+cv4jWl0Ukyi86WeizO7jh0EGmY6Yo= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706064141; c=relaxed/simple; bh=WHdvgHuKUB8kT08Um2BI/jzr8lTrLl8O6NHB9y+QW9E=; h=Message-ID:Date:Subject:To:Cc:References:From:In-Reply-To: Content-Type:MIME-Version; b=aUSkeVTRKHqwP7S2ID6QX9vmd5GBTd+ciTeAvA/lIiB+A33zy2gJjdv9PWch0CAwmBl+dkXo02Zkp11J7T3nN8VxUpfUxsCf7JcqeFwHuNXxNVBdNPSXJMdW4Y4+S0dn4BwQ5MXKKQZBi7o3l0mdbVkIb54xd19s/+O5pKyQWHo= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=vivo.com; spf=pass smtp.mailfrom=vivo.com; dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com header.b=FtRaZ7e4; arc=fail smtp.client-ip=40.107.215.117 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=vivo.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=vivo.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aLOMS7T0MzPLdvaop/g8g3N65UZY7R9lp6nnsytwHcdF3bW/cWpfa6E0bwSYQJMnF6OfACGY778f68emC4poOCkmWXRPhOCjQX7SOt/5bkJGW6D4a+nasQ9ybLOwgiGGb3U3xLfio4enul7YkW5FntdWXgar6Ff68ag5C2MNGgC1aYVjlcpUBrySTm6cgTj3NNargxst9HNfTXm+SqUGC6r/oEzO9xacIUNrNTIRqRNxuZSBoPU2nqMjco0bxttDzf6ABDH/uhABBtmsGAJysayCWi0QFDyJmI2xReQ544bxyiZ32xqtWIddaTeXdx9SA/s096NKskvaOGyZzgYQYg== 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=UUpaom51hJXjSvVhih0g0QjTelFX9vmGOrUDtVibyCc=; b=Zy+tQkSmWcvwcIZPearB7+Jxp9ntaZRFUh9/mycR9jHkfrRDTcbHhECJQmmGiNnmtGugNNuFN9xS7LY2XDO0fTq304fHs/LNZ4KXRt2vUdPJKI8DMfv05BQIqunS9voXE8UqLKi0Lxv+57H9bacmueD7fSxeOMumUJT5BH9uTd21pBcWP6rA+1kXkBpfbEhAQvlH7Tl6CKtdSpbYJy2d1eo4t5osRt0uJK12hTXQon37siG07c4WrPyKk6h/9kamhzpTEA/BiopwdrKAGnw6UntoH+JmWNSuJEDIwnXcotik8z8TQsUxgu/T9xHH4ImOrXFtl4PY2qBp/EuKtAheDw== 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=UUpaom51hJXjSvVhih0g0QjTelFX9vmGOrUDtVibyCc=; b=FtRaZ7e4DjAGu9EMs3f2NBJY9ieKIHeSJ8+jZBJd0xmzFrE7vj0A+nL7S/MxKjS7b2xGhQYOheWD4pLNHtJaDZdzDfeTKV+BhQg23C3F3BofleelO5tW7FOj3bb7x2g1Sy/TORbSWXh9tV3hB0BFBKlR/RVE8XzRoB1tKFNXVEH+AAgNAxsh61Y2ce/UebhYNteGAZQwmWeTd6TGuysZfdrZaJHhuz4WJlT6EdFz4s9HboKFE4CeazxDMtgm09Nv8wEY9DP1pjEB54ecuAEsQgqN8RzcLm8QLrmHcq9/cBfUuwuz5yQAAfFzKXuzduPXe2ywsoGx+265ugrtHTswXw== 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 TY0PR06MB5305.apcprd06.prod.outlook.com (2603:1096:400:210::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.22; Wed, 24 Jan 2024 02:42:15 +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.7228.022; Wed, 24 Jan 2024 02:42:14 +0000 Message-ID: Date: Wed, 24 Jan 2024 10:41:48 +0800 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH -next v6 0/2] Make memory reclamation measurable 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 References: <20240105013607.2868-1-cuibixuan@vivo.com> From: Bixuan Cui In-Reply-To: <20240105013607.2868-1-cuibixuan@vivo.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SG3P274CA0009.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:be::21) To TYZPR06MB4045.apcprd06.prod.outlook.com (2603:1096:400:21::8) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYZPR06MB4045:EE_|TY0PR06MB5305:EE_ X-MS-Office365-Filtering-Correlation-Id: 76d8f252-79b8-43c0-e720-08dc1c8612d9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sI8T/DVYN+EXR8ag9Sr5xZIKOwV6xgrxYXbiDuqf7dyqGE2M5ir1F/U3k+YaTVoE4DerAJMQDiNNC9u5gnlM+TNfRp0U5OvLIFqzi+HEuA8b4oK0NIHG7NOuLSzwamXsl4AkgIVwZdGO/BWF96Oh/rvpVFQT/dfWcPPuWHUdM2wCRmwUcnrMnqtMSveqKFhb1TTH9+FhjilYIMI5TG0yAivNb0CLKpwwcir0yHEuArlJFIMwJYuPyNUlR/rMsUTZqtR/2JnbwZ5gaJ/sQ/fAZWnQl/VAy61s4YDeaEuhYBvxxBKcARjT+J2QvsjoSw65bmcAAwonYTrFhNJuki7O6rtuC8i8BeQJFabBYGRzzvXjm0KLaV0mMcYefFp1DsPfK2BSHt3jgirVs9b5X8URXV50sdoDNZfaGs8JXRhvBjfA19Z3y7oozVo5ri2KwtBY5duhmC+iB56OyHhm7cvX22vryGsUSe9SkFXvxI0I98HELDYh43D2ujTt9RttbrjBnRGatjDe9s8ADgp28i91Uqcg/A4AAJT9NpnIsUiBIGNkftwlx8zA5t3jTBNOHBroGPfRUy97shbEJ5JZagjKy61wOsWNm2DHYkbFfBwmyDzoWX9190U/ScKjjjDUCXoItveRYBek/zSc9Y8IaA1t2szTZ4zWhGS9ix7aRn/En3UlUzOCwqb9NlhjxWPFZB1C 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)(39860400002)(136003)(346002)(396003)(376002)(366004)(230922051799003)(1800799012)(186009)(64100799003)(451199024)(2906002)(8676002)(4326008)(8936002)(66556008)(66946007)(66476007)(5660300002)(83380400001)(107886003)(2616005)(26005)(36756003)(38350700005)(86362001)(31696002)(316002)(31686004)(52116002)(6486002)(478600001)(6506007)(6666004)(6512007)(41300700001)(38100700002)(43740500002)(45980500001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?djdZeTdhelBYN04zMzBqcXdEQytma1RIU3NRZ1FIYVFZUndrU1A0b3c0RXlN?= =?utf-8?B?ejQ5aGZxNFk5UFJnc2lzWWJUcWgxajFiNXRvdkRjRUpwaGphbm5nUWcvVHdy?= =?utf-8?B?S0Z3aG9MdW9WYXYyOWQ1cWREa3ZxZ1JBL0p1TldZbVg0VWIvdDV0ZUltTDRq?= =?utf-8?B?SDJES2dXK0cxY2o4RDRhYlYwTUtneXZKTHVWZ1JERWxiNnViZytkN2hWSmdo?= =?utf-8?B?REkyVDFScjBDd3BIaEFUbnNpWU0va0xnT3NtaWpoMHlGeU9NamR6Z1BrL2w2?= =?utf-8?B?UE1RTS9wS0NEZzN6RGdjSGNsZzVxM2hUUUxJdWZSZW1yVUJrM0J0eUk1dHVX?= =?utf-8?B?alh6NVMwV2IyQlhYNUsrVFk0QnRUdGQyNkJXMlNsODZ4ekFOanZTR2o0aFJW?= =?utf-8?B?YitFbVlzK1h5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Tenant-AuthSource: TYZPR06MB4045.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2024 02:42:14.9193 (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: 0IO7zHQKBAttp4bJhQu66Mm4OIGnw9vhNyO2F7c2rUu6SVTcktZKO1lQD9Gb8orzJCegWFP8rNmKTpebV1XLTw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY0PR06MB5305 ping~ 在 2024/1/5 9:36, Bixuan Cui 写道: > When the system memory is low, kswapd reclaims the memory. The key steps > of memory reclamation include > 1.shrink_lruvec > * shrink_active_list, moves folios from the active LRU to the inactive LRU > * shrink_inactive_list, shrink lru from inactive LRU list > 2.shrink_slab > * shrinker->count_objects(), calculates the freeable memory > * shrinker->scan_objects(), reclaims the slab memory > > The existing tracers in the vmscan are as follows: > > --do_try_to_free_pages > --shrink_zones > --trace_mm_vmscan_node_reclaim_begin (tracer) > --shrink_node > --shrink_node_memcgs > --trace_mm_vmscan_memcg_shrink_begin (tracer) > --shrink_lruvec > --shrink_list > --shrink_active_list > --trace_mm_vmscan_lru_shrink_active (tracer) > --shrink_inactive_list > --trace_mm_vmscan_lru_shrink_inactive (tracer) > --shrink_active_list > --shrink_slab > --do_shrink_slab > --shrinker->count_objects() > --trace_mm_shrink_slab_start (tracer) > --shrinker->scan_objects() > --trace_mm_shrink_slab_end (tracer) > --trace_mm_vmscan_memcg_shrink_end (tracer) > --trace_mm_vmscan_node_reclaim_end (tracer) > > If we get the duration and quantity of shrink lru and slab, > then we can measure the memory recycling, as follows > > Measuring memory reclamation with bpf: > LRU FILE: > CPU COMM ShrinkActive(us) ShrinkInactive(us) Reclaim(page) > 7 kswapd0 26 51 32 > 7 kswapd0 52 47 13 > SLAB: > CPU COMM OBJ_NAME Count_Dur(us) Freeable(page) Scan_Dur(us) Reclaim(page) > 1 kswapd0 super_cache_scan.cfi_jt 2 341 3225 128 > 7 kswapd0 super_cache_scan.cfi_jt 0 2247 8524 1024 > 7 kswapd0 super_cache_scan.cfi_jt 2367 0 0 0 > > For this, add the new tracer to shrink_active_list/shrink_inactive_list > and shrinker->count_objects(). > > 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. > > cuibixuan (2): > mm: shrinker: add new event to trace shrink count > mm: vmscan: add new event to trace shrink lru > > include/trace/events/vmscan.h | 80 ++++++++++++++++++++++++++++++++++- > mm/shrinker.c | 4 ++ > mm/vmscan.c | 11 +++-- > 3 files changed, 90 insertions(+), 5 deletions(-) >