From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9F9FFD6AAF6 for ; Thu, 2 Apr 2026 17:42:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version: Content-Transfer-Encoding:Content-Type:In-Reply-To:From:References:CC:To: Subject:Date:Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=9kgioNl5kTwqaaX2RFdJjYYqLGwpEg6QOG0rfWy3MRA=; b=SSkpWcP9OE3qIIqS+1hQD3ap1B sRimlDFEXMGeNxjPnMkK7SnrMmpQyzsD0DVRwEKwzYyBMBDfXAl8gw+rvcln6kibKTCm9iCq2XSu8 hbiWeblVNcDXjqICAbJM5KcX1sdIItW38VCiw/rnioiU3MDD01GrQGj2Uy+8IGexfgVdoYUhwQUwE 0YtnG77h24qiVMTlqX/9s+D9URWgQF/Ftem3TOEBnHNmOV/g3fZRmwxTJwPALu00tKQk4PwzxSCNe FsXCT40DZw/WXV4plLElGGl/KtP12gssERe3q2/kkGdHCQnL6IsSgXnjh2j1Jz2am6qfYxlfU5XVa VqRjP4xQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1w8M3t-00000000bm0-35Vk; Thu, 02 Apr 2026 17:42:33 +0000 Received: from mgamail.intel.com ([192.198.163.12]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1w8M3r-00000000ble-1hGr for linux-arm-kernel@lists.infradead.org; Thu, 02 Apr 2026 17:42:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1775151751; x=1806687751; h=message-id:date:subject:to:cc:references:from: in-reply-to:content-transfer-encoding:mime-version; bh=HikSm6b/EpIJQiTNvC61xScuVUq3o77O6ZBgdHkM8tg=; b=jrfwjbnnHhKI4UedgO0gxnQLT8n+jHLWrrHOaEYyuvtFaEXxRZTACcKi PJriS67ypuI3sjui8uu/tuzf/gnIwOjqo6/BHkCwEGBAQ2KPb3rX87oAy iVw3pygSzeweXIoCwjOeRJFUIOC7TdpsRckK22K9G84EXQOzdEmCcWl33 4cucnIjWhPEO2qMNFhZHp5AYqHdx1bfLiTRRL9C47+jefHgY30ktsyCBU izT0wqDGUcdbBB16pMAccPF9QfAydR9fX7I4rl0t7FftviZPr+fI4HxOA HT1K8RRk3rvrybknculebVUdVu/4EzfBSK39Iz2NkN4GlxQw83vcyuWZE Q==; X-CSE-ConnectionGUID: VscB51VFRySI3vy8Mbj1qw== X-CSE-MsgGUID: pAtIpglLRoyyv7wGVi2Zaw== X-IronPort-AV: E=McAfee;i="6800,10657,11747"; a="80107141" X-IronPort-AV: E=Sophos;i="6.23,156,1770624000"; d="scan'208";a="80107141" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2026 10:42:30 -0700 X-CSE-ConnectionGUID: 0+oEJrKYQw2QCITh2vjbWA== X-CSE-MsgGUID: DlHcGPsZTNKaDrKJQK7pog== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,156,1770624000"; d="scan'208";a="227288503" Received: from fmsmsx901.amr.corp.intel.com ([10.18.126.90]) by orviesa007.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2026 10:42:29 -0700 Received: from FMSMSX901.amr.corp.intel.com (10.18.126.90) by fmsmsx901.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Thu, 2 Apr 2026 10:42:28 -0700 Received: from fmsedg901.ED.cps.intel.com (10.1.192.143) by FMSMSX901.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Thu, 2 Apr 2026 10:42:28 -0700 Received: from CH4PR04CU002.outbound.protection.outlook.com (40.107.201.69) by edgegateway.intel.com (192.55.55.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Thu, 2 Apr 2026 10:42:28 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jShCQdvm/4X+MwHK2LMVXo62RLx8gYcjx4D0yX/Q5ACuJ7d/jwU5o1XfIV8FoJb+BTo04+SNqSqR0scnjHbzrnX4T09gvax2alP8QrrkbySeR2dYaiZWUW22/N2zr3NPMaxJUHGOTT/oBKD2qTa2qGREHdfGQCUOCh2Kq78wv1HjFiD8ZFGVtkBnCsL/gO9WmTS4Mxy52j68H+Srqbs/xHoHT1eD9AA1uiYgZuaHuXPLsmhS45JcvU66vlg6zs5WaZz/+XiRoLfkzLAMwErssqyF7dFwP+UB9xYOpfrSpPs8NBWcT5Lv8CFZ2sm63eGg3ccNwdCRTZHmjQcmrW7OvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=9kgioNl5kTwqaaX2RFdJjYYqLGwpEg6QOG0rfWy3MRA=; b=bKLgDUbNXrfpSPu4AfTXu0BSR92A8xg1Ocl9xwTlrfV6PJfJOGAHrKiomEjmkWjyDSMP9Sjapv5NEKPaDw5QoXA4G23LYrBlUQt2daRwYSHzsOCcqDUyfnHR2pcd5KTTi4p6Cj7jDihbWiAjUABk099JXeDV2E+FltESKQX67sh2DptuY3vPU1eqClCGrsI9dFTnolz2CTIsvG13P5Dnk0dRWsc2R1G/8Y2DyCosOUBz3A8htedOQmC7vUqN0HZAcT1zjH8C8BJH1DTAhZjCCSpsYI7NHHq2WaTOwDawBx3GhSTayC9zamZRETaZiM0VKHjCSl/Ckoy8HjyBsOe/ug== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from SJ2PR11MB7573.namprd11.prod.outlook.com (2603:10b6:a03:4d2::10) by SA1PR11MB6735.namprd11.prod.outlook.com (2603:10b6:806:25e::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9769.17; Thu, 2 Apr 2026 17:42:24 +0000 Received: from SJ2PR11MB7573.namprd11.prod.outlook.com ([fe80::bfe:4ce1:556:4a9d]) by SJ2PR11MB7573.namprd11.prod.outlook.com ([fe80::bfe:4ce1:556:4a9d%5]) with mapi id 15.20.9769.017; Thu, 2 Apr 2026 17:42:24 +0000 Message-ID: Date: Thu, 2 Apr 2026 10:42:21 -0700 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/3] selftests/resctrl: Introduced linked list management for IMC counters To: Yifan Wu , , , , , , , , , , , , , , CC: , , , , , References: <20260324125034.1509177-1-wuyifan50@huawei.com> <20260324125034.1509177-2-wuyifan50@huawei.com> Content-Language: en-US From: Reinette Chatre In-Reply-To: <20260324125034.1509177-2-wuyifan50@huawei.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: MW4P220CA0028.NAMP220.PROD.OUTLOOK.COM (2603:10b6:303:115::33) To SJ2PR11MB7573.namprd11.prod.outlook.com (2603:10b6:a03:4d2::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ2PR11MB7573:EE_|SA1PR11MB6735:EE_ X-MS-Office365-Filtering-Correlation-Id: 3aac7206-f0bb-493b-ca23-08de90df32dd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|366016|1800799024|921020|18002099003|22082099003|56012099003; X-Microsoft-Antispam-Message-Info: y42uG3GnXcOUU1tC1Tj+YCvxsGJRTkQUStDduDVpuUiyqzfWwwJNrJWcJ+3e9xMlTGa+yVcHEebexT5lg7do0zNlB0jWWDJPOLgzdLj2OnDqDCiMG2OnViALfUwH8G/rlF/Eq9cCg3Iyl8LCR7+dYaSKD7gfwOo/1DN57sS6Pvsb0p6VYjuKQyFf/TP8YKo5oQkUSiOooSRyLJ8bAJW91PgPJeJXXpirqU92blzZKssOc8XgCvemH4Oh0BMa/AorwYHxBINNz9O2kov2ucIgivXJWgsmubQuoeAP7lxQXmi+M0jQVG26/TLg+ElOIe13UDSs+O+qrcusIgr30lKfV2VCSpkwROQF/shu5SLB8msCInTwmIP5q+TmkQnZ2aNvCAg7kKS9A1OLgLV61DdbI08C85AA2sAbPJ/xpdzA2rt3+etBITybWqlybwS/H7YSlOGH/+HyJtoOucmanQRt8MJHweL2Xk/73IxON9zpZFc2lLFWr2oHnOMkzTuTSHPcfnv6Zf8qiNbAtt9q8/GVlZ0J3T1VCou38Ro2skiH+uP/3SkxNBa1kdt8uCaDSKG1BNtXH3XnSKDRp+/Nf8i5BvuagXYqE+uaBxY3zFrgyHUZTxEHRj/43TMFiSiOKvQeVrsBLwc+eOFMb8rbZLKu3hbWlKGMHh2z48c3iiDUmDO5DHGJaA5Sl67v2W3agSEuQqLkD5r4boVdRFFuUqJeV00T/531NHJEddeSt/YKpcSiL1Hepkr7u8O46AuWw5NjrXbjga+0pXifrq/bRQCHCg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ2PR11MB7573.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(7416014)(366016)(1800799024)(921020)(18002099003)(22082099003)(56012099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?bnhQYU5vRnNDTnFnNVJHc1pJU1lYZlQ4a2VnMm1HeGVBclNENnpZSE1HUlR2?= =?utf-8?B?VDJLaWdKNFRVdHQ2SEUvMlBNVk03dmhLcUhZZVJOVm5mWHhwRkRSWlo4Wm5J?= =?utf-8?B?Y2RwYnZ0Nk5rdE1RUFEwaWQyWWdVQnkrSzdyYWdRZWJmVEk2ZU4yM3NiNXVv?= =?utf-8?B?RkRhN2ZMc2JrbE0rRFU3amNqVkNaakpwaFU2N2QzQzl6bFhHeU9RSlk5UlF0?= =?utf-8?B?QWZaS0lPck9tT2JHQm0vemJjZy9FWDRPcnU1M2ZaeFVlWHh6WUNKYTlsTmdu?= =?utf-8?B?Qk84UnZPTXZMeDFMUDdoVkdPeS9GUG15emdhQm1raDBQcjJhbDJqYzdjTCs1?= =?utf-8?B?ekNHUi9raW9LZUtLQ0o3UEEvODIxcTQyejdnNU1UVkU1YmxxZVlrSllYMVNr?= =?utf-8?B?d1phbHlmSTlHMys4azNjcEFRclFkcWRtMzF3dVkveGQrZnc1ang2QUhDNE43?= =?utf-8?B?a1UzTGp2VGpPdERxcU9SVUNRZ0VuNk5SaDZ2MTduZGtnUW9zSkd3UjFVWmt6?= =?utf-8?B?NzByQmhWem1aQXRWL0h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mp2QkFiU3ZWTFFB?= =?utf-8?Q?E0ImwlscS8uxax2I=3D?= X-Exchange-RoutingPolicyChecked: pR7K3XEX9pFBlK53pbHtS8SmpqFGKqMsvC/XTfMJQZTQXZV+wrte2moKmc4Lo2F0JoMZiz1F0cMLXKnQF+DohzIdNGNgDYOh6AwTiIXYBqcQ5Ma2gjsk6jGPqzNDha7YLqcPcs4lj6lI656/7JHLkRSiIXgQcQLdzgjkqUQ+VerTQWM9MrZa4HNHemnlUuuDMuPcR/hPnZemQk145yyfpde+UIwqa4p+3l8u032JaVyEMIxqRlx0uGcPGD1ZG5eqR8pqyPItFYwVzAWsqKbSKK/vWqeOfVuIfisMRapCfY9K8GWGNdW0msgubg2/UsG9WKzihsqHgFUFtpjVhytlXQ== X-MS-Exchange-CrossTenant-Network-Message-Id: 3aac7206-f0bb-493b-ca23-08de90df32dd X-MS-Exchange-CrossTenant-AuthSource: SJ2PR11MB7573.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Apr 2026 17:42:24.0038 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: uSWa9B/EEv4uDIYPhJZXujBfkUa9jQKnIspbtryOSRTHdtGbt1pTcSbONlW517kT8BFO5QEGblUhBIYIdvClOtUL/7Y9Qax2qeS4ApXgH9U= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR11MB6735 X-OriginatorOrg: intel.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260402_104231_492677_A47F84AF X-CRM114-Status: GOOD ( 28.02 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Yifan, On 3/24/26 5:50 AM, Yifan Wu wrote: > Added linked list based management for IMC counter configurations, > allowing the system to dynamically allocate and clean up resources based on > actual hardware capabilities. Thank you very much for taking on this change, this is a good addition. One note on the customs, even though this is user space code it is the Linux kernel developers that work with it mostly and to support this the style is expected to (as much as possible) match kernel coding style. Specifically related to this, please follow coding and changelog guidance in Documentation/process/coding-style.rst and Documentation/process/maintainer-tip.rst. > > Signed-off-by: Yifan Wu > --- > tools/testing/selftests/resctrl/resctrl.h | 1 + > tools/testing/selftests/resctrl/resctrl_val.c | 25 +++++++++++++++++++ > 2 files changed, 26 insertions(+) > > diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h > index 175101022bf3..29c9f76132f0 100644 > --- a/tools/testing/selftests/resctrl/resctrl.h > +++ b/tools/testing/selftests/resctrl/resctrl.h > @@ -24,6 +24,7 @@ > #include > #include > #include > +#include (extra space) > #include "kselftest.h" > > #define MB (1024 * 1024) > diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c > index f20d2194c35f..ac58d3862281 100644 > --- a/tools/testing/selftests/resctrl/resctrl_val.c > +++ b/tools/testing/selftests/resctrl/resctrl_val.c > @@ -28,6 +28,7 @@ struct membw_read_format { > }; > > struct imc_counter_config { > + struct list_head imc_list; To make it obvious that this is an entry/node of a list as opposed to a list header, please use a name like "entry" or "node" or similar. > __u32 type; > __u64 event; > __u64 umask; > @@ -38,6 +39,7 @@ struct imc_counter_config { > static char mbm_total_path[1024]; > static int imcs; > static struct imc_counter_config imc_counters_config[MAX_IMCS]; > +LIST_HEAD(imc_counters_configs); > static const struct resctrl_test *current_test; > > static void read_mem_bw_initialize_perf_event_attr(int i) > @@ -235,6 +237,7 @@ static int read_from_imc_dir(char *imc_dir, unsigned int *count) > */ > static int num_of_imcs(void) > { > + struct imc_counter_config *imc_counters_config; Please avoid variable shadowing. > char imc_dir[512], *temp; > unsigned int count = 0; > struct dirent *ep; > @@ -263,14 +266,23 @@ static int num_of_imcs(void) > * first character is a numerical digit or not. > */ > if (temp[0] >= '0' && temp[0] <= '9') { > + imc_counters_config = malloc(sizeof(struct imc_counter_config)); One example of the kernel coding style applied here (see "Allocating memory" in Documentation/process/coding-style.rst) is to use pointer variable and not typing out the struct. Even so, this does not look to be the right place to do this allocation ... (more below) > + if (!imc_counters_config) { > + ksft_print_msg("Unable to allocate memory for iMC counters\n"); > + > + return -1; > + } > + memset(imc_counters_config, 0, sizeof(struct imc_counter_config)); Please use calloc() instead of the malloc() followed by memset(). > sprintf(imc_dir, "%s/%s/", DYN_PMU_PATH, > ep->d_name); > ret = read_from_imc_dir(imc_dir, &count); read_from_imc_dir() obtains "count", which is used as index to imc_counters_config[], as reference because it increments this counter. Doing so enables read_from_imc_dir() to initialize more than one array element. Only allocating one element for the list thus does not look right and I would actually expect this allocation to be closer to the initialization where it is known whether a new element is needed or not. Having new list element allocation within parse_imc_read_bw_events() looks more appropriate? > if (ret) { > + free(imc_counters_config); > closedir(dp); > > return ret; > } > + list_add(&imc_counters_config->imc_list, &imc_counters_configs); > } > } > closedir(dp); > @@ -303,6 +315,19 @@ int initialize_read_mem_bw_imc(void) > return 0; > } > > +void cleanup_read_mem_bw_imc(void) > +{ > + struct imc_counter_config *next_imc_counters_config; This could just be "*tmp" to make its usage clear. > + struct imc_counter_config *imc_counters_config; I find the "imc_counters_configs" and "imc_counters_config" names too similar for comfort and makes the code harder to follow. A short name that is obviously different from the global list name will make the code much easier to read. How about "imc_counter"? > + > + list_for_each_entry_safe(imc_counters_config, next_imc_counters_config, > + &imc_counters_configs, imc_list) { > + list_del(&imc_counters_config->imc_list); > + free(imc_counters_config); > + } > + INIT_LIST_HEAD(&imc_counters_configs); Why is INIT_LIST_HEAD() needed? > +} > + > static void perf_close_imc_read_mem_bw(void) > { > int mc; This patch allocates memory but never frees is. This is done later in patch #3 as a fix but that change would be better as part of this to make it easier to consider the memory management. Reinette