From nobody Mon Nov 25 04:41:22 2024 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2052.outbound.protection.outlook.com [40.107.220.52]) (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 689C6205141; Tue, 29 Oct 2024 23:22:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.52 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244146; cv=fail; b=NuSz0m2hJGkLDzFkw9MjDhhrIYGDCQhsk1JkDLNnZHMz6xy1vMoBdPb3Tz9TmpL3O8t24OlHp9tvW30zyeLM0/TXrLpxc3rxYtzbpThM1iMfC1DboLUIC2bmluG/GCzxkMgbgFLmSZbuftWSW3CXjt9n2OJsUHbQJzAfiF2XN98= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244146; c=relaxed/simple; bh=cDIxdaAbvSwVa5sy/9YAsI++wnwTunF7m0sb+kUBK6Q=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SmHnbDBZlW84wnTjZ3H2rkdmCKhTSIMcnoYEbEu2un5SM5v57N1FXYClM+JNQT9B7QBgN0Gd/QSCnnuObCKazG35/9PNPuu4rdIau9OhjBO8Q3oSdsJOM8VTln2EFCTEbrHbDCFZVOmnfMrzncOEYFQ2jz2UqclRsE/Ake72g4A= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=Lkm9DsxM; arc=fail smtp.client-ip=40.107.220.52 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) header.d=amd.com header.i=@amd.com header.b="Lkm9DsxM" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PWF2BFy+BMc+LFE0woZckOkCz3zbS9IZl1RcR2DbWZza3v1Ipp0FCY1nH8v5Q+2ScuX9RCucVas6gclvoameCgjEgOIuel5bwuGkfyIgrmm/MY+ZREe0uSsDGUfMdJuqiTCJcEMPldDg7wKvmRk0UMWANaefsaGMnmkc4jbdNgrq9n7qq7Lb7as5kwC8snN0yM+xuszfACDbgnbNkaDrPTly4/RSWqJVnbARayNBzIaDG4WNTSr0WZOGgUDJgFFLx69pHlWmXeRtXYh2Ww1RVHQBRAVMZvHbUgRBX5RCwG9Yh6nZB+kgJjmN4HwrkGWBdPMKlZNUTeP1UGgMEr5T4A== 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=cHWgWcThSJ6dZO+yDlGgR7f0+LGXTNQAnE7gyUfe0e0=; b=x0Bph2BDf4uHhl05lSj5K9tF1yT2HPebYsDd6vemzv6pMgcEJYyNchF+cPT+ygjYcY1ld4vgYrZiekfbQyQ+w7Y/Rln43HanE4LcAgNiy/FNIpc0yXfyVGh9kXjGAd1TOEI5UEyXw0H2RvhJYaYiHiPpyEuv2XRaj3QEzcFmY+cr9+pyor5dV7uQ9VBtGkPRGlxSTNIIIwxtE+hwAepMxufh86Vrd5BresynmWShEPKlH3TjfdMRCudjZzVGrVkctBCc1OKZhcAjdofX7Ja7qPjO3gMhimHMKkhMk+ixfkLI+4X6HSbWgK2bT4RndPZvL0nI6tFSJ6NVRMRG5KGMzA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net 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=cHWgWcThSJ6dZO+yDlGgR7f0+LGXTNQAnE7gyUfe0e0=; b=Lkm9DsxM00cst4SfuJw0XHMXGSp3hXAuANbZrX10Le32pjnV3BGrP1mFOEvpetTbL/+KhY1PKd8FR/rDU1/mgwPo56+/9JE9ktHNfQS8Bsft0R8m+VEDmlM+KGZ+Q/SldmUrwm/ydUSi3xSpHlPJsdQsmlQQHetTIkdbARucljw= Received: from CY5PR15CA0042.namprd15.prod.outlook.com (2603:10b6:930:1b::26) by CY5PR12MB6252.namprd12.prod.outlook.com (2603:10b6:930:20::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Tue, 29 Oct 2024 23:22:21 +0000 Received: from CY4PEPF0000E9D8.namprd05.prod.outlook.com (2603:10b6:930:1b:cafe::6) by CY5PR15CA0042.outlook.office365.com (2603:10b6:930:1b::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.26 via Frontend Transport; Tue, 29 Oct 2024 23:22:21 +0000 X-MS-Exchange-Authentication-Results: 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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000E9D8.mail.protection.outlook.com (10.167.241.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Tue, 29 Oct 2024 23:22:20 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 29 Oct 2024 18:22:18 -0500 From: Babu Moger To: , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v9 01/26] x86/resctrl: Add __init attribute for the functions called in resctrl_late_init Date: Tue, 29 Oct 2024 18:21:33 -0500 Message-ID: <2372314c135882d233eb8dba69af7c245efdcc8d.1730244116.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9D8:EE_|CY5PR12MB6252:EE_ X-MS-Office365-Filtering-Correlation-Id: 001e9623-8621-4b49-9ef0-08dcf87089ae X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|7416014|376014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?S3vo/+aY0r/KnnGOlnk446GcvfijQ3OFOgzoj6m8GlS/J9sThc7cukeovXIN?= =?us-ascii?Q?lRqiKbNHn7+aUtPL+vGg1asC6xCVR7cmVJ7mmO6mWLY/I4KXeOvf9AI+0bpR?= =?us-ascii?Q?rJ7/jhYaJl6JyYQY7pjsiQ8PyU5DS9Rfrx9uZXiqkQYB6u/+Mpm+WW/xBbm8?= =?us-ascii?Q?3NNLual/1FRZYKIO60HoElCS7MKCjH7gCqj3jC2celgcyMSVoVz/19Z2foRp?= =?us-ascii?Q?0KUIpIClHh15iGdu1jRcMWee+4u9qVlGS1H3LlId98EV4GIvnEwR6RrSjFFb?= =?us-ascii?Q?fu/a1sdtxy+Oaen3cFxORqi+ApZQtUuR99cJVMEqUnEZamAkNlle1TLEkK/7?= =?us-ascii?Q?mgynpjt3APGpr+TVEykoti3gUm8wdjZpWEt+KUdSSMBUTcbn9k14SPksWO9Y?= =?us-ascii?Q?5nSB6/cG29Pczi0iAGEtbjswIkMDnjmyEqFglgQPEm9LcTTrVz1+CWigusmg?= =?us-ascii?Q?OYUnzxQbkhvQr0JSyy8yktmQTdCBUVo0AO6Aimubx0rt+sRKeHKzS3wYrGtV?= =?us-ascii?Q?oXpcNugABE29cqCZMf1j/PcVJcsz4zXe6yGkECZin1fCgjYk3Ep2B8HidSW7?= =?us-ascii?Q?YC7Ad7pMrTyF7GBNvsSNwN++NEXPsTIW9KIHQlolBfB/cvSuVx1rd83mk2p3?= =?us-ascii?Q?xPcmRACV4VaiauEgmedVGlFx2u4EQcIRWOSv828TmNWaaTLdsksOONGd2QEJ?= =?us-ascii?Q?olfvWsZCCmZCOIogYaTP41lNVgrTncmCFPrqhEEF0jGC+bfbcXZekauvZsSL?= =?us-ascii?Q?kvEwvZXzkQoO3f2UKvz9P9EBgTUzJ1ee2LdoTLWGzEPhuC4GVxG5QDQEdKPx?= =?us-ascii?Q?TAqbrY6bRHOYsya8ObHUM5eYTW/QsSQBZIgAknR5UjKr+VlTiR7mu8bCjsI0?= =?us-ascii?Q?wNQEoOilpi480l3AeprJDzPZqtEeXVpS+LnWsNjrsGIhLdnXSFM2zl/WSsd9?= =?us-ascii?Q?JsXapMcbgQ7Ga50zzuHG/9eJtINrnYrQil3mBoqi7/s0UwM7/wfnoydDbzmk?= =?us-ascii?Q?R/4rSL3wTr/TGwpBWmOQzjV1PlmXrQDdPbfAW9Cgv8BJip87xDvoFM+rvn8m?= =?us-ascii?Q?8IFA1u2e8nS2yAcWyktj/4MbFuXX/iNoUc1mHqRmEpSuJw0yHn3qOLw35fAP?= =?us-ascii?Q?C+AnIA20jQiND1zCoaSlAIQhIboMRBeBJku68A+Jwxg3LsZJ04yE4J89otkD?= =?us-ascii?Q?l6sf5JngiLlE3rtCZsbVPP4co3S96GlKKqifL9zaXaP6u0MVbs3zBKBJoVs3?= =?us-ascii?Q?HFR6zSkPkzNHNgpHoZISHnacBPz76aBPPqXGD2VRyHlq1bdRHFyTeY0M+qUs?= =?us-ascii?Q?NdyDYR6y0u/Ybr8H2MNWUwlaqk9izWLsXmLWwtYQ1TvI3baFDgUmnewm6YHM?= =?us-ascii?Q?dX6+EkiIHcyiK5d92Kqhh9RupLK58FAnw8ysjfGIEhRSuKr8aA=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(7416014)(376014)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 23:22:20.8622 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 001e9623-8621-4b49-9ef0-08dcf87089ae 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9D8.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6252 Content-Type: text/plain; charset="utf-8" The function resctrl_late_init() has the __init attribute, but some functions it calls do not. Add the __init attribute to all the functions to maintain consistency throughout the call sequence. Fixes: 6a445edce657 ("x86/intel_rdt/cqm: Add RDT monitoring initialization") Fixes: def10853930a ("x86/intel_rdt: Add two new resources for L2 Code and = Data Prioritization (CDP)") Fixes: bd334c86b5d7 ("x86/resctrl: Add __init attribute to rdt_get_mon_l3_c= onfig()") Suggested-by: Reinette Chatre Signed-off-by: Babu Moger --- v9: Moved the patch to the begining of the series. Fixed all the call sequences. Added additional Fixed tags. v8: New patch. --- arch/x86/kernel/cpu/resctrl/core.c | 8 ++++---- arch/x86/kernel/cpu/resctrl/internal.h | 2 +- arch/x86/kernel/cpu/resctrl/monitor.c | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index b681c2e07dbf..f845d0590429 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -275,7 +275,7 @@ static __init bool __rdt_get_mem_config_amd(struct rdt_= resource *r) return true; } =20 -static void rdt_get_cache_alloc_cfg(int idx, struct rdt_resource *r) +static __init void rdt_get_cache_alloc_cfg(int idx, struct rdt_resource *r) { struct rdt_hw_resource *hw_res =3D resctrl_to_arch_res(r); union cpuid_0x10_1_eax eax; @@ -294,7 +294,7 @@ static void rdt_get_cache_alloc_cfg(int idx, struct rdt= _resource *r) r->alloc_capable =3D true; } =20 -static void rdt_get_cdp_config(int level) +static __init void rdt_get_cdp_config(int level) { /* * By default, CDP is disabled. CDP can be enabled by mount parameter @@ -304,12 +304,12 @@ static void rdt_get_cdp_config(int level) rdt_resources_all[level].r_resctrl.cdp_capable =3D true; } =20 -static void rdt_get_cdp_l3_config(void) +static __init void rdt_get_cdp_l3_config(void) { rdt_get_cdp_config(RDT_RESOURCE_L3); } =20 -static void rdt_get_cdp_l2_config(void) +static __init void rdt_get_cdp_l2_config(void) { rdt_get_cdp_config(RDT_RESOURCE_L2); } diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 955999aecfca..16181b90159a 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -627,7 +627,7 @@ int closids_supported(void); void closid_free(int closid); int alloc_rmid(u32 closid); void free_rmid(u32 closid, u32 rmid); -int rdt_get_mon_l3_config(struct rdt_resource *r); +int __init rdt_get_mon_l3_config(struct rdt_resource *r); void __exit rdt_put_mon_l3_config(void); bool __init rdt_cpu_has(int flag); void mon_event_count(void *info); diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 851b561850e0..17790f92ef51 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -983,7 +983,7 @@ void mbm_setup_overflow_handler(struct rdt_mon_domain *= dom, unsigned long delay_ schedule_delayed_work_on(cpu, &dom->mbm_over, delay); } =20 -static int dom_data_init(struct rdt_resource *r) +static __init int dom_data_init(struct rdt_resource *r) { u32 idx_limit =3D resctrl_arch_system_num_rmid_idx(); u32 num_closid =3D resctrl_arch_get_num_closid(r); @@ -1081,7 +1081,7 @@ static struct mon_evt mbm_local_event =3D { * because as per the SDM the total and local memory bandwidth * are enumerated as part of L3 monitoring. */ -static void l3_mon_evt_init(struct rdt_resource *r) +static void __init l3_mon_evt_init(struct rdt_resource *r) { INIT_LIST_HEAD(&r->evt_list); =20 --=20 2.34.1 From nobody Mon Nov 25 04:41:22 2024 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2060.outbound.protection.outlook.com [40.107.244.60]) (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 4186820ADE4; Tue, 29 Oct 2024 23:22:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.60 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244176; cv=fail; b=mGUde50wDnAIKcfs2iqA2CHxWMePB9nk0jCh9G6sPdK/Eh0Jz+GUE8avqk0ZM5jI3y58T9n0DwqnGi8rwEiynAvMJHSn+SKYtCf98XS4jfElTNORdI1VFzWTzDXL0IVXuNCXPtF5DIHQgNAJPIT6Ua25LXGKypWKqz1nAwFFM14= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244176; c=relaxed/simple; bh=pT5+Br2tUiTm71jfJkWRNOB+j2H3CoSRUTm2fJy679M=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=AW/FN1rVayc9dntTy2KqCnpZotp5PdtWjgIJZMdua0kIHHlMatIXp2x4xjz6Rm6hi8pFkRgYbhN9Sba+dMABfBEvZEUm/ZV1gxDAfETJQgYo1nsc4RZHApoQpf/iPfZPfCrCpyuTpMQgTTnmqR/iL1TXRVxkFr8shpiOtdJWwNU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=OPSIrSA/; arc=fail smtp.client-ip=40.107.244.60 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) header.d=amd.com header.i=@amd.com header.b="OPSIrSA/" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BRBq016LzlmQ6GIRGl7Etz4Bz3oZSFNIp2GRgwWLS72D+pa3DGmM2/ti3wLtbcpOik8eovVC0tGdlDE8S7m8XnX7gd3JL8rSkg3ZOBRAchshzrv2oYbu39nLvhZwvQstAgY0VJtlb1Aj94D5bumM7vJLXKf9cEctBrnaCIVzWgMKtA1UrdV0/lgj/waLr7V0b8PaU4sHsEGQcf2CM4t29IrLGiWjSp9Ph3JS0zgCCDjeZHFoV5oJwpuGoHmpSC2mJ3D9Htlrh3Wx/Wkr++LdUv6Ct0zhSma1L9FyVr5dHZl7vaUlxZLkf21gU7la72ghwc0SoyOz3w5WM/5lJdKTBQ== 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=ov5xJv4hj0/RBb1KGcph702JHb9CzsrWt88ffsFN/rw=; b=b9GMqmpnHbTjy/X5ABvEOecEngD7Oq6wB8jYWHxsuyBFFjSUu+eTM1VloG4BqzSNIX8ZvGOJIeAx3M9VY7zB/MIUaPS6WqAprrjKuziN0ZpgBLgRTqgc9ZZ9oe/WVtsdUO/kAK0KuhL+1nnqX9uXfHRWIjc9oOU8TWzHHWs2mHJTZnSDuQWzgg7R3HFMtKrCr/1ghkaqfStemEiW6wb70jMiWjgF8t14xJZ6UFQaDDN6SIhR07UAaB54C2IT+Gmq6OO0hGCjOBT45t86cM8okMUWJS0atDvTq9tPpKDKhcXlaBEoQxveWki8TacmbNsUtjFe8iTEFSQXX89VqANn5w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net 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=ov5xJv4hj0/RBb1KGcph702JHb9CzsrWt88ffsFN/rw=; b=OPSIrSA/1yO/+qfsYAUZ5LHmwf8FawVmlwHZhpXVKOSWGSCbue/YPuSAW0ATvJrdaXjzgzs4sQJdSJJB6qSvERqiWPu2Z9HJ7CbY2ssE+euqTxIhWdPZ5MVgSppaUYJBbYIPIUs1kjQI8JwRj6t6Nyrzbd2IxQHa6JxsZR+C4sk= Received: from CY5PR17CA0060.namprd17.prod.outlook.com (2603:10b6:930:12::27) by SN7PR12MB8026.namprd12.prod.outlook.com (2603:10b6:806:34b::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Tue, 29 Oct 2024 23:22:51 +0000 Received: from CY4PEPF0000E9DB.namprd05.prod.outlook.com (2603:10b6:930:12:cafe::78) by CY5PR17CA0060.outlook.office365.com (2603:10b6:930:12::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32 via Frontend Transport; Tue, 29 Oct 2024 23:22:51 +0000 X-MS-Exchange-Authentication-Results: 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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000E9DB.mail.protection.outlook.com (10.167.241.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Tue, 29 Oct 2024 23:22:50 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 29 Oct 2024 18:22:26 -0500 From: Babu Moger To: , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v9 02/26] x86/cpufeatures: Add support for Assignable Bandwidth Monitoring Counters (ABMC) Date: Tue, 29 Oct 2024 18:21:34 -0500 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9DB:EE_|SN7PR12MB8026:EE_ X-MS-Office365-Filtering-Correlation-Id: 9456a30e-aff1-450f-a531-08dcf8709b9c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?wycguPE3VgXKzqDTium79kmec+4pOVf80Hm5WK8L2C5ksakA1GdMRlvaxAiN?= =?us-ascii?Q?s3izN8uFqgjBgMT2R7GEWkxNKUHL0FV1LhPmJ25d1IM40bQSIsCasv+sx/Jg?= =?us-ascii?Q?VAx7S99Mn+O8qmGU5PqH8oUSGPqIrSks2IzZPKjARSxNTazPAaCZgmyqK1Nh?= =?us-ascii?Q?O6/DWcXvkw/u0ghTmXPH3mgtvsOJBfy/gDGHmMTasFwLaZUdddBlR84ZDN3f?= =?us-ascii?Q?nTatqnHodUiZl1n4WsK++lt2/sr+ic7oAtMzXcyQDIY9I2vOvdNwB4/i3T79?= =?us-ascii?Q?/LMuuG8nyDzi1oTcMiq4rj9Y8wXSsN9MmSkxZC7lILr9HNYeFa5HyEQ+5Net?= =?us-ascii?Q?Epr5sMYCa9hjrySSSSGtbYmyTfzravf+28HG30sbHxDhA2cxXc5VbnqZYn6H?= =?us-ascii?Q?+6TDecJYEmMCzhXAxrZ9JNHNBYQSCxDRjMjV/bOO9wKRHqbA8Zp6VGVXXyK8?= =?us-ascii?Q?XILwxFBaaBKKOVj/+sDVYFlEO4KsNqRHKffhzrOQFtwLKGNTFmam74XuHiuP?= =?us-ascii?Q?m76QWp78UsiQqi6YV464cw7QxXZMtrqUd+7KLesASsKUnN+0in1j12kvvyqh?= =?us-ascii?Q?qUwsRW5hnjZGVKSGCxLcfirw/aQKo+HtOL5NsmxSmj8obswlNc2gQun1xl5k?= =?us-ascii?Q?5qi54FQdSp3GqY+5nX96JOT8pHCfa2Z/jXBWwIVRdgpHSqsPMUe+GYgmmoak?= =?us-ascii?Q?ozVma9myM2KuV5WXxF/fY+8chzVYfkDcj/bLl9f585WZNvYQnpCAYoKBXkBn?= =?us-ascii?Q?Pqza6ojB13+JYVVOpROP/ksjC3s7/ctcceR8M4KNgEPArztLOd5Qj1T78FaQ?= =?us-ascii?Q?x0vufVWAo6BcBdEtEi1CLHnsPoYIGKerrfGXMc1vm+dd9hExQ8iS9wKHrgCc?= =?us-ascii?Q?2iDhKoiIuDYjeIXGGv4+jKhsaXPXssZRY1Y1zcfAWXfUma4juDkKg/qoXINc?= =?us-ascii?Q?7x4I4dKBpq4/apqy+dOL9mQxyYBYtV1aTyomVP7227RRjVAAXeWHF2f5tsSP?= =?us-ascii?Q?lyRBvimCvFQ1xhnNGnb+nFCgcdi8XY/uQv9ew9ES+k6WiqX0UkhUUcAd508t?= =?us-ascii?Q?dGTccWQRxDTSnKJ4gQuXeUhjmbmbw3VZmO89+r6Ujyoop6HAIq86goKROuLs?= =?us-ascii?Q?Sz3+BpfICUEvcRRj1U79PJ9qJZ3Hm9Se43TqI7HoPgozDxbNMVB8EyzSRXTp?= =?us-ascii?Q?427IJkqz/eY7vPLQ3rAvCBqZ/JFUIjmXVqUGAecNj9ogSQk/C8cbYZeaBydl?= =?us-ascii?Q?+VQLED3fHIR9mdM2tEaMZDPBFtwcKcNsZlVD6MMnFN1GG9sU6uurbafV2+xb?= =?us-ascii?Q?7+bKH773PfiuEniSKSS3JkAPRHBI2c4ilFij4eHCQMJEcZRZ8LPpVqb5zqBJ?= =?us-ascii?Q?DE597wdsqZQ7qX6PbL16raPD5jk19Jwd5PXjkp5rGuTGQSymX1VAJiod0rv/?= =?us-ascii?Q?QOCdPbMROX0=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(1800799024)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 23:22:50.8809 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9456a30e-aff1-450f-a531-08dcf8709b9c 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9DB.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB8026 Content-Type: text/plain; charset="utf-8" Users can create as many monitor groups as RMIDs supported by the hardware. However, bandwidth monitoring feature on AMD system only guarantees that RMIDs currently assigned to a processor will be tracked by hardware. The counters of any other RMIDs which are no longer being tracked will be reset to zero. The MBM event counters return "Unavailable" for the RMIDs that are not tracked by hardware. So, there can be only limited number of groups that can give guaranteed monitoring numbers. With ever changing configurations there is no way to definitely know which of these groups are being tracked for certain point of time. Users do not have the option to monitor a group or set of groups for certain period of time without worrying about RMID being reset in between. The ABMC feature provides an option to the user to assign a hardware counter to an RMID, event pair and monitor the bandwidth as long as it is assigned. The assigned RMID will be tracked by the hardware until the user unassigns it manually. There is no need to worry about counters being reset during this period. Additionally, the user can specify a bitmask identifying the specific bandwidth types from the given source to track with the counter. Without ABMC enabled, monitoring will work in current mode without assignment option. Linux resctrl subsystem provides the interface to count maximum of two memory bandwidth events per group, from a combination of available total and local events. Keeping the current interface, users can enable a maximum of 2 ABMC counters per group. User will also have the option to enable only one counter to the group. If the system runs out of assignable ABMC counters, kernel will display an error. Users need to disable an already enabled counter to make space for new assignments. The feature can be detected via CPUID_Fn80000020_EBX_x00 bit 5. Bits Description 5 ABMC (Assignable Bandwidth Monitoring Counters) The feature details are documented in APM listed below [1]. [1] AMD64 Architecture Programmer's Manual Volume 2: System Programming Publication # 24593 Revision 3.41 section 19.3.3.3 Assignable Bandwidth Monitoring (ABMC). Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D206537 Signed-off-by: Babu Moger Reviewed-by: Reinette Chatre --- Note: Checkpatch checks/warnings are ignored to maintain coding style. v9: Took care of couple of minor merge conflicts. No other changes. v8: No changes. v7: Removed "" from feature flags. Not required anymore. https://lore.kernel.org/lkml/20240817145058.GCZsC40neU4wkPXeVR@fat_crat= e.local/ v6: Added Reinette's Reviewed-by. Moved the Checkpatch note below ---. v5: Minor rebase change and subject line update. v4: Changes because of rebase. Feature word 21 has few more additions now. Changed the text to "tracked by hardware" instead of active. v3: Change because of rebase. Actual patch did not change. v2: Added dependency on X86_FEATURE_BMEC. --- arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/kernel/cpu/cpuid-deps.c | 3 +++ arch/x86/kernel/cpu/scattered.c | 1 + 3 files changed, 5 insertions(+) diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpuf= eatures.h index ea33439a5d00..f52e5f8fe24f 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -476,6 +476,7 @@ #define X86_FEATURE_AMD_FAST_CPPC (21*32 + 5) /* Fast CPPC */ #define X86_FEATURE_AMD_HETEROGENEOUS_CORES (21*32 + 6) /* Heterogeneous C= ore Topology */ #define X86_FEATURE_AMD_WORKLOAD_CLASS (21*32 + 7) /* Workload Classificat= ion */ +#define X86_FEATURE_ABMC (21*32 + 8) /* Assignable Bandwidth Monitoring C= ounters */ =20 /* * BUG word(s) diff --git a/arch/x86/kernel/cpu/cpuid-deps.c b/arch/x86/kernel/cpu/cpuid-d= eps.c index 8bd84114c2d9..7e4d63b381d6 100644 --- a/arch/x86/kernel/cpu/cpuid-deps.c +++ b/arch/x86/kernel/cpu/cpuid-deps.c @@ -70,6 +70,9 @@ static const struct cpuid_dep cpuid_deps[] =3D { { X86_FEATURE_CQM_MBM_LOCAL, X86_FEATURE_CQM_LLC }, { X86_FEATURE_BMEC, X86_FEATURE_CQM_MBM_TOTAL }, { X86_FEATURE_BMEC, X86_FEATURE_CQM_MBM_LOCAL }, + { X86_FEATURE_ABMC, X86_FEATURE_CQM_MBM_TOTAL }, + { X86_FEATURE_ABMC, X86_FEATURE_CQM_MBM_LOCAL }, + { X86_FEATURE_ABMC, X86_FEATURE_BMEC }, { X86_FEATURE_AVX512_BF16, X86_FEATURE_AVX512VL }, { X86_FEATURE_AVX512_FP16, X86_FEATURE_AVX512BW }, { X86_FEATURE_ENQCMD, X86_FEATURE_XSAVES }, diff --git a/arch/x86/kernel/cpu/scattered.c b/arch/x86/kernel/cpu/scattere= d.c index 16f3ca30626a..3b72b72270f1 100644 --- a/arch/x86/kernel/cpu/scattered.c +++ b/arch/x86/kernel/cpu/scattered.c @@ -49,6 +49,7 @@ static const struct cpuid_bit cpuid_bits[] =3D { { X86_FEATURE_MBA, CPUID_EBX, 6, 0x80000008, 0 }, { X86_FEATURE_SMBA, CPUID_EBX, 2, 0x80000020, 0 }, { X86_FEATURE_BMEC, CPUID_EBX, 3, 0x80000020, 0 }, + { X86_FEATURE_ABMC, CPUID_EBX, 5, 0x80000020, 0 }, { X86_FEATURE_AMD_WORKLOAD_CLASS, CPUID_EAX, 22, 0x80000021, 0 }, { X86_FEATURE_PERFMON_V2, CPUID_EAX, 0, 0x80000022, 0 }, { X86_FEATURE_AMD_LBR_V2, CPUID_EAX, 1, 0x80000022, 0 }, --=20 2.34.1 From nobody Mon Nov 25 04:41:22 2024 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2082.outbound.protection.outlook.com [40.107.220.82]) (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 D983E2076DE; Tue, 29 Oct 2024 23:23:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.82 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244196; cv=fail; b=jJc78ubSe8vFLKUSv/SUP0ozmDpQlc8DfeX0/aWod/jVTLJrMWFLKHu5cs4hsQsfr3lgbu6214BxvWoJdXXLTcBa8n7HDWV8k3T7NMWndRLAx+5l23aUbKM0kPTYAR4a+805R92HJ8R49Havr1r8f4gXkpAVeNFpzvwrjxmk+IA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244196; c=relaxed/simple; bh=l56DovnidThDsXMrnVyEro1Hw85z6Rmw/Z11Z3YKvzo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VUlG9sEJF8g5dlBKRAnahfs6IliRpAgQ+ry2if/1miqrNECMiiPp+FP5tNHIZA/8W/ZROX8XAgciORkpvEIW/SfSxcwAupaY9uYzwbg0AlazJ6o54CTpZ0pw6PuXots3ImDyp8aB2zBqUqzteqkHhsHxxSxFvZgtskrGYTFOQFk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=rGoFgvoX; arc=fail smtp.client-ip=40.107.220.82 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) header.d=amd.com header.i=@amd.com header.b="rGoFgvoX" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=HZCLiFXJeS+r9S+q10ZMUmPTs/Omi2Qa0lSXFo8AX4P+tf7eZB7qOBvMIKqfpbd1kPaRCremFU0/KJq341r+ZaeGCLiSKOJYTC98g89GrBv++NUnBqVYDLhZNjOgHyiaR3QwGfnpPY8KQ6+Q8k+nCL0b1e0LGOzGOlDMDhizzSdsTxXE7scm0jM+7ozmU2qkFap19q0Jo00BRkw5u+mbk1bydZEZfl2h3c1OQLNgsfVuNo8xn4/X4ttmiJg/yzZMWaLMPizq9F0AflE1UpQDAAHqesQHN+2nHH5rngt5/XJWIpZhwURZ9IxXdFwefLpUdMD0LqJuLXwfbxYU+wy4ww== 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=u+Md8RrToehNwQXPWr/7lezNM6CNIb2vxqDahjNpXRM=; b=QQv2HbCoDpgTq+E3RBP3WAVWvrxRMzjP5f1HPKLYJSrfcnc9mWedQFiOnkuhGUBCloqRmu1degDhiHnZyaQZ0PRR7mGbVgpVc4NkNFc+CMxY3qosdNMg1Jlcd9/uOkWaddMQA6VEGWEgTSdfTAs9Gz5m5I0hnI5gFSpBOsug350+CKTBjWjjqvkrELxuOzncxm9cZ61hlYefy4nC+nw+TV5fykAav3OJ+31/ZS6IRyQWuN+TLhUoIP/il9GS/uXR2kVB7Ye03Ypp1S6S4t7a0pTA4EusQV5iiGfXOr8uxB5+PJxukhmJYF5Eq/dmTYc2vRGUMDmX4rQdFQgcTl+NYA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net 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=u+Md8RrToehNwQXPWr/7lezNM6CNIb2vxqDahjNpXRM=; b=rGoFgvoX0ju4H0UD6llplU2N2zD/WwH6Jj0AlpR+PCk5JhBstewIl5vbM32Y3+AEZm/P+pF43wg/WXWuSxPQWFqUHe8aklKYcB67oLH6djOD6bTFKeArYP4nf+6rOdnXuRVpQ7X8HUVyes1XDs7sg3zu72WWD5qh7SjHIeauFL8= Received: from CY5PR17CA0049.namprd17.prod.outlook.com (2603:10b6:930:12::33) by SJ2PR12MB8033.namprd12.prod.outlook.com (2603:10b6:a03:4c7::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.23; Tue, 29 Oct 2024 23:22:52 +0000 Received: from CY4PEPF0000E9DB.namprd05.prod.outlook.com (2603:10b6:930:12:cafe::61) by CY5PR17CA0049.outlook.office365.com (2603:10b6:930:12::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.29 via Frontend Transport; Tue, 29 Oct 2024 23:22:52 +0000 X-MS-Exchange-Authentication-Results: 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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000E9DB.mail.protection.outlook.com (10.167.241.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Tue, 29 Oct 2024 23:22:52 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 29 Oct 2024 18:22:34 -0500 From: Babu Moger To: , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v9 03/26] x86/resctrl: Add ABMC feature in the command line options Date: Tue, 29 Oct 2024 18:21:35 -0500 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9DB:EE_|SJ2PR12MB8033:EE_ X-MS-Office365-Filtering-Correlation-Id: e57dcd74-7542-4caf-5e6f-08dcf8709c99 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|376014|36860700013|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?VPOnIKVqRQUO6a91cDk42zJNY0+H4hd6taa3i779r79jBFwF1JYkJsmYet6F?= =?us-ascii?Q?78lOrBaC23oXEeNWBxQU/E6VR4v6Nh/lzocM4lG5KSgbXYcxq3VmFxmaMk3e?= =?us-ascii?Q?YU6vsk1FAXQ6wJs0y5bFQH//0REmVpjGOsqy/8sx/VwYpe2G3JigqxfhLCW4?= =?us-ascii?Q?l4elRACWmVo6MHPGG6fRDdduAw1Y8A52bPsDA+wmrXU98jnrrvNQz28BT/5d?= =?us-ascii?Q?7IxAn1jD4MWcGNSzOMpzJbDLiOcWp5cSwMJpBbyHMzAbHEf/j53w0HYoZ51i?= =?us-ascii?Q?t8PQXwnnFJRUaNu0uBjxMMzgOpKwGJjOkTYPo/B26S1tw60OTC2zP1O2bpP7?= =?us-ascii?Q?FW0VXvndixUpeo0IJ2cSPtVV5er+nX0uVVf0lxCSeUiQyB2H4GY60XiebdBX?= =?us-ascii?Q?d27GTEvo5kJu3sLrtVkK8jv7mgxlIjKZsDjO7iw7X9yreklB65JHfg3e28Lv?= =?us-ascii?Q?hkqye8e9OzExSsm0jWs9a7SdqezIJ2tunuOiBWC6Arufh8svIxjaoLFkNGCS?= =?us-ascii?Q?8aOT3F1G0kxeLQGbosdm2KTQd5+T2LIlvcE3hdPeKqclUn5+pubxZ8mdqadC?= =?us-ascii?Q?5qzqw9LMAXDRrSWG11LHib2t+FjWss9YDBA5C6WTYQ0Jh3EVRB5SinXq8qh5?= =?us-ascii?Q?IiBJO2+FvNJz1WxxoK95SimgjD/sNpCkZe+ovYM+xFVV8Fs08xwTeOEakVCP?= =?us-ascii?Q?2rnPLIiURH9c6rK8+TOE9B/JkYrqj06A2i3QdoIF/wplYXsoh/rTTOzgYI7D?= =?us-ascii?Q?bH5NnbSoip2PUwW+1isi7VRlc8t8XxXFSp0948gTW8G8gd3ZsI3KhHbTxVGK?= =?us-ascii?Q?/PBBb/o84jEofw80Swy16rhl727izPPObh4QMJifoO34Io5enOt2vjLKUkiJ?= =?us-ascii?Q?dSck5iqBIn5fWVeYBBZRJzopjWIHMrs3pr+LTemuvRuxoJo3xL6145e5HS+d?= =?us-ascii?Q?rN7mbSN4f+uZ2v7sQqjRVqqJu7gzxpNuqAm21cvhBt4Hq9mlvq9HPLAE+Eqv?= =?us-ascii?Q?yn8QNlIxJdJ+K4Jk2kOCFcB2BnLt58qV8l6yQjQCQocyns6hDH7UVUkSh07A?= =?us-ascii?Q?SUlciQ4+oLP6XkkATdwJOiWSSol5OiQiXrdNVXzUJRmN8xubj8Ta0qITkYh7?= =?us-ascii?Q?dVr9XMdt6JsrHZS69HSYMix2Nl4Igbco+JySND61jHEZFkBDX1TYZBAOU0W+?= =?us-ascii?Q?yWNUI2HphjXZYV1N/A/PCgtqNaBOs5yoI1V4FUkC2JFg0aXvNp/P3g9sAydV?= =?us-ascii?Q?RUvfPBlvQMNw560V4M2RS3lJgn1jNuHOoTPJ2z+d/Rx/Uy8fD1XHZ4oq5PCK?= =?us-ascii?Q?tk7AyRCB4w1M1LB7Eg5mPPoVl66+BkXaUuie3OsHgVW+IQxeBl6nkmqUGHSH?= =?us-ascii?Q?gUPk+ZfolnlKka5TNZBUFGz7chuPp4QppM0Ri8bQ7a27xEcf7A=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(1800799024)(376014)(36860700013)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 23:22:52.5527 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e57dcd74-7542-4caf-5e6f-08dcf8709c99 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9DB.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8033 Content-Type: text/plain; charset="utf-8" Add the command line option to enable or disable exposing the ABMC (Assignable Bandwidth Monitoring Counters) hardware feature to resctrl. Signed-off-by: Babu Moger Reviewed-by: Reinette Chatre --- v9: No code changes. Added Reviewed-by. v8: Commit message update. v7: No changes v6: No changes v5: No changes v4: No changes v3: No changes v2: No changes --- Documentation/admin-guide/kernel-parameters.txt | 2 +- Documentation/arch/x86/resctrl.rst | 1 + arch/x86/kernel/cpu/resctrl/core.c | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentatio= n/admin-guide/kernel-parameters.txt index 1518343bbe22..b3b3ca564220 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -5677,7 +5677,7 @@ rdt=3D [HW,X86,RDT] Turn on/off individual RDT features. List is: cmt, mbmtotal, mbmlocal, l3cat, l3cdp, l2cat, l2cdp, - mba, smba, bmec. + mba, smba, bmec, abmc. E.g. to turn on cmt and turn off mba use: rdt=3Dcmt,!mba =20 diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/re= sctrl.rst index a824affd741d..30586728a4cd 100644 --- a/Documentation/arch/x86/resctrl.rst +++ b/Documentation/arch/x86/resctrl.rst @@ -26,6 +26,7 @@ MBM (Memory Bandwidth Monitoring) "cqm_mbm_total", "cqm_= mbm_local" MBA (Memory Bandwidth Allocation) "mba" SMBA (Slow Memory Bandwidth Allocation) "" BMEC (Bandwidth Monitoring Event Configuration) "" +ABMC (Assignable Bandwidth Monitoring Counters) "" =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D =20 Historically, new features were made visible by default in /proc/cpuinfo. = This diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index f845d0590429..25616d82c0cc 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -809,6 +809,7 @@ enum { RDT_FLAG_MBA, RDT_FLAG_SMBA, RDT_FLAG_BMEC, + RDT_FLAG_ABMC, }; =20 #define RDT_OPT(idx, n, f) \ @@ -834,6 +835,7 @@ static struct rdt_options rdt_options[] __initdata =3D= { RDT_OPT(RDT_FLAG_MBA, "mba", X86_FEATURE_MBA), RDT_OPT(RDT_FLAG_SMBA, "smba", X86_FEATURE_SMBA), RDT_OPT(RDT_FLAG_BMEC, "bmec", X86_FEATURE_BMEC), + RDT_OPT(RDT_FLAG_ABMC, "abmc", X86_FEATURE_ABMC), }; #define NUM_RDT_OPTIONS ARRAY_SIZE(rdt_options) =20 --=20 2.34.1 From nobody Mon Nov 25 04:41:22 2024 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2059.outbound.protection.outlook.com [40.107.244.59]) (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 929BF20ADE6; Tue, 29 Oct 2024 23:22:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.59 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244179; cv=fail; b=tenE9LVsHhVNAjm5rHxCwNKOfDmRBBl8YES7COvJdLUuxgce4Y+KcnF1bXgixQxU77adh4+gJiUQ7sloJWzt18v/k5fEUehr7Dm8tj9xJ7H8jYRznFQ8teEfyqntY5ktqnW6+uA1tS7LAcd01LtJdqKXMYNwnHlu8kKODzm/0CY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244179; c=relaxed/simple; bh=YnocjKKyo2n/NXGXlsPxMZCb3y1Pvf82EuggF84hcFQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=m9KALjdlZRIbBRFeuPGX998cTaBQAuY8yiLD4R0rEJDxgmU2VpC7qhkoLU3wUjTh5dzGM+BKV+VyLnSEraDkAuGuVX8ntzNCEuqXbvFg8gj8OQBXKOV1vDR01u8B8ry4f7NvOPDpCdaF13fp6lONuEH+KdWPNkmNY3kJIFiwefY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=RhH3ROhH; arc=fail smtp.client-ip=40.107.244.59 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) header.d=amd.com header.i=@amd.com header.b="RhH3ROhH" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=MrsZD9VxyRqUWlkdw6jJsOsPOdFeyKRY2Y9GX3sxMgLsjBbdXeE8wsWjbJMmfoPwhn0KcFR53w2vfXQYov5VBFuUf5SrJeGVzea6SSgGjtpocY69NUTVnDm2X3QLKmz8lj6Ix2vBb0kINvpvUQ9S0B9ooA/evvcD8ZOzWuYlWVbrZF1cMmshVNuqf4HLddCPBlOTsrreNdsKM7oSKK1whVtIGV0dv9R6LhwDYNzUVmBwv6WlHreuLFg/CFKQQkRTPg8f3rulG2uMauMqhqTnbtP8sHoeSoG5bshCaybfcZLP0SHGxQ2G3ppcP9Wu/4Zc9phGPylCkVNZoBAjMDRIpg== 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=v/FpFxUOalctJHHMAU/m0ygyyuRxwf39r2jX4i8bg/g=; b=Kq6o8GRPlJAJRd0HvW0LX5spFqENaqA8JUKY76MkLndhOMDqu+PuYlQzyzFk74RQGZwOAhgLVxQcnP33Aw9cIjFT78DYoY//ldkWOFXtYvIkirJyKayp7PevNH+8WDpAeaN7vVG1jP/NlYEd2lhHWgwNeydMxlXZCLYUgjfCzCsrDqAuM6QxHnN/8jiwSOTK1EhyM8J3I7zeTFnCEfCiOrr3s6qCP6ayohN7uKB015yD2kf3qqVgHT1Y75rIsG9mlY3EN0ybIyj3qizpsoYqN3/5KlmZ8vhjcbhPz3/qgNT42ykXT1kNUVHO/+QW3WaiyLePxOdfD06W2Ljes/BvZQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net 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=v/FpFxUOalctJHHMAU/m0ygyyuRxwf39r2jX4i8bg/g=; b=RhH3ROhHpuhqbaxfG7m9tph0PI6c7mwxkzSyZcdbCSHefDq7ZN6oKZKWJ+s0Uuu+n5xm8D5D0ahSpkxCFbYp2i4iW4o43XjId5Wy+Op+jZu7Fc+e51DqvwRi9h4noO694Nio8/8arivLpzDlfjJXCJ444+nGd9AQ7dQWd1jYnSQ= Received: from CY5PR17CA0048.namprd17.prod.outlook.com (2603:10b6:930:12::9) by SN7PR12MB8003.namprd12.prod.outlook.com (2603:10b6:806:32a::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.27; Tue, 29 Oct 2024 23:22:53 +0000 Received: from CY4PEPF0000E9DB.namprd05.prod.outlook.com (2603:10b6:930:12:cafe::9b) by CY5PR17CA0048.outlook.office365.com (2603:10b6:930:12::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.26 via Frontend Transport; Tue, 29 Oct 2024 23:22:53 +0000 X-MS-Exchange-Authentication-Results: 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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000E9DB.mail.protection.outlook.com (10.167.241.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Tue, 29 Oct 2024 23:22:53 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 29 Oct 2024 18:22:43 -0500 From: Babu Moger To: , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v9 04/26] x86/resctrl: Consolidate monitoring related data from rdt_resource Date: Tue, 29 Oct 2024 18:21:36 -0500 Message-ID: <8e78afcaf6d84ffc6631cfe641eab2ca7b45fe36.1730244116.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9DB:EE_|SN7PR12MB8003:EE_ X-MS-Office365-Filtering-Correlation-Id: 50a277de-b32c-4be3-93d1-08dcf8709d10 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|36860700013|376014|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?XA+KRocVM2tffzyx6//pyJ8eojXmKJiMtSHc5nG9ERLu6zaGg+k/bRUvBzsG?= =?us-ascii?Q?MCz1lUWRZq6MQqvDkKBZ4sjrl3pTgW6wqSVUTHoYgRVsgVVOeT0vN5tKD6Js?= =?us-ascii?Q?cl8QYSs5K87UDymT8kyzG/nEjNOuotTK/ruGygFIRtggLJhpox/3ed0NZcJ4?= =?us-ascii?Q?WGcdpwopHeKrdQwtwKEPpaRZhGulnqeETAsm+SwDWg489TRyesZxyrv+LRA6?= =?us-ascii?Q?mWb7Sd0RodZ6tlpTxpOGPgfNahFoJ7GPd9p3AP8zaW1o3xMVcSx1N5s997KZ?= =?us-ascii?Q?EjHqLUt78wri+H2radfY6dmugYudpAjuv+8clvaOCj5LEA52zEcaiUZk0YJ0?= =?us-ascii?Q?kPmcbN/yyJxJ8iWjTDW5rYGLkm+nbFHDN1U7uJM1eqQ6/KturKPVmJgB0W/f?= =?us-ascii?Q?yzhJr20giDQ0Md1KOaxJMd/0dz739cH17pOM6xg1zp4S3w3ClEMzSLzZQerv?= =?us-ascii?Q?ll0nYSdcBBBZL6nQicf9UT+F45UQZBKyo4m8vs/tABh0E4APEIO+YhJi+2MG?= =?us-ascii?Q?PCK1SRANTK7MQYLhQpniV5hdfgggooyr1BHMCxMJCtma3pA4Gox2fYyPY7CB?= =?us-ascii?Q?vN4zz7J0rBJ82+wB43F+egu0zhVnX0c3PGKC4Gntqljv7CIOL5YF40MYx+jc?= =?us-ascii?Q?C6wUg/+XTX++qJpcA6LscLArzwJVty+YJYn75UAC+y/q3P8So1V1Ha0bfgDE?= =?us-ascii?Q?qhp/1wXMT8xn1PFvYompQH1HKZIOUDynSkQUJbX9OohU7TfJLbdhQL+Qdmgc?= =?us-ascii?Q?rhjmUaiS3awjXpeZ4P3mgoEt7+Fw/rS6QErykYWeIvi1Q4Pgfq6YepHmFKhJ?= =?us-ascii?Q?zJ2TxG41EE+67NGuGdwxLgiOcifXZUs8Rd3YteUrCC3oqOTMpx8mpAZzn8F+?= =?us-ascii?Q?Dpz9zvpihrMIYX6AMIB5QDFZv+X3PeSGwvWifSiQm8cIv18qElfm0mRSb/v7?= =?us-ascii?Q?pgKWrsyzh5hFdznTThteml4BM3BQ32eSp9Na4guo09byAdXwbNbZq0SwSCsy?= =?us-ascii?Q?z6z/0fK2CQLxYqFu1vheEza4qBEuYjqgXu1ZCNqmcsTwarAG4dpjYgIKQbUi?= =?us-ascii?Q?eSn9mndP59tfMdJR+tDIfXvhXL3/o3fOnJ/TF9u4Cg6zqPECPBMyR/c6UZUU?= =?us-ascii?Q?ymNFKRMg44RFraPg/6m3mJae5ebpCN2bxvi5I682kFF3bAMUK0ZYcoUTLRhU?= =?us-ascii?Q?3B2zyzd14cP829bgHff2K96EK217yH3X4z50iubQ+eM0IEpHBhO8cBBAFHWp?= =?us-ascii?Q?lKICt6juIK+QQ8OVfpjlL+A2S1NzCPyNIoFTMN1U0lVfXDTUmpIbxXpjxbjC?= =?us-ascii?Q?wXSyPdY2tLeXxDxIDzUjVNkFFRQ0Whfc7YujmoDmbuC6EOIyZgEq9FyGf0xJ?= =?us-ascii?Q?z9map+Oj+qmIOiXIYObMRpEbysR6BMZjhmDtR2Rzt82pSjhNvA=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(36860700013)(376014)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 23:22:53.3183 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 50a277de-b32c-4be3-93d1-08dcf8709d10 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9DB.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB8003 Content-Type: text/plain; charset="utf-8" The cache allocation and memory bandwidth allocation feature properties are consolidated into struct resctrl_cache and struct resctrl_membw respectively. In preparation for more monitoring properties that will clobber the existing resource struct more, re-organize the monitoring specific properties to also be in a separate structure. Suggested-by: Reinette Chatre Signed-off-by: Babu Moger Reviewed-by: Reinette Chatre --- v9: No changes. v8: Added Reviewed-by from Reinette. No other changes. v7: Added kernel doc for data structure. Minor text update. v6: Update commit message and update kernel doc for rdt_resource. v5: Commit message update. Also changes related to data structure updates does to SNC support. v4: New patch. --- arch/x86/kernel/cpu/resctrl/core.c | 4 ++-- arch/x86/kernel/cpu/resctrl/monitor.c | 18 +++++++++--------- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 8 ++++---- include/linux/resctrl.h | 16 ++++++++++++---- 4 files changed, 27 insertions(+), 19 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 25616d82c0cc..468af203ca69 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -124,7 +124,7 @@ u32 resctrl_arch_system_num_rmid_idx(void) struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; =20 /* RMID are independent numbers for x86. num_rmid_idx =3D=3D num_rmid */ - return r->num_rmid; + return r->mon.num_rmid; } =20 /* @@ -625,7 +625,7 @@ static void domain_add_cpu_mon(int cpu, struct rdt_reso= urce *r) =20 arch_mon_domain_online(r, d); =20 - if (arch_domain_mbm_alloc(r->num_rmid, hw_dom)) { + if (arch_domain_mbm_alloc(r->mon.num_rmid, hw_dom)) { mon_domain_free(hw_dom); return; } diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 17790f92ef51..f7fdf2c767f0 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -222,7 +222,7 @@ static int logical_rmid_to_physical_rmid(int cpu, int l= rmid) if (snc_nodes_per_l3_cache =3D=3D 1) return lrmid; =20 - return lrmid + (cpu_to_node(cpu) % snc_nodes_per_l3_cache) * r->num_rmid; + return lrmid + (cpu_to_node(cpu) % snc_nodes_per_l3_cache) * r->mon.num_r= mid; } =20 static int __rmid_read_phys(u32 prmid, enum resctrl_event_id eventid, u64 = *val) @@ -297,11 +297,11 @@ void resctrl_arch_reset_rmid_all(struct rdt_resource = *r, struct rdt_mon_domain * =20 if (is_mbm_total_enabled()) memset(hw_dom->arch_mbm_total, 0, - sizeof(*hw_dom->arch_mbm_total) * r->num_rmid); + sizeof(*hw_dom->arch_mbm_total) * r->mon.num_rmid); =20 if (is_mbm_local_enabled()) memset(hw_dom->arch_mbm_local, 0, - sizeof(*hw_dom->arch_mbm_local) * r->num_rmid); + sizeof(*hw_dom->arch_mbm_local) * r->mon.num_rmid); } =20 static u64 mbm_overflow_count(u64 prev_msr, u64 cur_msr, unsigned int widt= h) @@ -1083,14 +1083,14 @@ static struct mon_evt mbm_local_event =3D { */ static void __init l3_mon_evt_init(struct rdt_resource *r) { - INIT_LIST_HEAD(&r->evt_list); + INIT_LIST_HEAD(&r->mon.evt_list); =20 if (is_llc_occupancy_enabled()) - list_add_tail(&llc_occupancy_event.list, &r->evt_list); + list_add_tail(&llc_occupancy_event.list, &r->mon.evt_list); if (is_mbm_total_enabled()) - list_add_tail(&mbm_total_event.list, &r->evt_list); + list_add_tail(&mbm_total_event.list, &r->mon.evt_list); if (is_mbm_local_enabled()) - list_add_tail(&mbm_local_event.list, &r->evt_list); + list_add_tail(&mbm_local_event.list, &r->mon.evt_list); } =20 /* @@ -1186,7 +1186,7 @@ int __init rdt_get_mon_l3_config(struct rdt_resource = *r) =20 resctrl_rmid_realloc_limit =3D boot_cpu_data.x86_cache_size * 1024; hw_res->mon_scale =3D boot_cpu_data.x86_cache_occ_scale / snc_nodes_per_l= 3_cache; - r->num_rmid =3D (boot_cpu_data.x86_cache_max_rmid + 1) / snc_nodes_per_l3= _cache; + r->mon.num_rmid =3D (boot_cpu_data.x86_cache_max_rmid + 1) / snc_nodes_pe= r_l3_cache; hw_res->mbm_width =3D MBM_CNTR_WIDTH_BASE; =20 if (mbm_offset > 0 && mbm_offset <=3D MBM_CNTR_WIDTH_OFFSET_MAX) @@ -1201,7 +1201,7 @@ int __init rdt_get_mon_l3_config(struct rdt_resource = *r) * * For a 35MB LLC and 56 RMIDs, this is ~1.8% of the LLC. */ - threshold =3D resctrl_rmid_realloc_limit / r->num_rmid; + threshold =3D resctrl_rmid_realloc_limit / r->mon.num_rmid; =20 /* * Because num_rmid may not be a power of two, round the value diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index d906a1cd8491..1647ad9145ef 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -1097,7 +1097,7 @@ static int rdt_num_rmids_show(struct kernfs_open_file= *of, { struct rdt_resource *r =3D of->kn->parent->priv; =20 - seq_printf(seq, "%d\n", r->num_rmid); + seq_printf(seq, "%d\n", r->mon.num_rmid); =20 return 0; } @@ -1108,7 +1108,7 @@ static int rdt_mon_features_show(struct kernfs_open_f= ile *of, struct rdt_resource *r =3D of->kn->parent->priv; struct mon_evt *mevt; =20 - list_for_each_entry(mevt, &r->evt_list, list) { + list_for_each_entry(mevt, &r->mon.evt_list, list) { seq_printf(seq, "%s\n", mevt->name); if (mevt->configurable) seq_printf(seq, "%s_config\n", mevt->name); @@ -3057,13 +3057,13 @@ static int mon_add_all_files(struct kernfs_node *kn= , struct rdt_mon_domain *d, struct mon_evt *mevt; int ret; =20 - if (WARN_ON(list_empty(&r->evt_list))) + if (WARN_ON(list_empty(&r->mon.evt_list))) return -EPERM; =20 priv.u.rid =3D r->rid; priv.u.domid =3D do_sum ? d->ci->id : d->hdr.id; priv.u.sum =3D do_sum; - list_for_each_entry(mevt, &r->evt_list, list) { + list_for_each_entry(mevt, &r->mon.evt_list, list) { priv.u.evtid =3D mevt->evtid; ret =3D mon_addfile(kn, mevt->name, priv.priv); if (ret) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index d94abba1c716..3c2307c7c106 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -182,16 +182,26 @@ enum resctrl_scope { RESCTRL_L3_NODE, }; =20 +/** + * struct resctrl_mon - Monitoring related data of a resctrl resource + * @num_rmid: Number of RMIDs available + * @evt_list: List of monitoring events + */ +struct resctrl_mon { + int num_rmid; + struct list_head evt_list; +}; + /** * struct rdt_resource - attributes of a resctrl resource * @rid: The index of the resource * @alloc_capable: Is allocation available on this machine * @mon_capable: Is monitor feature available on this machine - * @num_rmid: Number of RMIDs available * @ctrl_scope: Scope of this resource for control functions * @mon_scope: Scope of this resource for monitor functions * @cache: Cache allocation related data * @membw: If the component has bandwidth controls, their properties. + * @mon: Monitoring related data. * @ctrl_domains: RCU list of all control domains for this resource * @mon_domains: RCU list of all monitor domains for this resource * @name: Name to use in "schemata" file. @@ -199,7 +209,6 @@ enum resctrl_scope { * @default_ctrl: Specifies default cache cbm or memory B/W percent. * @format_str: Per resource format string to show domain value * @parse_ctrlval: Per resource function pointer to parse control values - * @evt_list: List of monitoring events * @fflags: flags to choose base and info files * @cdp_capable: Is the CDP feature available on this resource */ @@ -207,11 +216,11 @@ struct rdt_resource { int rid; bool alloc_capable; bool mon_capable; - int num_rmid; enum resctrl_scope ctrl_scope; enum resctrl_scope mon_scope; struct resctrl_cache cache; struct resctrl_membw membw; + struct resctrl_mon mon; struct list_head ctrl_domains; struct list_head mon_domains; char *name; @@ -221,7 +230,6 @@ struct rdt_resource { int (*parse_ctrlval)(struct rdt_parse_data *data, struct resctrl_schema *s, struct rdt_ctrl_domain *d); - struct list_head evt_list; unsigned long fflags; bool cdp_capable; }; --=20 2.34.1 From nobody Mon Nov 25 04:41:22 2024 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2071.outbound.protection.outlook.com [40.107.96.71]) (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 0491620B208; Tue, 29 Oct 2024 23:22:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.96.71 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244180; cv=fail; b=WNgmiMPtFVI5JoXilXevpf/JPEG5L8vkynRiQnB7I0BH3Zw2PVb0NjY3itsCw3U0o8mTx9AHqbRpAI8OuAr/R2gT12ipItnbI4/wvVfTYBWoFHuhCMCAaMWqmvw8UFnTAjUIv9cbWKblcCrpIjTlv5bUweGgdBM4XURHgxfL9vw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244180; c=relaxed/simple; bh=PuD1Sp+iCOPAM0bf8vS7VUiUduMBWImWahmCjyuHR1Y=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=r+ayLZa5XZskE8JEZ2ZcCtjuGMYH7P0YNVhr9JrP1VA+CWWZBDQPgs8tGWBkCK9HcR5cYZxJJiT2l2ZOY9uiHWB0ut3plBuDDx15zppy9sYCfJ4+pllU2MoUTn4uBhoCUuIABLs1eIe4kPi7C8rcavSDRfK2nk9ISW9PL/Cw6iA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=K+VgfMEJ; arc=fail smtp.client-ip=40.107.96.71 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) header.d=amd.com header.i=@amd.com header.b="K+VgfMEJ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Rz3dUjS/dds7aMVdNwpwKQhxgT3ecqc6pKskYpD7wVGht8sQVbjvyoJGeTjPt2HHLYOO5gHBSBIFOEWRTc48ywzlaA5ogp9mMv9GPby+JKeqs1muC1EbPxVO6kio/foPhohl4GAHi5wH5O8QEmkTPhWI029yjDYdkECUFJ2CRPb6+noTnCKO9jOTGJeAZazG75h5H/4h50aHZJd4LJHYQ0QWeBPxMJ4ErqRDD5DO+QWSTneqQ13Z8vEFTLR8gzI+yNMu4EzAqOiJt4p6ON20bqYTIzog50QNfK4xUwT234EYte6M0pdV/3qpl7G/C+fakRQKQ2ZZz7vNepWR5dpJcw== 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=HEEcZaIslTpPMrS+eOeuB3s73jtKGZG2WXB6kSu+bI0=; b=CRZRx84+TpA19YPYjHj/sAmXYkOAO1n3lPEEMYTXj8Z5lVZhKyk3j7pgEYWj8q9rV8HeDxY3Dm3wDSkWbe9PxzjsPlEZW6vuxzJ4PV2eq/igMDe+6ROmdfnnf4AROcYUP1lU4DNfMFiEnTc4lF37v4DFckhg86Dg1XjHvwhcq80y438/G8Stt00wzl2oSHn/326m2mbtFWaxXboR2lDsyLGZJchlGkUdNyNBZ+HBeBlyBGF+Ksc+Bm98jAsN1FxPUIgsPkgK7QNJysRFyM6wIFwI9PIPnc8ZM67h3rCPPICKZeWltBIFvsiHWOb+xFUfcjHPXG8A6jxxd21117Rcag== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net 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=HEEcZaIslTpPMrS+eOeuB3s73jtKGZG2WXB6kSu+bI0=; b=K+VgfMEJK6/GfcjXqp1tbNsVToA3E+ZooK484rHtdBQTrdqZ2i8qM+q+wqHZBJHkSi6BsJygq0C26DYuvspwaX2XFVDbcSex0ErhqXPKhlA/tSv06Z1xIRfTuVQHA0SP0ouZowFjYrE5MNugjFYeeBYya6dTIAm+C1PL4wpba9k= Received: from CY5PR17CA0058.namprd17.prod.outlook.com (2603:10b6:930:12::20) by IA1PR12MB6090.namprd12.prod.outlook.com (2603:10b6:208:3ee::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20; Tue, 29 Oct 2024 23:22:54 +0000 Received: from CY4PEPF0000E9DB.namprd05.prod.outlook.com (2603:10b6:930:12:cafe::12) by CY5PR17CA0058.outlook.office365.com (2603:10b6:930:12::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.17 via Frontend Transport; Tue, 29 Oct 2024 23:22:54 +0000 X-MS-Exchange-Authentication-Results: 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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000E9DB.mail.protection.outlook.com (10.167.241.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Tue, 29 Oct 2024 23:22:54 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 29 Oct 2024 18:22:51 -0500 From: Babu Moger To: , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v9 05/26] x86/resctrl: Detect Assignable Bandwidth Monitoring feature details Date: Tue, 29 Oct 2024 18:21:37 -0500 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9DB:EE_|IA1PR12MB6090:EE_ X-MS-Office365-Filtering-Correlation-Id: 267c545c-eb0f-47f0-6730-08dcf8709d85 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|36860700013|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?Fmw4vlkn7LZo+DbmFCm7yXkykUDqPSzy5LKIwLa/+Ia4kdAa+mJ1XWoSP851?= =?us-ascii?Q?nGF2yuZ4Pn9VVPpXoxEtoXZBn2zMywaU0Ow2gAcb7DMyIFoIgd1umAcqqTRs?= =?us-ascii?Q?Rv2AcgVMPDdzcYVc6ULbzZisL4LS143O4rJNPi40ar5wGQJniY6+YbrvQT5i?= =?us-ascii?Q?mMmpPU6INSNNVC3rfqXOeqEdiW+VTpAHJGY6yaZcd6T2wWaA/Fcrf1IHlP6L?= =?us-ascii?Q?0SS35kDD29m2eQe30EF1U/eupOtesePFz37h9U1qx5OnOQa1YRbRVPgi/eWx?= =?us-ascii?Q?5TFuQ6MeKqJjghYhhvNcW9RIoTYSb/+SZV/rEEq8glfwDiPHSd8YkzNl0vRq?= =?us-ascii?Q?60CXntLeh/uysGgXjUJlNMe6Fu8LMV2++6kkAah8BsZPMDS4aUCylMtJjiAf?= =?us-ascii?Q?kKzAmM1e9HqcnznR3HX5jyZGqygb0R/nxBIInwuKQRL6cKx8MpOq5zZYdtDq?= =?us-ascii?Q?cJyO48fG7GFSq88lhby75KR6w22bWTaWQYFXSuQZ8niZefWASLZH4U6oZ6Pi?= =?us-ascii?Q?KXsK/mw9xlr9J6PRSEc538hp9jgOKoUKntKSicG0JucqiVIhLTo+QCiKnKwn?= =?us-ascii?Q?YAlWrd/160fVDOOYdmyomjWmIfx1PEusy4bg4D7Qn+IWAtMzU6Oj2nxiTYqd?= =?us-ascii?Q?UhpfkE1GNb6kvQxFW8HGdN0NdGn5n/CmMJtLesYzTrzR6xhONgL27cgD/nQ+?= =?us-ascii?Q?5xRxFlIjtjqNgvEC/BlqAWiDgzaMu1mXVX1BbMiOSgcQNvRHbaaZHncg/rOJ?= =?us-ascii?Q?/vLz0sZKxWA367JAKqLUlrVrunmZVOe2bNs2pwHX6HKGAmY2XiU4Qxtd3F5Y?= =?us-ascii?Q?Ux7ICg8rW4x2XkBxIUjbeJjE6QDHYlO9vXE75pQzHvOhctT+E9U65OC+XD9d?= =?us-ascii?Q?rnIAeqaX9/LloRmB6hoRqiGFYtFw+Rf1hHThh7DoJ5MnI0EDzO/08Qp0p38o?= =?us-ascii?Q?veIper/hc5kJ5I8X80LdPbW/lYrSy7dKpWslDWxkevvZ6CM9l8n3ysyXQC0o?= =?us-ascii?Q?BKEt/Qon/Mpn7DJdmxGU+kYX0Mt1f5pKalkA2bR6GOvZksyXHp+TgExjR4XL?= =?us-ascii?Q?1Mg+WRJMsqL1HQ/n28+tDaMB2UBFaacCM+5IxTSE5tonxz1dApJpfRjSMDGE?= =?us-ascii?Q?/a2IzLQCh2U6BkOaI0tx1BYLroYNCOffbYtzl9RUajdOaW+WCA9U3Nrerab5?= =?us-ascii?Q?7/ynvvEZJn3I2OQvs0EyJUjszuiTedeVMbC2CKU97CCIL8f42mcPlTv/no+C?= =?us-ascii?Q?Y/DHXKUxgL+wqXvK7+8hN/2eCrdIxbc0ixFnbzOzhGXPkLQuQfmU25ynrvdh?= =?us-ascii?Q?3cmVmYCHZrM5lNZDWrlk4oF9+bNAXp2iG9JEZ8VLdP7PmoyNL3EkynSdHgef?= =?us-ascii?Q?XUrqulmRURp54sE8lVg9S+/BTxS1vHp/ae+AIogNZ8yviuFhwA=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(36860700013)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 23:22:54.0840 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 267c545c-eb0f-47f0-6730-08dcf8709d85 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9DB.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6090 Content-Type: text/plain; charset="utf-8" ABMC feature details are reported via CPUID Fn8000_0020_EBX_x5. Bits Description 15:0 MAX_ABMC Maximum Supported Assignable Bandwidth Monitoring Counter ID + 1 The feature details are documented in APM listed below [1]. [1] AMD64 Architecture Programmer's Manual Volume 2: System Programming Publication # 24593 Revision 3.41 section 19.3.3.3 Assignable Bandwidth Monitoring (ABMC). Detect the feature and number of assignable monitoring counters supported. Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D206537 Signed-off-by: Babu Moger Reviewed-by: Reinette Chatre --- v9: Added Reviewed-by tag. No code changes v8: Used GENMASK for the mask. v7: Removed WARN_ON for num_mbm_cntrs. Decided to dynamically allocate the bitmap. WARN_ON is not required anymore. Removed redundant comments. v6: Commit message update. Renamed abmc_capable to mbm_cntr_assignable. v5: Name change num_cntrs to num_mbm_cntrs. Moved abmc_capable to resctrl_mon. v4: Removed resctrl_arch_has_abmc(). Added all the code inline. We dont need to separate this as arch code. v3: Removed changes related to mon_features. Moved rdt_cpu_has to core.c and added new function resctrl_arch_has_abm= c. Also moved the fields mbm_assign_capable and mbm_assign_cntrs to rdt_resource. (James) v2: Changed the field name to mbm_assign_capable from abmc_capable. --- arch/x86/kernel/cpu/resctrl/monitor.c | 6 ++++++ include/linux/resctrl.h | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index f7fdf2c767f0..383bf3ad2dcf 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -1229,6 +1229,12 @@ int __init rdt_get_mon_l3_config(struct rdt_resource= *r) mbm_local_event.configurable =3D true; mbm_config_rftype_init("mbm_local_bytes_config"); } + + if (rdt_cpu_has(X86_FEATURE_ABMC)) { + r->mon.mbm_cntr_assignable =3D true; + cpuid_count(0x80000020, 5, &eax, &ebx, &ecx, &edx); + r->mon.num_mbm_cntrs =3D (ebx & GENMASK(15, 0)) + 1; + } } =20 l3_mon_evt_init(r); diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 3c2307c7c106..511cfce8fc21 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -185,10 +185,14 @@ enum resctrl_scope { /** * struct resctrl_mon - Monitoring related data of a resctrl resource * @num_rmid: Number of RMIDs available + * @num_mbm_cntrs: Number of assignable monitoring counters + * @mbm_cntr_assignable:Is system capable of supporting monitor assignment? * @evt_list: List of monitoring events */ struct resctrl_mon { int num_rmid; + int num_mbm_cntrs; + bool mbm_cntr_assignable; struct list_head evt_list; }; =20 --=20 2.34.1 From nobody Mon Nov 25 04:41:22 2024 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2071.outbound.protection.outlook.com [40.107.93.71]) (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 373E520ADE4; Tue, 29 Oct 2024 23:23:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.71 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244210; cv=fail; b=SHh4v2FXdQhzN6UG8IAnV+SJaOX16qBRzIE1FKIQ6Wk2vqH2Saoe7QuJlDND5t5mA1sCLBd+Scag8tI/vdWRO0JACvDTGjCL18P8BlpFaXhGWPiNvXdW/T0+zxewf5DrhulLbV9WnRslBhdOVPlhu2DMP5Y5uD/31E4/5/yjWYk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244210; c=relaxed/simple; bh=ojcFsP7y14AuphmGEMlrKhyR2NqWX8T/haJ1kWERDUk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qXwOcWvQA9oTqvMDRKGoCUNYi1MoUIyYSjNxwRFhnYhQfX8Z1BjQVw49RHChf15fXw39Qgd9k0CzXGrknPPZabKCaqHsNJP1SJwFkgJw1HdlOE+LV/xamjK0M+K6bxtlfDLI/2aeyF2RHhc0Nre10Z+mBBDMfh+ZmrIMwj7PcA8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=ZUcKjurr; arc=fail smtp.client-ip=40.107.93.71 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) header.d=amd.com header.i=@amd.com header.b="ZUcKjurr" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cESDbchEqXmzcZ7mSObc8YfvJ/gNrpgU9fqNaBFzOvAIrdh2PGFV89jh9zXL3DIvXNsq0m5p8pXyB1H3dhdNR4fSroLp2bxWV8LAfGlgoBUs0lgiimL0jx9tNebMeeDW7RE66cZLdQ/zsT2dnil5FTkSbhTQjMY7qRnZIVuhI84WT8Zt8ekMfrNl325hCZq76XIo5VXm4nEZ//6S5Qc3A+zqXmPKee9VPMNlJZksALwiDxtzlA0aumkp2NpLZ2egULrYmA2rAYLMt4GgodQ33d3Qr2q7AbGYMlshqqQxh2B0RBInTiP2fFJJMUuoc19ZHjpjFWG2C99kRtmIGf4vnw== 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=5XGyz4UBN0RuYpQ5CUySLMPegAu5VDwJognTfSCM2xA=; b=Xw79LH0yzk50tbXtiohVI3Bza+dXBUelnt9TAlP/qMULEhUTSR68QmT/oky3Qil1ELlaOKpCSWqvbKamnXhljtOzTrJk61rCRgzhXFwRgHzcC4cNsqHan17v2ofnyp5XtmWIbBMebf4xvGctIObxmS3yaNDZBY9y6Xy0rhKIj8p6XlmTwIP4L4ZYV/UJnhZJ1yETMdI5hKyCyvP4nffUFnOAS0uGi5O+ub1d+unb4zrgZhaM+HWbKl4PLX3aChZykT3C7s7ERBkLfj66SdqK8NgvIOPOi5s3A6mc5ANxeriwbAoOobtqRQPdNfNh/x1fKvddOgCoiLcqoiRYme2new== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net 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=5XGyz4UBN0RuYpQ5CUySLMPegAu5VDwJognTfSCM2xA=; b=ZUcKjurriz9sE8mu6Y4rZ97NPm9j0O2O9odq7Y04W4Q8c2ArmqNVYVBKuCJUMTcH4iW1XLVBT2KswmDX74BGn+9TExocgTuE4x1/oRKdMct9+6z1c2OwucZDLnkAxdSxCoGklf6qdZXIIkDggyWjfmk6yfMPC22AzVk20GsS6Pw= Received: from MW3PR06CA0017.namprd06.prod.outlook.com (2603:10b6:303:2a::22) by CH0PR12MB8552.namprd12.prod.outlook.com (2603:10b6:610:18e::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Tue, 29 Oct 2024 23:23:24 +0000 Received: from CY4PEPF0000E9DA.namprd05.prod.outlook.com (2603:10b6:303:2a:cafe::b2) by MW3PR06CA0017.outlook.office365.com (2603:10b6:303:2a::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.17 via Frontend Transport; Tue, 29 Oct 2024 23:23:23 +0000 X-MS-Exchange-Authentication-Results: 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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000E9DA.mail.protection.outlook.com (10.167.241.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Tue, 29 Oct 2024 23:23:23 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 29 Oct 2024 18:22:59 -0500 From: Babu Moger To: , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v9 06/26] x86/resctrl: Introduce resctrl_file_fflags_init() to initialize fflags Date: Tue, 29 Oct 2024 18:21:38 -0500 Message-ID: <237409fb566288d9f3dc7568385e6488b62dbba0.1730244116.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9DA:EE_|CH0PR12MB8552:EE_ X-MS-Office365-Filtering-Correlation-Id: b48c7b63-ea39-41c8-8084-08dcf870aedd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?ew5ba4pqzP7iCBAItCU1GSglkAKUb++oHDo/nqNG+304p1Bgtbw5/PwbKdtg?= =?us-ascii?Q?anKM3V5MEX6GWqKH/7Vovq+NuyCM8ZO+FsRrG6PfDg6shhHlT9lP5qG5Sj2W?= =?us-ascii?Q?bn3cBkvGxcjLaUt6E9rWl7dqY9JNsH1RgSL1eKUda+QLeI+C8VVg0iKbxrkU?= =?us-ascii?Q?m87azWm1oiTkaFxGJraUToOntEvmlGqHYRnQjfj6NOmcmdeQVM4f7zJgg/SP?= =?us-ascii?Q?3CLXAKhJX4H4zYdQ53cWdpwhEIFRADlqN1DehH5KlI4eVd6+TipEjQhUTYyx?= =?us-ascii?Q?Flc1NfqlIW900nnFVJFqCJ/nFI2+qQFxqkaogAFKpyqep1hCcT8lVVs76KbV?= =?us-ascii?Q?hF/fMMH5clX2tZNGKKwT29zQngTHBwD/mWr3aIO43YWQHwlU1Ywf3VDTXe5A?= =?us-ascii?Q?2SYERK4fWPdoum1wGIsuHNsh6CLSO3rcpcUFWuElGV2+kyzaZDuWwi//CTfk?= =?us-ascii?Q?xBpnqBdHC/9KWR3GMsb/gpOIRWzeBLwtnJYlwVlr5ikh2PzBqjDpJgURlRky?= =?us-ascii?Q?5H9bitiizureSZW0AVj3Ix8anPJ0cgeWrKzxG4v+I9b8yXeoChLNbsRVuFuH?= =?us-ascii?Q?MVh2IKvknJVulCxitggKhyX0YP7LBJSPJPgIezxgwHOR8qjEMyoPR5wfHPkZ?= =?us-ascii?Q?VU7Ex0LgidNrjI5N8YnN6ZqzLZqpMVFzEE617ceQ8jc/B7WE1b22sKddwzd3?= =?us-ascii?Q?wMBXfBFFSu9wpM3aKKLA6TUgzoj+W3JzXU6EBvI7VmoiHUV9nuWmRfnT3eBn?= =?us-ascii?Q?tFeNsxtT65/UAACxv3HvEosWtlF4da1nKsNtfQBSIq4fjgL1PXlay7WZOjFk?= =?us-ascii?Q?t+VvywLNzrEejARxZwZsr/GnxGyYxM7Z9E8ZRh9fWd1WRmfIIHVTHW9j/dsH?= =?us-ascii?Q?UVC8SU9H88ChOlNeRBJBTLCRI3/jqutFiM5Xjq9orzYeFgzaM2R5d5U2jZqf?= =?us-ascii?Q?jfahzrW2i7PEnFP4Wt3dGxBu7aHh2tX1dE7znvPy3LpQRRb0HhqlWuSLtYX0?= =?us-ascii?Q?zYSKo5vgeOlb7AHLapP4nJnhrtFlQmPeXEeNuT5XUHh+/7u1ZiOOC9nGxfeP?= =?us-ascii?Q?JfrQIEakzRR2iZj+/3LtGR4HV0PNR/1pxUQQN0mO2btsASDARXnet3aGjBG9?= =?us-ascii?Q?qMGflNwlurVcEsPmy5EwYJvlsl2DykdtEpxhxn+pvGfVbhDVO42rOroOPuR4?= =?us-ascii?Q?sWI7HSiaiqPzkbGCODlGgU0DlktTGcdDM+YJS1SyD3+jTOjhsgA8M2BfHe6I?= =?us-ascii?Q?s/Y1vioIyLKSnH+QgYRI5cvEkY5UQ08EvtFNeILHNdm1x5PReL6vjqI2JlLD?= =?us-ascii?Q?ERepkiPg6fspGjYCSHmo96yJiVt0DSbSn8hvJzcGd5I1vRsiMHcalBY7jF6D?= =?us-ascii?Q?ikydqOPIl1+sO9sx4i13EvF7AAF3al+JBOcF4/jrzoQW9eIWgQ=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(376014)(7416014)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 23:23:23.1982 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b48c7b63-ea39-41c8-8084-08dcf870aedd 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9DA.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB8552 Content-Type: text/plain; charset="utf-8" thread_throttle_mode_init() and mbm_config_rftype_init() both initialize fflags for resctrl files. Adding new files will involve adding another function to initialize the fflags. This can be simplified by adding a new function resctrl_file_fflags_init() and passing the file name and flags to be initialized. Consolidate fflags initialization into resctrl_file_fflags_init() and remove thread_throttle_mode_init() and mbm_config_rftype_init(). Signed-off-by: Babu Moger Reviewed-by: Reinette Chatre --- v9: No changes. v8: No changes. v7: No changes. v6: Added Reviewed-by from Reinette. v5: Commit message update. v4: Commit message update. v3: New patch to display ABMC capability. --- arch/x86/kernel/cpu/resctrl/core.c | 4 +++- arch/x86/kernel/cpu/resctrl/internal.h | 4 ++-- arch/x86/kernel/cpu/resctrl/monitor.c | 6 ++++-- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 16 +++------------- 4 files changed, 12 insertions(+), 18 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 468af203ca69..7beac735c8e5 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -234,7 +234,9 @@ static __init bool __get_mem_config_intel(struct rdt_re= source *r) r->membw.throttle_mode =3D THREAD_THROTTLE_PER_THREAD; else r->membw.throttle_mode =3D THREAD_THROTTLE_MAX; - thread_throttle_mode_init(); + + resctrl_file_fflags_init("thread_throttle_mode", + RFTYPE_CTRL_INFO | RFTYPE_RES_MB); =20 r->alloc_capable =3D true; =20 diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 16181b90159a..9dd1799adba3 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -647,8 +647,8 @@ void cqm_handle_limbo(struct work_struct *work); bool has_busy_rmid(struct rdt_mon_domain *d); void __check_limbo(struct rdt_mon_domain *d, bool force_free); void rdt_domain_reconfigure_cdp(struct rdt_resource *r); -void __init thread_throttle_mode_init(void); -void __init mbm_config_rftype_init(const char *config); +void __init resctrl_file_fflags_init(const char *config, + unsigned long fflags); void rdt_staged_configs_clear(void); bool closid_allocated(unsigned int closid); int resctrl_find_cleanest_closid(void); diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 383bf3ad2dcf..9209fb3dc78f 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -1223,11 +1223,13 @@ int __init rdt_get_mon_l3_config(struct rdt_resourc= e *r) =20 if (rdt_cpu_has(X86_FEATURE_CQM_MBM_TOTAL)) { mbm_total_event.configurable =3D true; - mbm_config_rftype_init("mbm_total_bytes_config"); + resctrl_file_fflags_init("mbm_total_bytes_config", + RFTYPE_MON_INFO | RFTYPE_RES_CACHE); } if (rdt_cpu_has(X86_FEATURE_CQM_MBM_LOCAL)) { mbm_local_event.configurable =3D true; - mbm_config_rftype_init("mbm_local_bytes_config"); + resctrl_file_fflags_init("mbm_local_bytes_config", + RFTYPE_MON_INFO | RFTYPE_RES_CACHE); } =20 if (rdt_cpu_has(X86_FEATURE_ABMC)) { diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 1647ad9145ef..687d9d8d82a4 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -2020,24 +2020,14 @@ static struct rftype *rdtgroup_get_rftype_by_name(c= onst char *name) return NULL; } =20 -void __init thread_throttle_mode_init(void) -{ - struct rftype *rft; - - rft =3D rdtgroup_get_rftype_by_name("thread_throttle_mode"); - if (!rft) - return; - - rft->fflags =3D RFTYPE_CTRL_INFO | RFTYPE_RES_MB; -} - -void __init mbm_config_rftype_init(const char *config) +void __init resctrl_file_fflags_init(const char *config, + unsigned long fflags) { struct rftype *rft; =20 rft =3D rdtgroup_get_rftype_by_name(config); if (rft) - rft->fflags =3D RFTYPE_MON_INFO | RFTYPE_RES_CACHE; + rft->fflags =3D fflags; } =20 /** --=20 2.34.1 From nobody Mon Nov 25 04:41:22 2024 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2087.outbound.protection.outlook.com [40.107.237.87]) (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 DD55020B1E1; Tue, 29 Oct 2024 23:23:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.87 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244211; cv=fail; b=shm8yqGsGyU6iTNafxkMU61+jrAnzH+wD8gU06edDWoQQt5E4RW11Utt25gtxePoaTAbONe+Y/5C6YNuokR1pSVg7TbWQWNMZWdC35TP1ew7htAB3Klk6O8ncDoj5aAIGC4G3WGw19wKAqFMjXFFDpstK3cLe8E1lQ0NGxKjujY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244211; c=relaxed/simple; bh=bM7G9rhz7fS9fFrT5fpHKNoHD+RlInYvyzrWLnRpi34=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=vB1R9HGrQsQJDuhcCZhQcYJzpD3YlULArVWcdM4wby61N9Hk6ffILosvwkTPRXvYGSrl/JPpxJSEKmEqQRkgXHfzV1iA1tnfTJH/WdJ6Z526TT3gHKa+FcTiIjGNor5ipJq1dnaCCKTWUPTND9Qh1oDxFhed+YmUCbIt0fWfjC0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=Vu9zUS76; arc=fail smtp.client-ip=40.107.237.87 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) header.d=amd.com header.i=@amd.com header.b="Vu9zUS76" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=w8IPYiazYMrj8l9mGXwjWmGIvHxhv7/CY/zEM3RXLnN1IsXtDY4WUsxsYgWGLRhiNQ7dEchFxsNqzThkjHZedsg0CYYmrOeP+eectEgWXNjubZoJ0maLpyTeZrqEpV03ucVkaapM3rSH/grf1uGcgvB9/VPRoFZd6sfr6OLDQyR0cUoGNvNASTzbooUVyVeic8dDGUlLNB6+zFg4IiK/WW7JRYvzuwfyM+gKPvlMJ62s6vS3jmIMeZy/Lqp7qwrQEdveKLtEg1XrsRPKZ8aBrSZgdUpCNr2E7bNXnlgLpI0UnuDjblXPBfpY7/ngdcTm0EQr9XusSJn4fHCvsA1Uwg== 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=wgC4xsyggsbag7VOHcTxXDOXQKnolLhpcCgOEXWrkos=; b=CaX3tbmYezvvVGHnQPQwsCfsJDVgrRNcd3y941f3EoAyU4mfChYXV7Dns9N/aV+o9SaYXnCwsBbT0bwBn7KzK2CIhb2Y2c6ak3MmXAVC6mrhKjn5MyHtmu/x5MzCk0aeQiJ8o9YUfMOatrtnA/6DA5s/xtmfjydEyse4PcZXS5c3VPycIG4Af+wPTr3We3B0g+8L9O7y7397b4o17aX5EFFefIT+lNqNjONqmZMNrcWp/gBE01ES+2LzFOEOsi6JiaJqDzS3JKevUg56ofRdxSjWJUhNKm070ISEncXS3SjB7LWlXJb83ZwH7zpbXCk5um9PRI+TJ4rwEAEzerm+DA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net 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=wgC4xsyggsbag7VOHcTxXDOXQKnolLhpcCgOEXWrkos=; b=Vu9zUS76wa6SmXbsrIJOtJQEj1rhOAEuV2zjVct3yoJgHwckUmq4trTZQkQrvS4vlUbU3zrbF0S2ZF9sbaLoOGel6QNKuZhVju3PUrfLcAzPFWNZClyPyCx4iBv9ulqZwsUvvgq4Q8mABnw61qQNJCS8em5voZFStMfOAnDiv/c= Received: from MW3PR06CA0024.namprd06.prod.outlook.com (2603:10b6:303:2a::29) by PH0PR12MB7907.namprd12.prod.outlook.com (2603:10b6:510:28d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.23; Tue, 29 Oct 2024 23:23:25 +0000 Received: from CY4PEPF0000E9DA.namprd05.prod.outlook.com (2603:10b6:303:2a:cafe::53) by MW3PR06CA0024.outlook.office365.com (2603:10b6:303:2a::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.26 via Frontend Transport; Tue, 29 Oct 2024 23:23:24 +0000 X-MS-Exchange-Authentication-Results: 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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000E9DA.mail.protection.outlook.com (10.167.241.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Tue, 29 Oct 2024 23:23:24 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 29 Oct 2024 18:23:08 -0500 From: Babu Moger To: , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v9 07/26] x86/resctrl: Add support to enable/disable AMD ABMC feature Date: Tue, 29 Oct 2024 18:21:39 -0500 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9DA:EE_|PH0PR12MB7907:EE_ X-MS-Office365-Filtering-Correlation-Id: ddd5706a-d7ef-4eea-4f55-08dcf870afaf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|7416014|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?RLiFHDPDXtYzBOxzg8ZsmXXClnbYTkzUGHt1tjZ2j/fXZfhP7df1k/HmlztJ?= =?us-ascii?Q?GxADNzjwQMq30ySeRoWIG2CFnbwhEE5MVRit8P7Qv2fWa879kRImZwQ2SFZG?= =?us-ascii?Q?Y7xqeY1QmKkJC9m//uP8gobNgTs6Kamn2Mrq7xjHODLraVwrIYwDnDByi/dj?= =?us-ascii?Q?KmmcpI6rp/+MfUipMQuvNutIaHrVEN+ZCmKJA2JTLb49XjlPhDK3eWwN0ldS?= =?us-ascii?Q?+T+PzTW9HFyhYRgcOYlHWW3i+TmzHyJHgju5fW8uGDz70KhvIKO3SHla5HcB?= =?us-ascii?Q?sMuT6IXQrLSMYTJ3T6BfZjnbd87R5JZRGzIfgqjp7d5P1o7leCRXNSEnGSvS?= =?us-ascii?Q?p+ToNmB7+U1aXE7BlK/U5easV/zxIP+w5dHlaxkZXuE1y7xQvop5HmhIYYTR?= =?us-ascii?Q?RLQF7Kr3/DSBUl/xu+bQz39KN8Q5xoOsIvRjtBYEPCFKc6tvJ/K2+V/D+yWB?= =?us-ascii?Q?vnsxc6jFg2nHRx2cFkbQjmO0NdkcAQb3ZhG9PJwb99N2UfEYAgyNvzpgIx/n?= =?us-ascii?Q?F8TBKdEgZ2a2H7zZQeDBwJZrnTFcRk2L8RP/gYs3dq1EBUMdxQtYXIN87DYp?= =?us-ascii?Q?QjVm0BQoIylXaCq6j3+2dlPvWiaSzNIUIrGrgKHMWlSOsdKnMxeTjSiNVZba?= =?us-ascii?Q?x+0t6/Sjt2R5+GrnL1iNHEXJ86kNaTP7wBOSwEFRj07vpwwx+6WFYOPTX8zH?= =?us-ascii?Q?Ckvyo+aE8oCgnofevfTaEZVBujEPBmDHi6OpcSIaf+6wvLBGZ+1mU49kANVg?= =?us-ascii?Q?qALW6RyP4YYI1cy6rY6WYzrZwc5LbwDgtIpqy7TO6vF4cENlwWH6CpjQnbxS?= =?us-ascii?Q?gg7adBEIusR2owq2zMVOTRHihRx/plGh8R//1pt+HYZ376K0ukCteoeP4d68?= =?us-ascii?Q?lKNuIeAEMpftgdr8v9197flIvIuv6KoZLO1yrhR3vNsuoVHkXVOVWrIJv3jQ?= =?us-ascii?Q?urvDEAtjwo0hv4GM0ZMZxc/cDUG1ja6aCyRLxUW0txIPme9Bb0QyaA1i1piq?= =?us-ascii?Q?qVMTEll2zxj0wCYZxSQ/ySL0kqf5wC3qhkPd344IyeQXV/ERRBIFpC8EgrsG?= =?us-ascii?Q?QaDTOymqyteygOblrB1cF39vBXQl4IfDBpCB6mpqTE++Q12pqiU8OwvLJXYw?= =?us-ascii?Q?nQ2qGl9LnZoHvCAx+2Z8DA/egadFgOe6KU55r4eOg5v2FcQeNyX5MFFawLXs?= =?us-ascii?Q?+UsHl0GqXHiBbePlEX6CYHr1Xmrkqdx6oel3EDdwYkoiB1soH/l81vTAX1Md?= =?us-ascii?Q?SwDUNYvyz0YDFOsjb8yR+yBgFjPD1J/GlOCSwvyJLsk7XMy28phgl3cWLedU?= =?us-ascii?Q?XNcBeSBZboRsB+sTbVd2v+vWIi0MnJQd9k2uOvCUiaQ3wP6HUL95iOZAkydS?= =?us-ascii?Q?yw7T3kZd2Vl4JpvpUv8qVZHfYZGra6jGksIW/7pZp639dr9pHA=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(7416014)(376014)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 23:23:24.5576 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ddd5706a-d7ef-4eea-4f55-08dcf870afaf 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9DA.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7907 Content-Type: text/plain; charset="utf-8" Add the functionality to enable/disable AMD ABMC feature. AMD ABMC feature is enabled by setting enabled bit(0) in MSR L3_QOS_EXT_CFG. When the state of ABMC is changed, the MSR needs to be updated on all the logical processors in the QOS Domain. Hardware counters will reset when ABMC state is changed. The ABMC feature details are documented in APM listed below [1]. [1] AMD64 Architecture Programmer's Manual Volume 2: System Programming Publication # 24593 Revision 3.41 section 19.3.3.3 Assignable Bandwidth Monitoring (ABMC). Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D206537 Signed-off-by: Babu Moger Reviewed-by: Reinette Chatre --- v9: Re-ordered the MSR and added Reviewed-by tag. v8: Commit message update and moved around the comments about L3_QOS_EXT_CFG to _resctrl_abmc_enable. v7: Renamed the function resctrl_arch_get_abmc_enabled() to resctrl_arch_mbm_cntr_assign_enabled= (). Merged resctrl_arch_mbm_cntr_assign_disable, resctrl_arch_mbm_cntr_assi= gn_disable and renamed to resctrl_arch_mbm_cntr_assign_set(). Moved the function definition to linux/resctrl.h. Passed the struct rdt_resource to these functions. Removed resctrl_arch_reset_rmid_all() from arch code. This will be done from the caller. v6: Renamed abmc_enabled to mbm_cntr_assign_enabled. Used msr_set_bit and msr_clear_bit for msr updates. Renamed resctrl_arch_abmc_enable() to resctrl_arch_mbm_cntr_assign_enab= le(). Renamed resctrl_arch_abmc_disable() to resctrl_arch_mbm_cntr_assign_dis= able(). Made _resctrl_abmc_enable to return void. v5: Renamed resctrl_abmc_enable to resctrl_arch_abmc_enable. Renamed resctrl_abmc_disable to resctrl_arch_abmc_disable. Introduced resctrl_arch_get_abmc_enabled to get abmc state from non-arch code. Renamed resctrl_abmc_set_all to _resctrl_abmc_enable(). Modified commit log to make it clear about AMD ABMC feature. v3: No changes. v2: Few text changes in commit message. --- arch/x86/include/asm/msr-index.h | 1 + arch/x86/kernel/cpu/resctrl/core.c | 5 ++++ arch/x86/kernel/cpu/resctrl/internal.h | 5 ++++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 36 ++++++++++++++++++++++++++ include/linux/resctrl.h | 3 +++ 5 files changed, 50 insertions(+) diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-in= dex.h index 3ae84c3b8e6d..bdc95b7cd1b0 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -1194,6 +1194,7 @@ /* - AMD: */ #define MSR_IA32_MBA_BW_BASE 0xc0000200 #define MSR_IA32_SMBA_BW_BASE 0xc0000280 +#define MSR_IA32_L3_QOS_EXT_CFG 0xc00003ff #define MSR_IA32_EVT_CFG_BASE 0xc0000400 =20 /* AMD-V MSRs */ diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 7beac735c8e5..9603f5cb483c 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -405,6 +405,11 @@ void rdt_ctrl_update(void *arg) hw_res->msr_update(m); } =20 +bool resctrl_arch_mbm_cntr_assign_enabled(struct rdt_resource *r) +{ + return resctrl_to_arch_res(r)->mbm_cntr_assign_enabled; +} + /* * rdt_find_domain - Search for a domain id in a resource domain list. * diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 9dd1799adba3..c07a93da31cc 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -56,6 +56,9 @@ /* Max event bits supported */ #define MAX_EVT_CONFIG_BITS GENMASK(6, 0) =20 +/* Setting bit 0 in L3_QOS_EXT_CFG enables the ABMC feature. */ +#define ABMC_ENABLE_BIT 0 + /** * cpumask_any_housekeeping() - Choose any CPU in @mask, preferring those = that * aren't marked nohz_full @@ -477,6 +480,7 @@ struct rdt_parse_data { * @mbm_cfg_mask: Bandwidth sources that can be tracked when Bandwidth * Monitoring Event Configuration (BMEC) is supported. * @cdp_enabled: CDP state of this resource + * @mbm_cntr_assign_enabled: ABMC feature is enabled * * Members of this structure are either private to the architecture * e.g. mbm_width, or accessed via helpers that provide abstraction. e.g. @@ -491,6 +495,7 @@ struct rdt_hw_resource { unsigned int mbm_width; unsigned int mbm_cfg_mask; bool cdp_enabled; + bool mbm_cntr_assign_enabled; }; =20 static inline struct rdt_hw_resource *resctrl_to_arch_res(struct rdt_resou= rce *r) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 687d9d8d82a4..d54c2701c09c 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -2402,6 +2402,42 @@ int resctrl_arch_set_cdp_enabled(enum resctrl_res_le= vel l, bool enable) return 0; } =20 +static void resctrl_abmc_set_one_amd(void *arg) +{ + bool *enable =3D arg; + + if (*enable) + msr_set_bit(MSR_IA32_L3_QOS_EXT_CFG, ABMC_ENABLE_BIT); + else + msr_clear_bit(MSR_IA32_L3_QOS_EXT_CFG, ABMC_ENABLE_BIT); +} + +/* + * Update L3_QOS_EXT_CFG MSR on all the CPUs associated with the monitor + * domain. + */ +static void _resctrl_abmc_enable(struct rdt_resource *r, bool enable) +{ + struct rdt_mon_domain *d; + + list_for_each_entry(d, &r->mon_domains, hdr.list) + on_each_cpu_mask(&d->hdr.cpu_mask, + resctrl_abmc_set_one_amd, &enable, 1); +} + +int resctrl_arch_mbm_cntr_assign_set(struct rdt_resource *r, bool enable) +{ + struct rdt_hw_resource *hw_res =3D resctrl_to_arch_res(r); + + if (r->mon.mbm_cntr_assignable && + hw_res->mbm_cntr_assign_enabled !=3D enable) { + _resctrl_abmc_enable(r, enable); + hw_res->mbm_cntr_assign_enabled =3D enable; + } + + return 0; +} + /* * We don't allow rdtgroup directories to be created anywhere * except the root directory. Thus when looking for the rdtgroup diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 511cfce8fc21..f11d6fdfd977 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -355,4 +355,7 @@ void resctrl_arch_reset_rmid_all(struct rdt_resource *r= , struct rdt_mon_domain * extern unsigned int resctrl_rmid_realloc_threshold; extern unsigned int resctrl_rmid_realloc_limit; =20 +int resctrl_arch_mbm_cntr_assign_set(struct rdt_resource *r, bool enable); +bool resctrl_arch_mbm_cntr_assign_enabled(struct rdt_resource *r); + #endif /* _RESCTRL_H */ --=20 2.34.1 From nobody Mon Nov 25 04:41:22 2024 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2065.outbound.protection.outlook.com [40.107.243.65]) (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 7C5FF20ADEE; Tue, 29 Oct 2024 23:23:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.65 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244211; cv=fail; b=qF22FXTAMz86l+JCx4sWBr1anwq+h3c0bAOafkxk3X16m3asHiNiQPONyxARVLGPIRca8zEGqoBbGjrlxOJAvspxZTRi4j+MNqwtbS4bz28zsMJmooJz8QsgGfzNPN7oyPtUGasTvhnlqm2q1JdkTAFDG9sqWzHMwDGl7ZF+E9s= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244211; c=relaxed/simple; bh=lJisS6vwmoNNFvV5hmSIcyfzfg/4AdxIixD6fizga/0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=eammc76EhdDahF4vcaxFQCMc8C2sZvfYqUitSesVoLfYL4eug5BDFzSU01X02oOYGu6HUAEfkm+Gw2AcoYFva2Fub+xCJ2nl+nK/UBwZ35PbcteEzL6wUMsuAp9YFrcFFUuqR7qW6cyhtPxR71HP2eVNkL0OLjVBjzt31v+vOeg= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=ulK/R6u5; arc=fail smtp.client-ip=40.107.243.65 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) header.d=amd.com header.i=@amd.com header.b="ulK/R6u5" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=oEybSDtzGDKSVD+MXTtpu9Ta9cNlo2XgzWz7pYofFhBPpp35VuAiU8K0UOwk7tM9U9T/4r6jiSxjhSDKHBqfF7juXcYz1fyLh2tLSz4thjJHPoipCOema9EKToMupwJ3BvUDYQnDnygtukJUfcP71sQ/JQA+ufyC2BUZ250lj7v2vVNCMFR1Is9ZXznJw3irCzMEeWiPNW4TBNMAebpmG/e1IExUR11iCV3QTo79D4CZaWHT0LNAfZ1lfrIo8HIMBe28DafVhNOPfI1KYC6yg/XiIesB391YHtIbBrDrgyR59xnPbj2cR46YmvcoB2xva7jLIhoenPyl5YVl9+2HXA== 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=8YW2EUxo9+x4djJsOCl7ehZfpP16KkrtX933N+/K6jg=; b=JfEBcghwN4i/VAIRyELqG6kyiWOkgyUQLkAONoQXJIyt8/+3Z09BnD77uv4o88Qm/n6HGg782pz2lFJuou21OWnb0stsUpszp9IXuCH+V4wZMg4BasCZ/DOExYZ78o2Ietil5kbqDMZlCsbbw5YMceP23wszjkgQbLyw2KR7T1oTD5zBAvu48IQW6HFa9cPABXk2yoBXm3RSEIZ9L1mdLOErQJ6kajZVbPDI4lgY1l4u6sZiniwcliODHHMBYVyJVOkOK15IygYYC2F/5Lt+fHEeqzRWGifcFQ1+OiimmKAPLNFU+cnv7/1Ot3+MHnv9lV65fyvnBc1Zd8H1jkXGOQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net 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=8YW2EUxo9+x4djJsOCl7ehZfpP16KkrtX933N+/K6jg=; b=ulK/R6u53pnhn3Ml05t5j7J0BcY9uHA45Qq2mbaKFmZyDnDP5EObRF/kgKoi4oSuJEiFCbysLNpJu7VXIrLl8gwIpsZLPF2epak9tejprwvItfcVyeZV0NLb65NBPU9cJY6La0SpP0VBNQQeI1VmdNM5a6dLCIQ0DEaavYR5b30= Received: from MW3PR06CA0025.namprd06.prod.outlook.com (2603:10b6:303:2a::30) by IA1PR12MB9466.namprd12.prod.outlook.com (2603:10b6:208:595::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Tue, 29 Oct 2024 23:23:26 +0000 Received: from CY4PEPF0000E9DA.namprd05.prod.outlook.com (2603:10b6:303:2a:cafe::e2) by MW3PR06CA0025.outlook.office365.com (2603:10b6:303:2a::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.29 via Frontend Transport; Tue, 29 Oct 2024 23:23:25 +0000 X-MS-Exchange-Authentication-Results: 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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000E9DA.mail.protection.outlook.com (10.167.241.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Tue, 29 Oct 2024 23:23:25 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 29 Oct 2024 18:23:16 -0500 From: Babu Moger To: , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v9 08/26] x86/resctrl: Introduce the interface to display monitor mode Date: Tue, 29 Oct 2024 18:21:40 -0500 Message-ID: <121c79ea1abe6f21f726d086eba9fa61d31da3f1.1730244116.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9DA:EE_|IA1PR12MB9466:EE_ X-MS-Office365-Filtering-Correlation-Id: 3396cb32-20c9-433c-e614-08dcf870b047 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|36860700013|7416014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?sWd7PZqZvUhOhsipNU278bvIUtro6U36ri4zyCqyeOjPcAgLsij8VxI1yG4x?= =?us-ascii?Q?xBoJr2zGYh20Ci3UYvqRTLF2fweb6AEkSt8rFGtiuvtnX7hlBoh0eC2pi65W?= =?us-ascii?Q?KBfVAFg7Wj71vEfmJTriVXFPJx13+WUHLy9TAn9gpQkqC2wcTfzUFqKXKmS0?= =?us-ascii?Q?sUNRiLNTbgAYE/4MFkZqKnuZcpjiPGRgmIXDiFlrhqFjO7k+nokZkuxwmeh0?= =?us-ascii?Q?hyTnmLzXi7+0ZJeXkN6ZPgM2JnhT5/EK7057PU53pvZElGjo1S5/kFH1X40y?= =?us-ascii?Q?6SVVaWE9EAcBoRqPWbWsoqfUj9wrSgGgbwKSaI7mIE3SFTTF4u/KYMI01RoZ?= =?us-ascii?Q?cgjDH7+lflEGF8sPIeizbNbSIckke3ku3Tq/z4VBIsinxlFa+nWrZ67PNbny?= =?us-ascii?Q?GoKLGRaL/FuD+6Tn1wOOWm8TPMzs6aAFr7/8DzQscBoKc5pt8qN+KsBIOPI/?= =?us-ascii?Q?RPBQXpOax3mFnAIk2YUiPRqjRtbV2JsZnHXkSuo15Da6Hj3VqwyUcdGvXFw/?= =?us-ascii?Q?zZ5BW8dIY1Lve+CIp/j/Bh77BtjNOY58kMXPattfNeA+Pnw5KxYRb61hsuqa?= =?us-ascii?Q?KukJuzJSmS5Of5VBliv/cGbw1iyviX80JWnztdH1nwSlTusbgod6W4I6J5F/?= =?us-ascii?Q?zM8gKQ4SRk1/9kXkNVI6VyI709eVPtyyqyx55apwDH3gqjnOWcbyCcOlO4lb?= =?us-ascii?Q?FqS7uFPeq1cOVoUIr2LwlI9pHtRhAyeo7yL5fZJQGlUAr0HkoITVSq16bANF?= =?us-ascii?Q?nloDRYZaJeNgrqB8vOteJxuBhJryiT2dI8tZV3yYyzYH5TfY1HlWhrHV4nff?= =?us-ascii?Q?3bq974GNCNTHr6G4oRYH8jgXSyeAd1urbeoWXTVhBQYf7k0owewmaSySHCuM?= =?us-ascii?Q?+qLk2xtOA+79u5ct8CvSeyqvcm2j8FcuXdAASHKD6CzCbAjJb7raxx28h/ht?= =?us-ascii?Q?CpQ15wmu3Zov2IRBErAbnkZJx9tFXqFf+ComKs4z0DxBZEbNt9pRotKsQuy7?= =?us-ascii?Q?xD5L+3Cijcmzk5uPIXPSZplw3Zx5taf8UO3CFqK4z8d62i4Xd/Z57bfXaioK?= =?us-ascii?Q?PkxrF3mJ/FuijZMkE+PetGIUqPj0ZCeFdCpfueFhRH26LrVhU5bbL0yjxsH0?= =?us-ascii?Q?V3wT5mHzRRKvQRB8cMVzLDRQ4J8zrA8+/bSMtqrAqm6988UJkNWL/wSdKSSh?= =?us-ascii?Q?KzDZlKIk4XXCKeyFMvnj6IvotRa1PzaxnCb1/MKNQIAYcL/WAZTfgt90t5ps?= =?us-ascii?Q?RJZu/uYuD7xbAutyM8TOO33psYCpiFkHMpCg4D5r2gCcOff0Sf6rvZaNtLTS?= =?us-ascii?Q?55RCCiNqHxZ8br3ekQRTab5a/VohIP2+HIUG8XruGb3WeRlF1EDkK0lq8adw?= =?us-ascii?Q?9WyHy6Z44JGnNwZD8o8Yk0of1RKVE8sXJ3qPTozbVkTbDTBh5w=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(376014)(36860700013)(7416014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 23:23:25.5732 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3396cb32-20c9-433c-e614-08dcf870b047 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9DA.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB9466 Content-Type: text/plain; charset="utf-8" Introduce the interface file "mbm_assign_mode" to list monitor modes supported. The "mbm_cntr_assign" mode provides the option to assign a counter to an RMID, event pair and monitor the bandwidth as long as it is assigned. On AMD systems "mbm_cntr_assign" is backed by the ABMC (Assignable Bandwidth Monitoring Counters) hardware feature and is enabled by default. The "default" mode is the existing monitoring mode that works without the explicit counter assignment, instead relying on dynamic counter assignment by hardware that may result in hardware not dedicating a counter resulting in monitoring data reads returning "Unavailable". Provide an interface to display the monitor mode on the system. $ cat /sys/fs/resctrl/info/L3_MON/mbm_assign_mode [mbm_cntr_assign] default Signed-off-by: Babu Moger --- v9: Updated user documentation based on comments. v8: Commit message update. v7: Updated the descriptions/commit log in resctrl.rst to generic text. Thanks to James and Reinette. Rename mbm_mode to mbm_assign_mode. Introduced mutex lock in rdtgroup_mbm_mode_show(). v6: Added documentation for mbm_cntr_assign and legacy mode. Moved mbm_mode fflags initialization to static initialization. v5: Changed interface name to mbm_mode. It will be always available even if ABMC feature is not supported. Added description in resctrl.rst about ABMC mode. Fixed display abmc and legacy consistantly. v4: Fixed the checks for legacy and abmc mode. Default it ABMC. v3: New patch to display ABMC capability. --- Documentation/arch/x86/resctrl.rst | 33 ++++++++++++++++++++++++++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 31 ++++++++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/re= sctrl.rst index 30586728a4cd..a93d7980e25f 100644 --- a/Documentation/arch/x86/resctrl.rst +++ b/Documentation/arch/x86/resctrl.rst @@ -257,6 +257,39 @@ with the following files: # cat /sys/fs/resctrl/info/L3_MON/mbm_local_bytes_config 0=3D0x30;1=3D0x30;3=3D0x15;4=3D0x15 =20 +"mbm_assign_mode": + Reports the list of monitoring modes supported. The enclosed brackets + indicate which mode is enabled. + :: + + # cat /sys/fs/resctrl/info/L3_MON/mbm_assign_mode + [mbm_cntr_assign] + default + + "mbm_cntr_assign": + + In mbm_cntr_assign mode user-space is able to specify which of the + events in CTRL_MON or MON groups should have a counter assigned using the + "mbm_assign_control" file. The number of counters available is described + in the "num_mbm_cntrs" file. Changing the mode may cause all counters on + a resource to reset. + + The mode is useful on platforms which support more CTRL_MON and MON + groups than the hardware counters, meaning 'unassigned' events on CTRL_MO= N or + MON groups will report 'Unavailable' or count the traffic in an unpredict= able + way. + + AMD Platforms with ABMC (Assignable Bandwidth Monitoring Counters) feature + enable this mode by default so that counters remain assigned even when the + corresponding RMID is not in use by any processor. + + "default": + + In default mode resctrl assumes there is a hardware counter for each + event within every CTRL_MON and MON group. Reading mbm_total_bytes or + mbm_local_bytes may report 'Unavailable' if there is no counter associated + with that event. + "max_threshold_occupancy": Read/write file provides the largest value (in bytes) at which a previously used LLC_occupancy diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index d54c2701c09c..f25ff1430014 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -845,6 +845,30 @@ static int rdtgroup_rmid_show(struct kernfs_open_file = *of, return ret; } =20 +static int rdtgroup_mbm_assign_mode_show(struct kernfs_open_file *of, + struct seq_file *s, void *v) +{ + struct rdt_resource *r =3D of->kn->parent->priv; + + mutex_lock(&rdtgroup_mutex); + + if (r->mon.mbm_cntr_assignable) { + if (resctrl_arch_mbm_cntr_assign_enabled(r)) { + seq_puts(s, "[mbm_cntr_assign]\n"); + seq_puts(s, "default\n"); + } else { + seq_puts(s, "mbm_cntr_assign\n"); + seq_puts(s, "[default]\n"); + } + } else { + seq_puts(s, "[default]\n"); + } + + mutex_unlock(&rdtgroup_mutex); + + return 0; +} + #ifdef CONFIG_PROC_CPU_RESCTRL =20 /* @@ -1901,6 +1925,13 @@ static struct rftype res_common_files[] =3D { .seq_show =3D mbm_local_bytes_config_show, .write =3D mbm_local_bytes_config_write, }, + { + .name =3D "mbm_assign_mode", + .mode =3D 0444, + .kf_ops =3D &rdtgroup_kf_single_ops, + .seq_show =3D rdtgroup_mbm_assign_mode_show, + .fflags =3D RFTYPE_MON_INFO, + }, { .name =3D "cpus", .mode =3D 0644, --=20 2.34.1 From nobody Mon Nov 25 04:41:22 2024 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2063.outbound.protection.outlook.com [40.107.220.63]) (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 C17AE20C00E; Tue, 29 Oct 2024 23:23:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.63 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244214; cv=fail; b=R3M/zPmFdhR7E9xTmCRLnYJUqzY8CkoCo/3zWiFIjNac+lY0okZXoFxRAOmxEiIa2RMx2jmnLyoBhlAxWZVgZVzhr2HbtJWEi1x+xeKiOL64EgUkJEXzKUBlPPVkYaeLQcF658kcRtxy5mXfac+0DKEqeva4f57Kv7/ox6rwjjs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244214; c=relaxed/simple; bh=yZAJT4uX2VTMRwzX8ufpwX2XBXVezXu6R9QcB8lidWY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FErW2THkupQCO/BU44L6Nan3Om92pXdWvZLyZAa9i/d4bEDx0z/scbWV2r4hqD1A+oDE8W1EIXLpX1FuMIbZBufFFBX152QAVM5R0yO6n7lFY7VPAvHsmYYVeFzmlyR0QZ9ihRtdXw1FuUrh8NcYd3PyPykEhxZKyMzUJN/TDDw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=YlMPuFmw; arc=fail smtp.client-ip=40.107.220.63 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) header.d=amd.com header.i=@amd.com header.b="YlMPuFmw" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=fN3CBe8tTTsh8JLlWIIx+nMdLFNseHokhqj7TkGc76UnR5s+KdMtFcI8p1f3oAOU4bIT34ogzMUuAzj3BgezVKnL7tVyN0HsFuHwpUpAoPJ46KxT1k1ViHvgc0NO1+c64FNH0velHZaF+I7o0/Y+w0iaiy3hWy+dUiQ7moKsyY53+qflPfaj+mztwXAsKsRNfOO2IElolAuMChl0x2wsoj3wLV/hd3mMpB5EZ0Z8nHY3DOaauWnrhEnDlqA8hSFUwliuFR96nA9K4L+7g9AUJYazzdw9HHhNQEyhD2VxQHRQqT5Fj6Bj4WD7Hc577QUj0OIWWsb/KMmUJXDzmvdIDw== 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=LiOaVJZfAOPm06RSE1UzskqReBP4js38qM+vdJpQm+Y=; b=Bt2fyBBHtXm9/CJq7kEZ3q0pMC2WbUAg6Htv4YgBVSFigaS7bOkxS9z4wx8o5QmOCX2jFbmok+8RHnKlYkDnuAiCIyxUvJgg/QR71o+27q6S3ZWe23kHFpbBcdG+zNYb+s7r8DklaY+G1/R7izp8F52wv3a1b3z38VQsibGNt0qnQaxMV5mGHJdjEATB2fiqdW2Q+E8LVty/7oCKLKeBul3N1DO3HM2/VwVLaqtEctY/kApCpiOsr7261n5evgmauIAYOZr0rDmF0QEi23v9pmHvxsreJfBn3lsxZO46aA0C23PhDzNPaVhU3+oBPTrhKbzCp+RpCmvgOhmjhhzKPw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net 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=LiOaVJZfAOPm06RSE1UzskqReBP4js38qM+vdJpQm+Y=; b=YlMPuFmwiAzT6xL4nIAux97CxGTSYsK+MjEuFeSDgxnSH4xAmUUqK/RoueFRhhakSXFk6Ty6ChKnPX03mlHmwF1ag70kxxYSQ6Dfnzs9H6ZTIkqCF7YRbXauTRbQGnfNAgfOU6fiXKj7mdTIMl2RrVZ1k5V8aYQO6wAxDHfz0nE= Received: from MW3PR06CA0015.namprd06.prod.outlook.com (2603:10b6:303:2a::20) by PH7PR12MB6834.namprd12.prod.outlook.com (2603:10b6:510:1b4::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.24; Tue, 29 Oct 2024 23:23:28 +0000 Received: from CY4PEPF0000E9DA.namprd05.prod.outlook.com (2603:10b6:303:2a:cafe::f1) by MW3PR06CA0015.outlook.office365.com (2603:10b6:303:2a::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.26 via Frontend Transport; Tue, 29 Oct 2024 23:23:28 +0000 X-MS-Exchange-Authentication-Results: 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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000E9DA.mail.protection.outlook.com (10.167.241.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Tue, 29 Oct 2024 23:23:27 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 29 Oct 2024 18:23:24 -0500 From: Babu Moger To: , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v9 09/26] x86/resctrl: Introduce interface to display number of monitoring counters Date: Tue, 29 Oct 2024 18:21:41 -0500 Message-ID: <447a268e3cddcebc30a0b2c5ccb321e3c6b9c8d9.1730244116.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9DA:EE_|PH7PR12MB6834:EE_ X-MS-Office365-Filtering-Correlation-Id: e8df657c-494f-401b-1181-08dcf870b198 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|36860700013|7416014|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?I1/DduRQwgPIVmspU4SvfjFE7yxXaOq09LZjT0pvbY/ioMmRSho6LGatZpMP?= =?us-ascii?Q?30UhuCOfBIBCnxYhWtXg47/p5MmarYQ6b1LkdN8cOI8GdsU8l1EWkm1K5oPC?= =?us-ascii?Q?iRckaQwpfV5vVr5Bh2adx/0VpX1NQSbH1p5hHztFntMt8VCEawQTuIXgwLqS?= =?us-ascii?Q?sZUAQrf3rpOpanqnhsp3+R/G2HWDsIY5km1VLYVR+R60x0FkrTF4UUIcymVw?= =?us-ascii?Q?+MVf9DCQdOoLuEguEffyQin9wd54JJexEbx/auFZPvJesUGbs9/t8yArJ1pp?= =?us-ascii?Q?55hKWX4XVIDKKV8UDuhDCE4XvDC0GXPVfxjr+HRlZMy4d1aGZtmX6SpbxwDp?= =?us-ascii?Q?hbcMhTywobyfHE7ii3abfl/La2D4DmXPIWkZaeYZDVYL1Y1Fw3C76fpTChJ7?= =?us-ascii?Q?I9F+/9RZDisanUgJIfDqzeCo8ImUdLS6ffkXn8IcTRVIQRblxabcPGhMkdSA?= =?us-ascii?Q?xFCANFHOc0EIHolMkjHVp+MyGADh1Qt8SEPf5mRwJmvDDKjBKek++5YBLl+e?= =?us-ascii?Q?LQNwJPj5vxxVCCS0gqpuZoOIDfJSgzVl/yFSZRjvNBqIJkU61L0Jr0jcRnnM?= =?us-ascii?Q?oCteEY2FdiR2DoqvIxdzeA+sTHMLqyjOp2sRgBWJyu3qKv3zPgyP0pyGv0z6?= =?us-ascii?Q?pCjLc9D7ADNUAm7tWniPfveVFdRsAnJ6LZxqioWAgHadoX+RcAgh9wQX35GN?= =?us-ascii?Q?DVtxaiQCObTsIUAAtw4wtsBbq5+kXSDkcrmc1LjwAMsuI8XF2V7KOLu3kPOt?= =?us-ascii?Q?MOjIbmuMtjjgXf25hzIyE4xeiRBvIZ0bW7VxpxiwHSVcFrY9uUpuMblrC7fO?= =?us-ascii?Q?Sn4m9jokZ5ad8/xC/kPxX+WgnXa9MFZlG5CCVoUpuTSreBE0lF2t+oELy13O?= =?us-ascii?Q?aYk03wUSsc0roXzzDQDwoZNDE0JHDrVdPcKLOHGiaPjR2MwRl/gPTSROuvNC?= =?us-ascii?Q?nrM4bIIucxP/GXvYoKNWvUU6CKDgVnY34o+JYnmWAe0O2K5qL1Vt7ArJwdmg?= =?us-ascii?Q?dCjpYCmCO7GEy/Dqy2LMBog6McD+P1PMUG3ou1vUByWEDGxfztBZslEyRle5?= =?us-ascii?Q?BkQiuel6ge2YC78cEI2uLQYk6E9eEshIpmaESuYrMVdXwvwH5xA4HLRDOt69?= =?us-ascii?Q?W83o5Yy0YezdmvAzX/a2TA75KTcd6unA4LV0iUAxkroghDjgNj3LizYT8bsw?= =?us-ascii?Q?Gn9FrEq2lq/UAxi21Vae2HImJ1HK22TYn9slHCwPwn5dnMgk7144FAoo3V8c?= =?us-ascii?Q?IO+psdPsqzKtOVTy+3YD4FtiIZDaYV72E6VXetE9DwR87X/auSN64+zAduwi?= =?us-ascii?Q?sbWG9bSNWsaBH8hRI5pgBnsSZEEve7n4pvJ4E+wqou6rh+SvfFR5EB4wNF9k?= =?us-ascii?Q?pqb82dJ3imA76+mv1uS61mc0iQ+tGJSJrf0U3COMkyU+XfYRYg=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(36860700013)(7416014)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 23:23:27.7764 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e8df657c-494f-401b-1181-08dcf870b198 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9DA.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6834 Content-Type: text/plain; charset="utf-8" The mbm_cntr_assign mode provides an option to the user to assign a counter to an RMID, event pair and monitor the bandwidth as long as the counter is assigned. Number of assignments depend on number of monitoring counters available. Provide the interface to display the number of monitoring counters supported. The interface file 'num_mbm_cntrs' is available when an architecture supports mbm_cntr_assign mode. Signed-off-by: Babu Moger --- v9: Updated user document based on the comments. Will add a new file available_mbm_cntrs later in the series. v8: Commit message update and documentation update. v7: Minor commit log text changes. v6: No changes. v5: Changed the display name from num_cntrs to num_mbm_cntrs. Updated the commit message. Moved the patch after mbm_mode is introduced. v4: Changed the counter name to num_cntrs. And few text changes. v3: Changed the field name to mbm_assign_cntrs. v2: Changed the field name to mbm_assignable_counters from abmc_counter. --- Documentation/arch/x86/resctrl.rst | 12 ++++++++++++ arch/x86/kernel/cpu/resctrl/monitor.c | 1 + arch/x86/kernel/cpu/resctrl/rdtgroup.c | 16 ++++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/re= sctrl.rst index a93d7980e25f..2f3a86278e84 100644 --- a/Documentation/arch/x86/resctrl.rst +++ b/Documentation/arch/x86/resctrl.rst @@ -290,6 +290,18 @@ with the following files: mbm_local_bytes may report 'Unavailable' if there is no counter associated with that event. =20 +"num_mbm_cntrs": + The number of monitoring counters available for assignment when the + architecture supports mbm_cntr_assign mode. + + The resctrl file system supports tracking up to two memory bandwidth + events per monitoring group: mbm_total_bytes and/or mbm_local_bytes. + Up to two counters can be assigned per monitoring group, one for each + memory bandwidth event. More monitoring groups can be tracked by + assigning one counter per monitoring group. However, doing so limits + memory bandwidth tracking to a single memory bandwidth event per + monitoring group. + "max_threshold_occupancy": Read/write file provides the largest value (in bytes) at which a previously used LLC_occupancy diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 9209fb3dc78f..e0d8080dcdcf 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -1236,6 +1236,7 @@ int __init rdt_get_mon_l3_config(struct rdt_resource = *r) r->mon.mbm_cntr_assignable =3D true; cpuid_count(0x80000020, 5, &eax, &ebx, &ecx, &edx); r->mon.num_mbm_cntrs =3D (ebx & GENMASK(15, 0)) + 1; + resctrl_file_fflags_init("num_mbm_cntrs", RFTYPE_MON_INFO); } } =20 diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index f25ff1430014..339bb0b09a82 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -869,6 +869,16 @@ static int rdtgroup_mbm_assign_mode_show(struct kernfs= _open_file *of, return 0; } =20 +static int rdtgroup_num_mbm_cntrs_show(struct kernfs_open_file *of, + struct seq_file *s, void *v) +{ + struct rdt_resource *r =3D of->kn->parent->priv; + + seq_printf(s, "%d\n", r->mon.num_mbm_cntrs); + + return 0; +} + #ifdef CONFIG_PROC_CPU_RESCTRL =20 /* @@ -1940,6 +1950,12 @@ static struct rftype res_common_files[] =3D { .seq_show =3D rdtgroup_cpus_show, .fflags =3D RFTYPE_BASE, }, + { + .name =3D "num_mbm_cntrs", + .mode =3D 0444, + .kf_ops =3D &rdtgroup_kf_single_ops, + .seq_show =3D rdtgroup_num_mbm_cntrs_show, + }, { .name =3D "cpus_list", .mode =3D 0644, --=20 2.34.1 From nobody Mon Nov 25 04:41:22 2024 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2074.outbound.protection.outlook.com [40.107.243.74]) (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 E52FE20C493; Tue, 29 Oct 2024 23:23:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.74 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244233; cv=fail; b=bSEiVsDAoMtrrBl6tdqClK171Jg4FqNXOine1dXGKnEgO+OgBct34VoHE5vauKfcWJJrXZmRqhdREdtX+naGCMV7Dx811C9l5414UZaXasmn9y+lsYCIWygBniJ36NrFBzuRJM2Yeo1nNsm2jqSijiSoO1+iKCKAvT18tDw20eA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244233; c=relaxed/simple; bh=nCuO+Vv2mgcXXbVfbB3I5v85C3HVDXBVS9FASdUajS4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=mhSX4wjK6pCrpj3Mpp818SDW6Fi9qCX/mZQTohA9+KL7EcJ3jNmuGJWI6X6ulBTatoTFUEYckO6X8SYsQ1PH8Oe2y3E1ElXu36+1XroDcI2yfUXOmR22mtUpzkVRLHo0lKs0reLwfM5l47elmjO3uMmk3BrU+QoVw3M3VEBaQXY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=2jaWM5i9; arc=fail smtp.client-ip=40.107.243.74 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) header.d=amd.com header.i=@amd.com header.b="2jaWM5i9" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=J5PhOPYWpJJLqkzSe1Xlrk6uWwAPNCNw5ZJpsJlTngvVMLFhZnJAnNBJNV0yYMhEiujtx8S2+0o8+Kp96Xk2GFXOh9NOJfKD7MIKoCi4Ju4W0oUC/CzZFtrqBW7muNpawa0Wa+CrwJTzVRPPfEkWXQhSYfmv82VG7m9YxC1RfJD1sQoBzo8DhoMG600B2elxQKOXU0lDhq2oT4hjsBtcgne77z49RKaPNGLv5iisKHsPhZvTdBRsQhlg7qpcTgcQFkjAVIdS0WPr7I7xAL/9SSS4MntYzzaOmOzioZtqr6u5YtmK3o7hsiEF7NT/WbZUCFM/t1XLQBEUWVi7zqi+Ww== 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=STS/1bVXOKa7pUwinRf+BzeIByynmucKkkvfKknqXu0=; b=CrTqzxJRbZNxwyu6ZFelwM3ihdZ40dZrQHtZM/wp86OHPyARvO4rM7XyzbX3T3u17gDlHUdbSpzu/nIuGVa5km/a13AOGsFULhSJftMlA3wO+xKi1ibtdDIrFYcsUsaVD+VAbGQrvdz9rzMoWabgBHKkmFM3TDbSAIAQK4USw5TxTpQELQ/SzyllOsMUSN/9kBUUNdslmZcTtNJCM2zMQL2ybFJyHUnofNb/+GeajQkkfA2dFArVVIYAYXVPwKzT2EF6aWvwgDAZ4G7AxNlwD+e/fzH0adELVrFYjRR6WDaHHFMW7i9kdpbqZl7TYOF5OtcwG1FM1+weHTKzlf3aKA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net 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=STS/1bVXOKa7pUwinRf+BzeIByynmucKkkvfKknqXu0=; b=2jaWM5i92qY97jU7mnPpnKBwfXavCpKKMQ35cLCDZ67ikx3rAywu8pl39O1vauxSWpoyTYXUGLSJkkPWnJh+N4p6UEiFoROLD2yre6R2N14CFrzZmaRX7W3ZgrpifLpzf62yoFauiLBaiu3wK5wzzldoLHE5Rcryb4bW1iUGcjo= Received: from SA9PR13CA0111.namprd13.prod.outlook.com (2603:10b6:806:24::26) by MW3PR12MB4361.namprd12.prod.outlook.com (2603:10b6:303:5a::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Tue, 29 Oct 2024 23:23:48 +0000 Received: from SA2PEPF0000150B.namprd04.prod.outlook.com (2603:10b6:806:24:cafe::52) by SA9PR13CA0111.outlook.office365.com (2603:10b6:806:24::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.14 via Frontend Transport; Tue, 29 Oct 2024 23:23:47 +0000 X-MS-Exchange-Authentication-Results: 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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SA2PEPF0000150B.mail.protection.outlook.com (10.167.242.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Tue, 29 Oct 2024 23:23:47 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 29 Oct 2024 18:23:32 -0500 From: Babu Moger To: , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v9 10/26] x86/resctrl: Introduce bitmap mbm_cntr_free_map to track assignable counters Date: Tue, 29 Oct 2024 18:21:42 -0500 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF0000150B:EE_|MW3PR12MB4361:EE_ X-MS-Office365-Filtering-Correlation-Id: b17a2f03-4e09-4870-19fa-08dcf870bd7a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?NNdJ6NOeSjMWGdOozCZQv5UhlP6R3BdcwfqPzt+2+Z9hjTokB9zo/8+zY2eR?= =?us-ascii?Q?Sr/cQlpBUXy08pif+NfU5TZ3rDVZx0M727k4a54dZLtNrwK9lELYkZrhz5MX?= =?us-ascii?Q?ExumD5Hc8EYa114cVoBSfacbz3Skot7QyNN8oHYDbODXz3M5qVB65KFcnVgZ?= =?us-ascii?Q?oWZ8pMQYdzoM4eNpm9tsWxTh4p4Fj22etVhDgH0xNq8ce4Bb+Ng0/E7eYvx6?= =?us-ascii?Q?F7C4t2YRjFwQISZTHRrJUF9lrYdMW+1iDKqqWVA3L4R1tHk8wqwA1cgz7qMe?= =?us-ascii?Q?xBRQr9Ekqnx2tDJNTHjtB/WFaJPJdjz37wC7vUwb9d8sX8Arowrr4TwBIFPc?= =?us-ascii?Q?JxNcW3sTdiLCN39bJGysAhz9XcXaWK0llxU3kNWVzd6icGJwCj9R+Krtw3mI?= =?us-ascii?Q?Vq+w7uCDgoCNGSqDBdvO0CfMaotalCQQtisqwe1NEZkwYYxgm7PGHb+pzr3M?= =?us-ascii?Q?WQjGobLQnnD4lUa4KK27twPdNuaegN3CZKqYvCO6Hje6L0wz9UzwIPceMzsB?= =?us-ascii?Q?c4Hnx18sBUdtQmO7gFBsq2G4EY5wNNek5hkbYUCrqiAahlvKwpF48Tpjw0G7?= =?us-ascii?Q?wBj5uIjuJtT+iMTcyM1QeR6nYTMhYUXsgsJHnYdTZMuu1xP/jdnZ9T/bsAEA?= =?us-ascii?Q?NbLRmO38JiUBt4+vDAva6yrJF+Ik1nFPUEU4mMvINrqyafg4GrdBWlrROTfX?= =?us-ascii?Q?b/CW0HRM6Nnrj/1XlZuEmuXwxYMdPVtu7NQ0bTFJu++DUjAQApleVXSAWSGO?= =?us-ascii?Q?Gt/6pZ6c0Lt0Ou+wWgKw+03lZSw5r8psc9J4nCmcgfsW7P2YYieinmdAmsJa?= =?us-ascii?Q?3/ayYXFUba61fVkmmcoAFH9G85X9HBwIr1a+ocx6Jg/uK2ZkeIKzDrSl7Npq?= =?us-ascii?Q?AmxiJzixgwHXj/MKWYzQlXOATWYzk0aH/UwKy4jZ6tlRIHGLDjK7fH3f0uAX?= =?us-ascii?Q?Ep+uJypZGm95x1FkTeH1EdSYtehmjr2f3tdwCttBaB42uG8S6Ra4h1MNxzIr?= =?us-ascii?Q?tvDJiFpMMT5BUSr0HeOOouPoYWUAc6BuC+bMiFpf6x8460CkGYKrVZBOsQU5?= =?us-ascii?Q?3VjZcgcgijAlFf9pQAgb8JuPMe73Jrf4+nStiuUijMcxIalJE7UB5TckQGmF?= =?us-ascii?Q?Uq5IhQ35YIXuJBq0jd8MakEbyZ7yACkzC3XYLVNpKXS0cgQTkvtma+oA068u?= =?us-ascii?Q?61TpQa+Xd2vEl0c2NQTwEnAQ/zkomcjOtw95YFDAIa1/xP1e3goALnAl/W0l?= =?us-ascii?Q?jzNjLMhLDnfTlIQBpIv7afdmE2Vyn4R7Z61rom9muDmMaN9hgDQtGZ+PmPhW?= =?us-ascii?Q?VeVPlosFsW/NN8JJym8A3Pfml2pVOYkQJpHej7PAEpSbhngTgDf1BPh/sM1C?= =?us-ascii?Q?uu6Q0A0MN1FuT1YgLc3DQnsljRKm4N0d+e+XXVZ4KpRV5NixTg=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(376014)(7416014)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 23:23:47.7907 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b17a2f03-4e09-4870-19fa-08dcf870bd7a 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF0000150B.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4361 Content-Type: text/plain; charset="utf-8" Hardware provides a set of counters when mbm_assign_mode is supported. These counters are assigned to the MBM monitoring events of a CTRL_MON or MON group that needs to be tracked. The kernel must manage and track the available counters. Introduce mbm_cntr_free_map bitmap to track available counters and set of routines to allocate and free the counters. dom_data_init() requires mbm_cntr_assign state to initialize mbm_cntr_free_map bitmap. Move dom_data_init() after mbm_cntr_assign detection. Signed-off-by: Babu Moger Reviewed-by: Reinette Chatre --- v9: Commit message update and kernel doc update. v8: Moved the init and exit functionality inside dom_data_init() and dom_data_exit() respectively. v7: Removed the static allocation and now allocating bitmap mbm_cntr_free_m= ap dynamically. Passed the struct rdt_resource mbm_cntr_alloc and mbm_cntr_free. Removed the reference of ABMC and changed it mbm_cntr_assign. Few other text changes. v6: Removed the variable mbm_cntrs_free_map_len. This is not required. Removed the call mbm_cntrs_init() in arch code. This needs to be done at higher level. Used DECLARE_BITMAP to initialize mbm_cntrs_free_map. Moved all the counter interfaces mbm_cntr_alloc() and mbm_cntr_free() in here as part of separating arch and fs bits. v5: Updated the comments and commit log. Few renames num_cntrs_free_map -> mbm_cntrs_free_map num_cntrs_init -> mbm_cntrs_init Added initialization in rdt_get_tree because the default ABMC enablement happens during the init. v4: Changed the name to num_cntrs where applicable. Used bitmap apis. Added more comments for the globals. v3: Changed the bitmap name to assign_cntrs_free_map. Removed abmc from the name. v2: Changed the bitmap name to assignable_counter_free_map from abmc_counter_free_map. --- arch/x86/kernel/cpu/resctrl/core.c | 2 +- arch/x86/kernel/cpu/resctrl/internal.h | 4 ++- arch/x86/kernel/cpu/resctrl/monitor.c | 49 ++++++++++++++++++++++---- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 19 ++++++++++ include/linux/resctrl.h | 2 ++ 5 files changed, 67 insertions(+), 9 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 9603f5cb483c..02ccb4d2955d 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -1140,7 +1140,7 @@ static void __exit resctrl_exit(void) rdtgroup_exit(); =20 if (r->mon_capable) - rdt_put_mon_l3_config(); + rdt_put_mon_l3_config(r); } =20 __exitcall(resctrl_exit); diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index c07a93da31cc..8ab59d59c15a 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -633,7 +633,7 @@ void closid_free(int closid); int alloc_rmid(u32 closid); void free_rmid(u32 closid, u32 rmid); int __init rdt_get_mon_l3_config(struct rdt_resource *r); -void __exit rdt_put_mon_l3_config(void); +void __exit rdt_put_mon_l3_config(struct rdt_resource *r); bool __init rdt_cpu_has(int flag); void mon_event_count(void *info); int rdtgroup_mondata_show(struct seq_file *m, void *arg); @@ -654,6 +654,8 @@ void __check_limbo(struct rdt_mon_domain *d, bool force= _free); void rdt_domain_reconfigure_cdp(struct rdt_resource *r); void __init resctrl_file_fflags_init(const char *config, unsigned long fflags); +int mbm_cntr_alloc(struct rdt_resource *r); +void mbm_cntr_free(struct rdt_resource *r, u32 cntr_id); void rdt_staged_configs_clear(void); bool closid_allocated(unsigned int closid); int resctrl_find_cleanest_closid(void); diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index e0d8080dcdcf..185ac210d46e 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -983,6 +983,27 @@ void mbm_setup_overflow_handler(struct rdt_mon_domain = *dom, unsigned long delay_ schedule_delayed_work_on(cpu, &dom->mbm_over, delay); } =20 +/* + * Bitmap to track the available hardware counters when operating in + * "mbm_cntr_assign" mode. A hardware counter can be assigned to a RMID, + * event pair. + */ +static __init unsigned long *mbm_cntrs_init(struct rdt_resource *r) +{ + r->mon.mbm_cntr_free_map =3D bitmap_zalloc(r->mon.num_mbm_cntrs, + GFP_KERNEL); + if (r->mon.mbm_cntr_free_map) + bitmap_fill(r->mon.mbm_cntr_free_map, r->mon.num_mbm_cntrs); + + return r->mon.mbm_cntr_free_map; +} + +static __exit void mbm_cntrs_exit(struct rdt_resource *r) +{ + bitmap_free(r->mon.mbm_cntr_free_map); + r->mon.mbm_cntr_free_map =3D NULL; +} + static __init int dom_data_init(struct rdt_resource *r) { u32 idx_limit =3D resctrl_arch_system_num_rmid_idx(); @@ -1020,6 +1041,17 @@ static __init int dom_data_init(struct rdt_resource = *r) goto out_unlock; } =20 + if (r->mon.mbm_cntr_assignable && !mbm_cntrs_init(r)) { + if (IS_ENABLED(CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID)) { + kfree(closid_num_dirty_rmid); + closid_num_dirty_rmid =3D NULL; + } + kfree(rmid_ptrs); + rmid_ptrs =3D NULL; + err =3D -ENOMEM; + goto out_unlock; + } + for (i =3D 0; i < idx_limit; i++) { entry =3D &rmid_ptrs[i]; INIT_LIST_HEAD(&entry->list); @@ -1044,7 +1076,7 @@ static __init int dom_data_init(struct rdt_resource *= r) return err; } =20 -static void __exit dom_data_exit(void) +static void __exit dom_data_exit(struct rdt_resource *r) { mutex_lock(&rdtgroup_mutex); =20 @@ -1056,6 +1088,9 @@ static void __exit dom_data_exit(void) kfree(rmid_ptrs); rmid_ptrs =3D NULL; =20 + if (r->mon.mbm_cntr_assignable) + mbm_cntrs_exit(r); + mutex_unlock(&rdtgroup_mutex); } =20 @@ -1210,10 +1245,6 @@ int __init rdt_get_mon_l3_config(struct rdt_resource= *r) */ resctrl_rmid_realloc_threshold =3D resctrl_arch_round_mon_val(threshold); =20 - ret =3D dom_data_init(r); - if (ret) - return ret; - if (rdt_cpu_has(X86_FEATURE_BMEC)) { u32 eax, ebx, ecx, edx; =20 @@ -1240,6 +1271,10 @@ int __init rdt_get_mon_l3_config(struct rdt_resource= *r) } } =20 + ret =3D dom_data_init(r); + if (ret) + return ret; + l3_mon_evt_init(r); =20 r->mon_capable =3D true; @@ -1247,9 +1282,9 @@ int __init rdt_get_mon_l3_config(struct rdt_resource = *r) return 0; } =20 -void __exit rdt_put_mon_l3_config(void) +void __exit rdt_put_mon_l3_config(struct rdt_resource *r) { - dom_data_exit(); + dom_data_exit(r); } =20 void __init intel_rdt_mbm_apply_quirk(void) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 339bb0b09a82..a4b92476f501 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -185,6 +185,25 @@ bool closid_allocated(unsigned int closid) return !test_bit(closid, &closid_free_map); } =20 +int mbm_cntr_alloc(struct rdt_resource *r) +{ + int cntr_id; + + cntr_id =3D find_first_bit(r->mon.mbm_cntr_free_map, + r->mon.num_mbm_cntrs); + if (cntr_id >=3D r->mon.num_mbm_cntrs) + return -ENOSPC; + + __clear_bit(cntr_id, r->mon.mbm_cntr_free_map); + + return cntr_id; +} + +void mbm_cntr_free(struct rdt_resource *r, u32 cntr_id) +{ + __set_bit(cntr_id, r->mon.mbm_cntr_free_map); +} + /** * rdtgroup_mode_by_closid - Return mode of resource group with closid * @closid: closid if the resource group diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index f11d6fdfd977..afe3b22d3e60 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -187,12 +187,14 @@ enum resctrl_scope { * @num_rmid: Number of RMIDs available * @num_mbm_cntrs: Number of assignable monitoring counters * @mbm_cntr_assignable:Is system capable of supporting monitor assignment? + * @mbm_cntr_free_map: Bitmap of free MBM counters * @evt_list: List of monitoring events */ struct resctrl_mon { int num_rmid; int num_mbm_cntrs; bool mbm_cntr_assignable; + unsigned long *mbm_cntr_free_map; struct list_head evt_list; }; =20 --=20 2.34.1 From nobody Mon Nov 25 04:41:22 2024 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2078.outbound.protection.outlook.com [40.107.220.78]) (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 AE94A20C499; Tue, 29 Oct 2024 23:23:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.78 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244237; cv=fail; b=cOwZwlyeo6YDON2ytADM8AgbP/HD3wrQrQK43MBRJf4ptlQ7J62GItvbt/QKbY6dwZyn5HImq1VkYTJVM2gcHVqHGjd5hu+bLXhJNg+NQOX1WwAE0ihkiXBjCF7SY6MjQIf81W+h/OsfJkGo0C6cNKiOfoZpNiXzaL1Gd1mWS4o= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244237; c=relaxed/simple; bh=f/BSWxa9+GBQgRmW85N1XH4jjYKGe7jn0Xzu7pUeHQU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=k53N3WzVHaff1YIqi2ThHUWKPLrgkdgqjtLPT9ef7pVjmKyTVSRebCYdqP6vtw8z3xfDn1qA6+Dh6BJ78LxeltaQQN98sVhFj4dr1amtvo7DY9a4G/AKxpLZ6PNFrksUtx3NRftiOUTqltEsNnzYkoUWnbfy+zCTxA6IwznKt6g= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=nq6aVtIl; arc=fail smtp.client-ip=40.107.220.78 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) header.d=amd.com header.i=@amd.com header.b="nq6aVtIl" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nxVlIbJo5AsaedNwRX0H3x9v6Ss6AAhvGKLjt+FblGk+XhNZeP5ZeKcQkAWeHLQOE5M+cw6MjC9+UtfSr8f7BWPUiml/WXS5j012BJfEgDLU1KRUWVOcGjAxK5jrPRXE7qwFL4gINnPB57/DnsggXvbCKjcFXIQb9+1k31p8kRZk5mSTlCE6hfml0o74reCPCX2QFclgXTPhoVgAFpFxphFtEofsqXvhRi9Wj/aHL20nCVy4drJotIjddGIPY79delDRMDKH16lUfQYTuRh4XHvuGv5Ridb8shYY525sYf8UOET+spyBBmxvCVaAfYScTat2S4DJeRX1GLCwo7ZqBQ== 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=Hj1mrtz0YnCm0z+g2Sz7o4rw1L/++YHoW4GU6JHW68Y=; b=PnhBcqetpHngGwSXt1+cq4Hiu0tjXRxsCvCyYXz722uxnsD3IE/gd1DpXUHPdSvavMnbtEMxQdyffAxxp0stg6jSBM3lIABEBkiYCPh95DyWmilCm7EjhuWO3HX2NtVN7gH6/6D1xiACqyTG5YdBD+V8fGl7kUhJfDYa9U4LIb0kLjIVRfFrS8qQkzJgqSvE/SDDqeVYDKV42L8mRILroaQHRf5pOHcs77KjrQpa1w8KBTtnFrXnW0bm6ZrM0oeiqzVZNGt8wIAYFmDrETlvbtpVWpYnSRQNVvg3cz59nSShGsTrjEIKl0aQlQCP0lCnboe0+pRTLOFWcP8Jh7GiOQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net 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=Hj1mrtz0YnCm0z+g2Sz7o4rw1L/++YHoW4GU6JHW68Y=; b=nq6aVtIlh8L+J79KQWR7v0AeMuJnTPybIsOGXlfxDEwiRVWMoUx6EjiX8GQjLY0u8jzqVok0zkvdKcPT02P5Jd2ZKd0q0se80PJPVwzCqsgngRCiXy0bLoNU+k1+Y0sgGEp6UAcvG3QBoM0Ofvw0UJXvpjMO+XWBEIct6IZa8JM= Received: from SA9PR13CA0109.namprd13.prod.outlook.com (2603:10b6:806:24::24) by CH3PR12MB7545.namprd12.prod.outlook.com (2603:10b6:610:146::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20; Tue, 29 Oct 2024 23:23:49 +0000 Received: from SA2PEPF0000150B.namprd04.prod.outlook.com (2603:10b6:806:24:cafe::fa) by SA9PR13CA0109.outlook.office365.com (2603:10b6:806:24::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.13 via Frontend Transport; Tue, 29 Oct 2024 23:23:48 +0000 X-MS-Exchange-Authentication-Results: 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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SA2PEPF0000150B.mail.protection.outlook.com (10.167.242.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Tue, 29 Oct 2024 23:23:48 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 29 Oct 2024 18:23:41 -0500 From: Babu Moger To: , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v9 11/26] x86/resctrl: Introduce mbm_total_cfg and mbm_local_cfg in struct rdt_hw_mon_domain Date: Tue, 29 Oct 2024 18:21:43 -0500 Message-ID: <9df47857dabab2c2a21b98c77322b430c8d9dce1.1730244116.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF0000150B:EE_|CH3PR12MB7545:EE_ X-MS-Office365-Filtering-Correlation-Id: e2ac636d-4ac6-4975-b0a1-08dcf870be12 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?mojmUVLqpz5O/Bp0LG2rNYsWJkUx5LV13ME62pYJnWq7fkWVAB9G12as7ldE?= =?us-ascii?Q?36EENpcDw1tcoV+97p3sA0HmtJFgQg/20wQdlTkZS9k/FwJVTZIyoHa8rfcN?= =?us-ascii?Q?KClyrD93HFi7ybVy3f7wk8pDxFmabHPJM//kiI3/QeOXJjifT10K6kmI3wE7?= =?us-ascii?Q?QfWnOceTfTxxvwAAWUdL73eUPBwzqbMa0WNaeDYuDNmKoeb/3Dxtv9DdUQ3P?= =?us-ascii?Q?n4trr0Jai0ae+2LAukY8wGJEH1H8peH+ZN6jcWpvnyR4cMIdzHB++urVj4qK?= =?us-ascii?Q?tmIkUkbvRxJrplximb6mIQgM0HpJcR4cOpjdJaIyXnuqlVoR+ghpN0fMN/gJ?= =?us-ascii?Q?ChI21CExhi9pvP20LpVZkrL+Tp7baOb5k9pQL7or6idAnQYHrwLmawqnJWZL?= =?us-ascii?Q?O8EvqcCIFLaBypEKIWPo6X2lUglKNVdVu9QUjfLMjMZ3brBAOtNcZda8tAYl?= =?us-ascii?Q?aTl40L/9EnJUvvtsRru4JgrLnoeCWFcdccRvxHRP6oDiJ+q4RN7IFnsDWIIF?= =?us-ascii?Q?WC0aw8NYcM/b4pNRqlqs0JncnJh0nKViy5M+01SDvHneLU1uq+zYFZC6W8cQ?= =?us-ascii?Q?LvQV+1eMhOK4VJk0MYeb3BB4fpjljMXnP2aPOPlw2NzerlYZsHg6KcKeWN31?= =?us-ascii?Q?6Z3HB9GAl7zTNBwTN6mYzuxAs0G5/dzqJCsqpAVh7MSGO1Kl8p5oONu4g9WG?= =?us-ascii?Q?0bo0cHLbGSBSXFkRdjXrqHtJYOxthjlFp0QYBbpCbEuXxg3T1gf0uieiSUlL?= =?us-ascii?Q?+6HcjiZXPPRa3YDuzTY57z3w0esQp8xoYipXE3ciJsvTDuuJ7HaR36F5t0Rs?= =?us-ascii?Q?onD79bEAjpXS3nLvdCb3IxahZY/qKuR9vB44U+nIwP96EHsIsv4tDW7BGwDZ?= =?us-ascii?Q?sLsVdOALZMR2feZ36wXPfOsXPHfVvrGSfNAWaNPdlb0oIac8B1KeDhkMU0eu?= =?us-ascii?Q?XBhxHXiTM6aOgl2brALeb4Bc+bUC6EQu7Zd98N+QnW1Nu+zBRtG+XCw+jJiE?= =?us-ascii?Q?PIIZIL7EHVqYdYwNEfB3hqAtM+JTKezmQJKo8vRyCXTNGntjhVXMQF3CVIOe?= =?us-ascii?Q?o7RswXFw33PEDGGhcHtBbzO/kpQmGBmo4xtGoD6P5eiIBIsWPbCOY0L5vjo6?= =?us-ascii?Q?CcO5y/EXD67hyhHfgHK9isgSoSEMjgKnhF4AsdkmEO54IiVnEZHne5ZFteT4?= =?us-ascii?Q?yixUqKoFPEj9YpfCB3RtAY4zCFUVxK0HDlvhRFAhMpT/p0HnQS6fv2xbqJTP?= =?us-ascii?Q?lGxyhLsJSt7LcfdE+PXedOo8S3Y+vhaEcdNCDHI6oIzcMaaiskMvwOt0Z7iD?= =?us-ascii?Q?7AvjCfyTItjOJzF6ggwClB6yMzCAJJlUjxZUevhDQCxeO69J1tdn8G8hNC2x?= =?us-ascii?Q?P6zKLWkgNd3bgoytuHcRYR+YMmeUirThC1140VRi+5BrY1RDLw=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(376014)(7416014)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 23:23:48.7908 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e2ac636d-4ac6-4975-b0a1-08dcf870be12 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF0000150B.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB7545 Content-Type: text/plain; charset="utf-8" If the BMEC (Bandwidth Monitoring Event Configuration) feature is supported, the bandwidth events can be configured to track specific events. The event configuration is domain specific. ABMC (Assignable Bandwidth Monitoring Counters) feature needs event configuration information to assign a hardware counter to an RMID. Event configurations are not stored in resctrl but instead always read from or written to hardware directly when prompted by user space. Read the event configuration from the hardware during the domain initialization. Save the configuration value in struct rdt_hw_mon_domain, so it can be used for counter assignment. Signed-off-by: Babu Moger Reviewed-by: Reinette Chatre --- v9: Added Reviewed-by tag. No other changes. v8: Renamed resctrl_mbm_evt_config_init() to arch_mbm_evt_config_init() Minor commit message update. v7: Fixed initializing INVALID_CONFIG_VALUE to mbm_local_cfg in case of err= or. v6: Renamed resctrl_arch_mbm_evt_config -> resctrl_mbm_evt_config_init Initialized value to INVALID_CONFIG_VALUE if it is not configurable. Minor commit message update. v5: Exported mon_event_config_index_get. Renamed arch_domain_mbm_evt_config to resctrl_arch_mbm_evt_config. v4: Read the configuration information from the hardware to initialize. Added few commit messages. Fixed the tab spaces. v3: Minor changes related to rebase in mbm_config_write_domain. v2: No changes. --- arch/x86/kernel/cpu/resctrl/core.c | 2 ++ arch/x86/kernel/cpu/resctrl/internal.h | 9 +++++++++ arch/x86/kernel/cpu/resctrl/monitor.c | 26 ++++++++++++++++++++++++++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 4 +--- 4 files changed, 38 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 02ccb4d2955d..11cba9f35945 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -632,6 +632,8 @@ static void domain_add_cpu_mon(int cpu, struct rdt_reso= urce *r) =20 arch_mon_domain_online(r, d); =20 + arch_mbm_evt_config_init(hw_dom); + if (arch_domain_mbm_alloc(r->mon.num_rmid, hw_dom)) { mon_domain_free(hw_dom); return; diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 8ab59d59c15a..add8e84b483e 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -56,6 +56,9 @@ /* Max event bits supported */ #define MAX_EVT_CONFIG_BITS GENMASK(6, 0) =20 +#define INVALID_CONFIG_VALUE U32_MAX +#define INVALID_CONFIG_INDEX UINT_MAX + /* Setting bit 0 in L3_QOS_EXT_CFG enables the ABMC feature. */ #define ABMC_ENABLE_BIT 0 =20 @@ -401,6 +404,8 @@ struct rdt_hw_ctrl_domain { * @d_resctrl: Properties exposed to the resctrl file system * @arch_mbm_total: arch private state for MBM total bandwidth * @arch_mbm_local: arch private state for MBM local bandwidth + * @mbm_total_cfg: MBM total bandwidth configuration + * @mbm_local_cfg: MBM local bandwidth configuration * * Members of this structure are accessed via helpers that provide abstrac= tion. */ @@ -408,6 +413,8 @@ struct rdt_hw_mon_domain { struct rdt_mon_domain d_resctrl; struct arch_mbm_state *arch_mbm_total; struct arch_mbm_state *arch_mbm_local; + u32 mbm_total_cfg; + u32 mbm_local_cfg; }; =20 static inline struct rdt_hw_ctrl_domain *resctrl_to_arch_ctrl_dom(struct r= dt_ctrl_domain *r) @@ -656,6 +663,8 @@ void __init resctrl_file_fflags_init(const char *config, unsigned long fflags); int mbm_cntr_alloc(struct rdt_resource *r); void mbm_cntr_free(struct rdt_resource *r, u32 cntr_id); +void arch_mbm_evt_config_init(struct rdt_hw_mon_domain *hw_dom); +unsigned int mon_event_config_index_get(u32 evtid); void rdt_staged_configs_clear(void); bool closid_allocated(unsigned int closid); int resctrl_find_cleanest_closid(void); diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 185ac210d46e..3996f7528b66 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -1282,6 +1282,32 @@ int __init rdt_get_mon_l3_config(struct rdt_resource= *r) return 0; } =20 +void arch_mbm_evt_config_init(struct rdt_hw_mon_domain *hw_dom) +{ + unsigned int index; + u64 msrval; + + /* + * Read the configuration registers QOS_EVT_CFG_n, where is + * the BMEC event number (EvtID). + */ + if (mbm_total_event.configurable) { + index =3D mon_event_config_index_get(QOS_L3_MBM_TOTAL_EVENT_ID); + rdmsrl(MSR_IA32_EVT_CFG_BASE + index, msrval); + hw_dom->mbm_total_cfg =3D msrval & MAX_EVT_CONFIG_BITS; + } else { + hw_dom->mbm_total_cfg =3D INVALID_CONFIG_VALUE; + } + + if (mbm_local_event.configurable) { + index =3D mon_event_config_index_get(QOS_L3_MBM_LOCAL_EVENT_ID); + rdmsrl(MSR_IA32_EVT_CFG_BASE + index, msrval); + hw_dom->mbm_local_cfg =3D msrval & MAX_EVT_CONFIG_BITS; + } else { + hw_dom->mbm_local_cfg =3D INVALID_CONFIG_VALUE; + } +} + void __exit rdt_put_mon_l3_config(struct rdt_resource *r) { dom_data_exit(r); diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index a4b92476f501..811b477f7710 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -1601,8 +1601,6 @@ struct mon_config_info { u32 mon_config; }; =20 -#define INVALID_CONFIG_INDEX UINT_MAX - /** * mon_event_config_index_get - get the hardware index for the * configurable event @@ -1612,7 +1610,7 @@ struct mon_config_info { * 1 for evtid =3D=3D QOS_L3_MBM_LOCAL_EVENT_ID * INVALID_CONFIG_INDEX for invalid evtid */ -static inline unsigned int mon_event_config_index_get(u32 evtid) +unsigned int mon_event_config_index_get(u32 evtid) { switch (evtid) { case QOS_L3_MBM_TOTAL_EVENT_ID: --=20 2.34.1 From nobody Mon Nov 25 04:41:22 2024 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2077.outbound.protection.outlook.com [40.107.223.77]) (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 7022D20C008; Tue, 29 Oct 2024 23:23:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.77 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244238; cv=fail; b=gQ3IuBbR0t3ahM1yBpqZg3MGEoDa8j7NAqsXBZuDi6NERlCOGIansvIGSs/x/b8Bee2HwNTyYYJzSC/bfWydZI8iiuPE/gJ1OSD1SMkRKk2vZEU6dfYvMblpI4sAbwdTNuu9WtWwS5kxrwZEClJruMsZdYShgjMKcNeURjAJmYU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244238; c=relaxed/simple; bh=D5yaCKTll/trq2ZYQR7HCB4Qd1qrqFEP3YYYQ/2YA7E=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Cty9HPxyqxaZ7K6LkXIvTi8uDtTeUf268XHALXy2BX/Athgsnet7z9zE6Dg/pJXE3QcR9p6LS5C4Afhrl6ll3KGar5Qp3x4QOnjar5sy9bjNET4uiX+D0hgSklH3NO6DYDIKZz0rEHr8n0EIoueG00sehWq9kigc6Bz6LorTe1Y= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=VKZx90VD; arc=fail smtp.client-ip=40.107.223.77 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) header.d=amd.com header.i=@amd.com header.b="VKZx90VD" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=M5jn/nhIC4+2pQ4/GEMIigvlBv/jMW1ySzOV7hLToqOWfhPVysJctufRT3cX1ywmQjMtVJo8WbeTZViOCuHu6CBcHaTXaKskzUfSV7RR7Jv2XosqA0j+TFg8GHWNR0siRpN7l3kDn60KnPaVnKqLvOVbUbWdtZjjSBhqd03Hn5KwXJ7T2e78Wnb/fGz5yMUUgGhO9RIs85L6HjeNGsBAr+Iije1YiUdtm1evAtE5GcXmP2lKH9Q3pu915K9SLfskKBCwJvcqzw2wpkUmitAIiM/cNrPx0LmnU0ixWen3CYxGx8MFp0s6D5UvJbxUnd2jI1eXd7klOuj0582jkHYvsA== 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=tmB33JBfsU1aHxkGxbTudq+cV1CS5o3rY0NIf7+f1qU=; b=owYG7a0/RARMz/bzzQDav4PN94NHV2K3jUsgsb7iHQm7V+DlOjodJ5NkMjPQ9AiLy3im1z6wwVA9xh3XSShkZZcPEvC/gWrAxtQy2x+6tRURTEM80YSxKkbKMyZDgw4qPYA18iu9NExdwQ52lrxfCHh9ab8yIo8BY0NxWf1fSYCpUKGAGlz2mTMziyPV21zEcq0ANd9jUE91I6Pj5rnDJB2qPUG/NnnOscSPXcNsXHeDwHs+5sgzDo1AZ7G34CDSdAy5w5UzOpYCu5MTwhNo5qqPtFrefL0mUUPVICrEX0NtrSFBzyf+FXNbU8XgWQco/QFcCJvhhEjB0hJ1G0WMeA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net 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=tmB33JBfsU1aHxkGxbTudq+cV1CS5o3rY0NIf7+f1qU=; b=VKZx90VDL/DKf1iOcpOtdJ2ZNlA1C5w8VY+RBYXZUgfGoJ3JNIiKLISfhnP+N8txMhT/2BVc+o/JbqhsJn15Y6CZXbNLVH8mZ3D9UC/BdqUzGEnPra7qxmrboXZ14CdwTydtt06fgr2+8ZYWtwjs0GL8bHWvnam4r/yRUwWYcuI= Received: from SA9PR13CA0116.namprd13.prod.outlook.com (2603:10b6:806:24::31) by DS7PR12MB5960.namprd12.prod.outlook.com (2603:10b6:8:7f::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.21; Tue, 29 Oct 2024 23:23:53 +0000 Received: from SA2PEPF0000150B.namprd04.prod.outlook.com (2603:10b6:806:24:cafe::f3) by SA9PR13CA0116.outlook.office365.com (2603:10b6:806:24::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.17 via Frontend Transport; Tue, 29 Oct 2024 23:23:53 +0000 X-MS-Exchange-Authentication-Results: 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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SA2PEPF0000150B.mail.protection.outlook.com (10.167.242.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Tue, 29 Oct 2024 23:23:53 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 29 Oct 2024 18:23:49 -0500 From: Babu Moger To: , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v9 12/26] x86/resctrl: Remove MSR reading of event configuration value Date: Tue, 29 Oct 2024 18:21:44 -0500 Message-ID: <3180058bd0b5f80f8525063698c6d5971165193a.1730244116.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF0000150B:EE_|DS7PR12MB5960:EE_ X-MS-Office365-Filtering-Correlation-Id: 6c07e1ab-dd78-44c1-6c86-08dcf870c0b5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?bx5F3cMS7bPqSe3zcjTrNQ1kjXi4Tqs/NgHP7iR70lWlfBerrKCCUxl1fyzi?= =?us-ascii?Q?smPTYjIjMG7VKiu7ZXWlLqYVYvAFEqU/ZpPogsr6BhknRgvVQ8LqpXyxN5X1?= =?us-ascii?Q?0EsQr0P3wj6xtvfEsNXjwfDkWiq+FYBivQyx5l3nkO4OmHqitCwsQm/tYrMq?= =?us-ascii?Q?tVNucKU3hnXaMYbWSUfDtJRKUqeWDQrqEhydR7vjTxj6Vrgo0Dnqptp0660D?= =?us-ascii?Q?dFufaOkNEgEB9O9fq1yC0yBvKnSAPnPfssiiZU9zFvrV78/LexetQoJBSmWs?= =?us-ascii?Q?pCvDrmfM+JhXUf6LZsJAXjhdgdOIjuXcynKi47G68KjvbwXmC+njftwYm5zL?= =?us-ascii?Q?/Dk0urJf4kjxy4wnXX+/ys32F0qZnDJ6+xbqJR3zArD4yFfvCeqzMx3Ol4kC?= =?us-ascii?Q?JXl1FsdPV0CnYBhNsfWz+y1hBu8+qjcLsubZNkZ5VnOXn0q+djkRDmYXTqpZ?= =?us-ascii?Q?UVqhPe2jNst2XVqprYx+pjMt+fvzvjXRtJrparo3+xGtlcniUDNOWDRQW5NT?= =?us-ascii?Q?5DV/D+U9nIdzHDz1DIeAFlbukLwsNiLZa4kFTGIAxZxx4ivGNRJPV+7JXf8Q?= =?us-ascii?Q?LCbl4bFGmJ5X6A4normpmsGIWX6RLA7yBKPstPWK5OalC8KTFMimDW+H/5yR?= =?us-ascii?Q?4w9eUceOxV7ddAW7C1wa0FWuApXjDQ3YfVsYurNujUEuv22rkZ0jmOCwC0jf?= =?us-ascii?Q?a599RPEW9HLr2tUnhNvMUVRpcwrcQpjHg/aWiLSexxNOu+b9c3y2r3feTwnM?= =?us-ascii?Q?d4xyIOjEDnPbNEqsG+osIrv5uus0njr7F99aVxwLIFPFiVGW7/jPPJ7DgTr7?= =?us-ascii?Q?AUCMDu89IlO7FwfOEXAwY5pE0TNzOnLScGcugFSRnWco/wCsfBVD8OeI8jSw?= =?us-ascii?Q?1drUY2KSyFZ/paF9qG2/KmpUcm6dbUc92Jkg80lM5nraEPSkyuerpV+hBh7E?= =?us-ascii?Q?YDJWdzCJZlbE1/Dcg8W9LhQQtHNbJ3sq+gKC7nLJBfrYUIHQ0pnCURU3necs?= =?us-ascii?Q?C/T9IoYT2TifcSYwuiuT91iTbKxgwl7zbzMqP2nz9tA59FVjOfiWdeoWDSmA?= =?us-ascii?Q?E+YHKeftQfdz5IXgQ66kZ+EesCh7aJYc0uUz2SNfQdw53jpN9KZZsw9SWB1A?= =?us-ascii?Q?jDDgyevLF+1zz5oFoE7NtDtBdIBCXwfEedA9xchHfIEFkh4BesCtcDPlpzNZ?= =?us-ascii?Q?/cA4UDenz0Il+FcHoEEa8Bwt1W1+syBOdKTgWHxPzUEodjDv8CPW+7fIdEAr?= =?us-ascii?Q?Z5+frv+uqo812C8w/xkkEolJ0630200Qn2/3bC5PbGXyYZi6gecO0ygkDHpK?= =?us-ascii?Q?+hIiCWS++c/8UYFEddcnWS/2YMCfBkLx9xNX+t7WjSCSYfez4EShiUYcUVij?= =?us-ascii?Q?VnJv/eeeQvTkpxA1hRvszPyk3YK07tzJ8SJN7ZX2+3aGmhHrhg=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(1800799024)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 23:23:53.2127 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6c07e1ab-dd78-44c1-6c86-08dcf870c0b5 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF0000150B.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB5960 Content-Type: text/plain; charset="utf-8" The event configuration is domain specific and initialized during domain initialization. The values are stored in struct rdt_hw_mon_domain. It is not required to read the configuration register every time user asks for it. Use the value stored in struct rdt_hw_mon_domain instead. Introduce resctrl_arch_mon_event_config_get() and resctrl_arch_mon_event_config_set() to get/set architecture domain specific mbm_total_cfg/mbm_local_cfg values. Signed-off-by: Babu Moger --- v9: Removed QOS_L3_OCCUP_EVENT_ID switch case in resctrl_arch_mon_event_con= fig_set. Fixed a unnecessary space. v8: Renamed resctrl_arch_event_config_get() to resctrl_arch_mon_event_config_get(). resctrl_arch_event_config_set() to resctrl_arch_mon_event_config_set(). v7: Removed check if (val =3D=3D INVALID_CONFIG_VALUE) as resctrl_arch_even= t_config_get already prints warning. Kept the Event config value definitions as is. v6: Fixed inconstancy with types. Made all the types to u32 for config value. Removed few rdt_last_cmd_puts as it is not necessary. Removed unused config value definitions. Few more updates to commit message. v5: Introduced resctrl_arch_event_config_get and resctrl_arch_event_config_get() based on our discussion. https://lore.kernel.org/lkml/68e861f9-245d-4496-a72e-46fc57d19c62@amd.c= om/ v4: New patch. --- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 101 ++++++++++++++----------- include/linux/resctrl.h | 4 + 2 files changed, 60 insertions(+), 45 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 811b477f7710..3a3d98e8ca28 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -1597,10 +1597,55 @@ static int rdtgroup_size_show(struct kernfs_open_fi= le *of, } =20 struct mon_config_info { + struct rdt_mon_domain *d; u32 evtid; u32 mon_config; }; =20 +u32 resctrl_arch_mon_event_config_get(struct rdt_mon_domain *d, + enum resctrl_event_id eventid) +{ + struct rdt_hw_mon_domain *hw_dom =3D resctrl_to_arch_mon_dom(d); + + switch (eventid) { + case QOS_L3_OCCUP_EVENT_ID: + break; + case QOS_L3_MBM_TOTAL_EVENT_ID: + return hw_dom->mbm_total_cfg; + case QOS_L3_MBM_LOCAL_EVENT_ID: + return hw_dom->mbm_local_cfg; + } + + /* Never expect to get here */ + WARN_ON_ONCE(1); + + return INVALID_CONFIG_VALUE; +} + +void resctrl_arch_mon_event_config_set(void *info) +{ + struct mon_config_info *mon_info =3D info; + struct rdt_hw_mon_domain *hw_dom; + unsigned int index; + + index =3D mon_event_config_index_get(mon_info->evtid); + if (index =3D=3D INVALID_CONFIG_INDEX) + return; + + wrmsr(MSR_IA32_EVT_CFG_BASE + index, mon_info->mon_config, 0); + + hw_dom =3D resctrl_to_arch_mon_dom(mon_info->d); + + switch (mon_info->evtid) { + case QOS_L3_MBM_TOTAL_EVENT_ID: + hw_dom->mbm_total_cfg =3D mon_info->mon_config; + break; + case QOS_L3_MBM_LOCAL_EVENT_ID: + hw_dom->mbm_local_cfg =3D mon_info->mon_config; + break; + } +} + /** * mon_event_config_index_get - get the hardware index for the * configurable event @@ -1623,33 +1668,11 @@ unsigned int mon_event_config_index_get(u32 evtid) } } =20 -static void mon_event_config_read(void *info) -{ - struct mon_config_info *mon_info =3D info; - unsigned int index; - u64 msrval; - - index =3D mon_event_config_index_get(mon_info->evtid); - if (index =3D=3D INVALID_CONFIG_INDEX) { - pr_warn_once("Invalid event id %d\n", mon_info->evtid); - return; - } - rdmsrl(MSR_IA32_EVT_CFG_BASE + index, msrval); - - /* Report only the valid event configuration bits */ - mon_info->mon_config =3D msrval & MAX_EVT_CONFIG_BITS; -} - -static void mondata_config_read(struct rdt_mon_domain *d, struct mon_confi= g_info *mon_info) -{ - smp_call_function_any(&d->hdr.cpu_mask, mon_event_config_read, mon_info, = 1); -} - static int mbm_config_show(struct seq_file *s, struct rdt_resource *r, u32= evtid) { - struct mon_config_info mon_info; struct rdt_mon_domain *dom; bool sep =3D false; + u32 val; =20 cpus_read_lock(); mutex_lock(&rdtgroup_mutex); @@ -1658,11 +1681,8 @@ static int mbm_config_show(struct seq_file *s, struc= t rdt_resource *r, u32 evtid if (sep) seq_puts(s, ";"); =20 - memset(&mon_info, 0, sizeof(struct mon_config_info)); - mon_info.evtid =3D evtid; - mondata_config_read(dom, &mon_info); - - seq_printf(s, "%d=3D0x%02x", dom->hdr.id, mon_info.mon_config); + val =3D resctrl_arch_mon_event_config_get(dom, evtid); + seq_printf(s, "%d=3D0x%02x", dom->hdr.id, val); sep =3D true; } seq_puts(s, "\n"); @@ -1693,33 +1713,23 @@ static int mbm_local_bytes_config_show(struct kernf= s_open_file *of, return 0; } =20 -static void mon_event_config_write(void *info) -{ - struct mon_config_info *mon_info =3D info; - unsigned int index; - - index =3D mon_event_config_index_get(mon_info->evtid); - if (index =3D=3D INVALID_CONFIG_INDEX) { - pr_warn_once("Invalid event id %d\n", mon_info->evtid); - return; - } - wrmsr(MSR_IA32_EVT_CFG_BASE + index, mon_info->mon_config, 0); -} =20 static void mbm_config_write_domain(struct rdt_resource *r, struct rdt_mon_domain *d, u32 evtid, u32 val) { struct mon_config_info mon_info =3D {0}; + u32 config_val; =20 /* - * Read the current config value first. If both are the same then + * Check the current config value first. If both are the same then * no need to write it again. */ - mon_info.evtid =3D evtid; - mondata_config_read(d, &mon_info); - if (mon_info.mon_config =3D=3D val) + config_val =3D resctrl_arch_mon_event_config_get(d, evtid); + if (config_val =3D=3D INVALID_CONFIG_VALUE || config_val =3D=3D val) return; =20 + mon_info.d =3D d; + mon_info.evtid =3D evtid; mon_info.mon_config =3D val; =20 /* @@ -1728,7 +1738,8 @@ static void mbm_config_write_domain(struct rdt_resour= ce *r, * are scoped at the domain level. Writing any of these MSRs * on one CPU is observed by all the CPUs in the domain. */ - smp_call_function_any(&d->hdr.cpu_mask, mon_event_config_write, + smp_call_function_any(&d->hdr.cpu_mask, + resctrl_arch_mon_event_config_set, &mon_info, 1); =20 /* diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index afe3b22d3e60..70885a835acb 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -354,6 +354,10 @@ void resctrl_arch_reset_rmid(struct rdt_resource *r, s= truct rdt_mon_domain *d, */ void resctrl_arch_reset_rmid_all(struct rdt_resource *r, struct rdt_mon_do= main *d); =20 +void resctrl_arch_mon_event_config_set(void *info); +u32 resctrl_arch_mon_event_config_get(struct rdt_mon_domain *d, + enum resctrl_event_id eventid); + extern unsigned int resctrl_rmid_realloc_threshold; extern unsigned int resctrl_rmid_realloc_limit; =20 --=20 2.34.1 From nobody Mon Nov 25 04:41:22 2024 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2066.outbound.protection.outlook.com [40.107.102.66]) (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 39E2E209675; Tue, 29 Oct 2024 23:24:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.102.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244259; cv=fail; b=gQb1uur0NIRhPxMz+EA+Y8t/Pf7JCPPBgiMB6PEgnE8AdhO1QQQxKjmubBCehtNW1PzmqJ7yzfUBUv83UTCzZgPNGTp0E/N5BLe6bLc+HMCvcB2EIkWMEOGpf1iawM8Wby34oJKXLMkzJ8zRyW30dIOGsZcJFM6e2d/9Eptv34A= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244259; c=relaxed/simple; bh=XwZpZpM8kdLmgBRdTsCG+djMMTpPXEvNf6sHZhRMAxo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=puxwGWiwDJDR/qIsFRE9RTmAf/wA7azmt0V3WjWVnZF0+DS8bN8286m5vZGAeaxpjFI5G/WiQFV/amwoShFxD+/MHT8IQvT9j8J8HuSDx72OfHzJAU4KuUC4nFoDPqnNiOEmGHg9fu9KQNstZ05qGTg8HuihxA4mtnCFw1aCFjQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=XP1yVebi; arc=fail smtp.client-ip=40.107.102.66 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) header.d=amd.com header.i=@amd.com header.b="XP1yVebi" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dSQqwd/QHVcNXFotusewS1ItzM+doaoIm3CO+HENRxfiEonhIew8bbXYEECyBUxNg9GwSi1Q2HRSvmBQx620Ja6NGnuXrEerCHGu5HUReujsrDusFaJ7SD47QuF3tfBqQxEgob1TdzWZ3AJfOKDQgxRj1QKXOREmk6Y92LP3sXYhKY+1UH8f09p9z7QJXzTKKJJyZUkFyxLnwJ2NgT46fjKOcarWoI6WsYj1wyW/AtsjFC5ftceecauG8lOqLr6GGjBxf1AJETpKagkmlwESRceg4AKnLGJGsCl406nv12zS3Canrzm6V8oSr9NBMhQaNq1qNYrNOPB0vIeX6d14Kw== 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=AHMet9remyTgxk4reXcnkLvXEc7cV51IyQyH2DHDTLE=; b=JeMV59KZPL2J3Mt9i7MEg3+lc8a/XADKkm8TgfMXw7BcLA4bl9SuMwGlKuExkwgu3nIKw4E4YfnruIw/j7R1I5kAvzUOwWJ9OhJ27uqn3b28z4MIB3FXfRIv4TWJ8DfAKJ59vNfcc1LNd1GbFvd0LVoSlZK4L8fkqZpHyiESxrgfDal1hEXEMnrVl7aTpYr59qDQuHGZQzo1Q0EdnT+iikPt1FhrvXO6nlhSM5Min7nJBUq8u/Dr70uRX66i9ZDZcWzolIW7LRhD7XJNTFwyfXfBCe6HoUxpz65g9jCDn5DPUisgdHir+VVhucaJymgBWSkEBB2DbFeKdSLhS1YeUA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net 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=AHMet9remyTgxk4reXcnkLvXEc7cV51IyQyH2DHDTLE=; b=XP1yVebi7VP4m0qQltevz3M5n22jGXN7dRb5WfiroJnWi/NihaLSGH3yl7MQTQGK1VqIMAUa/+Lmtouizn8gy7qbtnwfTjAmT9xcyOg6Xt0mEVDWlUUg2AamukuG90Iwsd+4nJEWTQsq0ZROuBUsD09dtvuTcWOoNrhwnYHr59k= Received: from SN7PR04CA0225.namprd04.prod.outlook.com (2603:10b6:806:127::20) by DM4PR12MB5748.namprd12.prod.outlook.com (2603:10b6:8:5f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.24; Tue, 29 Oct 2024 23:24:14 +0000 Received: from SA2PEPF00001504.namprd04.prod.outlook.com (2603:10b6:806:127:cafe::f1) by SN7PR04CA0225.outlook.office365.com (2603:10b6:806:127::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.26 via Frontend Transport; Tue, 29 Oct 2024 23:24:14 +0000 X-MS-Exchange-Authentication-Results: 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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SA2PEPF00001504.mail.protection.outlook.com (10.167.242.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Tue, 29 Oct 2024 23:24:13 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 29 Oct 2024 18:23:57 -0500 From: Babu Moger To: , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v9 13/26] x86/resctrl: Introduce mbm_cntr_map to track assignable counters at domain Date: Tue, 29 Oct 2024 18:21:45 -0500 Message-ID: <8efab1cffec722b5dd8f302f7c520bc09a1934dc.1730244116.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00001504:EE_|DM4PR12MB5748:EE_ X-MS-Office365-Filtering-Correlation-Id: 7ace1c98-6b5b-44a9-fb43-08dcf870cd13 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|36860700013|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?Lh+wNxOHkhXigURLZQy4TkIYpwuvzXw8067F1WQM/cbT2de4Z4H4w89qBfJV?= =?us-ascii?Q?HvUYpiI56EubH6YO9ODQO5+BZS6XWcH7Dj99xyAHk89YI/9gyYgLhz7O0765?= =?us-ascii?Q?6/IXo4U9MmCOOCMR5D3E5vjHjd/sjhn+LSlOaEiEwkjtJnMkU/+Krxb4CC6D?= =?us-ascii?Q?FrA9q1oySP2ot0Ah4ex9uY8Y5SjF+6mg5/LxBDkutmN0+zcPnE58sMI60hP5?= =?us-ascii?Q?iKn81qF89LbugyrQtN/s26KTCdlX0ugrO8bP/ZO34GO8iQFcNAa1xFgLEIFZ?= =?us-ascii?Q?QXHWOY/p//80yWc4CAhh4fQ8plpd+zjz92aT4xCaxB5DpB4UTXSCs2GDtI/K?= =?us-ascii?Q?dQeFZd+FK8VwldI5y7Ow1LLobb/w3pfiBdGWRUrqVSDTwRK7dYhrssS+MFmB?= =?us-ascii?Q?g4AwRIJU+sGFclAqKw2wzlt7g8mBi9XDdCVMVgOBKvRRIqKiV3j0I1Su6ulp?= =?us-ascii?Q?hGGFwoCBFoxLN0c9ogPhSYH0dHeJN+cuPVe7IvYHqjt/7j4kFtTm2IwjLhP0?= =?us-ascii?Q?iFGlR1kaZcF9HX14Ds215pIYobOxsS1uepX6NGTy9NaAYBs6hxrMy8gHfq8i?= =?us-ascii?Q?FI2/GB+zzAlIjtsd8tfXWB3B+NwervAOjhlRtpml2I7NzDqwxguGz/so4g5i?= =?us-ascii?Q?j0+bQSIQo4SwfnuUhG6M87MJKPgjDCwsOdkIPGobRlT4AiG+iQdfg8l5efdl?= =?us-ascii?Q?cqfjLbsav+Ceh/hLuqZV5Dc/Mrvc8oQYwkMWfOo+6TDqfhcUUs4KAKZEw5X6?= =?us-ascii?Q?Lj1aH8NeinJWSHY7pDSMs0o9cAsW1vBHN7TuOq1DXVv1B4b3eIgAF+vqTYf+?= =?us-ascii?Q?K/BXouUg/Ft4VMTjWCkTMcTQ6flEG6onSvpd3J0Y0sKGzRVBzPOWBt5COxal?= =?us-ascii?Q?ruYONIX+AnFjCFKwxzOa+X3u7pBNvinnk49Eq5BBoAHxpueG6pB+gpSogSuu?= =?us-ascii?Q?CqXBBceg2p0PkViT2LRDlRB5TJZNEO3agEqJGSJCLZiOnC232i9Wi9FCsdvY?= =?us-ascii?Q?BJxEXMQgWcNKNVF4o/vvySMj+U7R/Ls2tYNsc8gd7sxAhpyLA3llSDaN05qu?= =?us-ascii?Q?QvYXyjjGWBkP85qfIWcotbEqGbuc+fvILg0X0OF1FOx67XBJE1v0aoybXlQk?= =?us-ascii?Q?YJADFtIMRfqW2GjHSKIbb99lfzZvV3KaxWQhoJSNjP2n5M0F3R8Ja9abQzyl?= =?us-ascii?Q?wc5csdEVSCSNs+iGYQNhq1PRlhSKkjYiXWazcG8sYhnlq9pKJJoc/YrbnEyQ?= =?us-ascii?Q?oHRmt4feffoP1wi2yrJpZUf26s/YtjHNGeQ9Rlg2akrykmu89MvoSCMnDuOB?= =?us-ascii?Q?Ml2/hac2OejPaYTx/CgqCu0Q7tNPWmi0XT0pZVXzkKBLU0V6Y8ZZKQVr01Z6?= =?us-ascii?Q?FKarwRm0cvR3727qcm4TMAUomppw/OrBj6DG317dwiWBOyWZbQ=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(376014)(36860700013)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 23:24:13.9650 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7ace1c98-6b5b-44a9-fb43-08dcf870cd13 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF00001504.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5748 Content-Type: text/plain; charset="utf-8" The MBM counters are allocated globally and assigned to an RMID, event pair in a resctrl group. It is tracked by mbm_cntr_free_map. Counters are assigned to the domain based on the user input. It needs to be tracked at domain level also. Add the mbm_cntr_map bitmap in struct rdt_mon_domain to keep track of assignment at domain level. The global counter at mbm_cntr_free_map can be released when assignment at all the domains are cleared. Signed-off-by: Babu Moger Reviewed-by: Reinette Chatre --- v9: Added Reviewed-by tag. No other changes. v8: Minor commit message changes. v7: Added check mbm_cntr_assignable for allocating bitmap mbm_cntr_map v6: New patch to add domain level assignment. --- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 10 ++++++++++ include/linux/resctrl.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 3a3d98e8ca28..654cdfee1b00 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -4091,6 +4091,7 @@ static void __init rdtgroup_setup_default(void) =20 static void domain_destroy_mon_state(struct rdt_mon_domain *d) { + bitmap_free(d->mbm_cntr_map); bitmap_free(d->rmid_busy_llc); kfree(d->mbm_total); kfree(d->mbm_local); @@ -4164,6 +4165,15 @@ static int domain_setup_mon_state(struct rdt_resourc= e *r, struct rdt_mon_domain return -ENOMEM; } } + if (is_mbm_enabled() && r->mon.mbm_cntr_assignable) { + d->mbm_cntr_map =3D bitmap_zalloc(r->mon.num_mbm_cntrs, GFP_KERNEL); + if (!d->mbm_cntr_map) { + bitmap_free(d->rmid_busy_llc); + kfree(d->mbm_total); + kfree(d->mbm_local); + return -ENOMEM; + } + } =20 return 0; } diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 70885a835acb..0b8eeb8afc68 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -105,6 +105,7 @@ struct rdt_ctrl_domain { * @cqm_limbo: worker to periodically read CQM h/w counters * @mbm_work_cpu: worker CPU for MBM h/w counters * @cqm_work_cpu: worker CPU for CQM h/w counters + * @mbm_cntr_map: bitmap to track domain counter assignment */ struct rdt_mon_domain { struct rdt_domain_hdr hdr; @@ -116,6 +117,7 @@ struct rdt_mon_domain { struct delayed_work cqm_limbo; int mbm_work_cpu; int cqm_work_cpu; + unsigned long *mbm_cntr_map; }; =20 /** --=20 2.34.1 From nobody Mon Nov 25 04:41:22 2024 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2064.outbound.protection.outlook.com [40.107.244.64]) (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 F1AD920C02F; Tue, 29 Oct 2024 23:24:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.64 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244261; cv=fail; b=mVmE6LCsb9c+Jzy8GmuFp9qfgCwxv/KHcc0ZjtThI6F+P+EF0Jx2S/+WTXOjJFSeV7XZjFuRrch4q1QBYb+edymkFecad51jx2LMJLA3mPNMH8BQv7lAG8SmEjkhzaFIpCoyk3PLClSB3w4cJcvm7cw9vGjfGYZ6Vsaq9NRLgz8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244261; c=relaxed/simple; bh=uKosg+X8JTtiQksnX0ueRWF8Un6v8SRHOD1Kp6m1oqM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=X9ac2UgC52xkgpTtxec1zfKgs+tPkkul1uA9+RpQhu+ocFCsIGoqLZQokc5CZEMTnwYoGhfOUIBkOy28w6U5OScDyjG5xXPzU06Kwu4meXvj39LPeViU9QzDY6Ki7JB704TyosB3vDBgr7zcJRETSUm8NqFijyibv/npGSBfh5k= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=YD9GoiT+; arc=fail smtp.client-ip=40.107.244.64 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) header.d=amd.com header.i=@amd.com header.b="YD9GoiT+" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=iTVW1iRdP/oDAW7JW5gDGJ1Vqsi5oMFy3N2+Z/1XJYQMLOpU0XqUJL6y0R0zdEEwfq5OXELNdq1hRVEkM5vy15vIixOo2zi5ocTocF/Jled8EwtJ4wxWYM3FVuE/Xe13GYY0wF3iwpbnjVKwWbLwcx5/air5Ae+wohFyqnZ4hX7B/0wvwhsOc6mI0YsxThLfF9XLBcXLyhWC3LIi1QVn30ircGlMILY6YUBqUxBrTIOmAJ/eTQ8579VRA/WUrh9Xr5AoovlM0xl2zIeO0TQcqrjdV9fki+JHJkGaiVE6rMjJ3wS5U+X2Ho2Ml4pdQ1KCdOxPScZpP94mU9XpfCzolQ== 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=DDhVrrFoCYPa4Z3w4K6fMGRRMFF7ib7y+dIqc/WR7qU=; b=GPQ4PDDIybGZnUJvGPkpDj/x9ElnzQa6ygBdUBOlSoyWIsFlnZtokpk6xJTUeuqw525iSwo8hcZr2GtgK+wPLFTOBxHJVT1o0MvUYc3wM4PTuZf8DeO5TuJU/OJYaFyHHYuy3j8wkljvQpL+Y6wEmcXeko3v2oQZ0A6tDGijb4/ZAzFgPaTtVlIIxsnaiJiQ8JGxStwOKN+jbTL+jMLZmiMOHMZo8512QSHDqMRtdDWM7Oku1KH44dJP5hoaQg9S2EXBvMaj+ZSxc+4SdBPPDHZMo2D3eVIVAf005rJmZinACqvCxhib+bUzxsZFM4Hz4fA5a3FsCQr6IVtwzTUVoQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net 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=DDhVrrFoCYPa4Z3w4K6fMGRRMFF7ib7y+dIqc/WR7qU=; b=YD9GoiT+KtxY5AFnnqCBU1gxvi4HldLk8ep9dVdi9kEF5bUoULXNdbwAbzpTkZ3YsglloZJYQhoGdpv6ch0uuzXZCGoxZw/bnDG+jaPghPKHMy7DD+TlvDmihNhJS1bghjyHkw+bBr8UR4LZq1S6/qqVu2qj11WjCCvdEmHshPE= Received: from SN7PR04CA0213.namprd04.prod.outlook.com (2603:10b6:806:127::8) by SN7PR12MB8003.namprd12.prod.outlook.com (2603:10b6:806:32a::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.27; Tue, 29 Oct 2024 23:24:16 +0000 Received: from SA2PEPF00001504.namprd04.prod.outlook.com (2603:10b6:806:127:cafe::1c) by SN7PR04CA0213.outlook.office365.com (2603:10b6:806:127::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32 via Frontend Transport; Tue, 29 Oct 2024 23:24:16 +0000 X-MS-Exchange-Authentication-Results: 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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SA2PEPF00001504.mail.protection.outlook.com (10.167.242.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Tue, 29 Oct 2024 23:24:16 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 29 Oct 2024 18:24:06 -0500 From: Babu Moger To: , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v9 14/26] x86/resctrl: Introduce interface to display number of free counters Date: Tue, 29 Oct 2024 18:21:46 -0500 Message-ID: <265f3700ac0c0d33703806fdc3d096b08c992efc.1730244116.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00001504:EE_|SN7PR12MB8003:EE_ X-MS-Office365-Filtering-Correlation-Id: e3c28c17-312b-4e4a-6312-08dcf870ce5f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|36860700013|376014|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?UgpiwojA2v3RO3n/0mBPfqlU6exAmjYz11YpnUJQnrmXZaYu/APFu3x4fp3X?= =?us-ascii?Q?8BzkvpW1EUsRaotKW26I9TF8Dnm41QkFU3Sex6UTbUM1FIYcKXpNdZCJhdGx?= =?us-ascii?Q?taYtv5GvGBS4WbSP9Q/ymnsKHiCZDBYgoPWriSJ6tLNtgNZCQegfPX+qbD8d?= =?us-ascii?Q?2d6sUSfRkGcnhk8qEprKh7CgTRx9wp4GELuXVQRpHgXRvTPtBIm9WyuGrO/K?= =?us-ascii?Q?N6A+oXl3xB4ygX32C/LuTAyEV7rnAWQmpi4qcrpuEeI6xJhmlUHRjEeOTdmL?= =?us-ascii?Q?U7CtXk0KAh0goX0eb2ggt724p1dCKkdlEdy7UJbPh+A5tK540FZKky5IWDOO?= =?us-ascii?Q?TwDQhe7khj9W7minSdUJmIWXupmV9e8zD9fhjqtkg8g+Uqa1WepSvQP7tJ/t?= =?us-ascii?Q?vBKNNRIOdK03Sb8CuTZ1K5EQsuaFW65DtHwNLaeY3TPHYoYpWbHHSfZwYwca?= =?us-ascii?Q?o2bcVXfVm9W4eAUZeDkuwojj99OSyl1XtKhUuYYxXEKGfzpTUoZOVJx/pphi?= =?us-ascii?Q?pDK/0hzHfVewoHVFgHwb9H+aNGHgROn1e+aA5KYNWUoBxawB2UBjWN6WgqR0?= =?us-ascii?Q?Jh0fVrazgPvee5I09tMea5EH2nmiNit0WxC2QZMIDXYkeCq30NdtA16Y6skj?= =?us-ascii?Q?1qUdD/QnJlVTjUiSfmCHEhnCkHKKfsThpZ9PlUtYfKTxmGlCc9Tx9asPRYke?= =?us-ascii?Q?93uA+dsQGJUERyzN9SKpvn1VklBJs1MJwl1y5f1nLNC5B+zoa3HN5ODeFvwg?= =?us-ascii?Q?cHYqGjEumVZS+QS0+M5l2m0vv/3H3pkg+ELMSXj4Zql8N/N5xfYNKZMNKgEC?= =?us-ascii?Q?6CPHjpFuF10ElwBebPVXZrZV1rMU5EqCIEvr1BC76o2RlT+pRKhtLEBfinFU?= =?us-ascii?Q?XXamrue8lIJS39oPSoti9IeYQb+fY9JvTGibdB2CkXB9gfC0szboTLIcYscO?= =?us-ascii?Q?A80nAk0BFiiF9o55G9QXmOf15tBskQvvHbN31SxI0DubC5iv0gdJtThkMB1S?= =?us-ascii?Q?UnxN5ihWCQNJf24bxDJXfFPtacMnEvvBZ0T/CiSTNrxRhNVjd/6/tUbgqKgk?= =?us-ascii?Q?e4wVz0ovORduFQb6Gwl+wGQWQdB6X8RnQWB76HzastcKdAtO7Kn4ssS7Y1FD?= =?us-ascii?Q?I/UUc/uH/YcRBaM58b6NzZwCsQUOo1hLf7E0lkqLm+muSsaaFRvT39IRdd38?= =?us-ascii?Q?J4gyIm4izopfe/71ph3mgKEKu+6LJ7RmIMn9yjY4dFeHJVGVGE1ZWhNOphSL?= =?us-ascii?Q?772LR1rVr4b1DQGfKj8yfphNU1vGVzZqE4D6A0LsiC2AaShdwd1GPeTKL5Ji?= =?us-ascii?Q?zaJmyXyb5czEBGIZ1Tsr3OnkQ13eua0OAg/CkjVhRWX8UtglZuMeu3TQjvYx?= =?us-ascii?Q?tZqYtdR5QqrYxjNcVG9HCR40yA4YALq8AM9CE85zi02GjyGw7A=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(36860700013)(376014)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 23:24:16.1369 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e3c28c17-312b-4e4a-6312-08dcf870ce5f 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF00001504.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB8003 Content-Type: text/plain; charset="utf-8" Provide the interface to display the number of free monitoring counters available for assignment in each doamin when mbm_cntr_assign is supported. Signed-off-by: Babu Moger --- v9: New patch. --- Documentation/arch/x86/resctrl.rst | 4 ++++ arch/x86/kernel/cpu/resctrl/monitor.c | 1 + arch/x86/kernel/cpu/resctrl/rdtgroup.c | 33 ++++++++++++++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/re= sctrl.rst index 2f3a86278e84..2bc58d974934 100644 --- a/Documentation/arch/x86/resctrl.rst +++ b/Documentation/arch/x86/resctrl.rst @@ -302,6 +302,10 @@ with the following files: memory bandwidth tracking to a single memory bandwidth event per monitoring group. =20 +"available_mbm_cntrs": + The number of free monitoring counters available assignment in each domain + when the architecture supports mbm_cntr_assign mode. + "max_threshold_occupancy": Read/write file provides the largest value (in bytes) at which a previously used LLC_occupancy diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 3996f7528b66..e8d38a963f39 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -1268,6 +1268,7 @@ int __init rdt_get_mon_l3_config(struct rdt_resource = *r) cpuid_count(0x80000020, 5, &eax, &ebx, &ecx, &edx); r->mon.num_mbm_cntrs =3D (ebx & GENMASK(15, 0)) + 1; resctrl_file_fflags_init("num_mbm_cntrs", RFTYPE_MON_INFO); + resctrl_file_fflags_init("available_mbm_cntrs", RFTYPE_MON_INFO); } } =20 diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 654cdfee1b00..ef0c1246fa2a 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -898,6 +898,33 @@ static int rdtgroup_num_mbm_cntrs_show(struct kernfs_o= pen_file *of, return 0; } =20 +static int rdtgroup_available_mbm_cntrs_show(struct kernfs_open_file *of, + struct seq_file *s, void *v) +{ + struct rdt_resource *r =3D of->kn->parent->priv; + struct rdt_mon_domain *dom; + bool sep =3D false; + u32 val; + + cpus_read_lock(); + mutex_lock(&rdtgroup_mutex); + + list_for_each_entry(dom, &r->mon_domains, hdr.list) { + if (sep) + seq_puts(s, ";"); + + val =3D r->mon.num_mbm_cntrs - hweight64(*dom->mbm_cntr_map); + seq_printf(s, "%d=3D%d", dom->hdr.id, val); + sep =3D true; + } + seq_puts(s, "\n"); + + mutex_unlock(&rdtgroup_mutex); + cpus_read_unlock(); + + return 0; +} + #ifdef CONFIG_PROC_CPU_RESCTRL =20 /* @@ -1984,6 +2011,12 @@ static struct rftype res_common_files[] =3D { .kf_ops =3D &rdtgroup_kf_single_ops, .seq_show =3D rdtgroup_num_mbm_cntrs_show, }, + { + .name =3D "available_mbm_cntrs", + .mode =3D 0444, + .kf_ops =3D &rdtgroup_kf_single_ops, + .seq_show =3D rdtgroup_available_mbm_cntrs_show, + }, { .name =3D "cpus_list", .mode =3D 0644, --=20 2.34.1 From nobody Mon Nov 25 04:41:22 2024 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2061.outbound.protection.outlook.com [40.107.92.61]) (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 99EC620C03F; Tue, 29 Oct 2024 23:24:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.61 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244262; cv=fail; b=bd8ehJeWihCp10tvnN0seLexIqhUWYAgZt2gGtTkD6ZgIu+W0tgmErxW/do95MYfMd5kPbjAiz4Ppzcmf0S2QRUTtLoI7GoKYnB/UPWRaf/QL/sRc/r8NRYiwQG3R3L4dZYsjC43hv7Ps8xZiliAmt8ZhZiItLZl9FtNWw3Qm88= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244262; c=relaxed/simple; bh=DQSyjovpsKAAF9YWLoG402aT+41YfWyK5PUh0NDD0oc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MzHAgmb2qEz97+UJD7r1PZTpUHzPxu2QIrQUSX5yz9Zf0H0Hr6YnASE/qMsyQiAboQ1+IMj+6uhXrsXyJweH2725a0JcXEb3U5fyEUzLoOTZgf0PxlQkYokq9ERCaKU+9ZCY2TNIJlQmcJG6V7XUsO/d3lwnZCVI9yOq0SoYn/Q= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=VA8dp/HK; arc=fail smtp.client-ip=40.107.92.61 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) header.d=amd.com header.i=@amd.com header.b="VA8dp/HK" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dWXyFABW/P7bjMYfWYe3CtqQVa+KFCXxHoB4l0cc6ACqlDNQqFRTxrFvV+N+KNDgwMOlGE5TbowlNi9UMOBxjgdCOPAbTKz1m0EMLdJMihGfY9r2VVn3MRAzEluzUD5fZNr7T9xzE9SNZYAz2tj+C59ezF9xSNajDW67JRGohnaW1TrEwbW14VtA5ciMTBfoIxViB528UW6tax2laczFJe0INNSheZxSbBRC2x6HPnW7DOVV+wkifqpqYJafERA2HZK+7gyEyS+L1qgG1kQ+cRtmMKns4KIuYISszOrPPW0e5ypIJkxwJfuOzjlSwHab3bJwXSYPw1jkDrNxU2UVsg== 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=h931puc7XL6ozQDQZjdsjRZnMopFuKOqaDWmB4dMLZE=; b=apMZNIhoUsmc2v+fZQyZO2Io+Y5DMUJNsJ1GjNIoWQndNfaEkXtGWKUjgWzzGGLd2V6Fl4a7yXeIufR7uTurJWMeRODoIR1X4u0sXMgf+fTbcNBNaYwHQl6OejcrTX5KVeReIneqwg2HC2m81Y/z5OKwjFKnWfb8b7FbYKdKjUevqJwOsmgU/hRpofsJtUPpLONDHhG393FEtLfV2oCE2a+4FtpLzzeUDZ69Ls/dato93DbRGLayTe6GQNXFVBBfUlhTaoktCa3P3NyvdTyTnPNNi6d1UKsElu13/4UT2HMOXYwm8oL33tcvYGrs8JE1dCdQm8a8HuXsUZFFuxsoHg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net 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=h931puc7XL6ozQDQZjdsjRZnMopFuKOqaDWmB4dMLZE=; b=VA8dp/HKOiwcZWPLEWUP5wuMWLJbsSeB2ntgWjVI1P5IPvZa3dPg5qpC5djMXgQBWG6jn5EcSPbbr0ReKWCVHNmgl3qWKUaQUMUriWwJrOHk038oj0VWdYLDWvEjFLQNrbr/2NRAELVkYnLfEvRxEUADapCiqqhNILpiyh5aTEQ= Received: from SN7PR04CA0222.namprd04.prod.outlook.com (2603:10b6:806:127::17) by SA0PR12MB7076.namprd12.prod.outlook.com (2603:10b6:806:2d5::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.25; Tue, 29 Oct 2024 23:24:16 +0000 Received: from SA2PEPF00001504.namprd04.prod.outlook.com (2603:10b6:806:127:cafe::69) by SN7PR04CA0222.outlook.office365.com (2603:10b6:806:127::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32 via Frontend Transport; Tue, 29 Oct 2024 23:24:16 +0000 X-MS-Exchange-Authentication-Results: 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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SA2PEPF00001504.mail.protection.outlook.com (10.167.242.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Tue, 29 Oct 2024 23:24:16 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 29 Oct 2024 18:24:14 -0500 From: Babu Moger To: , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v9 15/26] x86/resctrl: Add data structures and definitions for ABMC assignment Date: Tue, 29 Oct 2024 18:21:47 -0500 Message-ID: <219cac124638f576cc7a9c5a14207f8c018e31f1.1730244116.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00001504:EE_|SA0PR12MB7076:EE_ X-MS-Office365-Filtering-Correlation-Id: 856d1412-dbf2-4dab-fe01-08dcf870ce9a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: =?utf-8?B?WDQvbytXNXhGaFdmNzloOGtTajdna0c5Z1JXUkxEeXQrVkMvTy8yczVrbGg0?= =?utf-8?B?R2pEcW5IUWpuR0JjcVhITDV2d0RmbjJGZXE4MmJDQXFoQ0hrdFFuOXdVZXVF?= =?utf-8?B?UmhqL3BNeUZUaTljL2RjMUNOU0tSajBiSmUvblpNd2tpa3VmOVdUWERqMTdi?= =?utf-8?B?YWd3UkpKNnBuQlVmQWJoVFA5WW03ZThsYjBRMlpVZFpUNnJBUENadTd0eXJr?= =?utf-8?B?UzVWVm9qNVAvRDRuTUd4RmNRQzU1MU9wTkhVZk1KdHUrSjhlY0VCbU9wWlBy?= =?utf-8?B?Vjd2TEd6ZjZrdUxwcWhrSnVvL2k5Tml1M05FTW9zbWNVLy9tRUJ5b3ZldXQx?= =?utf-8?B?bmJXeEhPQldyZ1FBSzRzOVNqWnFIc3JjU3k4RzMrUzBacU9OQlZLZXBKOTFz?= =?utf-8?B?TDhUVXo2dEdhTG9SRk5rRnRTNG5HZS9jQ0FwYXltVnB4ZmVnOHlwRTM3amNF?= =?utf-8?B?dDdpNUJTRTNVeHlwQVJFSDdJSDEvc1FQZXB3VWIxTmVUWW1LUVYxTkRSRWVh?= =?utf-8?B?TDhKQzRDMCt1U0ZHUGFZNzhJVStUQ1dBYWNZWG1CeWQvamoyNjhabUxmY1kz?= =?utf-8?B?MjBPS28zNVBMM0hPaG81NWFNb0hFMjRvQXJWUjhvNUQvb2krbWlVcnM3K0JN?= =?utf-8?B?OXhqalkrb0d6YisyVmg4MDFDd3hVZ3RyaGFLem1PWFlnMGxHdVlVVEZRa2VD?= =?utf-8?B?V3RTVFYyNjRLZUE4YlQzWkpJODVQRTZGMWpxenlBTG1tUXFoRWFoRWM0eXhN?= =?utf-8?B?ck1HdERXMkV0RmlCSEtmd1dKc3I2UlNWU1NiV2xidS9xck5wWG9oVENIQmQz?= =?utf-8?B?TkZwSnJBdXM4aXp2V1Z6cmpMalBnNGtnUm5pZDdseUFMZnFGeE44bWM2UVZV?= =?utf-8?B?QzJ0QzNmNUpxbGplM1M2ZFpMd0g2bEMvdERPdU9KSkNMU0xpdGt5c0Y5OXla?= =?utf-8?B?VG1Renprc0x5YmVFdzJMUzVhMXlkUVEwTm16aTcrdVRuei9ERjliaHozclox?= =?utf-8?B?QkV1czFVTW5ScGIweG9OMDY0dkx3b2l5Q2hESkJtU0pDeUdPL3cxQjF3QUhD?= =?utf-8?B?d1pIOUlpdVIwL3M5MkUwZVZHbmdpTW9vbmtxR1ZadUhML1hoaEV1bXFVQUNK?= =?utf-8?B?SlBrT0dBZ2VaNE1uZ3k3STNWZU5ESEJGOVcwRUZkdGdDUlBFQzlDK2w1VnBY?= =?utf-8?B?ZmowbnVzOFpFdVBhaytvZTdWV2l2SHR2V2V0YktUM25LdE5EakpFSXFiRkhn?= =?utf-8?B?R1BFdDhEbnpVZUhRZXRwaWI3YjgyT0NwQ0JvMkYwSVZ6MStjT1RzNmtJT09O?= =?utf-8?B?b1V4VjdDcWV6UUxKVkV2TUFZM1lIQ1RrQ1RuUW0rOTJZeU5mS20xT0JiaVlu?= =?utf-8?B?SzZSYlFiYlRFQ0NCbWhnbmsxTVc2QmJpSW14bmV4NEF3MS9iYy9xeTZBcUE5?= =?utf-8?B?NkJqK3cxZE9RY1I0YWhNMDkyOWtJeUFGUGZoeHRmYktxdmZOV25Wd2VNR0Yx?= =?utf-8?B?aGxrZkdSVmx0WVI5d2JZYlMzc2lkeVRzaWlpQjZSYjZ5S1l6UmJ0UDBzYXBh?= =?utf-8?B?VWpXRCtEV3pKUlJBQ0lMTFhVOENuWk5yeTh6d1NhdVlLM1l0QnhnNkFja29C?= =?utf-8?B?T3U3RjBoY2ZOR2I3TGtvb0E4a20wQjNxY3F5N2p0ZXI1VDM3ejlpRmZrNEFL?= =?utf-8?B?SEZlU0htWHZzM3J6SlRlNUduYjF1WThaVFhPWkZDRzNlYlBVZnk4UU9UemZU?= =?utf-8?B?VzZMVFkvWXR5UXcvSisxcWRSNmtDWjd4RHhURHFzR2RJUk55bkVvWkdFZ05R?= =?utf-8?B?b2FiT3RnMWI1bW15MC90Y2NPbXhCdGFBc1pNSncvKzFISXk3WG92WXpFUi9w?= =?utf-8?B?ZmFJR1dvb0NDKzJWVG5yWUFHQTNFc0FvbHZ5bkJtUnc3UVE9PQ==?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(376014)(1800799024)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 23:24:16.5276 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 856d1412-dbf2-4dab-fe01-08dcf870ce9a 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF00001504.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB7076 The ABMC feature provides an option to the user to assign a hardware counter to an RMID, event pair and monitor the bandwidth as long as the counter is assigned. The bandwidth events will be tracked by the hardware until the user changes the configuration. Each resctrl group can configure maximum two counters, one for total event and one for local event. The ABMC feature implements an MSR L3_QOS_ABMC_CFG (C000_03FDh). Configuration is done by setting the counter id, bandwidth source (RMID) and bandwidth configuration supported by BMEC (Bandwidth Monitoring Event Configuration). Attempts to read or write the MSR when ABMC is not enabled will result in a #GP(0) exception. Introduce the data structures and definitions for MSR L3_QOS_ABMC_CFG (0xC000_03FDh): =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Bits Mnemonic Description Access Reset Type Value =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 63 CfgEn Configuration Enable R/W 0 62 CtrEn Enable/disable counting R/W 0 61:53 =E2=80=93 Reserved MBZ 0 52:48 CtrID Counter Identifier R/W 0 47 IsCOS BwSrc field is a CLOSID R/W 0 (not an RMID) 46:44 =E2=80=93 Reserved MBZ 0 43:32 BwSrc Bandwidth Source R/W 0 (RMID or CLOSID) 31:0 BwType Bandwidth configuration R/W 0 to track for this counter =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D The feature details are documented in the APM listed below [1]. [1] AMD64 Architecture Programmer's Manual Volume 2: System Programming Publication # 24593 Revision 3.41 section 19.3.3.3 Assignable Bandwidth Monitoring (ABMC). Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D206537 Signed-off-by: Babu Moger Reviewed-by: Reinette Chatre --- v9: Removed the references of L3_QOS_ABMC_DSC. Text changes about configuration in kernel doc. v8: Update the configuration notes in kernel_doc. Few commit message update. v7: Removed the reference of L3_QOS_ABMC_DSC as it is not used anymore. Moved the configuration notes to kernel_doc. Adjusted the tabs for l3_qos_abmc_cfg and checkpatch seems happy. v6: Removed all the fs related changes. Added note on CfgEn,CtrEn. Removed the definitions which are not used. Removed cntr_id initialization. v5: Moved assignment flags here (path 10/19 of v4). Added MON_CNTR_UNSET definition to initialize cntr_id's. More details in commit log. Renamed few fields in l3_qos_abmc_cfg for readability. v4: Added more descriptions. Changed the name abmc_ctr_id to ctr_id. Added L3_QOS_ABMC_DSC. Used for reading the configuration. v3: No changes. v2: No changes. --- arch/x86/include/asm/msr-index.h | 1 + arch/x86/kernel/cpu/resctrl/internal.h | 35 ++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-in= dex.h index bdc95b7cd1b0..d7dec2326cd8 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -1194,6 +1194,7 @@ /* - AMD: */ #define MSR_IA32_MBA_BW_BASE 0xc0000200 #define MSR_IA32_SMBA_BW_BASE 0xc0000280 +#define MSR_IA32_L3_QOS_ABMC_CFG 0xc00003fd #define MSR_IA32_L3_QOS_EXT_CFG 0xc00003ff #define MSR_IA32_EVT_CFG_BASE 0xc0000400 =20 diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index add8e84b483e..5895ea72fc26 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -602,6 +602,41 @@ union cpuid_0x10_x_edx { unsigned int full; }; =20 +/* + * ABMC counters are configured by writing to L3_QOS_ABMC_CFG. + * @bw_type : Bandwidth configuration (supported by BMEC) + * tracked by the @cntr_id. + * @bw_src : Bandwidth source (RMID or CLOSID). + * @reserved1 : Reserved. + * @is_clos : @bw_src field is a CLOSID (not an RMID). + * @cntr_id : Counter identifier. + * @reserved : Reserved. + * @cntr_en : Counting enable bit. + * @cfg_en : Configuration enable bit. + * + * Configuration and counting: + * Counter can be configured across multiple writes to MSR. Configuration + * is applied only when @cfg_en =3D 1. Counter @cntr_id is reset when the + * configuration is applied. + * @cfg_en =3D 1, @cntr_en =3D 0 : Apply @cntr_id configuration but do not + * count events. + * @cfg_en =3D 1, @cntr_en =3D 1 : Apply @cntr_id configuration and start + * counting events. + */ +union l3_qos_abmc_cfg { + struct { + unsigned long bw_type :32, + bw_src :12, + reserved1: 3, + is_clos : 1, + cntr_id : 5, + reserved : 9, + cntr_en : 1, + cfg_en : 1; + } split; + unsigned long full; +}; + void rdt_last_cmd_clear(void); void rdt_last_cmd_puts(const char *s); __printf(1, 2) --=20 2.34.1 From nobody Mon Nov 25 04:41:22 2024 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2060.outbound.protection.outlook.com [40.107.237.60]) (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 8D3DF20ADFF; Tue, 29 Oct 2024 23:24:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.60 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244297; cv=fail; b=QM/KLUJ0ebBScsU5ihBjTQHroBZSluFb0LwRabQgqfyz1LQ56xT0rfWKDkFPXglL64GjxloTC/Dr7b5umjPHxYQgPaozVtKGeYWObcD2L40tKDKDlJehjPVO+V+Y0+Hz/jvBzkfrnNOpY1gzPOvI3JgWYrs+hYMdvfgstP++WMs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244297; c=relaxed/simple; bh=mJgjoTVeYZiXyASUq46ilYdGUCDXvDZdb66qXm9MeUA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cp/5M1yhseNYH+KUkjAC1J9Ka7gtZ9IE5qMqVp+IDGdGNMgwPfQUjipE7OSka9WmQlowWcoUeB1UeqvlQgJvG9SRcIvsAat+rPVdAaNcPctlYTYjFSBEzyAYCTFMUjqLJ0jziOiPx42Qd9sG8nivMP3vtj9smEV5T65pc3uyIAY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=Jf9g485N; arc=fail smtp.client-ip=40.107.237.60 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) header.d=amd.com header.i=@amd.com header.b="Jf9g485N" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=SVtzXMM+5LUjLlTYeyycYK6Kt02DhdicOEvMEi4ySSV64EazhHDTFNcTyQO/hDtgaHYy1SHllS2k7ScakmBFtpVKDCG8FCshVd44Kd464ri+K8b4Ew8qRT8m8SXykYrZUvNHovtlwdECvGRRfdZnO8FlHqEyQtzefa+70cjEdjD2vshRffa3Vz5UwRf26apOqOw66Y3guuBaDE+7tRye76QCdVm1W8dci+Rwp0jnRvbeeqs+sm0vy5QbgCcwG0rSdFs6IW4yToDTxiV4O/F8an+WVBwCVXnjD3C0bVal2zcRo9tN+6fAHRVGqgf+pL04XVxqCNrbMU1wrIlsBYtpgw== 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=UQT+x6G+HqqBv8T85RQ1uNkuWADklLVvHgv4fIKxfZw=; b=c6m0ZDuQbFQHi4eMrASbMLwMIwAN2bOWtUL5DOj7PmbYTqKqQWeVv6pUKoR0aLqlL0HPsRT/quZcepeXEM6hZM+RHowxhYckWkyQqaSZPC8TccdpUaOtxWDXmSvoShjmD97G7KYCXtLINhuYcgyRNgpqlHWnDlaYiVk1re5uRWdJg/Atn3Fy2ubAPp3upytPm3dFSoKvF7uvPA5vnIPtlxZACsVa6Iok8BH0TJEmNLjzbcalNL3L1mKZdzKocLdiXUWAf5GGEaENZIHJOsaAaPI72IhfmY9Ue7KL8TfQoOD3Upim+sLXhUrldd1ewsIAV0CY+vGlDkk0l4RdoEMmTw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net 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=UQT+x6G+HqqBv8T85RQ1uNkuWADklLVvHgv4fIKxfZw=; b=Jf9g485NuiTSOktvvaC25YQV5jQu9HuRtTIpaW6Mnbxu1pp52e7JcwAPo2b0DpRtEyllg0zNN5ML7JzrqBctwimNRTqJhPkSrn9GAcn6xWBJeQDA9/wEodmKkDWy3Ic7ouZpAW6SHDRAZzAkAG3aPoblwd/ujxRSYQuTRLDft7c= Received: from SN6PR08CA0029.namprd08.prod.outlook.com (2603:10b6:805:66::42) by CH3PR12MB9147.namprd12.prod.outlook.com (2603:10b6:610:19a::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.27; Tue, 29 Oct 2024 23:24:52 +0000 Received: from SA2PEPF00001507.namprd04.prod.outlook.com (2603:10b6:805:66:cafe::46) by SN6PR08CA0029.outlook.office365.com (2603:10b6:805:66::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.31 via Frontend Transport; Tue, 29 Oct 2024 23:24:52 +0000 X-MS-Exchange-Authentication-Results: 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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SA2PEPF00001507.mail.protection.outlook.com (10.167.242.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Tue, 29 Oct 2024 23:24:52 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 29 Oct 2024 18:24:22 -0500 From: Babu Moger To: , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v9 16/26] x86/resctrl: Introduce cntr_id in mongroup for assignments Date: Tue, 29 Oct 2024 18:21:48 -0500 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00001507:EE_|CH3PR12MB9147:EE_ X-MS-Office365-Filtering-Correlation-Id: f1b16ef3-3926-4844-50c1-08dcf870e40b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?lMxAIqaob3R3RNMhREdgmoAE+KczyIt+iFaWIMRZL4TxO4S0z2lwzXCKEYU/?= =?us-ascii?Q?OUjWLb48s/UhVIDCnfHS0YfDjSaESq5W5eFBh/UHtY2FDxXdEpe2OjIP2Yiq?= =?us-ascii?Q?nG3/htcFMrkoDYvQ/ZioDxaHuGbi1+TxOnLie9LEKaQBTyW8LJCmWZq3YoMt?= =?us-ascii?Q?AQt717ZsXM7uJymaI1U00wVRGHbmmk70ubQ/EpfhT2qDKwTmLSdbe1LNOmY/?= =?us-ascii?Q?ATJfaedbZGG48EciDRKOU0/09NEcwjx3R/vDeyO1gACjUD67utYlvy7BXLip?= =?us-ascii?Q?T9qilq1LexSnjWf/L5mNQtvSEj8lra21fj8T5BwV61Nc8v3pDUOxnnUJrG7c?= =?us-ascii?Q?/H5vIh4M9wVOd1FjcYUsf2xgWxbDj+dDU0bfnvjYG61JuwiVHfuI4NSoBARv?= =?us-ascii?Q?25eeZ91sIUa5/iA8oHsSAHv8v7OoSffCDbVSIzNkAKl2+OaHffWpMuQbzh1A?= =?us-ascii?Q?NTWxU8344c1P1uB6EQ099xL+UPu9EwbGDutbgO3DdvzNMTTCpV0bbkkQ6Tbs?= =?us-ascii?Q?NU7YeOx2h3NpcNx15+Kn0hD1ZCQ88HrFvE+RcgfRzc/krCdGpNNovuHuP/Dd?= =?us-ascii?Q?B55O53ephE7C70YDSrGitzNCFS+e7Gtk73w2HbRWH9wxKsQzlejrakMLliAB?= =?us-ascii?Q?KYOyGv6XHxEk5AqDlIXA89G0OKAcJOxol9LRKX+jPO2YAdeZzSgPI8ir4M8y?= =?us-ascii?Q?sQgSrg438PpPaMnRLXVk0xYFH29PP2HA80ADW49V5hIl/Moro8RnWYOz+1iO?= =?us-ascii?Q?qAP9eax0QxtbvV/uVlrOj23VfL231+EMVORmgS4j6+369qUkZmOpnHZubR7l?= =?us-ascii?Q?Z/V9ESmuhtVgRae83qmVbwBsHADXTTuurvQDb0W2GK5XnrEKEW1ZXz8zuic8?= =?us-ascii?Q?gVU7X3XAb9oYbQFPa/xJ/lZMUdt0OPOOPxlPCZcuQGqpdz7TNBe/paAVhS9O?= =?us-ascii?Q?x8lOGgyaF2nrsA3sK9A6LWJlbhWDtZ9I+ArD/rp3NJN7D/f8ZESMqPOThUWf?= =?us-ascii?Q?LIhJklkE+gZSFiflGQqzmIW2EVFDa1JfMkOspWU9Xqf92EQ1M3IwXq/q3g9Z?= =?us-ascii?Q?3P1JQ5Vw+3COuFv7wDK7E/HXj2leHyGTuU6Os1GidFOcYkuyDaEauWHilt3q?= =?us-ascii?Q?SlhW1byXZg1YYMTGTOk40K57wSppvwAJ623QlFQEGZsBkwzdqiSfNGRYsLm0?= =?us-ascii?Q?94o6qA5KYRYIXrDKHDnZgWX91xVx7Xm61y2vAuYlkMVUtHDI02vJqC1EVGzh?= =?us-ascii?Q?9rFXw2Hwgm0FhOQ1s5rIflLdlsM6jUKjNalf2YDgTiE6Nxx+d0C+mS62700D?= =?us-ascii?Q?Z8Eesuro79xJVcpwJMO8n0gqW8EVWaep5BHAXjFVCv51Dci5fUs0EytnJ32J?= =?us-ascii?Q?z/uNBKg5oCepNmY1wVLioaIBFsrp3ScTNKHnBnqE/EoOAvyrZw=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(82310400026)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 23:24:52.4802 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f1b16ef3-3926-4844-50c1-08dcf870e40b 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF00001507.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB9147 Content-Type: text/plain; charset="utf-8" mbm_cntr_assign feature provides an option to the user to assign a counter to an RMID, event pair and monitor the bandwidth as long as the counter is assigned. There can be two counters per monitor group, one for MBM total event and another for MBM local event. Introduce cntr_id to manage the assignments. Signed-off-by: Babu Moger --- v9: Used MBM_EVENT_ARRAY_INDEX macro to get the event index. Introduced rdtgroup_cntr_id_init() to initialize the cntr_id. v8: Minor commit message update. v7: Minor comment update for cntr_id. v6: New patch. Separated FS and arch bits. --- arch/x86/kernel/cpu/resctrl/internal.h | 14 ++++++++++++++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 15 +++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 5895ea72fc26..d1f3f3ca4df9 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -62,6 +62,18 @@ /* Setting bit 0 in L3_QOS_EXT_CFG enables the ABMC feature. */ #define ABMC_ENABLE_BIT 0 =20 +/* Maximum assignable counters per resctrl group */ +#define MAX_CNTRS 2 + +#define MON_CNTR_UNSET U32_MAX + +/* + * Get the counter index for the assignable counter + * 0 for evtid =3D=3D QOS_L3_MBM_TOTAL_EVENT_ID + * 1 for evtid =3D=3D QOS_L3_MBM_LOCAL_EVENT_ID + */ +#define MBM_EVENT_ARRAY_INDEX(_event) ((_event) - 2) + /** * cpumask_any_housekeeping() - Choose any CPU in @mask, preferring those = that * aren't marked nohz_full @@ -231,12 +243,14 @@ enum rdtgrp_mode { * @parent: parent rdtgrp * @crdtgrp_list: child rdtgroup node list * @rmid: rmid for this rdtgroup + * @cntr_id: IDs of hardware counters assigned to monitor group */ struct mongroup { struct kernfs_node *mon_data_kn; struct rdtgroup *parent; struct list_head crdtgrp_list; u32 rmid; + u32 cntr_id[MAX_CNTRS]; }; =20 /** diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index ef0c1246fa2a..36845e8e400d 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -925,6 +925,14 @@ static int rdtgroup_available_mbm_cntrs_show(struct ke= rnfs_open_file *of, return 0; } =20 +static void rdtgroup_cntr_id_init(struct rdtgroup *rdtgrp, + enum resctrl_event_id evtid) +{ + int index =3D MBM_EVENT_ARRAY_INDEX(evtid); + + rdtgrp->mon.cntr_id[index] =3D MON_CNTR_UNSET; +} + #ifdef CONFIG_PROC_CPU_RESCTRL =20 /* @@ -3561,6 +3569,9 @@ static int mkdir_rdt_prepare_rmid_alloc(struct rdtgro= up *rdtgrp) } rdtgrp->mon.rmid =3D ret; =20 + rdtgroup_cntr_id_init(rdtgrp, QOS_L3_MBM_TOTAL_EVENT_ID); + rdtgroup_cntr_id_init(rdtgrp, QOS_L3_MBM_LOCAL_EVENT_ID); + ret =3D mkdir_mondata_all(rdtgrp->kn, rdtgrp, &rdtgrp->mon.mon_data_kn); if (ret) { rdt_last_cmd_puts("kernfs subdir error\n"); @@ -4115,6 +4126,10 @@ static void __init rdtgroup_setup_default(void) rdtgroup_default.closid =3D RESCTRL_RESERVED_CLOSID; rdtgroup_default.mon.rmid =3D RESCTRL_RESERVED_RMID; rdtgroup_default.type =3D RDTCTRL_GROUP; + + rdtgroup_cntr_id_init(&rdtgroup_default, QOS_L3_MBM_TOTAL_EVENT_ID); + rdtgroup_cntr_id_init(&rdtgroup_default, QOS_L3_MBM_LOCAL_EVENT_ID); + INIT_LIST_HEAD(&rdtgroup_default.mon.crdtgrp_list); =20 list_add(&rdtgroup_default.rdtgroup_list, &rdt_all_groups); --=20 2.34.1 From nobody Mon Nov 25 04:41:22 2024 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2042.outbound.protection.outlook.com [40.107.92.42]) (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 51F3C20C004; Tue, 29 Oct 2024 23:24:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.42 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244302; cv=fail; b=mD/wjV9EYQwk27Xs9SPQimNBiMXi/ojMWkJcIzAQQvzEzCgipJsCvkeKXKDWspWGSG8mX7tyvQvMHB2zP3sXJe9xWjbDZGqXeHwOoUbk2kqfWChny2MA+GE+aDxeQRt1loLbPFIawVe4pwlCs6Qm3xkhjJd2UOKG/JGvDW3M0vw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244302; c=relaxed/simple; bh=8jbUK9xKN+sMRgEmAmQA/nJmaobOJtL+oxfFu0mBsI0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Y5zcgYjpyCR6Vj63M/GiC5fh6O1gUxPjDFXPRzlz7TvIM7sEcLM14KfZatkezqkyaZJc4Gl3bQfBr7tpmImlrD6dLpgeO3NXeh3oKKHo0EUplwi/PXACz0hqvUC9dc000He0fcHZ4o4dFVkGWzc5m65KvpOFg+h2IVijTUhTICs= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=nEQSFcTL; arc=fail smtp.client-ip=40.107.92.42 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) header.d=amd.com header.i=@amd.com header.b="nEQSFcTL" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=mpeqcWy4ctynU1dN6DDWADCNf/DUMXNZMUCrhNb8qfvjvX/lpW2WN5rkisU4O8lF71EnPzlvxUghAHnC1ZBEOw/Kq5SwvQO4MkjOK5AtZM/chIFBGpeL02Dzxn6w+YZO8klrfFW1oES9Lo6WS7rJFDFZaMAagfXnFWK/JTNIi/gls+eM9YOKKIfKWplZNLytBLv5+KfedGBA3EkwtGzqynwE7OWTPatA1AYmqiHhi5c75SqAXHo/V5FRXqB9H05QcY3UGSRx5ptWgR6gVOarKpNqMe2iJ/a6FkXRaLwpepfTbne3xYdoPY4wR4v23rfTvmcyqzuv4/QYDLJX/PTtkw== 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=/Rtu0m1uldQtDd7y9k0ewKo7VWtuPjzlbof4Eot5QhY=; b=Kfvsr0ugIGSLoJ4+X3oGywv/uptcphRdIW0EuAvGl7uJtgdc+GMWR9uHFJD9f5owG0bfNMO59R5rqtx3+jlfiZfU76Hun+gBdnZ9NMv7U4v81z6JtRHNIWKt6lfane2M//scHR9nHqqMb8ME09sC1vmUdDnhb7NSsUYFlGmVyAQyhhyARDWasNH3jNMlcjixW3QnNDCEZY6/sH1PoKTgfhCdEzXJbMkr4pgJKphqzmNqdDH8qFGGWVNz7PAHVqkw2YnBOBCNvHYpXM1ZQaXDWHHsJNHiv7DJMH8bxu4lLc4+tIyC4EBVL0SxVeV5rfEQ4CrT6WSWS4ejwCwefF+z2g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net 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=/Rtu0m1uldQtDd7y9k0ewKo7VWtuPjzlbof4Eot5QhY=; b=nEQSFcTLLhRQ/XwO5F/3d7HMQ6xIyRYYq5sLleDVlJh+0jeLyObiE9LrDXMb8m/F94znpY3p4R74OOXhPk27FhsHoda/C8oBuvVmY99sIVeTintP+k/AzS0KcMKDPxHMyqV8R+O6ieI/H+QHNNDcdHnYKgUEutlZQvZGi6FfumE= Received: from SN6PR08CA0023.namprd08.prod.outlook.com (2603:10b6:805:66::36) by MW6PR12MB8836.namprd12.prod.outlook.com (2603:10b6:303:241::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Tue, 29 Oct 2024 23:24:54 +0000 Received: from SA2PEPF00001507.namprd04.prod.outlook.com (2603:10b6:805:66:cafe::7f) by SN6PR08CA0023.outlook.office365.com (2603:10b6:805:66::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.26 via Frontend Transport; Tue, 29 Oct 2024 23:24:54 +0000 X-MS-Exchange-Authentication-Results: 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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SA2PEPF00001507.mail.protection.outlook.com (10.167.242.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Tue, 29 Oct 2024 23:24:54 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 29 Oct 2024 18:24:31 -0500 From: Babu Moger To: , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v9 17/26] x86/resctrl: Implement resctrl_arch_config_cntr() to assign a counter with ABMC Date: Tue, 29 Oct 2024 18:21:49 -0500 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00001507:EE_|MW6PR12MB8836:EE_ X-MS-Office365-Filtering-Correlation-Id: 404323b9-74fa-4c75-924e-08dcf870e530 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|7416014|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?xdhBWlumhS88aa6G5dSMvMyWdBg/UiD4A1iTHwTogYjuWVr+4vyzZ8E1OTb2?= =?us-ascii?Q?qtDNMAzQpOeDNm9JSY5pSAlc3vSKn3AMTccXvoXIUTG3NPYRkATHEMZg8r/W?= =?us-ascii?Q?wJlyDx5pBKLtOVuoPT7jIxpyH+vAwGX0GJmLuOjbgLsS0ZJjMEdq1wGclO3K?= =?us-ascii?Q?WPtGUnaY/l1aelCJgw81AnigXa20D6DDUFysgAvR/jwZu9cZPevgCeHuXdTh?= =?us-ascii?Q?7MQ3tLhGQ09OWDayG399CpfrJlyj7tlvmXJdlXi6TW/YPZbc5UmyMMqKuie0?= =?us-ascii?Q?K5DoMz0AGiL2/KcYtw68YVKiAkez6fkeWx5WhCWR2+fO3HVIxEm1VtECRCkt?= =?us-ascii?Q?+ad5/ONMdj8c+ieINAz3RdAFdy0cQgVt4BZW3r/65Vr2SgLcffV1hlE/SDkQ?= =?us-ascii?Q?oviBG9s+TWYFU1RL6Nh/6QRrNE6XSPNql3WPEgvI2J7J6RHxUpgcHslD065M?= =?us-ascii?Q?ksaFlaexdvCs9bhfVYLEUW5feeF8MtXAddvqjHdCwMXT6+eimhlRlnCsBa+c?= =?us-ascii?Q?UxAu0WIbMPCXLL4iFwQ+KWvK2kWBx5oBzHZCGLS+CUs/2KoXB54Amx+9jyD/?= =?us-ascii?Q?haGUnC/veQlaTKzVbb9y/sizkbqNawrCiLZYGI7NsNHGckUdZl7FDR0qgMS+?= =?us-ascii?Q?BtJch3t/COxlvktSvmUqC/Jv3t2DVXfM9fbeQrmCWbXFTFNKSbTSrKIgRPXX?= =?us-ascii?Q?sIHZvMDgMg9awp5VMrsee9hNPHW+eaF9YGPbsEMfg7d3uZRfZrHk66bA4FC3?= =?us-ascii?Q?yN2zEKk4qt5Zvz+uwduafzNx1uNUl6rkg10Tfd+YVgr45hXKelvW0zJKWKmw?= =?us-ascii?Q?A6VJUT55iW5OQZfY6MQcT+lJh7EjNQQd8SO0Co6RitAIku0cWn09qByyDppD?= =?us-ascii?Q?H59WeN0D2o5EPNZgmQNKCG9FGSQ+C3UEtrHpLeoRm/s/3cf9LEjixRrJWBj0?= =?us-ascii?Q?2davN65IBbb4hgvZafrq7sTaRdRMAhHXFCLkq35rxArdeeH5omClLX58nV+y?= =?us-ascii?Q?SGUlu3/okqwNS3e/5l9RSacY61JEl0FqQ3RhasRviD2gSGnXIPfARMNgTXYm?= =?us-ascii?Q?Vc6VrsSZh1g3nSGA0y6zKURQgJ/BToxSnFqnKURu/E0ldu3PNG+FekbVZ9hC?= =?us-ascii?Q?QCu32jncA3FY46S05XtcUt/S47s5QrkQw/sNx/QSDB1wwVZT9pszfowGobCx?= =?us-ascii?Q?4OvRYp4v4VwHMKCMa+P256rIaqXWfUj0bPHKoSMic3ITNDBlaWqQd4PJKeRF?= =?us-ascii?Q?CxZlTtD4JbqkqhB9XZbg8IXs1p8VACbK+ad9xzCcDE6sr3uqEKuEJ9FqveWn?= =?us-ascii?Q?jynKpEFq+mXEu7+yLs9bnzPXYlm0g/PvUGjca4YwSZluwIsscOg4cBDTGXPB?= =?us-ascii?Q?FziS7kiBDbEjLfwvp5mXtr9aq8aQFLplO0t41B/1fnip7tvVGA=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(376014)(7416014)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 23:24:54.4021 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 404323b9-74fa-4c75-924e-08dcf870e530 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF00001507.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW6PR12MB8836 Content-Type: text/plain; charset="utf-8" The ABMC feature provides an option to the user to assign a hardware counter to an RMID, event pair and monitor the bandwidth as long as it is assigned. The assigned RMID will be tracked by the hardware until the user unassigns it manually. Counters are configured by writing to L3_QOS_ABMC_CFG MSR and specifying the counter id, bandwidth source, and bandwidth types. Provide the interface to assign the counter ids to RMID. The feature details are documented in the APM listed below [1]. [1] AMD64 Architecture Programmer's Manual Volume 2: System Programming Publication # 24593 Revision 3.41 section 19.3.3.3 Assignable Bandwidth Monitoring (ABMC). Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D206537 Signed-off-by: Babu Moger --- v9: Removed the code to reset the architectural state. It will done in another patch. v8: Rename resctrl_arch_assign_cntr to resctrl_arch_config_cntr. v7: Separated arch and fs functions. This patch only has arch implementatio= n. Added struct rdt_resource to the interface resctrl_arch_assign_cntr. Rename rdtgroup_abmc_cfg() to resctrl_abmc_config_one_amd(). v6: Removed mbm_cntr_alloc() from this patch to keep fs and arch code separate. Added code to update the counter assignment at domain level. v5: Few name changes to match cntr_id. Changed the function names to rdtgroup_assign_cntr resctr_arch_assign_cntr More comments on commit log. Added function summary. v4: Commit message update. User bitmap APIs where applicable. Changed the interfaces considering MPAM(arm). Added domain specific assignment. v3: Removed the static from the prototype of rdtgroup_assign_abmc. The function is not called directly from user anymore. These changes are related to global assignment interface. v2: Minor text changes in commit message. --- arch/x86/kernel/cpu/resctrl/internal.h | 3 ++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 38 ++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index d1f3f3ca4df9..00f7bf60e16a 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -714,6 +714,9 @@ int mbm_cntr_alloc(struct rdt_resource *r); void mbm_cntr_free(struct rdt_resource *r, u32 cntr_id); void arch_mbm_evt_config_init(struct rdt_hw_mon_domain *hw_dom); unsigned int mon_event_config_index_get(u32 evtid); +int resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_mon_domain= *d, + enum resctrl_event_id evtid, u32 rmid, u32 closid, + u32 cntr_id, bool assign); void rdt_staged_configs_clear(void); bool closid_allocated(unsigned int closid); int resctrl_find_cleanest_closid(void); diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 36845e8e400d..1b5529c212f5 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -1886,6 +1886,44 @@ static ssize_t mbm_local_bytes_config_write(struct k= ernfs_open_file *of, return ret ?: nbytes; } =20 +static void resctrl_abmc_config_one_amd(void *info) +{ + u64 *msrval =3D info; + + wrmsrl(MSR_IA32_L3_QOS_ABMC_CFG, *msrval); +} + +/* + * Send an IPI to the domain to assign the counter to RMID, event pair. + */ +int resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_mon_domain= *d, + enum resctrl_event_id evtid, u32 rmid, u32 closid, + u32 cntr_id, bool assign) +{ + struct rdt_hw_mon_domain *hw_dom =3D resctrl_to_arch_mon_dom(d); + union l3_qos_abmc_cfg abmc_cfg =3D { 0 }; + struct arch_mbm_state *arch_mbm; + + abmc_cfg.split.cfg_en =3D 1; + abmc_cfg.split.cntr_en =3D assign ? 1 : 0; + abmc_cfg.split.cntr_id =3D cntr_id; + abmc_cfg.split.bw_src =3D rmid; + + /* Update the event configuration from the domain */ + if (evtid =3D=3D QOS_L3_MBM_TOTAL_EVENT_ID) { + abmc_cfg.split.bw_type =3D hw_dom->mbm_total_cfg; + arch_mbm =3D &hw_dom->arch_mbm_total[rmid]; + } else { + abmc_cfg.split.bw_type =3D hw_dom->mbm_local_cfg; + arch_mbm =3D &hw_dom->arch_mbm_local[rmid]; + } + + smp_call_function_any(&d->hdr.cpu_mask, resctrl_abmc_config_one_amd, + &abmc_cfg, 1); + + return 0; +} + /* rdtgroup information files for one cache resource. */ static struct rftype res_common_files[] =3D { { --=20 2.34.1 From nobody Mon Nov 25 04:41:22 2024 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2042.outbound.protection.outlook.com [40.107.220.42]) (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 5537520C010; Tue, 29 Oct 2024 23:25:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.42 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244305; cv=fail; b=OVYbQHPhn5teSyaDXBJsm3I8wp2Zgo/Kv5EHmbEmToD+pZF9YLj83lRjNQzl5uTAv5XvBgSWjqT3DtxKU2h4QwR8M/SzCvGja8Avcp3faFEXhHQT+dO2vysaUPyXbPBmp2R2YNpv9OYJqiRnikPe56RIQkyrB1fdh4iRhn+xsmc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244305; c=relaxed/simple; bh=cmPycCslCVhqH15OPdzDaJH7QBDqnAczNtrx0WNpumA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qi+iOSTLbKiuFJ0quaP+RJLwPoyY/Fk01dAzvKD6nD1/W5CXK4HB/oPRjHV24WC+H+UGh983hZFoV7OgEN2lCZ1OtYYMpyG6sJ2C5PnoUkrIkUVXAWs/1U961agQzpsWMhx47/KbqBM0wwwQBvBtMjN7Zf/NSYPsvT2hGHN5fZE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=Sb3ZAHGT; arc=fail smtp.client-ip=40.107.220.42 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) header.d=amd.com header.i=@amd.com header.b="Sb3ZAHGT" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=QqR++lBHlPXS+JG4MTV2xAi1HvYrunyzNoKHjzWF166/UTfH+J8rmYOAP/xrQm/n9swLdzExNEWx1Is26uYEN/nWMqCIik8Nd8CND77FvG8vNX9VDKQ5SduAWkp1HiogVgXp10PlfJkPYey6GxihFZIslwOzYYu6j/Pb+E8O7RiBnbfsnP+Trdl1iXuT5SNA9S4/zpy6EsJwqpchNyQSGrK7D0DOGFP2ZzGu7zbBgy8DkzQ3gmqDXvCkDi4CZfcyYd1vDXyR0JuiQBusvkhKu4ctTMF/VYp8+5ro9CBGb6MTRFfiHbmrRC5R5fAvMWVn+jg14R+hd39Hy3wr3qokoA== 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=/OEC810PVHXizf+eNwCxetZg1u0KhT4uJPuZ3YYxUqs=; b=k1zbw9tqpWWzEKy2UwZn4rhAA67MFHldboGdGiaS8/tHosg9DaNXslgBOVm7hzOS7yw1RHns+ubkLXjBaMGZc2/4kppYTYqV1dJ05MEbx6QWT9qs7N5ayR5xuXMxlW5hY43jDFhdtaGnZdtyGI/oubNAJZZRAoPOhtq3/PjU+Otrk0JsyNElHvRqykX3+ZS4/C2zXyTOr790odD/pUo++oRgU07M73QlTVuIO5/1VqZOWdZwXUueLgkKYM+qliKBs0apjSFum9l66At3LH7fnFIKehJ+7K/RrFA2LqqeKkyj1/35dfF/jKXWDCSroAM+pBhXtvzKQr6pQrW4UAEUbw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net 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=/OEC810PVHXizf+eNwCxetZg1u0KhT4uJPuZ3YYxUqs=; b=Sb3ZAHGTxbgJ80oY2IwEnlDNWr2lEL+dMbz+dyjmCNNI8C47ZanOJUZ9E0knkVV1J3M+HcqrrcgCQmAB2tDDRt9sBMes9ih11vgeU3h+le2E12UUiS3cxTn2v6hTSj62xE6XJpK5Ln6IJhnBuW6jYvXAxgnpq4baYmcTZqwJbVY= Received: from SN6PR08CA0026.namprd08.prod.outlook.com (2603:10b6:805:66::39) by CH3PR12MB8583.namprd12.prod.outlook.com (2603:10b6:610:15f::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Tue, 29 Oct 2024 23:24:55 +0000 Received: from SA2PEPF00001507.namprd04.prod.outlook.com (2603:10b6:805:66:cafe::4) by SN6PR08CA0026.outlook.office365.com (2603:10b6:805:66::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32 via Frontend Transport; Tue, 29 Oct 2024 23:24:55 +0000 X-MS-Exchange-Authentication-Results: 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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SA2PEPF00001507.mail.protection.outlook.com (10.167.242.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Tue, 29 Oct 2024 23:24:54 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 29 Oct 2024 18:24:39 -0500 From: Babu Moger To: , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v9 18/26] x86/resctrl: Add the interface to assign/update counter assignment Date: Tue, 29 Oct 2024 18:21:50 -0500 Message-ID: <3851fbd6ccd1cdc504229e4c7f7d2575c13f5bd6.1730244116.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00001507:EE_|CH3PR12MB8583:EE_ X-MS-Office365-Filtering-Correlation-Id: 4677ecc1-c9b4-4b00-04d9-08dcf870e584 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|7416014|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?Bgnk7U0BfRzUJUIat7IwsRDdqOSysiHdA6xJovZ7W8bjY5xiC+owlEGieJNS?= =?us-ascii?Q?x86YJJraaYBG3VtcC16qisRpoB1R0p46JzFGfunCZ6TARngb0IEjShNW8kJM?= =?us-ascii?Q?tzH0UdqebCUX4X7XLhqhdyM87UULuv5q2ir4CeuVwAvD6gcAkuqEmzo3Ea5j?= =?us-ascii?Q?bvrhbXzAqlcTl7oQUsFrH4icPDzRzglTCkzDiFNZHVkKal4OczZ0z1VZAUB4?= =?us-ascii?Q?O3xBWcXoDLlngQrAxR8M4DDepRFY2bckRhCRK/5FxIFX1DjhVDrSH2pbJT6I?= =?us-ascii?Q?CAoYKbbohDxOOf7VX3sK/ES3hCUyVcxGNjiPg0zOIRyRotnjHjhSuYoNjNdd?= =?us-ascii?Q?WI9qYX19ppcqJ5YUiWFRxIp5p0GZFJrbzEGAJBKOrSmjCg7R9/BKTJTZnqDf?= =?us-ascii?Q?YGhyI+cKScKVzi4mFQQF5eQz2AJ9WW2WyRW/RGIVaHfkRbfxif8RKjD3Zrxe?= =?us-ascii?Q?ptJLOrRQ99LXICWNpjBK+xWt93ztc7EZgKvxYsvvhCgz1WX8hzxbbWeUCov7?= =?us-ascii?Q?3WybCuBiFYH3mBILa5ipUxzgHRIGnXy88CpC9Hvi7IP5FFsb9YmghQN2G3Pj?= =?us-ascii?Q?BlgNkfAW7/ZvDmk8883RRxtYizPqLnxSocNu6zoPB9vjnhbPUQMlTNCNnQR4?= =?us-ascii?Q?KfllnDj6wOEem1H8obETBnvY+8MrsxENbPx5vdX9tl3T265E8Qnlbq97JF3o?= =?us-ascii?Q?P8IliSq5wesee97hCVs6hcDXphebExkzhtQj2470YMmWuSGOvKzS0PyraCBx?= =?us-ascii?Q?XpW6iw84wwH+h7cArmiGy199jzChG+f8XPCIY3K2lHUz66+U2sxCaH9Wmd7E?= =?us-ascii?Q?SvKK4q1esbn4yQu8LdZLXeSvVvchjiF9FLMMyWYREOMJpLt3l7n2OV3T7g5P?= =?us-ascii?Q?gHkjtNFbd7tpAtz3qQkUCgRz3CLmYXxQnArRPjczxIOhniWgTmnj6b3t03RQ?= =?us-ascii?Q?IwhpNZUiOUCs2uK0eBIENf1+0rrsul3syZUtQjFaIhAJGZhjyw0GYIYkcb3A?= =?us-ascii?Q?WpWE/W7ROFgOYDITU8+9X3ouvqjcFzKIvZfdWk7LWs27wCeQafXVTPnRYuX3?= =?us-ascii?Q?KLk9U10YBLyaCNGD17ARNgaMRsSNi4eGCLSndxTGBa3v4QWnwXLAXgzgG7Lf?= =?us-ascii?Q?K8jUHkKRveW5kfES8gCwMGAdD++0deeZy9Jq/fLpTlbPSzdyW8o/4LpGBMfo?= =?us-ascii?Q?mMd2CFPXZPiwTCReYsUoRS0f9c4enxYGgy9g22z8TXL6qSsn61rlTI7gvQJ6?= =?us-ascii?Q?wLbOcdNskVhGUcaHmGjQiPvO3U9RhgdB3eJqA79jPp+j+2p3DKS1x93mK+Ob?= =?us-ascii?Q?nmnE54p0yHLTfQNkU4XgvPpTvSDAxDOvB2k3qxIuJ4oAwXfgfvV9OSl0ZCpb?= =?us-ascii?Q?oiMm+iWTTjU1ck+8nRqW5VZkGYll5SwxpBV5xY2b7W/s1D96vA=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(376014)(7416014)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 23:24:54.9646 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4677ecc1-c9b4-4b00-04d9-08dcf870e584 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF00001507.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8583 Content-Type: text/plain; charset="utf-8" The mbm_cntr_assign mode offers several hardware counters that can be assigned to an RMID, event pair and monitor the bandwidth as long as it is assigned. Counters are managed at two levels. The global assignment is tracked using the mbm_cntr_free_map field in the struct resctrl_mon, while domain-specific assignments are tracked using the mbm_cntr_map field in the struct rdt_mon_domain. Allocation begins at the global level and is then applied individually to each domain. Introduce an interface to allocate these counters and update the corresponding domains accordingly. Signed-off-by: Babu Moger --- v9: Introduced new function resctrl_config_cntr to assign the counter, upda= te the bitmap and reset the architectural state. Taken care of error handling(freeing the counter) when assignment fails. Moved mbm_cntr_assigned_to_domain here as it used in this patch. Minor text changes. v8: Renamed rdtgroup_assign_cntr() to rdtgroup_assign_cntr_event(). Added the code to return the error if rdtgroup_assign_cntr_event fails. Moved definition of MBM_EVENT_ARRAY_INDEX to resctrl/internal.h. Updated typo in the comments. v7: New patch. Moved all the FS code here. Merged rdtgroup_assign_cntr and rdtgroup_alloc_cntr. Adde new #define MBM_EVENT_ARRAY_INDEX. --- arch/x86/kernel/cpu/resctrl/internal.h | 2 + arch/x86/kernel/cpu/resctrl/rdtgroup.c | 87 ++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 00f7bf60e16a..cb496bd97007 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -717,6 +717,8 @@ unsigned int mon_event_config_index_get(u32 evtid); int resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_mon_domain= *d, enum resctrl_event_id evtid, u32 rmid, u32 closid, u32 cntr_id, bool assign); +int rdtgroup_assign_cntr_event(struct rdt_resource *r, struct rdtgroup *rd= tgrp, + struct rdt_mon_domain *d, enum resctrl_event_id evtid); void rdt_staged_configs_clear(void); bool closid_allocated(unsigned int closid); int resctrl_find_cleanest_closid(void); diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 1b5529c212f5..bc3752967c44 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -1924,6 +1924,93 @@ int resctrl_arch_config_cntr(struct rdt_resource *r,= struct rdt_mon_domain *d, return 0; } =20 +/* + * Configure the counter for the event, RMID pair for the domain. + * Update the bitmap and reset the architectural state. + */ +static int resctrl_config_cntr(struct rdt_resource *r, struct rdt_mon_doma= in *d, + enum resctrl_event_id evtid, u32 rmid, u32 closid, + u32 cntr_id, bool assign) +{ + int ret; + + ret =3D resctrl_arch_config_cntr(r, d, evtid, rmid, closid, cntr_id, assi= gn); + if (ret) + return ret; + + if (assign) + __set_bit(cntr_id, d->mbm_cntr_map); + else + __clear_bit(cntr_id, d->mbm_cntr_map); + + /* + * Reset the architectural state so that reading of hardware + * counter is not considered as an overflow in next update. + */ + resctrl_arch_reset_rmid(r, d, closid, rmid, evtid); + + return ret; +} + +static bool mbm_cntr_assigned_to_domain(struct rdt_resource *r, u32 cntr_i= d) +{ + struct rdt_mon_domain *d; + + list_for_each_entry(d, &r->mon_domains, hdr.list) + if (test_bit(cntr_id, d->mbm_cntr_map)) + return 1; + + return 0; +} + +/* + * Assign a hardware counter to event @evtid of group @rdtgrp. + * Counter will be assigned to all the domains if rdt_mon_domain is NULL + * else the counter will be assigned to specific domain. + */ +int rdtgroup_assign_cntr_event(struct rdt_resource *r, struct rdtgroup *rd= tgrp, + struct rdt_mon_domain *d, enum resctrl_event_id evtid) +{ + int index =3D MBM_EVENT_ARRAY_INDEX(evtid); + int cntr_id =3D rdtgrp->mon.cntr_id[index]; + int ret; + + /* + * Allocate a new counter id to the event if the counter is not + * assigned already. + */ + if (cntr_id =3D=3D MON_CNTR_UNSET) { + cntr_id =3D mbm_cntr_alloc(r); + if (cntr_id < 0) { + rdt_last_cmd_puts("Out of MBM assignable counters\n"); + return -ENOSPC; + } + rdtgrp->mon.cntr_id[index] =3D cntr_id; + } + + if (!d) { + list_for_each_entry(d, &r->mon_domains, hdr.list) { + ret =3D resctrl_config_cntr(r, d, evtid, rdtgrp->mon.rmid, + rdtgrp->closid, cntr_id, true); + if (ret) + goto out_done_assign; + } + } else { + ret =3D resctrl_config_cntr(r, d, evtid, rdtgrp->mon.rmid, + rdtgrp->closid, cntr_id, true); + if (ret) + goto out_done_assign; + } + +out_done_assign: + if (ret && !mbm_cntr_assigned_to_domain(r, cntr_id)) { + mbm_cntr_free(r, cntr_id); + rdtgroup_cntr_id_init(rdtgrp, evtid); + } + + return ret; +} + /* rdtgroup information files for one cache resource. */ static struct rftype res_common_files[] =3D { { --=20 2.34.1 From nobody Mon Nov 25 04:41:22 2024 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2064.outbound.protection.outlook.com [40.107.220.64]) (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 1F8D820C03E; Tue, 29 Oct 2024 23:24:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.64 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244301; cv=fail; b=Wjj4ueTxNfnvo/PZQ2KhrJV6vb0eO7y4WPBsvLPce5M4sCpdgqg/BKAesfl4d3PN7mOYeylCMx+nA1d9d9QLBmPj88KXksZ/6ojKeDMrKUZqmD5zS27ELNTD4GC5uG0Aj8dxhD5vAN6PzRY8E3BdMiwt1hM76LlcYgOvqoktLiU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244301; c=relaxed/simple; bh=3c+K7mTpbWuwj5DHbpGJwyFbugrQmeHvzdAMo/y0/E0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=c8Dywh3VoJ4xZceB5zOZLRJ7KdMdyTxcsSAO62uHMPwhRcvM2bGahFIMOpy4NgLOYs1X9XBMfojy1Ipa2Mfef1FUlM2DQ59l7V93YVWYAOCgekx5ZvX2UQ0vgU5LysliVbc/e8a7HKhJ9lelEAwfNCvWhYGHcd/pI7RD32Gs8X0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=QCDEKnDG; arc=fail smtp.client-ip=40.107.220.64 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) header.d=amd.com header.i=@amd.com header.b="QCDEKnDG" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BPOq+g1VVnqwSUgFW5EwvtwuSzLK/MPtRfKx4IniA/04wBdvy/vonlYL2sj4sxAVo4diuAqySizD5xJkpAokTCEVmR4kNLKjc5RFGYPCLkOIAc1btdKV4QMrWt4NBI13Xx5v+HRZSfy3thZNvKZwrVjF47YZIQowqZtKuaH/PgH8Q8hOlW7UVCn7MTlv2qBh6PDvAhopMkJQXavf4T2NLawga5axtKviizPWBWCJ63kJBejYNUsi32fWPRxVYgCH9DtKoc0gGa8e/OTGT8BKfdmkTqkEsNnEKBqSvhODTN0kWj4sn+KShLDo228nMknHNgCzEAkRwioFb4nXoSCT2A== 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=3lgJc4GFG8DitFNODUOSWfso0cmaBtUOP8bVocO6kQE=; b=HECUFX5yHR9YQb+MnbUZJoIfDc66aSU3YG2ZcHmZSJW3UEmIYDS94hteRxudjeDvbbNO0AUXhpyBWf6B1V//IhNjjagNcS61F/prFEgEpdmYHT48wUGAPqigx1wKFw3ETa8WidVSzqUyE5Ya1zm4JMriIDwWuH/SBp0HclwnDy5GmOIHcKiPXFV2WrkkrQTwzaJ5KUEaiDej7KeWeZNQZZflMoeZs08kSQZ7R8Hhu+xwiRBJ2aqG6hi5a63H+12uBXNZo2bdjnAhxmkw0+xMRSIJFTqE4jsj52reRlLqs0L1Si3PuOUChy41+dyaPv10Q6+g2VdJcBJFjB52rIEApw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net 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=3lgJc4GFG8DitFNODUOSWfso0cmaBtUOP8bVocO6kQE=; b=QCDEKnDGZD1mtWqFIa/5MougYFBpeL2cjOjW77mCicyLWjgqRFiV4xYYq14PK5Rmh5EzwH3Pg7AQxJxvG3WCkRM+GphyycMjZWVFbJ7zSXUJrxFpNhj4u4CVIYwsSn4mAi0ZnzUY/FbbWzFJ8d8jZNiJ99DQe50rp34pKDg0hGY= Received: from SN6PR08CA0004.namprd08.prod.outlook.com (2603:10b6:805:66::17) by PH8PR12MB7205.namprd12.prod.outlook.com (2603:10b6:510:227::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.29; Tue, 29 Oct 2024 23:24:55 +0000 Received: from SA2PEPF00001507.namprd04.prod.outlook.com (2603:10b6:805:66:cafe::c8) by SN6PR08CA0004.outlook.office365.com (2603:10b6:805:66::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.19 via Frontend Transport; Tue, 29 Oct 2024 23:24:55 +0000 X-MS-Exchange-Authentication-Results: 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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SA2PEPF00001507.mail.protection.outlook.com (10.167.242.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Tue, 29 Oct 2024 23:24:55 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 29 Oct 2024 18:24:47 -0500 From: Babu Moger To: , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v9 19/26] x86/resctrl: Add the interface to unassign a MBM counter Date: Tue, 29 Oct 2024 18:21:51 -0500 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00001507:EE_|PH8PR12MB7205:EE_ X-MS-Office365-Filtering-Correlation-Id: 8f510502-e80c-4ebf-c41d-08dcf870e604 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|1800799024|7416014|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?6/riaFmsFAgPSGuEmLF9XGICXTt37LbyR5eU2EonIgjePJVY6u0t0A11af/R?= =?us-ascii?Q?jS0SBf+CgKB+qScaaZkYJx/iz1urKJbZZHElbUizXySgEzyY3CxHfhLjHp22?= =?us-ascii?Q?1hGyYllomUFqcBwMCQGU3DAF2+IxICgsPJYoDfy28UPreVpZMysiusQdv/XJ?= =?us-ascii?Q?Jm4NGn0maYHBKXgUanE/2/aIucw4r5zcHXyDWZEVji7w5AgC5eBGodNgN97T?= =?us-ascii?Q?81miRUzzpxG7496Y6y8zT0p40IzXZRegXQxOuYDzN/brKsjgku2ICiLcko3g?= =?us-ascii?Q?W1q+WBxgg8GRdBvxl9shwTRlWWPBsPc+Pqg6e1KmjuSEx8aD/k9f2wXUoKcc?= =?us-ascii?Q?1yw55ZWNKmzbbOy73CvKpIVl8lzVs+I1C1Sv4Nzh+b0gIwgHMyhVuSsqaTZ5?= =?us-ascii?Q?XQBNk/Wx3vhuLDJHlUWrAmNKDsB74oIUgec498DTSRTVmlBNetH5L4fbyWwl?= =?us-ascii?Q?g1CG9xJj4K8/GnJP3wxNYljB2T2fNn/SJm4Tl/wmJpQuPlqLzlI5yFQLHwQZ?= =?us-ascii?Q?pIK3VxytZoTti72r1C7adC7gCdWF6TpceoHtLgAVXY4VxURlKpZ22y0f3jRK?= =?us-ascii?Q?QeIXlLdQYwTg94VTqmCFUf2CKY7GGP0aJ6mt8z1/Hpd0nri4f/Av9GvjaEBa?= =?us-ascii?Q?txa3peZ1EtBw8PL1C3ZX7jsA4vIEy6B273dnk/wkFvIgZNbAW45awoSpBKOR?= =?us-ascii?Q?vN7NoPCsexOe/5b2joGFu7mCdlw6k81vdisRfb7ZvcG1BV/TSl2dx9/FWjNN?= =?us-ascii?Q?3FEAc01DmFmoxPU4g3nV6+DWblRA2aK7uw4/d52jy1pKNJwyGC1Mzh29wvr2?= =?us-ascii?Q?LhkwHd+SbNqRiIICePUj8Pji9eaJAKMKvtKyF7cUfz+jUTEXywYM26RxT0bA?= =?us-ascii?Q?/EczN6BSAxKPiPN1RKUSAtCnoqAIx3nj7Qm9ACYqCQxAwrYKkaa/B/M8ANEw?= =?us-ascii?Q?SL5pdcK8elLQYu7kCMWdWjoN35cd8ZFciTa/XmY+pPgWwAKls77Ur5ZX7j1C?= =?us-ascii?Q?fvx3Kx9r3vJ0hoaTV0UEJ79rFl64sRaoRucTBbJuwL6X1oCD6dj8OYzYxQrd?= =?us-ascii?Q?Bgv5odackZg5OQ9l5483s+mu3VudIyYqi5nWX364ORLvLeDyw3/QD1+md6B0?= =?us-ascii?Q?TQar7WMDCCOA7Xv0rHwvYuYK/7EMW/87wDKM9xTZ3gXm/pSI9VT1Rg5wpTAF?= =?us-ascii?Q?VfCu+V9UyDKRMUl+NyHtjNmqwcfekN+Xgs1Nq7TmRBhOHy4xwQTCQTH1lIA8?= =?us-ascii?Q?dozxQgbuLsV7z4LfBQE2YVmIcZrEijXNQyCxi1XYDOps7EQDcQr/Q8zZm3vA?= =?us-ascii?Q?fs6ghoqC5FJF8CqaRJirGk8RMXWJu5T5ba43Dj4Qa9XW7oxJfghFEItKPLTu?= =?us-ascii?Q?9JODzxs2HnbhGR3glDtdla0O8pWwkXqX+WkBQliJfqHaL/ZOgg=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(376014)(1800799024)(7416014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 23:24:55.8084 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8f510502-e80c-4ebf-c41d-08dcf870e604 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF00001507.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7205 Content-Type: text/plain; charset="utf-8" The mbm_cntr_assign mode provides a limited number of hardware counters that can be assigned to an RMID, event pair to monitor bandwidth while assigned. If all counters are in use, the kernel will show an error message: "Out of MBM assignable counters" when a new assignment is requested. To make space for a new assignment, users must unassign an already assigned counter. Introduce an interface that allows for the unassignment of counter IDs from both the group and the domain. Additionally, ensure that the global counter is released if it is no longer assigned to any domains. Signed-off-by: Babu Moger --- v9: Changes related to addition of new function resctrl_config_cntr(). The removed rdtgroup_mbm_cntr_is_assigned() as it was introduced already. Text changes to take care comments. v8: Renamed rdtgroup_mbm_cntr_is_assigned to mbm_cntr_assigned_to_domain Added return error handling in resctrl_arch_config_cntr(). v7: Merged rdtgroup_unassign_cntr and rdtgroup_free_cntr functions. Renamed rdtgroup_mbm_cntr_test() to rdtgroup_mbm_cntr_is_assigned(). Reworded the commit log little bit. v6: Removed mbm_cntr_free from this patch. Added counter test in all the domains and free if it is not assigned to any domains. v5: Few name changes to match cntr_id. Changed the function names to rdtgroup_unassign_cntr More comments on commit log. v4: Added domain specific unassign feature. Few name changes. v3: Removed the static from the prototype of rdtgroup_unassign_abmc. The function is not called directly from user anymore. These changes are related to global assignment interface. v2: No changes. --- arch/x86/kernel/cpu/resctrl/internal.h | 2 ++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 41 ++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index cb496bd97007..66de0ce12aba 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -719,6 +719,8 @@ int resctrl_arch_config_cntr(struct rdt_resource *r, st= ruct rdt_mon_domain *d, u32 cntr_id, bool assign); int rdtgroup_assign_cntr_event(struct rdt_resource *r, struct rdtgroup *rd= tgrp, struct rdt_mon_domain *d, enum resctrl_event_id evtid); +int rdtgroup_unassign_cntr_event(struct rdt_resource *r, struct rdtgroup *= rdtgrp, + struct rdt_mon_domain *d, enum resctrl_event_id evtid); void rdt_staged_configs_clear(void); bool closid_allocated(unsigned int closid); int resctrl_find_cleanest_closid(void); diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index bc3752967c44..b0cce3dfd062 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -2011,6 +2011,47 @@ int rdtgroup_assign_cntr_event(struct rdt_resource *= r, struct rdtgroup *rdtgrp, return ret; } =20 +/* + * Unassign a hardware counter associated with @evtid from the domain and + * the group. Unassign the counters from all the domains if rdt_mon_domain + * is NULL else unassign from the specific domain. + * Free the global counter once unassigned from all the domains. + */ +int rdtgroup_unassign_cntr_event(struct rdt_resource *r, struct rdtgroup *= rdtgrp, + struct rdt_mon_domain *d, enum resctrl_event_id evtid) +{ + int index =3D MBM_EVENT_ARRAY_INDEX(evtid); + int cntr_id =3D rdtgrp->mon.cntr_id[index]; + int ret; + + /* Return early if the counter is unassigned already */ + if (cntr_id =3D=3D MON_CNTR_UNSET) + return 0; + + if (!d) { + list_for_each_entry(d, &r->mon_domains, hdr.list) { + ret =3D resctrl_config_cntr(r, d, evtid, rdtgrp->mon.rmid, + rdtgrp->closid, cntr_id, false); + if (ret) + goto out_done_unassign; + } + } else { + ret =3D resctrl_config_cntr(r, d, evtid, rdtgrp->mon.rmid, + rdtgrp->closid, cntr_id, false); + if (ret) + goto out_done_unassign; + } + + /* Free the counter id once it is unassigned from all the domains */ + if (!mbm_cntr_assigned_to_domain(r, cntr_id)) { + mbm_cntr_free(r, cntr_id); + rdtgroup_cntr_id_init(rdtgrp, evtid); + } + +out_done_unassign: + return ret; +} + /* rdtgroup information files for one cache resource. */ static struct rftype res_common_files[] =3D { { --=20 2.34.1 From nobody Mon Nov 25 04:41:22 2024 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2067.outbound.protection.outlook.com [40.107.94.67]) (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 095A320C017; Tue, 29 Oct 2024 23:25:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.67 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244318; cv=fail; b=Inj1PMesEgO7M/Z0MHufLLB36cnPxSXJRwtSniDfakdBoimEjmwTvy9JHN7puUvKnkpIFjwKaNBlnJKjevasgEsWrf3aLtQA810PK2h/IViy0ynnMmR65oYGwDRGilfvk7Ngwtn/T3gHFkFNMI+t/Yh6yKp32nwG7wsxJUNG8HA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244318; c=relaxed/simple; bh=/C/2kHRU0+d9XWAhefuEt2DD5Uxx7TfoKUvJC3phkC4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XjPaNLIg1KFxl/fb00MOn64haCh7I9FUVPhS/A6k0lRUTpNUjwS6zfMa5ljXi4JwG6lickllQsBB8FZOewYknS1i24qBAx3p0fY3X8/c3Bum/flQ0je7iQVMCBn0ppPKgHjriY16N8Vcp/BU6gN4hRpEWnikutW5vInh0+shXR0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=UhxUvaRF; arc=fail smtp.client-ip=40.107.94.67 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) header.d=amd.com header.i=@amd.com header.b="UhxUvaRF" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DIqfv4PqwRxk5GYzk5hmleLw6r7Hk5rnOItVrI5rgjg15dm8RXno4exoghy6OrvVVajMohA83lY6JXzL04txctBNZ2M7MEOA4yy0tDnpEQzd2HHtR1N4lrkhf6ImwPsH1H5bao3s7Z4qa5/hFWz8PdJxel06SWW86hUobb5MCTkVytFBkWyQbmqFWHGG9Ad9yAmbUSplhHVqAlRLX4vE5qoatQ5uiYR3LV57nycalVzJEbvw5fOwelo/ufDAhdLlcFUdIoo4J3IGbSJuYwqJ1Q3uc0hEWu7Yug28sjMKNhbDlbl5qqoKuJFdTl8F3XO3VYdRZZUGzIoySGtBlsSdtw== 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=CX9m6nhwVylvJd06phujkaiFhpD1fHqZRmkMhsZBUyY=; b=eSpaEtu5kAlZCAZj8wMqQkXfF78CwfivNHJbXKjClCjtCWO2WOClUBsv5X/N/ZLTLShrJ0xJB53zVNPkKKX0blS6/MMhZXZ4XyispGkBBGJfzWgNKV0Tc7q9227grsDuV4xSnqjN8qkyl0L7OIjNWR55sxts3ooxyjrS8igH6Nlk4ZHtSyglMtpBdoEwjHYDqEpBCgg1XJ2fOZmEUCOX1gNzt0lDQtntg/oSuh+rzTrb2PZnd0IU4IsFMf2htKlNsKrOPllsMFGXyRW4sXG3P0XVMQzaKmzn67z8qdRxuY06c66p0NjbmNN5qBo4uHLrkxT3HNuQj+x1tHXF3H/QfA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net 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=CX9m6nhwVylvJd06phujkaiFhpD1fHqZRmkMhsZBUyY=; b=UhxUvaRF626fPyrJrWcnsZ2Z/alTyREE2JnT0mO6XW3rYWUrhXdQxz9pcwfY9Krgys0JBc6yAa+dHPuXjPjR6KmRRZoueCSO8kAF3RX8+brilCTsE7eoT6wq/57mwv6wI5oYMvo2lHA60YoZUAUjzuyCwKY5c02p56krLQCrAN4= Received: from MW4PR03CA0347.namprd03.prod.outlook.com (2603:10b6:303:dc::22) by IA0PR12MB8277.namprd12.prod.outlook.com (2603:10b6:208:3de::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Tue, 29 Oct 2024 23:25:12 +0000 Received: from CO1PEPF000044F4.namprd05.prod.outlook.com (2603:10b6:303:dc:cafe::cd) by MW4PR03CA0347.outlook.office365.com (2603:10b6:303:dc::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.26 via Frontend Transport; Tue, 29 Oct 2024 23:25:12 +0000 X-MS-Exchange-Authentication-Results: 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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1PEPF000044F4.mail.protection.outlook.com (10.167.241.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Tue, 29 Oct 2024 23:25:12 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 29 Oct 2024 18:24:56 -0500 From: Babu Moger To: , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v9 20/26] x86/resctrl: Auto assign/unassign counters when mbm_cntr_assign is enabled Date: Tue, 29 Oct 2024 18:21:52 -0500 Message-ID: <4ec00fe60cd42c1f22c98c9f5c2f5d3ceb9f8d58.1730244116.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044F4:EE_|IA0PR12MB8277:EE_ X-MS-Office365-Filtering-Correlation-Id: 84858472-a70f-49f6-aeaf-08dcf870efd4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|7416014|376014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?CvZ/og522YSS0ULuESG0aPmGf8szhUhIGGlAAQZh6gGagdjjA+hL9DLWiFhi?= =?us-ascii?Q?rcQB+/hyQWG1SEOMfT5uqi6hddobfYNoNCeo3L5uzgDa2noG6+/9Nj7HT+hi?= =?us-ascii?Q?9pTAMCyX3Fq7xi6KrGrayO5d+Cm+XnNGfAB+f2W4deLI2xeB653PR9hJSg6v?= =?us-ascii?Q?lhhrMAR6Y1wCDvbep5GUZhE1XUahekGXM2PdcTOC6A8ttysjDLMWj+G1InKy?= =?us-ascii?Q?jYMR5rorzTA8L0pcFtRCKddKU1KedEpGs/EzWwJOUvN2wmC5kqzNhNoMa4K0?= =?us-ascii?Q?Z9/c7a+/Djw88jVUZ0sLg5x+9/1Ib4KHGeRYSjyInDe0suEorFDEmPOoC9wT?= =?us-ascii?Q?ZFakWOI8tSHz86yZ1ALXPVDxfOC1yeoeKCB05ZGDXku5CH1pDiFGlbC+IMXw?= =?us-ascii?Q?NOo7QILPgz6Sr5KksUwg3dUaEzGTAe2nZyOcEyxuAj2YUBaHS0gRQNVIu9JY?= =?us-ascii?Q?S0ECDApN9ow+E8LvgTN4s/Ce5oxmlB84Ieqxfcuw2wpSNEpIzDSXgYT05nj6?= =?us-ascii?Q?+8oGpB1mxQqYw0+j0mxgQykafQ03NGB2Flq7HGJIlAai5Jz0iTCi6O2MfoQY?= =?us-ascii?Q?4WdT/TRryoTaD/+du5U9/gW2de7o4gptN/JrbIIzMoXHWl44B46HLvulJJQu?= =?us-ascii?Q?9ANLKF1mk/fR9wA02PddmsK0ukci5XjT2TMOG3ES/9KHBc+9rf7dxN8l2Ap1?= =?us-ascii?Q?gT0yRKlSN7DKGaDB6I8osTF6t3nKlvKIq/wqCD4/3v+K3/Me0cLspwOqXBV8?= =?us-ascii?Q?Y0cjgv1tI3DPIWyqE2w5dohwHPYhsJUYu0MFmVnkt2EUzTRRoCx4MBiHB3J3?= =?us-ascii?Q?03R3PdXeVexUbGTeFjDwk0C6iDPLQ5UjxXgKk9/6hMBEZh17VFmi+gAd+uFf?= =?us-ascii?Q?JLah0mhqBCaQe2WYzDsqpUqGbau7fP2e9ZoXOlQu0JkahzgwCN0FEZtV4Scm?= =?us-ascii?Q?aGr/XaKLq6dise9LNhmNVG1Qfg5/4e8M0rTbBU5Sfo+fxmH55wU/wKt+WjcV?= =?us-ascii?Q?QxIAggmtnR76HuhMjtHZS0ycWwmUtrSUz5jicJ6e/vYe7utaPzmRwjO9QNdu?= =?us-ascii?Q?RdD6fqcgas1S6ryWSKZLggZEbVuUVWwnksl811+whKShR1+Yp3ziqWRTli5G?= =?us-ascii?Q?vcxApRnNYjXoJbqnuj8dJo9K62G8CQXoWTQ6xsgbN03GGRZqv5FwtgGGPkFi?= =?us-ascii?Q?fUc1QGShdp5+fGM97JoOX2AIE+8ZAzB9sPvOwleuqdzXBkKjo1UNuDZyrTTC?= =?us-ascii?Q?+HlNPJIr3QFSRMq7V5bG+gPja1ylZTxyKwhIbvq/PI4Wybft1hErLMJ6eQnN?= =?us-ascii?Q?6Il/zGRaSbKMYPSNx0P7ld1+3hXsE3ekldusZjmpci9OyOrhN+h3Lu24b0Rc?= =?us-ascii?Q?TpDEU+MhcYKbTFSZ/QMxmrz3K/0twb5MPKXCdMc+frUrhQjVQQ=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(7416014)(376014)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 23:25:12.1767 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 84858472-a70f-49f6-aeaf-08dcf870efd4 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044F4.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8277 Content-Type: text/plain; charset="utf-8" Assign/unassign counters on resctrl group creation/deletion. Two counters are required per group, one for MBM total event and one for MBM local event. There are a limited number of counters available for assignment. If these counters are exhausted, the kernel will display the error message: "Out of MBM assignable counters". However, it is not necessary to fail the creation of a group due to assignment failures. Users have the flexibility to modify the assignments at a later time. Signed-off-by: Babu Moger --- v9: Changed rdtgroup_assign_cntrs() and rdtgroup_unassign_cntrs() to return= void. Updated couple of rdtgroup_unassign_cntrs() calls properly. Updated function comments. v8: Renamed rdtgroup_assign_grp to rdtgroup_assign_cntrs. Renamed rdtgroup_unassign_grp to rdtgroup_unassign_cntrs. Fixed the problem with unassigning the child MON groups of CTRL_MON gro= up. v7: Reworded the commit message. Removed the reference of ABMC with mbm_cntr_assign. Renamed the function rdtgroup_assign_cntrs to rdtgroup_assign_grp. v6: Removed the redundant comments on all the calls of rdtgroup_assign_cntrs. Updated the commit message. Dropped printing error message on every call of rdtgroup_assign_cntrs. v5: Removed the code to enable/disable ABMC during the mount. That will be another patch. Added arch callers to get the arch specific data. Renamed fuctions to match the other abmc function. Added code comments for assignment failures. v4: Few name changes based on the upstream discussion. Commit message update. v3: This is a new patch. Patch addresses the upstream comment to enable ABMC feature by default if the feature is available. --- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 61 +++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index b0cce3dfd062..a8d21b0b2054 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -2932,6 +2932,46 @@ static void schemata_list_destroy(void) } } =20 +/* + * Called when a new group is created. If "mbm_cntr_assign" mode is enable= d, + * counters are automatically assigned. Each group can accommodate two cou= nters: + * one for the total event and one for the local event. Assignments may fa= il + * due to the limited number of counters. However, it is not necessary to = fail + * the group creation and thus no failure is returned. Users have the opti= on + * to modify the counter assignments after the group has been created. + */ +static void rdtgroup_assign_cntrs(struct rdtgroup *rdtgrp) +{ + struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; + + if (!resctrl_arch_mbm_cntr_assign_enabled(r)) + return; + + if (is_mbm_total_enabled()) + rdtgroup_assign_cntr_event(r, rdtgrp, NULL, QOS_L3_MBM_TOTAL_EVENT_ID); + + if (is_mbm_local_enabled()) + rdtgroup_assign_cntr_event(r, rdtgrp, NULL, QOS_L3_MBM_LOCAL_EVENT_ID); +} + +/* + * Called when a group is deleted. Counters are unassigned if it was in + * assigned state. + */ +static void rdtgroup_unassign_cntrs(struct rdtgroup *rdtgrp) +{ + struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; + + if (!resctrl_arch_mbm_cntr_assign_enabled(r)) + return; + + if (is_mbm_total_enabled()) + rdtgroup_unassign_cntr_event(r, rdtgrp, NULL, QOS_L3_MBM_TOTAL_EVENT_ID); + + if (is_mbm_local_enabled()) + rdtgroup_unassign_cntr_event(r, rdtgrp, NULL, QOS_L3_MBM_LOCAL_EVENT_ID); +} + static int rdt_get_tree(struct fs_context *fc) { struct rdt_fs_context *ctx =3D rdt_fc2context(fc); @@ -2991,6 +3031,8 @@ static int rdt_get_tree(struct fs_context *fc) if (ret < 0) goto out_mongrp; rdtgroup_default.mon.mon_data_kn =3D kn_mondata; + + rdtgroup_assign_cntrs(&rdtgroup_default); } =20 ret =3D rdt_pseudo_lock_init(); @@ -3021,8 +3063,10 @@ static int rdt_get_tree(struct fs_context *fc) out_psl: rdt_pseudo_lock_release(); out_mondata: - if (resctrl_arch_mon_capable()) + if (resctrl_arch_mon_capable()) { + rdtgroup_unassign_cntrs(&rdtgroup_default); kernfs_remove(kn_mondata); + } out_mongrp: if (resctrl_arch_mon_capable()) kernfs_remove(kn_mongrp); @@ -3201,6 +3245,7 @@ static void free_all_child_rdtgrp(struct rdtgroup *rd= tgrp) =20 head =3D &rdtgrp->mon.crdtgrp_list; list_for_each_entry_safe(sentry, stmp, head, mon.crdtgrp_list) { + rdtgroup_unassign_cntrs(sentry); free_rmid(sentry->closid, sentry->mon.rmid); list_del(&sentry->mon.crdtgrp_list); =20 @@ -3241,6 +3286,8 @@ static void rmdir_all_sub(void) cpumask_or(&rdtgroup_default.cpu_mask, &rdtgroup_default.cpu_mask, &rdtgrp->cpu_mask); =20 + rdtgroup_unassign_cntrs(rdtgrp); + free_rmid(rdtgrp->closid, rdtgrp->mon.rmid); =20 kernfs_remove(rdtgrp->kn); @@ -3272,6 +3319,7 @@ static void rdt_kill_sb(struct super_block *sb) for_each_alloc_capable_rdt_resource(r) reset_all_ctrls(r); rmdir_all_sub(); + rdtgroup_unassign_cntrs(&rdtgroup_default); rdt_pseudo_lock_release(); rdtgroup_default.mode =3D RDT_MODE_SHAREABLE; schemata_list_destroy(); @@ -3280,6 +3328,7 @@ static void rdt_kill_sb(struct super_block *sb) resctrl_arch_disable_alloc(); if (resctrl_arch_mon_capable()) resctrl_arch_disable_mon(); + resctrl_mounted =3D false; kernfs_kill_sb(sb); mutex_unlock(&rdtgroup_mutex); @@ -3871,6 +3920,8 @@ static int rdtgroup_mkdir_mon(struct kernfs_node *par= ent_kn, goto out_unlock; } =20 + rdtgroup_assign_cntrs(rdtgrp); + kernfs_activate(rdtgrp->kn); =20 /* @@ -3915,6 +3966,8 @@ static int rdtgroup_mkdir_ctrl_mon(struct kernfs_node= *parent_kn, if (ret) goto out_closid_free; =20 + rdtgroup_assign_cntrs(rdtgrp); + kernfs_activate(rdtgrp->kn); =20 ret =3D rdtgroup_init_alloc(rdtgrp); @@ -3940,6 +3993,7 @@ static int rdtgroup_mkdir_ctrl_mon(struct kernfs_node= *parent_kn, out_del_list: list_del(&rdtgrp->rdtgroup_list); out_rmid_free: + rdtgroup_unassign_cntrs(rdtgrp); mkdir_rdt_prepare_rmid_free(rdtgrp); out_closid_free: closid_free(closid); @@ -4010,6 +4064,9 @@ static int rdtgroup_rmdir_mon(struct rdtgroup *rdtgrp= , cpumask_var_t tmpmask) update_closid_rmid(tmpmask, NULL); =20 rdtgrp->flags =3D RDT_DELETED; + + rdtgroup_unassign_cntrs(rdtgrp); + free_rmid(rdtgrp->closid, rdtgrp->mon.rmid); =20 /* @@ -4056,6 +4113,8 @@ static int rdtgroup_rmdir_ctrl(struct rdtgroup *rdtgr= p, cpumask_var_t tmpmask) cpumask_or(tmpmask, tmpmask, &rdtgrp->cpu_mask); update_closid_rmid(tmpmask, NULL); =20 + rdtgroup_unassign_cntrs(rdtgrp); + free_rmid(rdtgrp->closid, rdtgrp->mon.rmid); closid_free(rdtgrp->closid); =20 --=20 2.34.1 From nobody Mon Nov 25 04:41:22 2024 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2086.outbound.protection.outlook.com [40.107.243.86]) (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 67FBB20C49E; Tue, 29 Oct 2024 23:25:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.86 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244318; cv=fail; b=ZUbuGLYLG8VNQQPnRsjFxU979xVSCJLKDMFEpLyQpAHxCflJAnKL0sQL4oofsCvCh4qiqpbEJz/ZpM3d9Pt17EV3I5pnitezHFya1bnauoj427koywKGx3d8bVsvYrN5TrqhuwX5KOoSBI63DGdJszHtNbMfr4da63jUzf0PtXc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244318; c=relaxed/simple; bh=mloZlnjpGQW5jvhsi6is6ot4gd8ajl7SBErTlHUfOHc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RsXq2Gg+EL0PuLUxjBOjBzRzK32Q2PBG2mmnKyPDLsdRs4PnURkcH/5ZuoJJWMBoPyjpP6EaDSo94Oa9rVLELqr34K3iAzms6tY7ph20WxZ2ZVA0nHSyCxYTYU5nX9B71ti9D1qrM3a/PFttABMUqLqZroOETxI0X5jgcAqwubo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=JiTfBH7z; arc=fail smtp.client-ip=40.107.243.86 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) header.d=amd.com header.i=@amd.com header.b="JiTfBH7z" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=k/f+nocROOxblYXjHOv4Ec02vKH1wtIAhaGi2Nm64nDwk1LcLf++I8SZNYf6fGEdBT12D69fRQqM7MVZh58lgCKbkH0EAwhdbmZ7sKrHE6Yqugh6/zelD0UOPbywE4ww3XigUuq/0zWqba7R0s4Bu+jZayQaLAMBIzg5aMqMujNw9uHfq9E1bhgKi40XoTMJ4eVyIU/EjWA22T3gPApNyLhMWpMVCqvzQ8cySe91IMrWeYLIYDXN/IsSNz6lapYrVipRMbBaZCRK9Lw/4TX/DydgMzKqBmRaGgFR0E5fSUQzD8ijRcLCn5C3+BbGh5F3rt9OThklqUHZhH7TPTqNug== 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=aZou7qGuKK8COqvffsuwn3JWZs/IBplc/L8y15Kolkc=; b=qO6coHCinnR4LPdvPCJ9PIZ6M8gaFxp8/feToHw02KfBPXSUpIKqq0z1L1lIeUz8sWccrofZDyDBadPfKQM9tbja0p2SGcGZQ6EqFeePf182yfLD1DJfb+tMFgf0lqbm+k/Sw4hscem7DBTpGjlEV/NLFBiC/LLdtBNJQZn6Azj3Fr8wP1d4EW8U2iYeKuFkF2lvAqB+l2ZBbTKmsek2gsLyAnmWCRAgIl1L28he9oYyNIcxD0D28gmx0f9KcEVjq2Q0zOuALvarwhuwZWzzjbitkosKy2FVhT2TcKI6fXevNXMBgz/RmdoZrOMOuojNiro4vtJsogA18spHbI+ojQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net 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=aZou7qGuKK8COqvffsuwn3JWZs/IBplc/L8y15Kolkc=; b=JiTfBH7zL6Vie2Cxkp7gpjWtjFVcZGevdL5H703+EfB34Smh/6xI1z4qvu1HAqSd61rQZyiwr6np1ADV4eI+lbgZ2i1Y2d8F0o93QBhtecQfHeLtbpD5KFY20j5dWDyHR+n6Oy1HbPT1fLe+2YFDiB8Zihq9T+bmGouePwFbd+Q= Received: from MW4PR03CA0344.namprd03.prod.outlook.com (2603:10b6:303:dc::19) by BL1PR12MB5753.namprd12.prod.outlook.com (2603:10b6:208:390::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Tue, 29 Oct 2024 23:25:13 +0000 Received: from CO1PEPF000044F4.namprd05.prod.outlook.com (2603:10b6:303:dc:cafe::de) by MW4PR03CA0344.outlook.office365.com (2603:10b6:303:dc::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.26 via Frontend Transport; Tue, 29 Oct 2024 23:25:13 +0000 X-MS-Exchange-Authentication-Results: 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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1PEPF000044F4.mail.protection.outlook.com (10.167.241.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Tue, 29 Oct 2024 23:25:13 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 29 Oct 2024 18:25:04 -0500 From: Babu Moger To: , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v9 21/26] x86/resctrl: Report "Unassigned" for MBM events in mbm_cntr_assign mode Date: Tue, 29 Oct 2024 18:21:53 -0500 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044F4:EE_|BL1PR12MB5753:EE_ X-MS-Office365-Filtering-Correlation-Id: e047c5bc-01fe-4101-a749-08dcf870f06f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|36860700013|7416014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?xF/pzApG9Ze3xX1X+wYGMmi6bIE8le8LcSPOvF40PCYPavb+LDPDrtEt8+rz?= =?us-ascii?Q?h1UjASfz/Cv5+oIpWN/MPmvNXzlNK75cUlEk30NwE/MeHNAwTvdiOPPwuGbS?= =?us-ascii?Q?ZyTUbqpUIPc35ZHnABSFDE+91awKf/3G5K1oL6QyyDqC8VxRLYjdlwvwzx5J?= =?us-ascii?Q?t75vH95OwpYDdU2kR4BkA80eJr48W8wt2X24fjwthby7s8KJvoXeoWlwvMsm?= =?us-ascii?Q?d9RvELNJdwoYl6PvfS2hQf6uv/gz96D0AejbIsE4920v6TElTbMxt2EMzO3J?= =?us-ascii?Q?PWPN+gs8aPkuc3NHu8VXWgVhCoNSO3ATHe4x3Cab/kcShIAxnALNP7cmcy4h?= =?us-ascii?Q?SJ3dogOxUZjDHPlTvCiuDMZ9BEfEK4bnQd7JIjVbxLJU+LTRPLYMFeGoDzBC?= =?us-ascii?Q?D6qHDhl8nCHuqYP9pxDkp/eoD//cjNKCo/Ivklmopp7ua/DfaK1Dgc8Ip8ps?= =?us-ascii?Q?27MrnWETt7kEsAPBC4joaqNWL93pJylng0Rz0+ObYpOY1OIkQnAKVaEqfDw8?= =?us-ascii?Q?+AWGPKutGA1ZgxuMhcfpNDCP6wZPVEe5JVtWYH06smUUH1yiKvGsU+GJR+jj?= =?us-ascii?Q?ZIf6VPXZpjzNKNpxJZekjLNLHN2CKf2L9slN6IOYXibdtevMoLEie187bKz1?= =?us-ascii?Q?jaZkuag0DwO3P2X7BaQIG1P7ZDPqWPf0/BNEVC1h7EX8uu4yHcyK/jyERDuo?= =?us-ascii?Q?OkCdc8t1pdF+WwtfYwk2GSNHIPewt+AyHilBEdQlk0zKcnsawZ456Dt3XxoO?= =?us-ascii?Q?lEWOgJShvJMmDvH8ntDD5RGqn7nKF50fF+fFUPs4wxJXvJA7vXDNaW5zFwf/?= =?us-ascii?Q?SkaXsue6JM2NiSXHRS2/4yQT9ZSMpMqRfnqIsM01VrDqbkn2IVOA3bGUtGeF?= =?us-ascii?Q?KaSPLPFSLRVLKogrjFb1Z5L52hw+r/AgV/m97elQt0kp7e3Bmmp8MlHIeAEY?= =?us-ascii?Q?WAEQQOkLn+mVSm2wUNd41xW1rMeilhhFUHkyWhcV1qYlHSlaHv3G1KOD+azC?= =?us-ascii?Q?TZOvPw7d10ICuj1eK5mB9Ku/WOGC7nFdeipmGc2C3piG6WHla6RttDiM6YyG?= =?us-ascii?Q?XGfu7FD0jME2su4/YQq2Jku2lPN9wVZwZs3HB1rw+W87IbnBmHflEKbTOsV7?= =?us-ascii?Q?+ewv0742GlDPldz5ebhkiNA5Tzc5xb1d5wx6sm1EEJp5zCWqq+bCiKgC2gz+?= =?us-ascii?Q?exVnbEyHlGT35vqakCvGUohjcI6AiWembmdECCfC/tjYsATAcCC6k5vVlhhZ?= =?us-ascii?Q?Jj8kxK48zLX8zoLSNG6urs31q9G4BWtFldgv12retK+e876JHTjHtF62vSby?= =?us-ascii?Q?7qE5tITS3IuZCYnntD7oO4RFgWwwZIaLJx3LUcCUBCLpPujPrMMVfnAJvcp9?= =?us-ascii?Q?RzTm23Vm9PF3MiZ8jnhHdbUHqMs9UBNZv4G+X9Nlm0swjqY3ug=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(376014)(36860700013)(7416014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 23:25:13.1923 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e047c5bc-01fe-4101-a749-08dcf870f06f 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044F4.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5753 Content-Type: text/plain; charset="utf-8" In mbm_cntr_assign mode, the hardware counter should be assigned to read the MBM events. Report "Unassigned" in case the user attempts to read the events without assigning the counter. Signed-off-by: Babu Moger --- v9: Used is_mbm_event() to check the event type. Minor user documentation update. v8: Used MBM_EVENT_ARRAY_INDEX to get the index for the MBM event. Documentation update to make the text generic. v7: Moved the documentation under "mon_data". Updated the text little bit. v6: Added more explaination in the resctrl.rst Added checks to detect "Unassigned" before reading RMID. v5: New patch. --- Documentation/arch/x86/resctrl.rst | 10 ++++++++++ arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 12 +++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/re= sctrl.rst index 2bc58d974934..864fc004d646 100644 --- a/Documentation/arch/x86/resctrl.rst +++ b/Documentation/arch/x86/resctrl.rst @@ -430,6 +430,16 @@ When monitoring is enabled all MON groups will also co= ntain: for the L3 cache they occupy). These are named "mon_sub_L3_YY" where "YY" is the node number. =20 + When supported the 'mbm_cntr_assign' mode allows users to assign a + counter to mon_hw_id, event pair enabling bandwidth monitoring for + as long as the counter remains assigned. The hardware will continue + tracking the assigned mon_hw_id until the user manually unassigns + it, ensuring that counters are not reset during this period. With + a limited number of counters, the system may run out of assignable + counters. In that case, MBM event counters will return "Unassigned" + when the event is read. Users must manually assign a counter to read + the events. + "mon_hw_id": Available only with debug option. The identifier used by hardware for the monitor group. On x86 this is the RMID. diff --git a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c b/arch/x86/kernel/cp= u/resctrl/ctrlmondata.c index 200d89a64027..43a48943578f 100644 --- a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c +++ b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c @@ -567,7 +567,7 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg) struct rdtgroup *rdtgrp; struct rdt_resource *r; union mon_data_bits md; - int ret =3D 0; + int ret =3D 0, index; =20 rdtgrp =3D rdtgroup_kn_lock_live(of->kn); if (!rdtgrp) { @@ -581,6 +581,14 @@ int rdtgroup_mondata_show(struct seq_file *m, void *ar= g) evtid =3D md.u.evtid; r =3D &rdt_resources_all[resid].r_resctrl; =20 + if (resctrl_arch_mbm_cntr_assign_enabled(r) && is_mbm_event(evtid)) { + index =3D MBM_EVENT_ARRAY_INDEX(evtid); + if (rdtgrp->mon.cntr_id[index] =3D=3D MON_CNTR_UNSET) { + rr.err =3D -ENOENT; + goto checkresult; + } + } + if (md.u.sum) { /* * This file requires summing across all domains that share @@ -618,6 +626,8 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg) seq_puts(m, "Error\n"); else if (rr.err =3D=3D -EINVAL) seq_puts(m, "Unavailable\n"); + else if (rr.err =3D=3D -ENOENT) + seq_puts(m, "Unassigned\n"); else seq_printf(m, "%llu\n", rr.val); =20 --=20 2.34.1 From nobody Mon Nov 25 04:41:22 2024 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2052.outbound.protection.outlook.com [40.107.101.52]) (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 0A77B20CCD1; Tue, 29 Oct 2024 23:25:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.101.52 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244321; cv=fail; b=Cp6Qm5UB6z6gZtKVzJY+/lHDAWMRJ7gXqlkBKrUrQLF2ajvdB2HHn82B/xRrWfI/Dg/8rzCswMntY4bUvgbdnoEz3nkAp7f3dpqrGIsMxIUspZq7CkE0yMVp8Ya7b3HI0bS904CXfFBnsTvIm9BKa06fkUZL4Zkpe+3g0td/SAM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244321; c=relaxed/simple; bh=mbRglOYee5vCNM6sfEI2hzdY2ZIohuLsgokK9DXAKMY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=sc9+aPGivXLKratYolM98AZO+CoQEqbg/n2Jzm572OkcRgVje76oDNaCgfL1fCyUscM+L6DFOnn/lUzvx8pEGY59aUoLwQ/fccsFp6nvmd00Eu2MedQnhLcEafdQVkv4UHOHCRo7yZKFMz7QFsYXIdK/++MTY6OdqwCI9349AJg= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=hfsGZNNu; arc=fail smtp.client-ip=40.107.101.52 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) header.d=amd.com header.i=@amd.com header.b="hfsGZNNu" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=icIhNsYKJKTgFVq7SKdV5DG8ENjmuRTLcFTvX3pdZzN5u2XjUjZe/f9WH78Lmi3g7tstdThgnxvLfMPyTtUdd63s3PDcuv2WXihG18cJVf2+ICcYhQokQRydG1I8Ef8s9ufO//UvYMs+Znzo/9/9CzmjRWn6YGXz8V59TCj8zCCGTA5MBGwGtt/tO7hNkPmbcePz/lsRStK7sg0rcbLaLNg1W9K/IiN807IRz3DLLPqZXcCX6oonGJpwpoZwAA4CidIoaoGIGkP2xcmBrP6cTi5/6d9gKtlacat6rMI/E77GS/aOftvestNaVEMHSLEHeJKvNTAowFpcwiohfNPI6A== 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=oHfbcN3J6fTw3VPEBFCLQbFy/BLgqSu8J9Yqvciip0k=; b=WXnNUi9MLy0xsEMLSqdzokTpX5YNmoSTET+eSaMgUhMJ0HwYae0mt4F3gPfChXrYjbhrMGX3aU2l7XPv9qtsva7fqJwGSQS04hMBGHC19NyvF0oR9Yks+Gf9NoKHiPp8FkIE/O+lhBem7qRPvOXhIOJQBHD6Y1exNg26+LDra1BBu04qyRxrp6Ql5omXcJyIQMvnZ/ehiBrJXouVQLChK6O479NbQezeOGr0UnEYD6AOHBtBGDBkMOY5rVIuM29EbNcsGiPJRt2QZzh+teNKWYw7nIeHY1eNbI7KMqhgUF/yzpTo6T27dhleBLVbKnA6JWJihnxPWAiUdHiLAyg0bA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net 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=oHfbcN3J6fTw3VPEBFCLQbFy/BLgqSu8J9Yqvciip0k=; b=hfsGZNNu/12O+aWeLwpAfnBRvN4ikCI8iYes9j2+i7wnz/iPPaEhqJkD0ujUYGTRh4bK3I8pMTW8UFx6tAk7OwKb8yq4zuHmN9bnD+JwubX5rm9KQ9hjbGiVd4d/D6cI6JHntLs5ZESqAg4ztyEIb1Q8zhQi4enT75e+wDaXzSM= Received: from MW4PR03CA0346.namprd03.prod.outlook.com (2603:10b6:303:dc::21) by IA0PR12MB8254.namprd12.prod.outlook.com (2603:10b6:208:408::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.25; Tue, 29 Oct 2024 23:25:16 +0000 Received: from CO1PEPF000044F4.namprd05.prod.outlook.com (2603:10b6:303:dc:cafe::f6) by MW4PR03CA0346.outlook.office365.com (2603:10b6:303:dc::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.26 via Frontend Transport; Tue, 29 Oct 2024 23:25:15 +0000 X-MS-Exchange-Authentication-Results: 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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1PEPF000044F4.mail.protection.outlook.com (10.167.241.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Tue, 29 Oct 2024 23:25:15 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 29 Oct 2024 18:25:12 -0500 From: Babu Moger To: , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v9 22/26] x86/resctrl: Introduce the interface to switch between monitor modes Date: Tue, 29 Oct 2024 18:21:54 -0500 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044F4:EE_|IA0PR12MB8254:EE_ X-MS-Office365-Filtering-Correlation-Id: 02ec2129-62ca-4681-9748-08dcf870f1c4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?JTxvKlWVPK4sgFT/FgmMRMDUj7W9DTAbSAQmbJQtxRqjMjIR2f6b484/jiFB?= =?us-ascii?Q?ythhVXmnjMxIjmfTHgKAFdzpEZv9pDm1psf3FaneG2EUMUp4Fxw5CdLF6F7k?= =?us-ascii?Q?Y0UDWUPSJuzcwrBgm1U0adH4PcelPk68Er9ctLWg40Mk89obIkHNYJStZDEL?= =?us-ascii?Q?jVTxUcBr7j+vTc8++WomQ7aCi0tilqpFFOjzGkFJYv3LNpNrFg0UYBg+GF/K?= =?us-ascii?Q?MJdWpG2mm5cjE5wFRH0uaR7M2nYLbZJgpH+XyUobZZ+WRCymgFortffPmkvk?= =?us-ascii?Q?kWU2/SI/9dM5rid4J6by0Yhkc8wUUhubjz9m/k4NiiRBsaE4U0Au+HtH04FB?= =?us-ascii?Q?Wzai6oTqbv3X2OinUqRofX+czK09otdAf7QWZaFKEbPSW1p25u+4q8dpu/Oz?= =?us-ascii?Q?yW84eMWpVDgPG3MBLdrN8t37y6ECEs/bN+A3MOpEH2HrwUYq0uLTNtGCYyJy?= =?us-ascii?Q?MpvwnIjP8cI7bSk2W77sdYhtxSz9IXFroTE0UN2DUOu7C+SUek0Z7QkzcNju?= =?us-ascii?Q?7UyA0p0hZTrNA3qx3C6frZv0wSoIiVhZ4JjOyMwLdghX3sOu5LS9mQb2Desd?= =?us-ascii?Q?qOLE5J5VeOKBYTCUnQ28gPhxIdHaXyfHC0FsG+XVoly7nGWyGbAo0o5ZBXUh?= =?us-ascii?Q?2fS8KSgbO7XNY9/yFGG/6UqdzfkmGfUpQPBhh6HxZTusO6ckRD/9qm2lqLOv?= =?us-ascii?Q?0Mkp5ovqa2eeTSvaBctLm1kV22ORBnzCHgqzySFSO6+cest3uuf5hroarnG5?= =?us-ascii?Q?sdbxjo1zvulCtAyNnUzHQtYCWsimHKrckI9DNEWcSrbvtCGX1L+i/ASnrcLY?= =?us-ascii?Q?PU2e+IZ5iDAF17nVneQaUQKQayg6CFqeajuYHMRxC54vmZA6WCRNNnjTm07u?= =?us-ascii?Q?7yyAtXISCrx1XYIftkV0GolnmZzABSafeymOT073Dpw/UFCXHXtd467++8AK?= =?us-ascii?Q?bPCvSCuuPlZY2zW9/Q2zYdwqkD4ZO/9XdNyW6GlsCrMTWWEyiXsbAJjfLK5V?= =?us-ascii?Q?l0p58OisBUV7aQGHvTQhEdWxA4NfBIb0IV0RFTi7Sr82dTI6RMF+bUzkAXkE?= =?us-ascii?Q?UaeEjxL62oCeUfqw4RtLeWaJtU10PqAH/T3GyGbmaUdrAB/czqaaYZxr7X75?= =?us-ascii?Q?R2UHg1MqusW5YmboJJVDlkAwOHqiOEjZU0QKADXBjYzt01vVmE/PWIRb60ws?= =?us-ascii?Q?Nhf0QhuW4+eOyqkIgpDDxbIg+MziMWdNk8/IOaHKoFqMs1YWQlEYKCnSxYx1?= =?us-ascii?Q?5o5mNEb4Cro9rmWLOuajHPWhj+pcLfeeD89N4DBQQ+s4OW5qkSAYz+oeKM7A?= =?us-ascii?Q?OUSCl/fFSXoTx9FEDKA9ndyeQ1ZzHD2ozHrjes+rGOpy+vqP1cIelWnUJ3Kf?= =?us-ascii?Q?FhAfAGx/PZ/TwStJS5HgxkTEFEJRHsq1FVsTeQykP9hIz2WekQ=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(376014)(7416014)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 23:25:15.4423 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 02ec2129-62ca-4681-9748-08dcf870f1c4 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044F4.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8254 Content-Type: text/plain; charset="utf-8" Introduce interface to switch between mbm_cntr_assign and default modes. $ cat /sys/fs/resctrl/info/L3_MON/mbm_assign_mode [mbm_cntr_assign] default To enable the "mbm_cntr_assign" mode: $ echo "mbm_cntr_assign" > /sys/fs/resctrl/info/L3_MON/mbm_assign_mode To enable the default monitoring mode: $ echo "default" > /sys/fs/resctrl/info/L3_MON/mbm_assign_mode MBM event counters will reset when mbm_assign_mode is changed. Signed-off-by: Babu Moger --- v9: Fixed extra spaces in user documentation. Fixed problem changing the mode to mbm_cntr_assign mode when it is not supported. Added extra checks to detect if systems supports it. Used the rdtgroup_cntr_id_init to initialize cntr_id. v8: Reset the internal counters after mbm_cntr_assign mode is changed. Renamed rdtgroup_mbm_cntr_reset() to mbm_cntr_reset() Updated the documentation to make text generic. v7: Changed the interface name to mbm_assign_mode. Removed the references of ABMC. Added the changes to reset global and domain bitmaps. Added the changes to reset rmid. v6: Changed the mode name to mbm_cntr_assign. Moved all the FS related code here. Added changes to reset mbm_cntr_map and resctrl group counters. v5: Change log and mode description text correction. v4: Minor commit text changes. Keep the default to ABMC when supported. Fixed comments to reflect changed interface "mbm_mode". v3: New patch to address the review comments from upstream. --- Documentation/arch/x86/resctrl.rst | 15 +++++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 81 +++++++++++++++++++++++++- 2 files changed, 95 insertions(+), 1 deletion(-) diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/re= sctrl.rst index 864fc004d646..1b39866e8b04 100644 --- a/Documentation/arch/x86/resctrl.rst +++ b/Documentation/arch/x86/resctrl.rst @@ -290,6 +290,21 @@ with the following files: mbm_local_bytes may report 'Unavailable' if there is no counter associated with that event. =20 + * To enable "mbm_cntr_assign" mode: + :: + + # echo "mbm_cntr_assign" > /sys/fs/resctrl/info/L3_MON/mbm_assign_mode + + * To enable default monitoring mode: + :: + + # echo "default" > /sys/fs/resctrl/info/L3_MON/mbm_assign_mode + + The MBM events (mbm_total_bytes and/or mbm_local_bytes) associated with + counters may reset when mbm_assign_mode is changed. Moving to + mbm_cntr_assign mode require users to assign the counters to the events. + Otherwise, the MBM event counters will return "Unassigned" when read. + "num_mbm_cntrs": The number of monitoring counters available for assignment when the architecture supports mbm_cntr_assign mode. diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index a8d21b0b2054..7fa6a86c6ca8 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -933,6 +933,84 @@ static void rdtgroup_cntr_id_init(struct rdtgroup *rdt= grp, rdtgrp->mon.cntr_id[index] =3D MON_CNTR_UNSET; } =20 +static void mbm_cntr_reset(struct rdt_resource *r) +{ + struct rdtgroup *prgrp, *crgrp; + struct rdt_mon_domain *dom; + + /* + * Hardware counters will reset after switching the monitor mode. + * Reset the architectural state so that reading of hardware + * counter is not considered as an overflow in the next update. + * Also reset the domain counter bitmap. + */ + list_for_each_entry(dom, &r->mon_domains, hdr.list) { + bitmap_zero(dom->mbm_cntr_map, r->mon.num_mbm_cntrs); + resctrl_arch_reset_rmid_all(r, dom); + } + + /* Reset global MBM counter map */ + bitmap_fill(r->mon.mbm_cntr_free_map, r->mon.num_mbm_cntrs); + + /* Reset the cntr_id's for all the monitor groups */ + list_for_each_entry(prgrp, &rdt_all_groups, rdtgroup_list) { + rdtgroup_cntr_id_init(prgrp, QOS_L3_MBM_TOTAL_EVENT_ID); + rdtgroup_cntr_id_init(prgrp, QOS_L3_MBM_LOCAL_EVENT_ID); + list_for_each_entry(crgrp, &prgrp->mon.crdtgrp_list, + mon.crdtgrp_list) { + rdtgroup_cntr_id_init(crgrp, QOS_L3_MBM_TOTAL_EVENT_ID); + rdtgroup_cntr_id_init(crgrp, QOS_L3_MBM_LOCAL_EVENT_ID); + } + } +} + +static ssize_t rdtgroup_mbm_assign_mode_write(struct kernfs_open_file *of, + char *buf, size_t nbytes, loff_t off) +{ + struct rdt_resource *r =3D of->kn->parent->priv; + int ret =3D 0; + bool enable; + + /* Valid input requires a trailing newline */ + if (nbytes =3D=3D 0 || buf[nbytes - 1] !=3D '\n') + return -EINVAL; + + buf[nbytes - 1] =3D '\0'; + + cpus_read_lock(); + mutex_lock(&rdtgroup_mutex); + + rdt_last_cmd_clear(); + + if (!strcmp(buf, "default")) { + enable =3D 0; + } else if (!strcmp(buf, "mbm_cntr_assign")) { + if (r->mon.mbm_cntr_assignable) { + enable =3D 1; + } else { + ret =3D -EINVAL; + rdt_last_cmd_puts("mbm_cntr_assign mode is not supported\n"); + goto write_exit; + } + } else { + ret =3D -EINVAL; + rdt_last_cmd_puts("Unsupported assign mode\n"); + goto write_exit; + } + + if (enable !=3D resctrl_arch_mbm_cntr_assign_enabled(r)) { + ret =3D resctrl_arch_mbm_cntr_assign_set(r, enable); + if (!ret) + mbm_cntr_reset(r); + } + +write_exit: + mutex_unlock(&rdtgroup_mutex); + cpus_read_unlock(); + + return ret ?: nbytes; +} + #ifdef CONFIG_PROC_CPU_RESCTRL =20 /* @@ -2166,9 +2244,10 @@ static struct rftype res_common_files[] =3D { }, { .name =3D "mbm_assign_mode", - .mode =3D 0444, + .mode =3D 0644, .kf_ops =3D &rdtgroup_kf_single_ops, .seq_show =3D rdtgroup_mbm_assign_mode_show, + .write =3D rdtgroup_mbm_assign_mode_write, .fflags =3D RFTYPE_MON_INFO, }, { --=20 2.34.1 From nobody Mon Nov 25 04:41:22 2024 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2050.outbound.protection.outlook.com [40.107.237.50]) (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 421E520B205; Tue, 29 Oct 2024 23:25:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244342; cv=fail; b=LHv0zYdFiBhdboj62UtSSCxw/Q57LLMPu1U4Nz9bQE7qpLHJ7xGp3fNTU8n0lxYSRIpvz4hX1BskUNVpXxFdgis7M/6PtTdfq62OPdL4UvNd5kZtcf5ZcbYuuYn+VlLFk5w1iT5dQe/hsCjJwS4Mpkdvg7G2KngSdklw9ZSbqa0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244342; c=relaxed/simple; bh=Odg4BbGdZD0H1Thz/1LPS6aNRPMC4gJkZgvuWuEBqC0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kbcV2o/pHvEzKaTqDK2dlMC2+zDvxHYnT9WOmMkYTcLnUfJpTXrLFTGLBhnkPcIZBfwFDlnUA4w3D7PUimw2ads0eqJU5B4iSDMMAz2uaeFDHodx+V+bZ0v67zdqTZ5cBioxopSdNGYt/SN9wXGNCMAXij61sqlgjsn1kXcwliw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=1qlhSjVs; arc=fail smtp.client-ip=40.107.237.50 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) header.d=amd.com header.i=@amd.com header.b="1qlhSjVs" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Ps50/JsShgs0OYGfd+8vClWbj6/pLltkajiQ0zoI8p527FTVJXvutkAZXxlTshZhklvcXaegimgfEKnjgO4TET27T+of0J6EofJLRl9keZq4RukbOyz4lBQG0RvBQG6//76wqFxIfBM7edoOcvKiSHuDj4MZhT9DQyusjXCAGNGryKSvMVrt3kV5zSUIDUlLxeUqWUFkCWFYpir2dATElKMHjSnnW6qQDn+8GRdc8nd/XebGNw1VtMa+u9tnh8wrMKKCke9xFNLcxNBgcWq5btFHY4qFLQY6pKfxZ4S+zYJIOwswXiNjkCJjAxWy3SFsrhPf5fZnDnHXsNnIku+ftw== 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=SWomWzCU3A5RdprHWMRth6YETaopobuqcBBuJ9JXT00=; b=Np1G1Z4GDdJADE+VmZOeQm0wLtKrgIbh20+btGdfCpvNv23AMatbhB2goNLzhyXhddPZKk9afgo4MfbavjLvGT/IWuoqztq2Zzs+fqbuXTL9WuvGKfjYTtfvxPjK0DaAIm4/woS/bjOmkCNAvwLM+M4/7qflhx9Nzoq9UOvzHEVpsqUBNZ6cWQR83rwv5anZQm/2jAHOTTwDuhDUVSHaOYYXKdfNxqYoXz0v5AIglSircQ6U3cK8PqNAyzAj1ayVfV+ecMyQZSJZwWyz+xYtJGdFkeNrO8ogDJlOsp2BI/m839AGIKXMm9GesIgXAC4Wf25+lWQzULz5/QPRhsm9Zg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net 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=SWomWzCU3A5RdprHWMRth6YETaopobuqcBBuJ9JXT00=; b=1qlhSjVsVEUENEfLNuuJHZAdWeZBDRaQMm9j3HtGYvEKuBU2NQO0sZKPsLYXQWgFPa8mrE8Nk8FCn47T7nCk7ieVpgI0ZPRLQs/DJdVu0UdvQIV+lxoT/sjJm+iViUfVFEAAnyWSog81t0tG/oZTfFAG/Fai/fpRhPAlhBaqRis= Received: from SA9PR13CA0096.namprd13.prod.outlook.com (2603:10b6:806:24::11) by CY8PR12MB7218.namprd12.prod.outlook.com (2603:10b6:930:5a::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Tue, 29 Oct 2024 23:25:36 +0000 Received: from SA2PEPF0000150B.namprd04.prod.outlook.com (2603:10b6:806:24:cafe::1d) by SA9PR13CA0096.outlook.office365.com (2603:10b6:806:24::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.14 via Frontend Transport; Tue, 29 Oct 2024 23:25:36 +0000 X-MS-Exchange-Authentication-Results: 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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SA2PEPF0000150B.mail.protection.outlook.com (10.167.242.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Tue, 29 Oct 2024 23:25:36 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 29 Oct 2024 18:25:21 -0500 From: Babu Moger To: , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v9 23/26] x86/resctrl: Configure mbm_cntr_assign mode if supported Date: Tue, 29 Oct 2024 18:21:55 -0500 Message-ID: <2964648aa19f9d961c76c83a25f10fe3993abf59.1730244116.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF0000150B:EE_|CY8PR12MB7218:EE_ X-MS-Office365-Filtering-Correlation-Id: 4c5b0fda-1a4e-4696-e14e-08dcf870fe2a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|7416014|376014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?w2DHId/oWRdRTmqLFH2zs2LoYQ1C1CXzzDS0WW9idz9QMy/Bf4uhz27AjZgz?= =?us-ascii?Q?8oBEUzxoRH6qVbTAikOy8oyhC4ao39zeQBEUzFnBSaTLYLtoP95yUEHssKbg?= =?us-ascii?Q?KKq+AABcBMuu3tU+hPOcSF7OyjnNeg/idFCIG293MPjzSCzbQbpqwUm25hJQ?= =?us-ascii?Q?T53QOvSl+f/Jmlv6cIjdtr4DhRlkMf7CbuGA39MRdNQ0HWkthIAm60wCP99n?= =?us-ascii?Q?3HUEwXnlpIrLsfn3Pdta6lgqnI1N6c/SPjTzFwHtRmk9FVJo0Yn8Di1Dw9eA?= =?us-ascii?Q?uM4iuhhdgjyMw3ZVOCxzAtj+OdoN4E4oIBOMejzyTmVy2uHHouhSm5ec9Mgr?= =?us-ascii?Q?fkFsmXYH+ekfsEzUQgvNfn3qhzhXgXfHfOJPlaxSbpOv1HbMifbrszwHtmA5?= =?us-ascii?Q?S3edyOGTIEQ3bdtK2vh9f5ExfGRJEjj8/f17yBSBIwz88DaOWdZcnbtSyiM7?= =?us-ascii?Q?zlv/I7CbUM8HqZdRnx46GUb+7xoWz0IXAtCp4sH/RbCpyA4GS+xhNecLoUsT?= =?us-ascii?Q?A1O4ly7RNpj2odzQ7wJ7kOOSpRYKQi7RVV6d7o1Np1Hda3E8EkONfHJAy2yv?= =?us-ascii?Q?TExyvdWOIVnjFoI4DbgtUMjEVeSeDOhxBXJ4Y2laQDUye45Mtqk8lSmZzRxo?= =?us-ascii?Q?Ek3OZZtPgLqzQ0drYZSE2C96zm+KBvDTyngCogq3Aux8bML7+q7mp/z9ZqdD?= =?us-ascii?Q?/IKBlK9yGRks3/tSMzdL9TcwQr9HT64vPHQtys8xHHbweOAhLLpkTRPbZ242?= =?us-ascii?Q?sFyOlUkO3UxRyiyC23WUhWsQ9XU8HO6hDYeT9R8+PgM9GGggAsWz/xVRBHFW?= =?us-ascii?Q?FOEFcOS4mtsKGLzB0v2J6Cdk8r7FXBo/KrTN4jk/Mf+YEf/wLfu3JjyP5+yU?= =?us-ascii?Q?V4O8q9MnOiN0u9VGJT61Z6/2ktuy4nLrwgvaLlPlDCDe/F4YEz5AYeUAxBkl?= =?us-ascii?Q?mg0aN2zceUjXy7J5gwZ9thPCTpC+CRKNE9eLGx/6vrOq3pZkgexga+/WJV+8?= =?us-ascii?Q?+lKnwsOa3MJjSW1XtZMQJQJYjA7KNr1argkd8w8pX5K7pwlgQI4SZ4I8ikXy?= =?us-ascii?Q?PEz22+NADgKKuBWHDT3Wkjg5pAFtHHBfovJp/0xWjOyQUa9Z1x/8U2pydRNN?= =?us-ascii?Q?8k1o8X9XIMD60UO81CVbuktBT+L10PJ3uamLTxkby+WNIeS0BNxtVUIh1lym?= =?us-ascii?Q?jdX9lN6svL8nC61NXhdU6sSMk2CVCzLWXpoPCkl+czyv82ElEVgxGkOLtCAf?= =?us-ascii?Q?UVlzNXrdLOa0vqVxTZqv33j04pTtU1UGmWVIHe5Jbeg+8UCIPetUq04uZds9?= =?us-ascii?Q?SemzCrv3S3fHouSUdN2EkSo1hBaoEpisex3c/IrHv76XOkLv/T1aR2k2HynV?= =?us-ascii?Q?LtKu+J4j38JfhcVTcqla/lq6ncJNWh0YPs+Hp1MapuvyuZeC2w=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(7416014)(376014)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 23:25:36.3235 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4c5b0fda-1a4e-4696-e14e-08dcf870fe2a 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF0000150B.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7218 Content-Type: text/plain; charset="utf-8" Configure mbm_cntr_assign on AMD. 'mbm_cntr_assign' mode in AMD is ABMC (Assignable Bandwidth Monitoring Counters). It is enabled by default when supported on the system. When the ABMC is updated, it must be updated on all the logical processors in the resctrl domain. Signed-off-by: Babu Moger --- v9: Minor code change due to merge. Actual code did not change. v8: Renamed resctrl_arch_mbm_cntr_assign_configure to resctrl_arch_mbm_cntr_assign_set_one. Adde r->mon_capable check. Commit message update. v7: Introduced resctrl_arch_mbm_cntr_assign_configure() to configure. Moved the default settings to rdt_get_mon_l3_config(). It should be done before the hotplug handler is called. It cannot be done at rdtgroup_init(). v6: Keeping the default enablement in arch init code for now. This may need some discussion. Renamed resctrl_arch_configure_abmc to resctrl_arch_mbm_cntr_assign_co= nfigure. v5: New patch to enable ABMC by default. --- arch/x86/kernel/cpu/resctrl/internal.h | 1 + arch/x86/kernel/cpu/resctrl/monitor.c | 1 + arch/x86/kernel/cpu/resctrl/rdtgroup.c | 11 +++++++++++ 3 files changed, 13 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 66de0ce12aba..b90d8c90b4b6 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -721,6 +721,7 @@ int rdtgroup_assign_cntr_event(struct rdt_resource *r, = struct rdtgroup *rdtgrp, struct rdt_mon_domain *d, enum resctrl_event_id evtid); int rdtgroup_unassign_cntr_event(struct rdt_resource *r, struct rdtgroup *= rdtgrp, struct rdt_mon_domain *d, enum resctrl_event_id evtid); +void resctrl_arch_mbm_cntr_assign_set_one(struct rdt_resource *r); void rdt_staged_configs_clear(void); bool closid_allocated(unsigned int closid); int resctrl_find_cleanest_closid(void); diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index e8d38a963f39..4ba5007fd1aa 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -1267,6 +1267,7 @@ int __init rdt_get_mon_l3_config(struct rdt_resource = *r) r->mon.mbm_cntr_assignable =3D true; cpuid_count(0x80000020, 5, &eax, &ebx, &ecx, &edx); r->mon.num_mbm_cntrs =3D (ebx & GENMASK(15, 0)) + 1; + hw_res->mbm_cntr_assign_enabled =3D true; resctrl_file_fflags_init("num_mbm_cntrs", RFTYPE_MON_INFO); resctrl_file_fflags_init("available_mbm_cntrs", RFTYPE_MON_INFO); } diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 7fa6a86c6ca8..5b8bb8bd913c 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -2799,6 +2799,13 @@ int resctrl_arch_mbm_cntr_assign_set(struct rdt_reso= urce *r, bool enable) return 0; } =20 +void resctrl_arch_mbm_cntr_assign_set_one(struct rdt_resource *r) +{ + struct rdt_hw_resource *hw_res =3D resctrl_to_arch_res(r); + + resctrl_abmc_set_one_amd(&hw_res->mbm_cntr_assign_enabled); +} + /* * We don't allow rdtgroup directories to be created anywhere * except the root directory. Thus when looking for the rdtgroup @@ -4582,9 +4589,13 @@ int resctrl_online_mon_domain(struct rdt_resource *r= , struct rdt_mon_domain *d) =20 void resctrl_online_cpu(unsigned int cpu) { + struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; + mutex_lock(&rdtgroup_mutex); /* The CPU is set in default rdtgroup after online. */ cpumask_set_cpu(cpu, &rdtgroup_default.cpu_mask); + if (r->mon_capable && r->mon.mbm_cntr_assignable) + resctrl_arch_mbm_cntr_assign_set_one(r); mutex_unlock(&rdtgroup_mutex); } =20 --=20 2.34.1 From nobody Mon Nov 25 04:41:22 2024 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2088.outbound.protection.outlook.com [40.107.212.88]) (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 02A5920C021; Tue, 29 Oct 2024 23:25:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.212.88 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244343; cv=fail; b=MdcfBA1+DdRDTj+pa+q3ShwWg5/iEolma0c0fHgGe9zHIZD+CW3LkVija+6HHY65nHOlFHRNRxaxl9FVD9qkf2UkJkmGZN9MOzWleBqOedILlX8QP0SG6S0zghTRYBN0Rbj2yKiBE1cL/W1AUzslkjN1JhDjpm0sy5+mFuSEKus= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244343; c=relaxed/simple; bh=LSt8nN0uTVbg99E+3w6E8o041GcbB1wKqieDFoqp1y0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=I7WHrQrVxfOgjafG6khaym7iDGDITNJgbJ5X1rRaEl301lkUMaTJ2sSK9lVQtT85m3IWhE5e1Uvzc4Toe5PQfZ7bEVum0cdizXIF4n+XOotpyGcfEnKOWuLWbIzaPnuxbe3GJSwnLRd1puGt/oO1pGHC3trlYiDj8nuqCGN5+nM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=D1Kk6oTh; arc=fail smtp.client-ip=40.107.212.88 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) header.d=amd.com header.i=@amd.com header.b="D1Kk6oTh" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=gBKgOi+NYxvOu05GJ53pQViZEcMNE9sMvSxWlyP1fWGY5tIQ6aNB9DOBE2TRpcGZVqNjI9FsyaAuISqibkAuNeqKEfYJRlC76twk+oemQwSZdXQIfghxa89q/qHs4FS+mM6WoN5J3WH6WKoWmAR9oo3vNDzACo875IPrBvxp1GdzqzH4Gfp+swJUY3dTatD++rEScbc54TQxA/4ORGt459M7MyBKr3SJcB+8hMSIzd/fx1OAxafeXgsdGpY3yKBuMCyzh1Yl+YcHYC/X/IpivAgBpT0VMkSyPs+zDpbPd7JUQZ8oNd8WiOzKaSJzi606OAFXpeOcAE+LCvrGFmERGA== 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=IOtoiGQDo3pa7mdmg9cD7sIP1t3VoH957KV4U35TJbs=; b=UreqH8jkIJt8m5Yb6Dbu9o3x5Js6cviEYfFjDcFsAbF1gVtXsvDCDPQyFhd/FALCf6YRYWYI9N44C3ML/AXPJqwWf9yPD9Ejtml+IhLaRvBNKBsior2yvsMsnnkhOlqctXVIezzTyiAFEIAS5PcxAU+Y2TuqvVpy0jaShdalMRMkVU5j0XFSyLrONQbKavsOEauRrt59VhCDApLNZNcuUZd3DX2g/PjEF8Tdv9qsVkHanKO2FVFgndquxBOotDUFCMfTjcEewN0/a7BIzFIqgci3WKSvRUiEJGIFBunCNgnq+MUALiVNT0duZeaoKKsVf0zArT3u02dyb/cqxPO/OQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net 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=IOtoiGQDo3pa7mdmg9cD7sIP1t3VoH957KV4U35TJbs=; b=D1Kk6oThDVVIgmx8GeF9b3bzBkKskWQlOVZjsVk6JWleY25UhZWkPUU6ZOfxzKkWW/Z9My3fIFXE/mT2ZttcOhBa6RQDGcTgMuQfAxYxqeeK2PZgtbmWNZ+2w/cdEtNcfnaWH/FIcxyxIi7o4CwegrGE0G75Wew/BfRReZd2k+g= Received: from SA9PR13CA0112.namprd13.prod.outlook.com (2603:10b6:806:24::27) by DM6PR12MB4299.namprd12.prod.outlook.com (2603:10b6:5:223::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Tue, 29 Oct 2024 23:25:37 +0000 Received: from SA2PEPF0000150B.namprd04.prod.outlook.com (2603:10b6:806:24:cafe::c8) by SA9PR13CA0112.outlook.office365.com (2603:10b6:806:24::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.14 via Frontend Transport; Tue, 29 Oct 2024 23:25:37 +0000 X-MS-Exchange-Authentication-Results: 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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SA2PEPF0000150B.mail.protection.outlook.com (10.167.242.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Tue, 29 Oct 2024 23:25:37 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 29 Oct 2024 18:25:29 -0500 From: Babu Moger To: , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v9 24/26] x86/resctrl: Update assignments on event configuration changes Date: Tue, 29 Oct 2024 18:21:56 -0500 Message-ID: <89e98891f50d1d57c1cf8bc18c1f562ac58d2cce.1730244116.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF0000150B:EE_|DM6PR12MB4299:EE_ X-MS-Office365-Filtering-Correlation-Id: b4e1a7ff-eb11-424c-b0ff-08dcf870fefc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?ykuf1LqseT0iBWdGKGqM2dvIN8lOie8/ruq9BmKijLdZ1bH4OUil8FyFgk+h?= =?us-ascii?Q?z8aZBSnr6XtMixFJ3XRiqCIkKrjCXjrQ48LMZoq30iZE+iq9iP8EbaArYnt4?= =?us-ascii?Q?qyYLGXA0F39LFMkO2CRapStKXADbQwmIcSoDIWwY840gT3IJS3A2kJVx/VPF?= =?us-ascii?Q?qjusooj3o9eFLDeIl2fEqsgW7/9eODVe3cfGULUjHZRoHb5DniiUq6ieUNcW?= =?us-ascii?Q?eV0X8C5raCvLVNtcTBxYjETwS7WnUKtl1ULbsFT/NVkCn2rUseqPPGtx9S2d?= =?us-ascii?Q?QyvGPfndFQOIbeOJIzWIVZ08DmT/sT+6KfWcSnKYrdftIoEiLnxjthWck1us?= =?us-ascii?Q?YHj9KvIIJLv5lYFt/OqYZButloUCqMIJI2WRGKUzTiOzr+2ZeILEDxRkiW8h?= =?us-ascii?Q?tE+Z4n1Is6nrMv9PoyrmyIqWrnjGsKasqjl8T3OVw0p1+N0ma6FqrhwsPDBZ?= =?us-ascii?Q?iflKKv+atREFwgocuAJOgB7jqzJUdSGoSXc40P/MY6rzPT0v7aFJTdyMVmxJ?= =?us-ascii?Q?ZZaw9pxnseAeB9c+Gyh4TO1W1qCNiVq/mIoIRFELJRzQabZyJo+/ezZCcalR?= =?us-ascii?Q?ja+5gmdS4TDM+sQIcHmpDgguiOMBPKt9SfL8fpiOXwXrSFnj+VVwPJ+SK0mF?= =?us-ascii?Q?EeL9OimovAfyoIJX+YUkqg22HCAvpIMvHIY8m6GmWibt/esdSM8cjecL1fV4?= =?us-ascii?Q?TrOhyHUL36Xo6gz9oo6uWOciVNau5Ocnm/AX/LjKWyXo3mVOzX9T1vDjzcg7?= =?us-ascii?Q?/We+h3gX8gqi9u5JUsWdD+IFrYJJ9G5U+DG41OBpEdimgo67DwJQfSzN1uDD?= =?us-ascii?Q?0BoOSUYZryJ0Zl3yAmTF3w2+hvPrEIPfwt9CYLm60pMdDkXY2bitcyMIJI7s?= =?us-ascii?Q?LGqWfG898E2nsMUbTk3GM4b7B+C/nieLfpbdD8ydoLfpVUpr7rCftzh0e7nU?= =?us-ascii?Q?7uWfrPDN1P65v1o4xM1LqK/bNCJb6yH8ZmInuL1exJg+prUbfqcF5loXF8lG?= =?us-ascii?Q?71+XSi2Ffy77580FaojqiCTsRML9lNWBYT6PpQ/L6RZd7FL0lhFWpS7FcZ8A?= =?us-ascii?Q?4YW4y2iO3yo5LlKvvnc5NVsm/8yqnTMsGmpUVupaHXvppobAuCwW/oxXeVHi?= =?us-ascii?Q?n3BUBXBaEX5lj09LJr0r+3U4YzotM9Z3HUVGNtRwXg0crJs/+AAOI3Ty74Li?= =?us-ascii?Q?v3UOgE6RJPWCp+ljE/ZhvSJAHHIJpAAn+D4hmZ/TtmUGhBD/KI8Q+fcq2lGA?= =?us-ascii?Q?6QlsqRBWqNmralrBi8CGZiMb3mPeEVOhVGfWSdc7O3dv/b0o39w4b4yfMdCj?= =?us-ascii?Q?p7MYDsW3ysqocfkGi9FPqKdVTRnLbufh+jojQyBLpppCDfyNDFisSxFRxXTV?= =?us-ascii?Q?FCYJhGZgNGrdnqL0WAdgk26ySplZFHzQ2o1EzYPfin39ezJYNZcQSFC6w4yO?= =?us-ascii?Q?PlQADK0bLb8=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(376014)(7416014)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 23:25:37.6985 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b4e1a7ff-eb11-424c-b0ff-08dcf870fefc 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF0000150B.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4299 Content-Type: text/plain; charset="utf-8" Users can modify the configuration of assignable events. Whenever the event configuration is updated, MBM assignments must be revised across all monitor groups within the impacted domains. Signed-off-by: Babu Moger --- v9: Again patch changed completely based on the comment. https://lore.kernel.org/lkml/03b278b5-6c15-4d09-9ab7-3317e84a409e@intel= .com/ Introduced resctrl_mon_event_config_set to handle IPI. But sending another IPI inside IPI causes problem. Kernel reports SMP warning. So, introduced resctrl_arch_update_cntr() to send the command = directly. v8: Patch changed completely. Updated the assignment on same IPI as the event is updated. Could not do the way we discussed in the thread. https://lore.kernel.org/lkml/f77737ac-d3f6-3e4b-3565-564f79c86ca8@amd.c= om/ Needed to figure out event type to update the configuration. v7: New patch to update the assignments. Missed it earlier. --- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 86 +++++++++++++++++++++++--- include/linux/resctrl.h | 3 +- 2 files changed, 79 insertions(+), 10 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 5b8bb8bd913c..7646d67ea10e 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -1710,6 +1710,7 @@ static int rdtgroup_size_show(struct kernfs_open_file= *of, } =20 struct mon_config_info { + struct rdt_resource *r; struct rdt_mon_domain *d; u32 evtid; u32 mon_config; @@ -1735,26 +1736,28 @@ u32 resctrl_arch_mon_event_config_get(struct rdt_mo= n_domain *d, return INVALID_CONFIG_VALUE; } =20 -void resctrl_arch_mon_event_config_set(void *info) +void resctrl_arch_mon_event_config_set(struct rdt_mon_domain *d, + enum resctrl_event_id eventid, u32 val) { - struct mon_config_info *mon_info =3D info; struct rdt_hw_mon_domain *hw_dom; unsigned int index; =20 - index =3D mon_event_config_index_get(mon_info->evtid); + index =3D mon_event_config_index_get(eventid); if (index =3D=3D INVALID_CONFIG_INDEX) return; =20 - wrmsr(MSR_IA32_EVT_CFG_BASE + index, mon_info->mon_config, 0); + wrmsr(MSR_IA32_EVT_CFG_BASE + index, val, 0); =20 - hw_dom =3D resctrl_to_arch_mon_dom(mon_info->d); + hw_dom =3D resctrl_to_arch_mon_dom(d); =20 - switch (mon_info->evtid) { + switch (eventid) { case QOS_L3_MBM_TOTAL_EVENT_ID: - hw_dom->mbm_total_cfg =3D mon_info->mon_config; + hw_dom->mbm_total_cfg =3D val; break; case QOS_L3_MBM_LOCAL_EVENT_ID: - hw_dom->mbm_local_cfg =3D mon_info->mon_config; + hw_dom->mbm_local_cfg =3D val; + break; + default: break; } } @@ -1826,6 +1829,70 @@ static int mbm_local_bytes_config_show(struct kernfs= _open_file *of, return 0; } =20 +static struct rdtgroup *rdtgroup_find_grp_by_cntr_id_index(int cntr_id, un= signed int index) +{ + struct rdtgroup *prgrp, *crgrp; + + /* Check if the cntr_id is associated to the event type updated */ + list_for_each_entry(prgrp, &rdt_all_groups, rdtgroup_list) { + if (prgrp->mon.cntr_id[index] =3D=3D cntr_id) + return prgrp; + + list_for_each_entry(crgrp, &prgrp->mon.crdtgrp_list, mon.crdtgrp_list) { + if (crgrp->mon.cntr_id[index] =3D=3D cntr_id) + return crgrp; + } + } + + return NULL; +} + +static void resctrl_arch_update_cntr(struct rdt_resource *r, struct rdt_mo= n_domain *d, + enum resctrl_event_id evtid, u32 rmid, + u32 closid, u32 cntr_id, u32 val) +{ + union l3_qos_abmc_cfg abmc_cfg =3D { 0 }; + + abmc_cfg.split.cfg_en =3D 1; + abmc_cfg.split.cntr_en =3D 1; + abmc_cfg.split.cntr_id =3D cntr_id; + abmc_cfg.split.bw_src =3D rmid; + abmc_cfg.split.bw_type =3D val; + + wrmsrl(MSR_IA32_L3_QOS_ABMC_CFG, abmc_cfg.full); +} + +static void resctrl_mon_event_config_set(void *info) +{ + struct mon_config_info *mon_info =3D info; + struct rdt_mon_domain *d =3D mon_info->d; + struct rdt_resource *r =3D mon_info->r; + struct rdtgroup *rdtgrp; + unsigned int index; + u32 cntr_id; + + resctrl_arch_mon_event_config_set(d, mon_info->evtid, mon_info->mon_confi= g); + + if (!resctrl_arch_mbm_cntr_assign_enabled(r)) + return; + + index =3D mon_event_config_index_get(mon_info->evtid); + if (index =3D=3D INVALID_CONFIG_INDEX) + return; + + for (cntr_id =3D 0; cntr_id < r->mon.num_mbm_cntrs; cntr_id++) { + if (test_bit(cntr_id, d->mbm_cntr_map)) { + rdtgrp =3D rdtgroup_find_grp_by_cntr_id_index(cntr_id, index); + if (rdtgrp) + resctrl_arch_update_cntr(mon_info->r, d, + mon_info->evtid, + rdtgrp->mon.rmid, + rdtgrp->closid, + cntr_id, + mon_info->mon_config); + } + } +} =20 static void mbm_config_write_domain(struct rdt_resource *r, struct rdt_mon_domain *d, u32 evtid, u32 val) @@ -1841,6 +1908,7 @@ static void mbm_config_write_domain(struct rdt_resour= ce *r, if (config_val =3D=3D INVALID_CONFIG_VALUE || config_val =3D=3D val) return; =20 + mon_info.r =3D r; mon_info.d =3D d; mon_info.evtid =3D evtid; mon_info.mon_config =3D val; @@ -1852,7 +1920,7 @@ static void mbm_config_write_domain(struct rdt_resour= ce *r, * on one CPU is observed by all the CPUs in the domain. */ smp_call_function_any(&d->hdr.cpu_mask, - resctrl_arch_mon_event_config_set, + resctrl_mon_event_config_set, &mon_info, 1); =20 /* diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 0b8eeb8afc68..4dc858d7aa10 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -356,7 +356,8 @@ void resctrl_arch_reset_rmid(struct rdt_resource *r, st= ruct rdt_mon_domain *d, */ void resctrl_arch_reset_rmid_all(struct rdt_resource *r, struct rdt_mon_do= main *d); =20 -void resctrl_arch_mon_event_config_set(void *info); +void resctrl_arch_mon_event_config_set(struct rdt_mon_domain *d, + enum resctrl_event_id eventid, u32 val); u32 resctrl_arch_mon_event_config_get(struct rdt_mon_domain *d, enum resctrl_event_id eventid); =20 --=20 2.34.1 From nobody Mon Nov 25 04:41:22 2024 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2079.outbound.protection.outlook.com [40.107.223.79]) (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 B3FBF209675; Tue, 29 Oct 2024 23:26:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.79 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244369; cv=fail; b=A+uwaWJeMqDHhk2+th1RB6sAYvd0Lgpwz9w9gVwn2BTgp17CfMQ3X8OMWhPCSXbWSjub9s4XuCBf2UAsKiXTWX+NY5Po9kPrY9oi+AjgCvui/hBQme7CmDRNYP8uhdRXI1srKGTmAfRHdXYZeQfWkSegvG0WmX/tJdUQh7gJrVE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244369; c=relaxed/simple; bh=yLx6B6k2fHyxymF9e0pZjYwlNSpiMUw0E980tmcKa+A=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JfEKvR2aVXAjDXS498qoifdNgMZqjx41uJmjDi/Jit3yf9wX7Dj+HzSXnHriGV/UM+ZPVqke2Q6qyp4KHXjVkEM3uD7aMSvcWAH2LJqss3kdIIYQG6NuQ+DE9tZkClkXG73L1d7hBHF72lnU6yw/boPMXm3eQvPzQkwQAmB/W1w= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=Q6NHf4rP; arc=fail smtp.client-ip=40.107.223.79 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) header.d=amd.com header.i=@amd.com header.b="Q6NHf4rP" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NtbtYRMXCdGPpD2jRkmKrrhHPs5tyuziTXnmMZlccn/Vzc6N/FuiObevNx9hf/0DPD1gO0bx5H0YvgA7BGR3JGrzXSdZWBtakH73cwQnC5t7kEaN6RGjRarAmd0vR/kVZ2bZMeBaJfYjyJ6l6PBU0E4UzWYqNvp8a6VTZ6dKOyAdGxwmf0jnJ0VBPoc0y7YUmID6IlvTbeXD3meMHAmLkNTBUJkJ8xSc6hE7cgdoNyINHdq/AhGWj0fzTeJdIqYcdsCkKm4J0t6v0ymtyfdZ+Db633MvycWKRuYyWb7cAfLYlbPWqF2YGtMEWVJ+/wmGVr+Ok+vCVx+f2Rn19ZAXxA== 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=8G5v+CjQIes4JHsUBsG7YnY1gP+3LSliecmbYfy/JFQ=; b=qKIgtl32wLz5ECVumk39vklj1fq/6B417av/1PtqSkUfBwyKheLLCiDdB5H6gw5a0Uk9vA9RXK1BbGa3/HolRNpRd02LG/D/fT84bWV9j/mXF4RXnk2e5rbeyPlUZLguRkbVhEXYfI3Kgud2oxjV1dEur5C8OtX4+/wheR9Fg4yOPzGLNJyl4KD3rUoFgi5kOVpCOSgvLM4RtMhp0PBb3SWopUIDc/73fxiKs+kD27XjtLsFy/OEB+/jNpp3r97mZ+Ii/gy6DX33qJw7mft1zWU1W3+vIMm3hI5uBj+Cbth0yUwm/xKatKBFTdZnq2IlZfZ5OM75kMvlio52KboeUQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net 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=8G5v+CjQIes4JHsUBsG7YnY1gP+3LSliecmbYfy/JFQ=; b=Q6NHf4rPd4C0BVLVG8s+cUhrfoTfReDchA5mZ9PgcYJQfGU2Az0VwIHgn4iYZVungkScHLK5Z/cMvlE3+5uzcExLrlIO4If32rCGcq8Lw+vrXH7M4/lSmMFjVT8YUBIWHbAagC2HRCF00YyfrTpzNQW5/KKzvnvz8JOjY2E+BbA= Received: from SN7PR04CA0228.namprd04.prod.outlook.com (2603:10b6:806:127::23) by CY5PR12MB6228.namprd12.prod.outlook.com (2603:10b6:930:20::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.27; Tue, 29 Oct 2024 23:26:03 +0000 Received: from SA2PEPF00001504.namprd04.prod.outlook.com (2603:10b6:806:127:cafe::71) by SN7PR04CA0228.outlook.office365.com (2603:10b6:806:127::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.31 via Frontend Transport; Tue, 29 Oct 2024 23:26:03 +0000 X-MS-Exchange-Authentication-Results: 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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SA2PEPF00001504.mail.protection.outlook.com (10.167.242.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Tue, 29 Oct 2024 23:26:03 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 29 Oct 2024 18:25:37 -0500 From: Babu Moger To: , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v9 25/26] x86/resctrl: Introduce interface to list assignment states of all the groups Date: Tue, 29 Oct 2024 18:21:57 -0500 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00001504:EE_|CY5PR12MB6228:EE_ X-MS-Office365-Filtering-Correlation-Id: c064548c-3792-4c57-2e10-08dcf8710e94 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|376014|7416014|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?zvvjFK7q6ZSNgt1BvgQrXv7OSD/wWTVBDLWvOkbmTYmh09BPSu5B4zMS6I2d?= =?us-ascii?Q?nDVnIiL/WLfWn+gifmtlYZ0soRfE68yzT9O66+b8Epw6j0KjWfMKw7iclxgx?= =?us-ascii?Q?iwgKM4rquCUHOG/cbIUdClbll26e006mqYkufglyeuMZmloK9tlFI4CPDMIq?= =?us-ascii?Q?cVBOQmqTcYZfCZH8aVyzwaOoipDfNIC0IHH5z6aifUEJ5ZpeGY3n2LZ47vAE?= =?us-ascii?Q?eo3wSwt6X7aehAt6Kp2HJ+1DJUgvddVb4NRQkRnd7P7dOTgZKpET2IyXvRbw?= =?us-ascii?Q?L6Zj2MStz7dMy3SNeD7Ql9lKUkpTRIX55hBLBrd36DsbWYm2ZYYDIcIH9csI?= =?us-ascii?Q?g2/FJDyvg5ee3mHy98RQseh5ddoU7/o6ybQJxoBZRW6VbjGpKtu6KtN+nvnG?= =?us-ascii?Q?IKLZWs4q/LToC0Wod0k18LE+n5a+P2POALshH7hmhZc9rBcRQUzA9y/mveP3?= =?us-ascii?Q?2RbEvHwTi+mG9opD2bgZSwgALRVk1Ig2Fj6ETUXc+KM4NDu+nfCeZOAkwjFk?= =?us-ascii?Q?4WWZveMWEBhG5tLRdwNkSgflwPndBsnFx5RAKtne8GFUFM/Pj+Q8nDgPwOPv?= =?us-ascii?Q?j9NLaesvnYnamrZyq/EoOybRBlQVOf/09z8EhWJUACrz6Ru+vDGhWxqP8S1d?= =?us-ascii?Q?x6oxGL7qGynQP8LsUKIhQx5dcVlN5Ui6uIpxCgoGzBPLnIY7ff65tFQ70wFQ?= =?us-ascii?Q?BGmu9mOGxfDe8ceMkmblwpEs8vly2X0ysN3jcG92GXTk1A7OpHHz9UhhTEKe?= =?us-ascii?Q?v4OsoiXBMFaf4LGyDi0zJCtRDMzhA7b7oMRzvCvJzWDFBBPxkxi4yp1wTxa+?= =?us-ascii?Q?21DP8NIQC7krQ64AeU5TA1UpSe0YDSLczZWvx79aMdWCNWJlSjdVeZ67Na+z?= =?us-ascii?Q?cGoYXcgRSzqTv64pJ7jJYaW/KaQHT2tTumO7CRhsRFuNGOLapYblcpBIwnmS?= =?us-ascii?Q?YcfNSi/pI3W+zQRPQpXDvnG8q1uUsEG/CKDBUKB3jWJAuUjVNv+kyOT/5Hsb?= =?us-ascii?Q?fMVDdDm/P7Fl/RIQggYb14E8ScfjEEPW4whOwjLYew7gZKekLiQ/ULFcdp1G?= =?us-ascii?Q?nPlgZXxJFSBXrB38SywKkBRNSvlttKvCSdGqPgBh0SgEO60KFIzPUnZHbFPb?= =?us-ascii?Q?qD72HXA6guWbBIU0kOeGtV2Xv6OLZBNCbit0Bh+WYycedIsP3fepRFdmUIMY?= =?us-ascii?Q?3IIKEHNmJMew6nsfre997pocm7evBB/mxqUqbMhqYwBf/Y6CAEEE2MFPHbUL?= =?us-ascii?Q?3Ve/O3rZUGXtwSEv1DfQ8f16thRNWi4DKP0NUEls8C5MP1APdFHY8DiuVTYQ?= =?us-ascii?Q?eA6Lsu/speGcKPaqalgD+TnZdxZhfofrpxx8GdfzT/D9JRtV31tRVvAcO9lG?= =?us-ascii?Q?6UTgybVt74oAS9y6OE874XmOU6bgEiyYRKQQi6Fmyxhbt0u68w=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(82310400026)(376014)(7416014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 23:26:03.8572 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c064548c-3792-4c57-2e10-08dcf8710e94 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF00001504.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6228 Content-Type: text/plain; charset="utf-8" Provide the interface to list the assignment states of all the resctrl groups in mbm_cntr_assign mode. Example: $ mount -t resctrl resctrl /sys/fs/resctrl/ $ cat /sys/fs/resctrl/info/L3_MON/mbm_assign_control //0=3Dtl;1=3Dtl; List follows the following format: "//=3D" Format for specific type of groups: - Default CTRL_MON group: "//=3D" - Non-default CTRL_MON group: "//=3D" - Child MON group of default CTRL_MON group: "//=3D" - Child MON group of non-default CTRL_MON group: "//=3D" Flags can be one of the following: t MBM total event is assigned l MBM local event is assigned tl Both total and local MBM events are assigned _ None of the MBM events are assigned Signed-off-by: Babu Moger --- v9: Minor parameter update in resctrl_mbm_event_assigned(). v8: Moved resctrl_mbm_event_assigned() in here as it is first used here. Moved rdt_last_cmd_clear() before making any call. Updated the commit log. Corrected the doc format. v7: Renamed the interface name from 'mbm_control' to 'mbm_assign_control' to match 'mbm_assign_mode'. Removed Arch references from FS code. Added rdt_last_cmd_clear() before the command processing. Added rdtgroup_mutex before all the calls. Removed references of ABMC from FS code. v6: The domain specific assignment can be determined looking at mbm_cntr_ma= p. Removed rdtgroup_abmc_dom_cfg() and rdtgroup_abmc_dom_state(). Removed the switch statement for the domain_state detection. Determined the flags incremently. Removed special handling of default group while printing.. v5: Replaced "assignment flags" with "flags". Changes related to mon structure. Changes related renaming the interface from mbm_assign_control to mbm_control. v4: Added functionality to query domain specific assigment in. rdtgroup_abmc_dom_state(). v3: New patch. Addresses the feedback to provide the global assignment interface. https://lore.kernel.org/lkml/c73f444b-83a1-4e9a-95d3-54c5165ee782@intel= .com/ --- Documentation/arch/x86/resctrl.rst | 44 +++++++++++++++ arch/x86/kernel/cpu/resctrl/monitor.c | 1 + arch/x86/kernel/cpu/resctrl/rdtgroup.c | 77 ++++++++++++++++++++++++++ 3 files changed, 122 insertions(+) diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/re= sctrl.rst index 1b39866e8b04..590727bec44b 100644 --- a/Documentation/arch/x86/resctrl.rst +++ b/Documentation/arch/x86/resctrl.rst @@ -321,6 +321,50 @@ with the following files: The number of free monitoring counters available assignment in each domain when the architecture supports mbm_cntr_assign mode. =20 +"mbm_assign_control": + Reports the resctrl group and monitor status of each group. + + List follows the following format: + "//=3D" + + Format for specific type of groups: + + * Default CTRL_MON group: + "//=3D" + + * Non-default CTRL_MON group: + "//=3D" + + * Child MON group of default CTRL_MON group: + "//=3D" + + * Child MON group of non-default CTRL_MON group: + "//=3D" + + Flags can be one of the following: + :: + + t MBM total event is assigned. + l MBM local event is assigned. + tl Both MBM total and local events are assigned. + _ None of the MBM events are assigned. + + Examples: + :: + + # mkdir /sys/fs/resctrl/mon_groups/child_default_mon_grp + # mkdir /sys/fs/resctrl/non_default_ctrl_mon_grp + # mkdir /sys/fs/resctrl/non_default_ctrl_mon_grp/mon_groups/child_non_de= fault_mon_grp + + # cat /sys/fs/resctrl/info/L3_MON/mbm_assign_control + non_default_ctrl_mon_grp//0=3Dtl;1=3Dtl; + non_default_ctrl_mon_grp/child_non_default_mon_grp/0=3Dtl;1=3Dtl; + //0=3Dtl;1=3Dtl; + /child_default_mon_grp/0=3Dtl;1=3Dtl; + + There are four resctrl groups. All the groups have total and local MBM ev= ents + assigned on domain 0 and 1. + "max_threshold_occupancy": Read/write file provides the largest value (in bytes) at which a previously used LLC_occupancy diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 4ba5007fd1aa..fc0e4ea480cd 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -1270,6 +1270,7 @@ int __init rdt_get_mon_l3_config(struct rdt_resource = *r) hw_res->mbm_cntr_assign_enabled =3D true; resctrl_file_fflags_init("num_mbm_cntrs", RFTYPE_MON_INFO); resctrl_file_fflags_init("available_mbm_cntrs", RFTYPE_MON_INFO); + resctrl_file_fflags_init("mbm_assign_control", RFTYPE_MON_INFO); } } =20 diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 7646d67ea10e..5cc40eacbe85 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -1011,6 +1011,77 @@ static ssize_t rdtgroup_mbm_assign_mode_write(struct= kernfs_open_file *of, return ret ?: nbytes; } =20 +static bool resctrl_mbm_event_assigned(struct rdtgroup *rdtg, + struct rdt_mon_domain *d, + enum resctrl_event_id evtid) +{ + int index =3D MBM_EVENT_ARRAY_INDEX(evtid); + int cntr_id =3D rdtg->mon.cntr_id[index]; + + return cntr_id !=3D MON_CNTR_UNSET && test_bit(cntr_id, d->mbm_cntr_map); +} + +static char *rdtgroup_mon_state_to_str(struct rdtgroup *rdtgrp, + struct rdt_mon_domain *d, char *str) +{ + char *tmp =3D str; + + /* Query the total and local event flags for the domain */ + if (resctrl_mbm_event_assigned(rdtgrp, d, QOS_L3_MBM_TOTAL_EVENT_ID)) + *tmp++ =3D 't'; + + if (resctrl_mbm_event_assigned(rdtgrp, d, QOS_L3_MBM_LOCAL_EVENT_ID)) + *tmp++ =3D 'l'; + + if (tmp =3D=3D str) + *tmp++ =3D '_'; + + *tmp =3D '\0'; + return str; +} + +static int rdtgroup_mbm_assign_control_show(struct kernfs_open_file *of, + struct seq_file *s, void *v) +{ + struct rdt_resource *r =3D of->kn->parent->priv; + struct rdt_mon_domain *dom; + struct rdtgroup *rdtg; + char str[10]; + + mutex_lock(&rdtgroup_mutex); + rdt_last_cmd_clear(); + + if (!resctrl_arch_mbm_cntr_assign_enabled(r)) { + rdt_last_cmd_puts("mbm_cntr_assign mode is not enabled\n"); + mutex_unlock(&rdtgroup_mutex); + return -EINVAL; + } + + list_for_each_entry(rdtg, &rdt_all_groups, rdtgroup_list) { + struct rdtgroup *crg; + + seq_printf(s, "%s//", rdtg->kn->name); + + list_for_each_entry(dom, &r->mon_domains, hdr.list) + seq_printf(s, "%d=3D%s;", dom->hdr.id, + rdtgroup_mon_state_to_str(rdtg, dom, str)); + seq_putc(s, '\n'); + + list_for_each_entry(crg, &rdtg->mon.crdtgrp_list, + mon.crdtgrp_list) { + seq_printf(s, "%s/%s/", rdtg->kn->name, crg->kn->name); + + list_for_each_entry(dom, &r->mon_domains, hdr.list) + seq_printf(s, "%d=3D%s;", dom->hdr.id, + rdtgroup_mon_state_to_str(crg, dom, str)); + seq_putc(s, '\n'); + } + } + + mutex_unlock(&rdtgroup_mutex); + return 0; +} + #ifdef CONFIG_PROC_CPU_RESCTRL =20 /* @@ -2310,6 +2381,12 @@ static struct rftype res_common_files[] =3D { .seq_show =3D mbm_local_bytes_config_show, .write =3D mbm_local_bytes_config_write, }, + { + .name =3D "mbm_assign_control", + .mode =3D 0444, + .kf_ops =3D &rdtgroup_kf_single_ops, + .seq_show =3D rdtgroup_mbm_assign_control_show, + }, { .name =3D "mbm_assign_mode", .mode =3D 0644, --=20 2.34.1 From nobody Mon Nov 25 04:41:22 2024 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2087.outbound.protection.outlook.com [40.107.92.87]) (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 3F34420C46D; Tue, 29 Oct 2024 23:26:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.87 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244372; cv=fail; b=AieJOzYE6XJipma3nyc0V9+eQIvOadiXRNilK8fjeMwXBuLZwURVy9ryD4gcyjeeM77B81fAqOfLQHeGuGx3TDVSnP/pmMkdObvIEZhYy6+MKOJqAfFzVwOLXN2iKDWlFVJEYJiftnLdK9g5DZ9aAcV6WW9X68YlO/aSBKDo9+g= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730244372; c=relaxed/simple; bh=9m65ClpxNVfQlngwhM8XM95G1YPtOlBC5Z18c1+VEgo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=V9VRzsLLXPFeT4JqIZsgUO1H5w/tLpEUUyvPDN7dOoN+0aHUTd49SHJ+fCtI6efmyVqNzYrmp8jsMSH/PUmhr3Ph0KkPqGhD7fATYLMZV+bAK2HHR2UrixHOdOIXxk23iEeJaoz1Oeugd/c3AP3jNmOM4yFTnFdJ8pzjC2pwpRM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=bw+zQqzh; arc=fail smtp.client-ip=40.107.92.87 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) header.d=amd.com header.i=@amd.com header.b="bw+zQqzh" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=h1e0VMvRUWSe/TJMe37Hab/JvZVby/Af6UKedZQgs0drcbj3Lglx22o+N1WvP6DRyanOjMwmliTWxqu4k7tPmdKzrZPBlvaRr5VNyiGHL3J8JwFlTX+EbSixsB7fwaC39d9LavWL5tgIkyzVkzL6PBENCJ4glQ1NQfJV91aL9Oyogq81aebIT4xiPIuZ1WGDuDOVzm56zpZ28+Ciq/QfVfywr4LYzKDp7ct8FPs85B8RtKg1lgrY7Klbe3dOuFEQD+Ejp+MM4xV10yiOwrhuZ+5TzO5fVWvaNLrOzcn6AnO0gPgsT2qAMv9noEWFo1oZXPPEe3ptCq3I6fLu/xsLcw== 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=XpuUQzZ3m6n5peXlKD8Llgs5qGiEScsi5EAcCniIV30=; b=sWa0dxrtEFUHFzuvDKgrZt8uGfheZkQ+38Buwe4cT2mO8ZcQObaL/A/pWrXxrB/TehyPy5vJQhvXSb/LNjeGAl0thAJCfYA/atZbEn7HOu6FnZTaeo/uEn26vLi3kfE8+fRpziTy0I3tkDEdSS4plIFo/zXS/hYeL4VVR2EwD8glbXNI+fNZSry8pg6EKh2t7slbLXJ4wDeIAn2/79ubmozl6GoVvBHduCjA6dsKrhftaDsMZP95czU5kld1X64fAuEsPiz1TdoBKS35R3QNgQsas98xEwkU21DF2X8cNaGFmoNmuoLDsw1D46zZyfMgbNxHPHdwfDPAEbCVHKJFXg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net 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=XpuUQzZ3m6n5peXlKD8Llgs5qGiEScsi5EAcCniIV30=; b=bw+zQqzhRjlApSuNjgXDxxeKwcdJoGR9g0j1PLquFIhrwDXJC1d886rWMp64lc3jkShe7JjQoppXKjzRjQ488L7TX4JnEyYo5vT0kiFk9gBovIw1K5pKOPWZ8RR01A6dvA0oOk5heELleAJGomTRAt6XC8TIwoY9T7ulm/W6BKA= Received: from SN7PR04CA0236.namprd04.prod.outlook.com (2603:10b6:806:127::31) by PH8PR12MB7303.namprd12.prod.outlook.com (2603:10b6:510:220::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.25; Tue, 29 Oct 2024 23:26:04 +0000 Received: from SA2PEPF00001504.namprd04.prod.outlook.com (2603:10b6:806:127:cafe::cb) by SN7PR04CA0236.outlook.office365.com (2603:10b6:806:127::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.17 via Frontend Transport; Tue, 29 Oct 2024 23:26:04 +0000 X-MS-Exchange-Authentication-Results: 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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SA2PEPF00001504.mail.protection.outlook.com (10.167.242.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Tue, 29 Oct 2024 23:26:04 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 29 Oct 2024 18:25:45 -0500 From: Babu Moger To: , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v9 26/26] x86/resctrl: Introduce interface to modify assignment states of the groups Date: Tue, 29 Oct 2024 18:21:58 -0500 Message-ID: <1dfa8b184a00d94013470b2818c23fd8eab66baa.1730244116.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00001504:EE_|PH8PR12MB7303:EE_ X-MS-Office365-Filtering-Correlation-Id: c0e3a92b-a106-4d13-1754-08dcf8710ede X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: =?utf-8?B?ZUdQb3ZtbDI3MktURFlXamluU2FTTkZWQ1dTc3ptdGVhQTlzUnBIKzBkY1cv?= =?utf-8?B?d092MjQrb2dCbURJcGhrSzZCWWRoSzY3UEZKcHVmNDEweWpuYmVSZEYzVHQ3?= =?utf-8?B?TCtOVjlRRUV3aXc3RGhCU3A1bjYrOGFOcS9xRmlVWm5hVEJvNzArbW84bjJI?= =?utf-8?B?UmNMbUIrckVFRHdtTUNQenJvNjA1RCtzYnQ0QlpDZVdqbUx5Vk1VL2k5Ym5t?= =?utf-8?B?TU9TOEw4YkZ3VDVQcWVsU0tZUnpRVVpqa1IySlUvckdoRWc4S3ltbWt1R0lu?= =?utf-8?B?ZHgwS1QwVHZKRi9LbzNPMmpCYlg0WFljdzl0WnhKT2xVOHBxVHdUTzU0b0xw?= =?utf-8?B?UEd4R2NMRTR3cUxyVG9oSFZSRkZoOXordHJMazk0WDZCMkRKd1dXQnFHMFV4?= =?utf-8?B?WVVlQWlQRjNXUGJJNnJ1bEptTjUrTWpINWRlNG9mckowZjF6LzdhZXBhZktk?= =?utf-8?B?b29EVHJuWXhVczBrblVGdHhtanA4ekZIUHlUSzg2WTBHQVJlQkFpRWgvM3BT?= =?utf-8?B?RTdlcEYxZlROYlhkMi9HbVFXSFFVWmtDaCtkclpNOEtzOG8zWnhPQ2NsYXdh?= =?utf-8?B?Wis1ZURKKzMyNHQ1VlJhQVN6Z0tkNzU1V01idDBXcVBwcnVGODZKeXp6OXRL?= =?utf-8?B?b1VsR2luQnpXM0U4ZklSc1NCWXJiWFp0c3dnN2FWYUkyZHg4S1ViZlRoTDhQ?= =?utf-8?B?VFo0M01SREw1aTlWWnRYQzhta1ozSEJ0QW1aZDIwdmQ5RUFLaUs0U215ZGtQ?= =?utf-8?B?T3FUWTBabHh5VW95d0MxM0p1ZXpTSkswWWVxKzJUT1dhRmVhTUJZek8wb0Uv?= =?utf-8?B?bG9GUmY5eVVabkhNNi9OamNFQ0dHbklZZEhvbnZBRWNKU3BEVXdmNCticEFz?= =?utf-8?B?TG9zMXFSYXNhWlZIeWwxSDZ3OUc0SE5sd1A4bEFwZTd0TUs5VmZsMEZIYStz?= =?utf-8?B?Z05zZEh2ZkErWjYvTTkyS2pGLy9NQjJoSWl4N2tZSFd1anNhcVhIZGJYOFJL?= =?utf-8?B?L2RuWFVQbGFzTUZWRGY5Y1hhNktEdzErRHFsdmpPc2FJanNCSXdRd3k1ZnQ3?= =?utf-8?B?MnZJeThPUE5JeUdPb3Y1TDhGMUJOaGNUQjhCbFFlNi9zMEsrSkEwa3p2VEc4?= =?utf-8?B?Wm1iODhES2tOUWg2Mm9tYUdkNXZ6ZEVWWG9BL0JVeHA4S3g0c3RJMkdWN0tL?= =?utf-8?B?TkFEWHNCOU5JbDhDQnhCRjZyRWRVZGZxVkplQ2w5WGxqUzZUaENBYkVIbXBu?= =?utf-8?B?REJPTkNDd05NcUZ1SHhhd3FvM0RzNkdVUXBleGwzLzA1MlB3NWc3QTNLcGVm?= =?utf-8?B?QkZLRW5zUkVTTkhibW54eCt4R3FSMlQyQXZ0Tm50SFU2R0lmak1xaGpKYm0z?= =?utf-8?B?Q1d2NE5neDcwQk1SZ0ZHL2orMFNIU3E1TVJ4Yy9pZ3BmQXBTM0VvS2E5d1pV?= =?utf-8?B?TnhGMHlmVFNjUUZLQXVHdnNBNE9MTzM3eDJ2T2x3VG9sVVFrTWxMZ1Z3MWRS?= =?utf-8?B?N1IxTGNaM09GeG9KaFZkTVRCc3ZWQllmcGtPMjFOOGpLekg4YUFET0NPWERP?= =?utf-8?B?VUROZk9jL1dEanIyOG9DeFlraGQ1K1ZEQ0JHSDhDbEVDYjRCUEZ1SnhWd1I4?= =?utf-8?B?TW5oMTZwTlRmZi9VSHg3ZGpBS3I4amMwcFlRU0lPRDB2K1Z5QTVxbWFrUlJV?= =?utf-8?B?NHoxK0RJb3cwKytLVXBvaEovM3M2S3Q5dXk3YWtwN3V6VER4Sk1ROVlNS1FK?= =?utf-8?B?ZTdUVldLUDFIanl5ZWlGNjM1Rmw3T0JKZE03NjM0Q25HTUcvcCtnV2kxMDlz?= =?utf-8?B?VEhsdlRWcjQxSG9JZjVQQW43Z1lQWHhtSzVBaWEwdlJEU2xJb0JYR2U1ZHFv?= =?utf-8?B?S2ZsZTNZK25UeSs0cVF6cU4wbUFMRTRpYjRFZUVZbFhNTVE9PQ==?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(1800799024)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 23:26:04.3259 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c0e3a92b-a106-4d13-1754-08dcf8710ede 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF00001504.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7303 Introduce the interface to assign MBM events in mbm_cntr_assign mode. Events can be enabled or disabled by writing to file /sys/fs/resctrl/info/L3_MON/mbm_assign_control Format is similar to the list format with addition of opcode for the assignment operation. "//" Format for specific type of groups: * Default CTRL_MON group: "//" * Non-default CTRL_MON group: "//" * Child MON group of default CTRL_MON group: "//" * Child MON group of non-default CTRL_MON group: "//" Domain_id '*' will apply the flags on all the domains. Opcode can be one of the following: =3D Update the assignment to match the flags + Assign a new MBM event without impacting existing assignments. - Unassign a MBM event from currently assigned events. Assignment flags can be one of the following: t MBM total event l MBM local event tl Both total and local MBM events _ None of the MBM events. Valid only with '=3D' opcode. This flag cannot be combined with other flags. Signed-off-by: Babu Moger --- v9: Fixed handling special case '//0=3D' and '//". Removed extra strstr() call. Added generic failure text when assignment operation fails. Corrected user documentation format texts. v8: Moved unassign as the first action during the assign modification. Assign none "_" takes priority. Cannot be mixed with other flags. Updated the documentation and .rst file format. htmldoc looks ok. v7: Simplified the parsing (strsep(&token, "//") in rdtgroup_mbm_assign_con= trol_write(). Added mutex lock in rdtgroup_mbm_assign_control_write() while processin= g. Renamed rdtgroup_find_grp to rdtgroup_find_grp_by_name. Fixed rdtgroup_str_to_mon_state to return error for invalid flags. Simplified the calls rdtgroup_assign_cntr by merging few functions earl= ier. Removed ABMC reference in FS code. Reinette commented about handling the combination of flags like 'lt_' a= nd '_lt'. Not sure if we need to change the behaviour here. Processed them sequen= cially right now. Users have the liberty to pass the flags. Restricting it might be a pro= blem later. v6: Added support assign all if domain id is '*' Fixed the allocation of counter id if it not assigned already. v5: Interface name changed from mbm_assign_control to mbm_control. Fixed opcode and flags combination. '=3D_" is valid. "-_" amd "+_" is not valid. Minor message update. Renamed the function with prefix - rdtgroup_. Corrected few documentation mistakes. Rebase related changes after SNC support. v4: Added domain specific assignments. Fixed the opcode parsing. v3: New patch. Addresses the feedback to provide the global assignment interface. https://lore.kernel.org/lkml/c73f444b-83a1-4e9a-95d3-54c5165ee782@intel= .com/ --- Documentation/arch/x86/resctrl.rst | 116 +++++++++++- arch/x86/kernel/cpu/resctrl/internal.h | 10 ++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 236 ++++++++++++++++++++++++- 3 files changed, 360 insertions(+), 2 deletions(-) diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/re= sctrl.rst index 590727bec44b..d0a107d251ec 100644 --- a/Documentation/arch/x86/resctrl.rst +++ b/Documentation/arch/x86/resctrl.rst @@ -347,7 +347,8 @@ with the following files: t MBM total event is assigned. l MBM local event is assigned. tl Both MBM total and local events are assigned. - _ None of the MBM events are assigned. + _ None of the MBM events are assigned. Only works with opcode '=3D' for= write + and cannot be combined with other flags. =20 Examples: :: @@ -365,6 +366,119 @@ with the following files: There are four resctrl groups. All the groups have total and local MBM ev= ents assigned on domain 0 and 1. =20 + Assignment state can be updated by writing to the interface. + + Format is similar to the list format with addition of opcode for the + assignment operation. + + "//" + + Format for each type of groups: + + * Default CTRL_MON group: + "//" + + * Non-default CTRL_MON group: + "//" + + * Child MON group of default CTRL_MON group: + "//" + + * Child MON group of non-default CTRL_MON group: + "//" + + Domain_id '*' will apply the flags on all the domains. + + Opcode can be one of the following: + :: + + =3D Update the assignment to match the MBM event. + + Assign a new MBM event without impacting existing assignments. + - Unassign a MBM event from currently assigned events. + + Examples: + Initial group status: + :: + + # cat /sys/fs/resctrl/info/L3_MON/mbm_assign_control + non_default_ctrl_mon_grp//0=3Dtl;1=3Dtl; + non_default_ctrl_mon_grp/child_non_default_mon_grp/0=3Dtl;1=3Dtl; + //0=3Dtl;1=3Dtl; + /child_default_mon_grp/0=3Dtl;1=3Dtl; + + To update the default group to assign only total MBM event on domain 0: + :: + + # echo "//0=3Dt" > /sys/fs/resctrl/info/L3_MON/mbm_assign_control + + Assignment status after the update: + :: + + # cat /sys/fs/resctrl/info/L3_MON/mbm_assign_control + non_default_ctrl_mon_grp//0=3Dtl;1=3Dtl; + non_default_ctrl_mon_grp/child_non_default_mon_grp/0=3Dtl;1=3Dtl; + //0=3Dt;1=3Dtl; + /child_default_mon_grp/0=3Dtl;1=3Dtl; + + To update the MON group child_default_mon_grp to remove total MBM event o= n domain 1: + :: + + # echo "/child_default_mon_grp/1-t" > /sys/fs/resctrl/info/L3_MON/mbm_a= ssign_control + + Assignment status after the update: + :: + + # cat /sys/fs/resctrl/info/L3_MON/mbm_assign_control + non_default_ctrl_mon_grp//0=3Dtl;1=3Dtl; + non_default_ctrl_mon_grp/child_non_default_mon_grp/0=3Dtl;1=3Dtl; + //0=3Dt;1=3Dtl; + /child_default_mon_grp/0=3Dtl;1=3Dl; + + To update the MON group non_default_ctrl_mon_grp/child_non_default_mon_gr= p to unassign + both local and total MBM events on domain 1: + :: + + # echo "non_default_ctrl_mon_grp/child_non_default_mon_grp/1=3D_" > + /sys/fs/resctrl/info/L3_MON/mbm_assign_control + + Assignment status after the update: + :: + + # cat /sys/fs/resctrl/info/L3_MON/mbm_assign_control + non_default_ctrl_mon_grp//0=3Dtl;1=3Dtl; + non_default_ctrl_mon_grp/child_non_default_mon_grp/0=3Dtl;1=3D_; + //0=3Dt;1=3Dtl; + /child_default_mon_grp/0=3Dtl;1=3Dl; + + To update the default group to add a local MBM event domain 0. + :: + + # echo "//0+l" > /sys/fs/resctrl/info/L3_MON/mbm_assign_control + + Assignment status after the update: + :: + + # cat /sys/fs/resctrl/info/L3_MON/mbm_assign_control + non_default_ctrl_mon_grp//0=3Dtl;1=3Dtl; + non_default_ctrl_mon_grp/child_non_default_mon_grp/0=3Dtl;1=3D_; + //0=3Dtl;1=3Dtl; + /child_default_mon_grp/0=3Dtl;1=3Dl; + + To update the non default CTRL_MON group non_default_ctrl_mon_grp to unas= sign all the + MBM events on all the domains. + :: + + # echo "non_default_ctrl_mon_grp//*=3D_" > /sys/fs/resctrl/info/L3_MON/= mbm_assign_control + + Assignment status after the update: + :: + + # cat /sys/fs/resctrl/info/L3_MON/mbm_assign_control + non_default_ctrl_mon_grp//0=3D_;1=3D_; + non_default_ctrl_mon_grp/child_non_default_mon_grp/0=3Dtl;1=3D_; + //0=3Dtl;1=3Dtl; + /child_default_mon_grp/0=3Dtl;1=3Dl; + "max_threshold_occupancy": Read/write file provides the largest value (in bytes) at which a previously used LLC_occupancy diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index b90d8c90b4b6..3ccaea6a2803 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -74,6 +74,16 @@ */ #define MBM_EVENT_ARRAY_INDEX(_event) ((_event) - 2) =20 +/* + * Assignment flags for mbm_cntr_assign feature + */ +enum { + ASSIGN_NONE =3D 0, + ASSIGN_TOTAL =3D BIT(QOS_L3_MBM_TOTAL_EVENT_ID), + ASSIGN_LOCAL =3D BIT(QOS_L3_MBM_LOCAL_EVENT_ID), + ASSIGN_INVALID, +}; + /** * cpumask_any_housekeeping() - Choose any CPU in @mask, preferring those = that * aren't marked nohz_full diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 5cc40eacbe85..9fe419d0c536 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -1082,6 +1082,239 @@ static int rdtgroup_mbm_assign_control_show(struct = kernfs_open_file *of, return 0; } =20 +static int rdtgroup_str_to_mon_state(char *flag) +{ + int i, mon_state =3D ASSIGN_NONE; + + if (!strlen(flag)) + return ASSIGN_INVALID; + + for (i =3D 0; i < strlen(flag); i++) { + switch (*(flag + i)) { + case 't': + mon_state |=3D ASSIGN_TOTAL; + break; + case 'l': + mon_state |=3D ASSIGN_LOCAL; + break; + case '_': + return ASSIGN_NONE; + default: + return ASSIGN_INVALID; + } + } + + return mon_state; +} + +static struct rdtgroup *rdtgroup_find_grp_by_name(enum rdt_group_type rtyp= e, + char *p_grp, char *c_grp) +{ + struct rdtgroup *rdtg, *crg; + + if (rtype =3D=3D RDTCTRL_GROUP && *p_grp =3D=3D '\0') { + return &rdtgroup_default; + } else if (rtype =3D=3D RDTCTRL_GROUP) { + list_for_each_entry(rdtg, &rdt_all_groups, rdtgroup_list) + if (!strcmp(p_grp, rdtg->kn->name)) + return rdtg; + } else if (rtype =3D=3D RDTMON_GROUP) { + list_for_each_entry(rdtg, &rdt_all_groups, rdtgroup_list) { + if (!strcmp(p_grp, rdtg->kn->name)) { + list_for_each_entry(crg, &rdtg->mon.crdtgrp_list, + mon.crdtgrp_list) { + if (!strcmp(c_grp, crg->kn->name)) + return crg; + } + } + } + } + + return NULL; +} + +static int rdtgroup_process_flags(struct rdt_resource *r, + enum rdt_group_type rtype, + char *p_grp, char *c_grp, char *tok) +{ + int op, mon_state, assign_state, unassign_state; + char *dom_str, *id_str, *op_str; + struct rdt_mon_domain *d; + struct rdtgroup *rdtgrp; + unsigned long dom_id; + int ret, found =3D 0; + + rdtgrp =3D rdtgroup_find_grp_by_name(rtype, p_grp, c_grp); + + if (!rdtgrp) { + rdt_last_cmd_puts("Not a valid resctrl group\n"); + return -EINVAL; + } + +next: + if (!tok || tok[0] =3D=3D '\0') + return 0; + + /* Start processing the strings for each domain */ + dom_str =3D strim(strsep(&tok, ";")); + + op_str =3D strpbrk(dom_str, "=3D+-"); + + if (op_str) { + op =3D *op_str; + } else { + rdt_last_cmd_puts("Missing operation =3D, +, - character\n"); + return -EINVAL; + } + + id_str =3D strsep(&dom_str, "=3D+-"); + + /* Check for domain id '*' which means all domains */ + if (id_str && *id_str =3D=3D '*') { + d =3D NULL; + goto check_state; + } else if (!id_str || kstrtoul(id_str, 10, &dom_id)) { + rdt_last_cmd_puts("Missing domain id\n"); + return -EINVAL; + } + + /* Verify if the dom_id is valid */ + list_for_each_entry(d, &r->mon_domains, hdr.list) { + if (d->hdr.id =3D=3D dom_id) { + found =3D 1; + break; + } + } + + if (!found) { + rdt_last_cmd_printf("Invalid domain id %ld\n", dom_id); + return -EINVAL; + } + +check_state: + mon_state =3D rdtgroup_str_to_mon_state(dom_str); + + if (mon_state =3D=3D ASSIGN_INVALID) { + rdt_last_cmd_puts("Invalid assign flag\n"); + goto out_fail; + } + + assign_state =3D 0; + unassign_state =3D 0; + + switch (op) { + case '+': + if (mon_state =3D=3D ASSIGN_NONE) { + rdt_last_cmd_puts("Invalid assign opcode\n"); + goto out_fail; + } + assign_state =3D mon_state; + break; + case '-': + if (mon_state =3D=3D ASSIGN_NONE) { + rdt_last_cmd_puts("Invalid assign opcode\n"); + goto out_fail; + } + unassign_state =3D mon_state; + break; + case '=3D': + assign_state =3D mon_state; + unassign_state =3D (ASSIGN_TOTAL | ASSIGN_LOCAL) & ~assign_state; + break; + default: + break; + } + + if (unassign_state & ASSIGN_TOTAL) { + ret =3D rdtgroup_unassign_cntr_event(r, rdtgrp, d, QOS_L3_MBM_TOTAL_EVEN= T_ID); + if (ret) + goto out_fail; + } + + if (unassign_state & ASSIGN_LOCAL) { + ret =3D rdtgroup_unassign_cntr_event(r, rdtgrp, d, QOS_L3_MBM_LOCAL_EVEN= T_ID); + if (ret) + goto out_fail; + } + + if (assign_state & ASSIGN_TOTAL) { + ret =3D rdtgroup_assign_cntr_event(r, rdtgrp, d, QOS_L3_MBM_TOTAL_EVENT_= ID); + if (ret) + goto out_fail; + } + + if (assign_state & ASSIGN_LOCAL) { + ret =3D rdtgroup_assign_cntr_event(r, rdtgrp, d, QOS_L3_MBM_LOCAL_EVENT_= ID); + if (ret) + goto out_fail; + } + + goto next; + +out_fail: + rdt_last_cmd_printf("Assign operation '%c%s' failed on the group %s/%s/\n= ", + op, dom_str, p_grp, c_grp); + + return -EINVAL; +} + +static ssize_t rdtgroup_mbm_assign_control_write(struct kernfs_open_file *= of, + char *buf, size_t nbytes, loff_t off) +{ + struct rdt_resource *r =3D of->kn->parent->priv; + char *token, *cmon_grp, *mon_grp; + enum rdt_group_type rtype; + int ret; + + /* Valid input requires a trailing newline */ + if (nbytes =3D=3D 0 || buf[nbytes - 1] !=3D '\n') + return -EINVAL; + + buf[nbytes - 1] =3D '\0'; + + cpus_read_lock(); + mutex_lock(&rdtgroup_mutex); + + rdt_last_cmd_clear(); + + if (!resctrl_arch_mbm_cntr_assign_enabled(r)) { + rdt_last_cmd_puts("mbm_cntr_assign mode is not enabled\n"); + mutex_unlock(&rdtgroup_mutex); + cpus_read_unlock(); + return -EINVAL; + } + + while ((token =3D strsep(&buf, "\n")) !=3D NULL) { + /* + * The write command follows the following format: + * =E2=80=9C//=E2= =80=9D + * Extract the CTRL_MON group. + */ + cmon_grp =3D strsep(&token, "/"); + + /* + * Extract the MON_GROUP. + * strsep returns empty string for contiguous delimiters. + * Empty mon_grp here means it is a RDTCTRL_GROUP. + */ + mon_grp =3D strsep(&token, "/"); + + if (*mon_grp =3D=3D '\0') + rtype =3D RDTCTRL_GROUP; + else + rtype =3D RDTMON_GROUP; + + ret =3D rdtgroup_process_flags(r, rtype, cmon_grp, mon_grp, token); + if (ret) + break; + } + + mutex_unlock(&rdtgroup_mutex); + cpus_read_unlock(); + + return ret ?: nbytes; +} + #ifdef CONFIG_PROC_CPU_RESCTRL =20 /* @@ -2383,9 +2616,10 @@ static struct rftype res_common_files[] =3D { }, { .name =3D "mbm_assign_control", - .mode =3D 0444, + .mode =3D 0644, .kf_ops =3D &rdtgroup_kf_single_ops, .seq_show =3D rdtgroup_mbm_assign_control_show, + .write =3D rdtgroup_mbm_assign_control_write, }, { .name =3D "mbm_assign_mode", --=20 2.34.1