From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=40.93.198.37 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796114155; b=bU8IeEUqj83aDRSHLIXCUa4d8zDw3nmgyImEmmnZgltHAXaGpB1rbnhYyXAFzbxaeYMg T4y+yVRJW0OSuYzetSpl5AlMt4TtYuf04G2Ckrxlg8CZPS+X/rb9lKT0TuwVsTJ3cOx+p VqewLfM3ChXcTMeZi5U8/Guk6EMnSQbygTgQWpp7+yVeSVoSUZbpLtDtaEd+Kw+Q7/oqw jX5BtgbvmdaWb1yNvaHeytSXbgEuAFTU5OuFsdMafk0lr0FUbtMXp1PABZaq6a8hs00Xb f+X5uMhFuDTtoOEeuiqfuA66FwA+LGH4CTWqRxBX02ahACyUhH0RygrVNJQ5dSmKBCg== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796114155; h=DMARC-Filter:DKIM-Signature:Received:Received: X-MS-Exchange-Authentication-Results:Received-SPF:Received:Received: From:To:CC:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding:Content-Type:X-Originating-IP: X-ClientProxiedBy:X-EOPAttributedMessage:X-MS-PublicTrafficType: X-MS-TrafficTypeDiagnostic:X-MS-Office365-Filtering-Correlation-Id: X-MS-Exchange-SenderADCheck:X-MS-Exchange-AntiSpam-Relay: X-Microsoft-Antispam:X-Microsoft-Antispam-Message-Info: X-Forefront-Antispam-Report: X-MS-Exchange-AntiSpam-MessageData-ChunkCount: X-MS-Exchange-AntiSpam-MessageData-0:X-OriginatorOrg: X-MS-Exchange-CrossTenant-OriginalArrivalTime: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-Id: X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-Transport-CrossTenantHeadersStamped; bh=g1LcnPrkrM7x1RvfJX9i+epe7AtvwlpFtovv0aSeGP0=; b=OKHb15FWBYPj3hF0609uZs/Yk5JMt0tEWJ3lMSMjRjqbrHUEoRjgz7L0jE3OBZ4ndUzR pTJwzJWZlJ28gWwhPMAMWjNiz1/h1WfA5Lm/A5YDfAMzmzF67AcZBqnLtIGqOgGFvuuny RJEGs9bq5l+EgksPFYrShn6lsZmBplwUSqFhReK7iVS5dNhJpIKB5YfFpyNRvBD4UFs8F PZQDf7ua8Ei8K3y+4gHkxi0Qhy6f1xxn7G6AYyugJR4SNtE3et5w64f1i/1dF97JiF+H/ iP4mMUFEKDbS/6s+REIOvhRMyzVn+9R0dtT05pfnCPiwefqube7SyOkDhV9z6lyzrlA== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b="WOdr/BNj"; arc=pass header.oldest-pass=0 smtp.remote-ip=40.93.198.37 Received: from CY7PR03CU001.outbound.protection.outlook.com (mail-westcentralusazon11010037.outbound.protection.outlook.com [40.93.198.37]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (secp384r1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3712A606A320; Tue, 1 Dec 2026 08:35:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3712A606A320 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=WOdr/BNj ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=F/YhKUll3OpDaFo56RM/+chuZvnKzgG8SkiwfaIwnA2wVxBmHXmiN69kilkCdB2MBslSTfPoGmGSglxFXZaPCBavderEIjU4Kd87UkQdImXmpRoYYzvUYfcAphiJ4j6bNTMMRTPpDJrTwk7uUG0Elctat4rBKsXQNL2Lzw72rA5+t4e1PFE96+J2iAKwHdZiILrKYOVkvdvVUhO2Vg8Wfhvdm4LwiLnCUu6T0eb+YH4HbqT8SQY+tjvvYlxBsLle/EfAx8mkZC5CKwXU85jSRd4QRUJiPh/jGJuNfTUsqWMTwefqcjgM6oDLbBlkTujleu01A7ZuphvawNeyzksbHA== 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=g1LcnPrkrM7x1RvfJX9i+epe7AtvwlpFtovv0aSeGP0=; b=D4Gd6a0gpyBn1IC86BSV6+J/DkYqFYm+iFHZK/gKEIVk3J95sLeLt8FMdi7GaeRU+abkcjztxtbI8GIx+/UuBCu/UO7oG6mxXkJfqhU8ecW2d/t3TK9cG94UBEaHG6PK2ABcxm1Op6ZAVmlNXxrdxghaikOyOenG7H+ampUoAV/WcLxjkSfFZ33AJDkyx6ZIfuwb1b84q5aDX4Pc6yu+liRWkg/5CDnrhgiScXRtmfWwljg6CziFeSxh9LLP1EjvpU9rFWfGYXtq0m1UJguSldWuZsdRuhS8CDnxyyLdOCyLY9cxtwwFA3wozK//zXRDH9kYLeTulzlB5326wkI2YQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=g1LcnPrkrM7x1RvfJX9i+epe7AtvwlpFtovv0aSeGP0=; b=WOdr/BNj+QPU/XhdxqpVli4L6+67NVysqJpbkfO/EryEahOi4eF9Akla7vWkKFjaf3mmByVAh05kjfGO9WI55X2hwUsMWGqD73ypv8NN8cHbHGcGkOc/f/Qtw/8vyrkcPJHfsV4fG0sMPenWDSWWCKz422UK+OTVb4nl2qyGz1E= Received: from PH7P220CA0008.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:326::7) by PH7PR12MB7939.namprd12.prod.outlook.com (2603:10b6:510:278::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.10; Tue, 1 Dec 2026 08:35:50 +0000 Received: from SJ1PEPF000037A7.namprd04.prod.outlook.com (2603:10b6:510:326:cafe::5f) by PH7P220CA0008.outlook.office365.com (2603:10b6:510:326::7) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.688.10 via Frontend Transport; Tue, 1 Dec 2026 08:35:49 +0000 X-MS-Exchange-Authentication-Results: mx.microsoft.com 1; spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by SJ1PEPF000037A7.mail.protection.outlook.com (10.167.244.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.5 via Frontend Transport; Tue, 1 Dec 2026 08:35:49 +0000 Received: from tapi.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Tue, 1 Dec 2026 02:35:45 -0600 From: Swapnil Sapkal To: , , , , CC: , , , , , , , , Subject: [PATCH v6 2/5] selftests/resctrl: Detect vendor to select memory controller sysfs name Date: Tue, 1 Dec 2026 08:34:23 +0000 Message-ID: <20261201083426.26730-3-swapnil.sapkal@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261201083426.26730-1-swapnil.sapkal@amd.com> References: <20261201083426.26730-1-swapnil.sapkal@amd.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000037A7:EE_|PH7PR12MB7939:EE_ X-MS-Office365-Filtering-Correlation-Id: 5c9cf58c-7743-4e1b-4cb9-08df4f861a7e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700016|1800799024|376014|7416014|23010399003|82310400026|10067099003|56012099006|261022105027099003|261028144727099003|261026121527099003|261026140227099003|261021123027099003|261021121427099003|261102123227099003|261009223027099003|22082099003|18002099003|11063799006|6133799003|3023799007; X-Microsoft-Antispam-Message-Info: 0YNNw1jTFprtwglSEwZBnhJFUV6seSYyb771QiXBXt4CZObCoOfsaH0G8tmS+O65LOEY032kJFH8KKhEJIu4X+imGbRNtkDgOB/lxCZuWPHYqS/Ee6n7ndgeZsZU0iz6AilmQOGi6iG/tRfnD+s3rRcwfcXVFiFpv5pSFCcvWb0fd2TR2ddrIFz738XmlNmzw9VDhmIYc+ApSGKYFLDYDtynC9vuBPR7BwJGFF++KY3cqiVX7kGV+zi0d5+2ZQQrEFlzsy63/lLNz0heQr6eckhljpr4iJ5J2VcwdB6kwehnOJrPxaZADl8IYp5a9kQn/kWjA6o8S0f84K5XMAmW3srYsN0/iei0+Ta7TIuzPTdY9oGVHNy73/ArEXPZh7ojUFxxd8+LkiE3ViLfKFYCUmr5OpFL+H7EOHBZcVypAzd+prYwivliXghZ7r+Qhcwk9d4nf0Opn0sATFz9RiZO4PRLc2pku4pH9pMSis3m5EiHXqtGNXGpWUR97fXW5DGpuPJ54+fbdjH4/+UZBsjyeC4z7hzn3MxuNbie94SKUF0uljef2pB04N5O59aIejA9bcftkVeLaeTdn4IiGTO1MGgWn9WdCgUvNXJ+O6luYeH0L2U8HA5Y7me6ukKNbpbppmv3CXxuYmLK77YvauJe3wW91+kIf4BnTileeQv30V86KtxpDQrwN/kAxT+yWQQlgiM5sTGuxbOgYifhM0iHew== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700016)(1800799024)(376014)(7416014)(23010399003)(82310400026)(10067099003)(56012099006)(261022105027099003)(261028144727099003)(261026121527099003)(261026140227099003)(261021123027099003)(261021121427099003)(261102123227099003)(261009223027099003)(22082099003)(18002099003)(11063799006)(6133799003)(3023799007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vtVmBypbYR8CKjKV6fEBkMq/+2wBPQf9Nych3LRX6HgxoIUR34j5IsCTU+SSoBtwo2wfSI5G0qvqogLPBLNxUOMrziImceZ72m+6KdG8AEIXgbJtIthpR1nZezyljL+Lh8nnsmEOMn8gly5/YbWUnYBfGyAPSeAN33diAnEq8+rINSOfgXAoE+IoiVKrYGx0L1oXGl/IGvI1kUvIVIaZ/L+IIDlonSg9fQyr2Y3vbosbOni2Y082U9eZlcYtthPztWLdRDs/s92C7JFNuiqry6F/Qzo7OTPsSnjeUnZISWicBqIxUS2r1zNjGFCnmuO8piSIrz8+iQRWq7f5HTKWKNJfh4+F6wK27oJBIOxvxgjs6nC49AHY4Aw+O/UzETwK/nxZS33hBkTPKVlmm3nOWyurayjnxO8qhPMn0yaka5dX20k9On98m3f7G3w4gn5p X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2026 08:35:49.7343 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5c9cf58c-7743-4e1b-4cb9-08df4f861a7e X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF000037A7.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7939 From: Babu Moger The test detects the number of memory controllers by scanning the perf sysfs (DYN_PMU_PATH) for the vendor specific memory controller PMU name. On Intel this PMU is named "uncore_imc_". Detect the vendor and select the memory controller PMU name accordingly so that the rest of the code stays generic and can be extended to other vendors. Bail out on vendors that are not yet supported. Rename the UNCORE_IMC macro to INTEL_IMC to make the vendor it belongs to explicit. While at it, match against the full "uncore_imc_" string and use strlen() instead of sizeof() to advance past the prefix. This is clearer than relying on sizeof() counting the terminating NULL to make up for the trailing underscore. Signed-off-by: Babu Moger Co-developed-by: Swapnil Sapkal Signed-off-by: Swapnil Sapkal --- v5->v6: - Renamed the UNCORE_IMC macro to INTEL_IMC so the vendor it belongs to is explicit alongside AMD_UMC. (Reinette) v4->v5: - Rebased onto kselftest/next; the vendor detection now lives in enumerate_mcs(). tools/testing/selftests/resctrl/resctrl_val.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c index ce670db02dbe..a97604e33609 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -10,7 +10,7 @@ */ #include "resctrl.h" -#define UNCORE_IMC "uncore_imc" +#define INTEL_IMC "uncore_imc_" #define READ_FILE_NAME "cas_count_read" #define DYN_PMU_PATH "/sys/bus/event_source/devices" #define SCALE 0.00006103515625 @@ -235,24 +235,29 @@ static int enumerate_mcs(void) { char mc_dir[512], *temp; struct dirent *ep; + char *sysfs_name; int ret; DIR *dp; + if (get_vendor() == ARCH_INTEL) { + sysfs_name = INTEL_IMC; + } else { + ksft_print_msg("Unsupported vendor\n"); + return -1; + } + dp = opendir(DYN_PMU_PATH); if (dp) { while ((ep = readdir(dp))) { - temp = strstr(ep->d_name, UNCORE_IMC); + temp = strstr(ep->d_name, sysfs_name); if (!temp) continue; /* * mc counters are named as "uncore_imc_", hence - * increment the pointer to point to . Note that - * sizeof(UNCORE_IMC) would count for null character as - * well and hence the last underscore character in - * uncore_imc'_' need not be counted. + * increment the pointer to point to . */ - temp = temp + sizeof(UNCORE_IMC); + temp = temp + strlen(sysfs_name); /* * Some directories under "DYN_PMU_PATH" could have -- 2.43.0