Received: by 2002:ab2:788f:0:b0:1ee:8f2e:70ae with SMTP id b15csp394774lqi; Wed, 6 Mar 2024 23:41:11 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV0a5nUjowjGEUqSw+Em8jq7ki/tzizy10r+D3ZxnW8iJiUxp+CuaAZntUflrQUlUSXtUUlqO3MEVaSdtxx0siHdeorzSZ6K0BJYhJyoQ== X-Google-Smtp-Source: AGHT+IHwZquooqjFMIf3GfLTSiGoXcHYODTQ9lyXm7++61D4I7yd4S3QX4s2sRs/vttHKqFSOv/A X-Received: by 2002:a17:906:6d14:b0:a45:27bd:e1ff with SMTP id m20-20020a1709066d1400b00a4527bde1ffmr7668989ejr.6.1709797271709; Wed, 06 Mar 2024 23:41:11 -0800 (PST) Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id f21-20020a1709067f9500b00a452d150025si3813354ejr.1015.2024.03.06.23.41.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 23:41:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-95071-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=Ty+OPoJe; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-95071-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-95071-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 3EC241F21CD6 for ; Thu, 7 Mar 2024 07:41:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 96E8D63114; Thu, 7 Mar 2024 07:41:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com header.b="Ty+OPoJe" Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01on2054.outbound.protection.outlook.com [40.107.117.54]) (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 BF110629EE; Thu, 7 Mar 2024 07:41:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.117.54 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709797264; cv=fail; b=Hu5ujmckVn156Eq99peYHMAQ1cqroF4bF6dfLDaZDw82qE/xqR2F9E+s1V9ia4gCZBLQCwoxD5dfPZhdnMc0g5JjG3QRpuN74jWJmtl0aCbMq6PjgBsAxhItoZ1m2YCk3XaTHWW+589wSbudAt7xXWw8CvJwsjDjBchoRpOFBlA= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709797264; c=relaxed/simple; bh=4gKjjFSeaqv7CGLwTErgKgOi6WzyhKLxq0/xePGUgCk=; h=Message-ID:Date:Subject:To:Cc:References:From:In-Reply-To: Content-Type:MIME-Version; b=RtXQgHdXN1NlsNHyHIsUXtwmWlzFm+D963+qxv5KJTTM8AFQy3UFIzaRAOJ3sS78uKPB9TnDTHo2TK3ltcM/gKwZza/3b2kboiWClld4T/fQPkUxlkjbfzxz1gYI6LGs3G/1bAlMNBqMGrtlubNj38aOS40AO8Sqvw2Q+PeFv64= 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=Ty+OPoJe; arc=fail smtp.client-ip=40.107.117.54 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=aDIw5SqX2aMHFRIsknKsAwj3LBaP2ZU8fNWtfMV1zOq5Rvvte1BKlxgasg1MoKx+rJBh52ntIRQg8ty5FrrOhJIwzovNcWRswCFYnOjsLdOD/LfqJNjof217N8tKKUM91/V//OPjSayCDU8kF63zOi8vhv11C/ZGxIXGsQtJWK+Kz2ucmwgQiQzQQ9zmf5Hn7AwIovKGZXynvj+7kesFslVYOv0F656al8qs+MRXbv/kSFoF/HduAwYK8GQQUhY0HBWIbLcDAjPp0ECztOR3zOAApj791YooPUTyxABItUNezGXkRZiN+yXFMKhaXRwG+6IFnRfJrIfoNseGgQeCzg== 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=+33F0XBm3gGmiz5l6LMLlgOL4HM4LAPhvTid4jKMUc8=; b=Y9S5f3xx+SFgoZlO0kfS3OOowpUaCXqtMrCX/DEjqDfnhnJsfvYVK1q15/x3PuHGM8IZ5JdbrdtgZBE6OUfdgrylXfKKsWT9MXdHUrHryAKF5Yw85M8Pl4Z+ujp9YLtIESJN3p9shMVPa7a1STp9g5ucmeHa30KCrUoEVDrvDkx2tAaAxt8Ki9FC/wxmNshZsbFlte/1huKtXPOUDPaAiZN8WjD0BWWWJOVzMtjRJfMWBoA4+JrueudUvq04/orrrlc/7yazfA/XmlUm1D8ua6hDqawMKt1MKkzVPdTmWgB9c3YJEhDBe2a8dI9EA6y9yTxlkOkfQ1HGrtctG/86nA== 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=+33F0XBm3gGmiz5l6LMLlgOL4HM4LAPhvTid4jKMUc8=; b=Ty+OPoJevHkH/v9vaQAEHbsU9NS125PDBfvRVSqluiEXElYoCdyBSbs83fH2MigVHI4TvwGw617g80fJ94UcgrxdGNgHtkqdzCLfP6poyAk7BK1Hsrww6fpPXc2A8HrfU5sKwLElKwGi+GYfUI5bX0g6CidUh7XFdHyUNns3HQWcfELd2QzV8ruLsEdPR+JJbjDWCZOhymCQ/PqHVHyTHA1CjyzTLqMq20MtWbNRi2BNWgLVr+VsUvZx+a+HjmVi/5wgUcq2knCVRODxb8DgbRlB5KhQRfpLB4BP8OfifGiG1QtNsbBD0qpAKISK1KQlp40Dk93wi7vs3mAmCgJL7g== 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 SEYPR06MB5962.apcprd06.prod.outlook.com (2603:1096:101:d7::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.37; Thu, 7 Mar 2024 07:40:58 +0000 Received: from TYZPR06MB4045.apcprd06.prod.outlook.com ([fe80::2c2e:81cd:24b0:bc35]) by TYZPR06MB4045.apcprd06.prod.outlook.com ([fe80::2c2e:81cd:24b0:bc35%7]) with mapi id 15.20.7362.024; Thu, 7 Mar 2024 07:40:57 +0000 Message-ID: Date: Thu, 7 Mar 2024 15:40:29 +0800 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH -next v6 0/2] Make memory reclamation measurable To: Michal Hocko Cc: Steven Rostedt , akpm@linux-foundation.org, mhiramat@kernel.org, mathieu.desnoyers@efficios.com, 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> <20240220212202.59ddc123@gandalf.local.home> <3d4f44ee-f533-446f-a9e6-7f58afc78d65@vivo.com> From: Bixuan Cui In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SI2P153CA0036.APCP153.PROD.OUTLOOK.COM (2603:1096:4:190::11) 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_|SEYPR06MB5962:EE_ X-MS-Office365-Filtering-Correlation-Id: 7d1451c9-5162-4d39-5ae0-08dc3e79ed74 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kuZpcfyNeaM0/kAW8DweV2PnnTAJPaXRn2HTpkscx0fOtWLgREzlUMibGWV3nxSJlwIiqDBsTXS2FkCbtaUsiCCgaDgQ3pBKnxWbQXmhrZFPNKB1XC1ffaAqZjAELM5CSxB2m9DidfhYiErwVFhowPzn019TF+WCL/B7TsiJavdau+pyihLzRaGPV1nV1+iGZZYiO+VdFe69NFGuPYkeEIoaJOAf7CPW7u3aC/J30PwRj2+UQ5jHK4d9bw4rP3EIkfiJqvkOO1kJ4qq45gjopkXcg4zJxeLIhDpQKnkgR50rw936Ubyfz1Nyc9FpU9OYQVDGx94xdSmfHnFuHqv0qzjXfyhvQonN1Ap+rMBHBaMpYumj5odMgo8P7MDOI/eHmkJafdeiqKBanhRFUfXU8eQdZj1uMJ+VGITRxyEhp6f12FklQd2DDLWgcBAzf6rHYVq991htHJRBtLnOawGepH+i08f043zv40L/JsnwIpQuyn4PwgJ+/3S7Py44Fwbyk6VW4vKFnPNxcFUd0/1Fhug7hEZW/ogpj6Uzn79Q7id/jrbZbSFyA+h+Cr2vjPEtLPVpJczdEoA9BzFfLGyiluHukijhFHW9JxmWWbGAetHgiYi0x6lpjgpMwEtpVcfo4/HaFvDLrzCTytA4PoUGpCARSy0wuEm99Hiptx1rue8+s/WUE0XsAhoec3kgCLYbP97yZ96KvHCV9fYDA50tj498kdGukrETLdR3OFm6HqY= 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)(376005)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?dWxYMU1taTc5VGdEOTV5dmRqTGMyMFZ0bUUwM3NIRUF1NjcwOGhRc2I1S2FM?= =?utf-8?B?NldXMXU5dnJHcTQ5ckpZUzhIUWdyeEY3L0VRL1A1Y3VnRlkyaXcvYjVCazVi?= =?utf-8?B?TzN1bzhvSVp0OVc3VnhGdXowNFhKd0xSTFZQU1ZVdUhhZS9lSmh5ZTdIbi94?= =?utf-8?B?cHMyYllZV2U4RkxmeHVOOHNaamFuOXkxclpkVDVDdm1mdVJqVVZJNWZVTWN2?= =?utf-8?B?YjNjOWFrNW9qdjhUa3ZBL0MzQ1FiYXdYMjhGNmZ6WEpSWm8zMWVyQmpKVS9B?= =?utf-8?B?NlpleEsvVVVpc3pJTDUxOVFBb050ZkhoWGdlSElYTnpEdkZlYUxNaCtkMVll?= =?utf-8?B?QVFLSStyampPK2oxNlZPSTBXS1c3eUM2OWpEdXFqZWNTN28vVzZ4QSs0WDNL?= =?utf-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rossTenant-AuthSource: TYZPR06MB4045.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Mar 2024 07:40:57.7240 (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: oYGC6LZ6KH4ZWTYJ3qtKZBC0wI5ex7h3fEUPqexFbGQXXRmZZyBipwunnBXkQjTwFcsTxjNnKT887LUMGmV/VQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEYPR06MB5962 在 2024/2/21 15:44, Michal Hocko 写道: > It would be really helpful to have more details on why we need those > trace points. It is my understanding that you would like to have a more > fine grained numbers for the time duration of different parts of the > reclaim process. I can imagine this could be useful in some cases but is > it useful enough and for a wider variety of workloads? Is that worth a > dedicated static tracepoints? Why an add-hoc dynamic tracepoints or BPF > for a very special situation is not sufficient? In other words, tell us > more about the usecases and why is this generally useful. Thank you for your reply, I'm sorry that I forgot to describe the detailed reason. Memory reclamation usually occurs when there is high memory pressure (or low memory) and is performed by Kswapd. In embedded systems, CPU resources are limited, and it is common for kswapd and critical processes (which typically require a large amount of memory and trigger memory reclamation) to compete for CPU resources. which in turn affects the execution of this key process, causing the execution time to increase and causing lags,such as dropped frames or slower startup times in mobile games. Currently, with the help of kernel trace events or tools like Perfetto, we can only see that kswapd is competing for CPU and the frequency of memory reclamation triggers, but we do not have detailed information or metrics about memory reclamation, such as the duration and amount of each reclamation, or who is releasing memory (super_cache, f2fs, ext4), etc. This makes it impossible to locate the above problems. Currently this patch helps us solve 2 actual performance problems (kswapd preempts the CPU causing game delay) 1. The increased memory allocation in the game (across different versions) has led to the degradation of kswapd. This is found by calculating the total amount of Reclaim(page) during the game startup phase. 2. The adoption of a different file system in the new system version has resulted in a slower reclamation rate. This is discovered through the OBJ_NAME change. For example, OBJ_NAME changes from super_cache_scan to ext4_es_scan. Subsequently, it is also possible to calculate the memory reclamation rate to evaluate the memory performance of different versions. The main reasons for adding static tracepoints are: 1. To subdivide the time spent in the shrinker->count_objects() and shrinker->scan_objects() functions within the do_shrink_slab function. Using BPF kprobe, we can only track the time spent in the do_shrink_slab function. 2. When tracing frequently called functions, static tracepoints (BPF tp/tracepoint) have lower performance impact compared to dynamic tracepoints (BPF kprobe). Thanks Bixuan Cui