From nobody Sat Oct 11 00:35:49 2025 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2046.outbound.protection.outlook.com [40.107.94.46]) (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 2186C246BB9; Wed, 11 Jun 2025 21:24:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.46 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749677044; cv=fail; b=cIu01Kbgb5HCLTC7OKcwhpMd0+zN/Op/G65Va8W3cq+33WY4UesMs0uRgVYiv7sL3u2hg1m+bMxi+Gs6kawJXvQoSVMNPuSU5zdJM3FSa6HzZOJg2r5BshEKQAoeDkIAfWAFru02pmTyAbX44eWg/qMgMcKnc6o1SyJr8lwTcxY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749677044; c=relaxed/simple; bh=8Hx6bfUY90mijE/L6336xd3ujV3xVxkrIHeEIsP77Lw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=W1upE5YrEq+WHmsg85AY7KbtpyhSSm3va8lBLNZKiUBoWnJYOGcmR0XVEfD9NtAUbsvHXQQboRzeC1pDS4xVtxcCgwHKLofs4s+EHXtaTaTEavPXhHcpojj5ZUCZbeRS3Wh1paKAXgyINYFtkRMFjxCZgT2/H4AFt4DMeMM+tTM= 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=PvEPfwUR; arc=fail smtp.client-ip=40.107.94.46 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="PvEPfwUR" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=T7XWZvkN5ZqcobSRcJh542cXW7z+O7fFarI+g93d+31PQ1uVYTHYxGJcmepuMTlghfn9F+KvutW/GoR4cmQ3Mc9ve5EvSb53+Hk+HYybDylGmjd+fMImeKN9iUMOnfPiQ2uCElvbV8Tv+MLttN+kt7UyCdGFIdxkCdqmm5eQ+3VXQBxtIt7VJG3RiKqtE7a/xMqbvjpOc9C2+hSCT0HsaewSxYHAVA5p9w4052UmEyBCitPFTe2szytaN1bYSQvRkBj9hW9GQunhFBUlVXbo0HvTZWZzFP05Oqp9+FDdy+zQl3cUcLGcFD3A1CSkCkCAWRw09HXAXmIw0QoOK32G6w== 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=huBDnqNQr5Kr68v8dgWjWVaAVpVqVHEuJu4PFO/5IUY=; b=oq8ElO9k05DssBke8I84BI/BpBjOjJxy6rUihdEES6ZbkiLQPEK+M9hpfMTcYCWbBGNmX/RFv+s9QT0Lioy/xAo/MNMwWQ3Dt/GnydJAWx+QKyTEpyC0i1s1wXV5cx+ps0U/uRvmDj23O38maKuG41V31TpwYLhkTWheF1H9iACRd3u5Xjizz0VfltzUKlThAiBzrnhDvTQIODLvwM3GIxLCzGM7PVP38TzmQJNTfz1rbF8Yfz4DVzKklEYuLlwfu9UHGSoG9WYqcIltINuStBSS196HSekWvX0Kvvkz63loFeGLXaGp86kXzfw6wS64q5YtSpqoHXFhzqmF90MGKA== 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=huBDnqNQr5Kr68v8dgWjWVaAVpVqVHEuJu4PFO/5IUY=; b=PvEPfwURIfSdQlmKRf5DCNu1+/NPkAf1vAN1qmWKKrtveq5L8qTBttb8rCQA/poLjbE1ejVESdNRB6s1l6O+9sPSkEm+YKEejR81DqFaDjrNHeMbZ6NblTJHDuR/rSVn7Kt0sffCzB0lTqemrfJELKd8zjmXS8a0njGPfq/9aYY= Received: from BY3PR10CA0025.namprd10.prod.outlook.com (2603:10b6:a03:255::30) by SA1PR12MB8093.namprd12.prod.outlook.com (2603:10b6:806:335::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8792.35; Wed, 11 Jun 2025 21:23:59 +0000 Received: from SJ1PEPF0000231B.namprd03.prod.outlook.com (2603:10b6:a03:255:cafe::81) by BY3PR10CA0025.outlook.office365.com (2603:10b6:a03:255::30) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8835.19 via Frontend Transport; Wed, 11 Jun 2025 21:23:59 +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 SJ1PEPF0000231B.mail.protection.outlook.com (10.167.242.232) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8835.15 via Frontend Transport; Wed, 11 Jun 2025 21:23:58 +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; Wed, 11 Jun 2025 16:23:55 -0500 From: Babu Moger To: , , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v6 1/8] x86/cpufeatures: Add support for L3 Smart Data Cache Injection Allocation Enforcement Date: Wed, 11 Jun 2025 16:23:26 -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: SJ1PEPF0000231B:EE_|SA1PR12MB8093:EE_ X-MS-Office365-Filtering-Correlation-Id: 85aa8ac9-12af-4fff-62dd-08dda92e4783 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|376014|7416014|82310400026|13003099007|921020; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?eey6Rfg/b0TcGV0o6OyIQ736khFIDOiF9t9yjhKAt0zLihiCT0feHWAkinBN?= =?us-ascii?Q?lBDalGbmea6qmUb2BNd6hD2nshaVBd4sWhLM9HRQ+6XKuurc1NNsqpO7S5rR?= =?us-ascii?Q?h1/V5allXKZCt29pA4/OKUosUIOsg9e0TMkPKlRBYBzO4/9k3Vor0uaz5wyw?= =?us-ascii?Q?6hq/YsC41Zca19PCt7eq8TzAh/SwTzed4KJQ8vdM97UCEyWSosioHuDKl6gR?= =?us-ascii?Q?zbqoRO7TdPs+oCoHdiSi64brsLYo5wOUVnQ7yCPXSrYVPYc1hJzgtjok7KdV?= =?us-ascii?Q?74H3SUlH7OLsOCWbmWUXvA/sr+S6f3oqAujRcXFbDC9bfha7n9JjK3YdD7jg?= =?us-ascii?Q?yS3mKSLZuxcQ5whbBD06K0rWyqvuGZ72OSe5HQk2UYaTtH7GZOHDWFYyWsP+?= =?us-ascii?Q?3u9GWvAkp2QQ7qFOe6RWlHVOxxjjOzJpfSJUk5KstpOoygacsqqXEXPlW26Q?= =?us-ascii?Q?Ce7lfZu+VKMn+3zPxt7MDmzo8ZjayOXIa93kJlhBs7ASVB0VVhlAgLBNBs9K?= =?us-ascii?Q?Vgl4TLw6+h3HeXRyHj403VUZ1b4LebqeGZG635sl8RYogJpegY96PXKnrTZ0?= =?us-ascii?Q?A925F1aLPibkiQtv7r5Rtk1DZeOCFR4D3OZPupCWrDC12ifR2Nb9EpQ6gjTG?= =?us-ascii?Q?aQzSGb7F6cz1ng53JVoDxqMSThGyH2N9OWOBpx5IFkLu5aY9p6i8/1Ph0Pj7?= =?us-ascii?Q?JSEmedvt8h+IZwulZy+jtoFb+z6xgXzt6eomwRI6ILw1UHMAQ92heI8KSQz8?= =?us-ascii?Q?M8PpS3VjBIdxkhmKd+xM8zCYLtdCFMyVlpjXoozHx4UcdQX1/Z7acMX60FT2?= =?us-ascii?Q?2eIIQ8o/3p+2QicveF9G6/uNpHC8mzNa95thTPQeQpz0ZEeMGSB3Cf77u3LW?= =?us-ascii?Q?sDO9RYT4ivJ52Ufd4FpGJFzig4azRrZEk33z8RDUfLr7lSx9oZWakDIhw0TF?= =?us-ascii?Q?8nHgxJ21ncuZ7PmM3B5+uPwiduFLvQBrsJ4REWeW3KSNM8fmjT6XUngz8wzh?= =?us-ascii?Q?FNnmfdWYt24VbWfnn0Tt2BtSLjq/yx91rd4u2EWCN/0078pSI0CC0Ra6IZPY?= =?us-ascii?Q?K3FfCAka5jbbKjA/oj9sjR8DdvJAC+KeoLLaQiaipDR/zaMUAQ/I6Ph8Vw11?= =?us-ascii?Q?SbZIxq5wpllpMvPvNUV+LtCy2s28x3LvwHrpjVaQHArIj+pyDJ448Vv+56wK?= =?us-ascii?Q?M9JkAEKOfMMcyUqkDVHhK1RF0q61ZnU8LcZRPLpZJtqJ6ho2yIfYptU73PoX?= =?us-ascii?Q?z/PCYamhOZnTxPNaE254YcAv1h/KgE+9S/e19t1yjxbgzrx9vaWn2XmqU5Rq?= =?us-ascii?Q?5jZ4tm2BV1+/VOqjpaBYkcf85hvieiRTfq6Z+NdbCn0JpTnxvC4+uB+EvCX4?= =?us-ascii?Q?r7oOJi3xGU6NXOp6Uavhxk75ZgvHpiw11nj7db2csmlKefO2jFUrorCLu1uk?= =?us-ascii?Q?SQNX+0s1lT5z3UBYhgYRocNGOzWsODrH10fKWun+HeDn9m2fYYX1Gg4ZVZn+?= =?us-ascii?Q?PUsdNYxLXB3FhYViJ19vduUSwq4RjSv9K9ElVspfCXpdKk7XHb8rYWy9dQ?= =?us-ascii?Q?=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)(1800799024)(376014)(7416014)(82310400026)(13003099007)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2025 21:23:58.8599 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 85aa8ac9-12af-4fff-62dd-08dda92e4783 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: SJ1PEPF0000231B.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB8093 Content-Type: text/plain; charset="utf-8" Smart Data Cache Injection (SDCI) is a mechanism that enables direct insertion of data from I/O devices into the L3 cache. By directly caching data from I/O devices rather than first storing the I/O data in DRAM, SDCI reduces demands on DRAM bandwidth and reduces latency to the processor consuming the I/O data. The SDCIAE (SDCI Allocation Enforcement) PQE feature allows system software to control the portion of the L3 cache used for SDCI. When enabled, SDCIAE forces all SDCI lines to be placed into the L3 cache partitions identified by the highest-supported L3_MASK_n register, where n is the maximum supported CLOSID. Add CPUID feature bit that can be used to configure SDCIAE. 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.4.7 L3 Smart Data Cache Injection Allocation Enforcement (SDCIAE) Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D206537 Signed-off-by: Babu Moger --- v6: Resolved conflicts in cpufeatures.h. v5: No changes. v4: Resolved a minor conflict in cpufeatures.h. v3: No changes. v2: Added dependancy on X86_FEATURE_CAT_L3 Removed the "" in CPU feature definition. Minor text changes. --- arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/kernel/cpu/cpuid-deps.c | 1 + arch/x86/kernel/cpu/scattered.c | 1 + 3 files changed, 3 insertions(+) diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpuf= eatures.h index ee176236c2be..1e3d4d8a45ec 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -487,6 +487,7 @@ #define X86_FEATURE_PREFER_YMM (21*32+ 8) /* Avoid ZMM registers due to d= ownclocking */ #define X86_FEATURE_APX (21*32+ 9) /* Advanced Performance Extensions */ #define X86_FEATURE_INDIRECT_THUNK_ITS (21*32+10) /* Use thunk for indirec= t branches in lower half of cacheline */ +#define X86_FEATURE_SDCIAE (21*32+11) /* L3 Smart Data Cache Injection Al= location Enforcement */ =20 /* * BUG word(s) diff --git a/arch/x86/kernel/cpu/cpuid-deps.c b/arch/x86/kernel/cpu/cpuid-d= eps.c index 46efcbd6afa4..87e78586395b 100644 --- a/arch/x86/kernel/cpu/cpuid-deps.c +++ b/arch/x86/kernel/cpu/cpuid-deps.c @@ -72,6 +72,7 @@ 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_SDCIAE, X86_FEATURE_CAT_L3 }, { 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 dbf6d71bdf18..3d1f4d718a84 100644 --- a/arch/x86/kernel/cpu/scattered.c +++ b/arch/x86/kernel/cpu/scattered.c @@ -50,6 +50,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_SDCIAE, CPUID_EBX, 6, 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 Sat Oct 11 00:35:49 2025 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2061.outbound.protection.outlook.com [40.107.237.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 8889B23AB81; Wed, 11 Jun 2025 21:24:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.61 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749677054; cv=fail; b=ibVbt3NtC8lsFO04rJh1OB5Op07u2EILhsfvBrCjPKrDL8DdDtwwGCA/EP5Bljkhy36Gg9VPOdvi3KpRcbFgWE+apOOAT7T+NPQx1aS0XgzN/lwokXeL8VMOzoZVZOJkmX1lUjJ8L+W9ybDHPdgT2zaDnAr/H/+IxQX04gHNjBE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749677054; c=relaxed/simple; bh=Zi+HlO67SV1SGTWi4ycwHUpg2uHh5R7+DRVxXo0UhQQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=q74ZrwVTTEYYzdj38Bggge+m5FIblnU9pYUh+KBA/DhCi0CpoSBZgfFFeJ4fVkhujY/GvPiVLFZT5QgzYgIcpmrnsYEmgkgjZqaTBFf9T9PnnFv32M81iOrrsZyiAQHvHp3VKJS5Q6C3e1FBtCX0oScjgMJ1E1ZGuF1KkUtnEtM= 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=KD0TXbfp; arc=fail smtp.client-ip=40.107.237.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="KD0TXbfp" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cxu3E/QcUTEThinpuEf0EPyb4dUj7vEVceTFZfw2xUg+JDRh92qDFHEtIXcG7j4uFMBDic0awYRPXweVnETnyq8cRMHqObsYoIV/3+arakKIwR3sVOKU+naHIUDXL9LjDt4jwIua2R4mG48DT4+WflSaTHYkO3/ptBzRlIPfnZBLJCqxT4mH1nbeUYXYEwHrHdp7PJ1NPtezRWaUTdhYqWCC+yTFda+0vw5wWDwTlxgHI2sD0abbtFWsSgTBVqwVuEI1+gs5Hsi2OYir9tc4Rb8Hifo4CsXMS1jSlmqJds6tnpGUzYSTjOodHJ8N0AnhHbCbuqN4XSc+CJsCoru+ng== 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=t9xGFVRbTUsmehLiQw9DvSUU6O+3WP+vQN1ZwkL8cC4=; b=dZbBMOond0+SMxozk1VswgRjzCdT35RFq9VqmCXBglJT+xTFweDgi6f7W4EWifGAvbzip7AYzi6/gPslvKLE4WT09KAC2LZstqOVY+l561glgu+Uwz0KfoGc+xDSOYMTq0oh2KhECNko/5jllNDmaPl0UwIaI6l3iLHdA6vuH9Vz/K8C5Ucnuz9eGGPLW7/givYpkj0PxY4itvDPTcWZAFgJ/HPztVftifYX31qaLoA/Gb8s+AfH2vra3ZXBSkOm1+n3Pm1Uwz7Xttg3AvcmgPgnW37vZVwP1gkL73mG3fYkPS9LNhxeywnaF9OGT8CEg1gZOFIqFGCmaCTAHDvhTg== 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=t9xGFVRbTUsmehLiQw9DvSUU6O+3WP+vQN1ZwkL8cC4=; b=KD0TXbfpesHi7B9NRxUrf7VmPqr5UsmSDyg2woDDWzy90SWwFpsCkv0hX+iwpDWz7Sm0TNd499KaizVQI1XcGueZgO7q40jOqlgwHrM1DX020lwEMkVI2u0gwqRu3BG5+yNytyOz1GcL1/HTMcqFY49HgGPevgGJHAYA0k/TVZs= Received: from BY3PR10CA0027.namprd10.prod.outlook.com (2603:10b6:a03:255::32) by DS0PR12MB7803.namprd12.prod.outlook.com (2603:10b6:8:144::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8792.34; Wed, 11 Jun 2025 21:24:09 +0000 Received: from SJ1PEPF0000231B.namprd03.prod.outlook.com (2603:10b6:a03:255:cafe::5b) by BY3PR10CA0027.outlook.office365.com (2603:10b6:a03:255::32) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8792.34 via Frontend Transport; Wed, 11 Jun 2025 21:24:09 +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 SJ1PEPF0000231B.mail.protection.outlook.com (10.167.242.232) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8835.15 via Frontend Transport; Wed, 11 Jun 2025 21:24:09 +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; Wed, 11 Jun 2025 16:24:05 -0500 From: Babu Moger To: , , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v6 2/8] x86/resctrl: Add SDCIAE feature in the command line options Date: Wed, 11 Jun 2025 16:23:27 -0500 Message-ID: <22176f481564e2fea9936592f0adc6824efe2edf.1749677012.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: SJ1PEPF0000231B:EE_|DS0PR12MB7803:EE_ X-MS-Office365-Filtering-Correlation-Id: b08cef35-4341-457c-10ea-08dda92e4da6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|36860700013|376014|7416014|921020; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?/WLZ8nb8a0rGHJWdMzalc/ZrWr5pzpd3enWsBwqTYIJurruzmm9YPk7gnCaJ?= =?us-ascii?Q?VH9R+U5WFZWHCYUOqfsQemdt549nVw5GQinCI7m9avO5vmRTZQwkEnhfEU5d?= =?us-ascii?Q?fTA8ptNJuXOG/ZqhSj5a753r3ASdnHx9+TltBQUMPiH8CsJ2OkweAh9XID/E?= =?us-ascii?Q?X0ZJfEEBvZExqGzIdhQVad0YITAzgohyZmAuJV7ggaBxpBZqR+LMcAzWHXzM?= =?us-ascii?Q?97LmxxWDLDb5R0dGZTgHMKf89O1QVSQONbLvlzQhkD/XrizvIEhqnET+Q0fK?= =?us-ascii?Q?77dEtiTyeYVzwgHdMJEFH6SwUke01db5/FfY1fUUHnjuztYFOJBP3C5qR6Ud?= =?us-ascii?Q?9BXQhsSHssw23WRKz0pHciFNDq20/NPQqDq38f8C8/SbW+IJ6rFpL8S+kiJI?= =?us-ascii?Q?qKeDWW9AJ8/lD5TnmXBLQW/ngw3aJBhqFkbSwEegzaPP3KvIfjOCPBcU07fk?= =?us-ascii?Q?cgLQHpLT0ScrZp3jNEgttU6X+IX+rHm3GUuIMQsVqPelSvPSjVXI28qMseWC?= =?us-ascii?Q?T6kIMnEupyhqBgD2jOdnJRteOu/jwHO+SF1xUV8gHwLaKNSHeF7NBcDvziGY?= =?us-ascii?Q?2baoAcPKiAUxiNv/BiHILUP/RhAGKYRpAl/OcIY5D1oUL0pUjDuZO7M0JWXH?= =?us-ascii?Q?1YndkVQUNu+G2lLg13pAcPq0RTKm7mpZwCOcDn0zPBNYwwF1fYK8TME/w4xo?= =?us-ascii?Q?J3IEuaQ3G1IZxiEnTrdkCP8ZRa+FQbjHLWA3h6s28JOpPy+uBSVPlcaogZqj?= =?us-ascii?Q?Y21VPcS3O7C0weOGLzS5qyT2qHoBEM9XkHikda5phIow7UDNvvpEM4E/Ruqn?= =?us-ascii?Q?R/Bxlk8ThKn9QoVRaoruLSd9JYiCz7H42IRfP+uxGM2H8/pARjc2uxw0PPJ6?= =?us-ascii?Q?RZP1AZsNcqNcLPEQ4La1marx81OJEsqUkPRs0Jh8ksieSCt1dghQC6A2hglQ?= =?us-ascii?Q?Gd0vJO0PyoRSXjv8hKytCb+Tt3j2uq42swWKDZ6Iiln/HKiEu7GlbgQMR90l?= =?us-ascii?Q?NTS7KVPHJUUdY2cYCkb+eD012RH9xZmROvQ67otP0Cf2/sqRbrIdAH6jibny?= =?us-ascii?Q?nrI1gl1YpA+N9joUdJtzhf98CNVv1iHPQJJo+AORlvSdphPHFvos/ZbdMBGf?= =?us-ascii?Q?GBzVHl1M59YiCTa/k697BC0RxhhC3SRFBBmmzMzBftAzrUkNeU/4c2Mfg/jr?= =?us-ascii?Q?Q7zosau8AozEu9b/06j79EZe6/zFV2g83lAlksub6B/zTzCwxDcXnEUqTeEJ?= =?us-ascii?Q?uV5LTU9eHEz8AxKar2OC55+FhXGeWcDr3TISABILmwvPxHCTaZ95UVFAnRAX?= =?us-ascii?Q?jubQdHwMWi8wCDgNrk3ttoXH5vCybTg6B3Hw/R+c8Dl6X/msetDp1NDMBIge?= =?us-ascii?Q?CNBIgD1Sy1GuIWr1AKLzmLUNbL39rxwg/6Z2R602SxTGH7jm27DJXaMRh+AO?= =?us-ascii?Q?wy69Fqkdm8ME/QEV+QjEWwj4P3e/Jqna8HBD/MoFlJ4AfOAiGSUunav/Y8Q0?= =?us-ascii?Q?22M0dxTK8l/AjPMiPew1v0olVooeghXXB0ypp4hKjaBRBFr1FFdK0AZirw?= =?us-ascii?Q?=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)(36860700013)(376014)(7416014)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2025 21:24:09.1531 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b08cef35-4341-457c-10ea-08dda92e4da6 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: SJ1PEPF0000231B.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7803 Content-Type: text/plain; charset="utf-8" Add the command line options to enable or disable the new resctrl feature L3 Smart Data Cache Injection Allocation Enforcement (SDCIAE). Signed-off-by: Babu Moger --- v6: No changes. v5: No changes. v4: No changes. v3: No changes. v2: No changes. --- Documentation/admin-guide/kernel-parameters.txt | 2 +- arch/x86/kernel/cpu/resctrl/core.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentatio= n/admin-guide/kernel-parameters.txt index f1f2c0874da9..95d89f881e10 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -6066,7 +6066,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, sdciae. E.g. to turn on cmt and turn off mba use: rdt=3Dcmt,!mba =20 diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 7109cbfcad4f..326c679ade5c 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -705,6 +705,7 @@ enum { RDT_FLAG_MBA, RDT_FLAG_SMBA, RDT_FLAG_BMEC, + RDT_FLAG_SDCIAE, }; =20 #define RDT_OPT(idx, n, f) \ @@ -730,6 +731,7 @@ static struct rdt_options rdt_options[] __ro_after_ini= t =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_SDCIAE, "sdciae", X86_FEATURE_SDCIAE), }; #define NUM_RDT_OPTIONS ARRAY_SIZE(rdt_options) =20 --=20 2.34.1 From nobody Sat Oct 11 00:35:49 2025 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2084.outbound.protection.outlook.com [40.107.223.84]) (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 D2F9D1F7904; Wed, 11 Jun 2025 21:24:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.84 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749677063; cv=fail; b=poEVDM4uwYAABoCiHpY2MttHiiXeBKR6X8LumzOG+aB7UzR1upeRctOxSBemvvXBGHn54WIEef98A96/2TKasWjnQtSgoqteES6/8iYSHyaOAY0BE/6ua1zLcRZ+3+BU74KVug2CS6OKDHHEk8x52O9hTlJVVmcIpD+81tFwjHM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749677063; c=relaxed/simple; bh=5fd2Cq855QzimkXAeGqDfI4dj7WrLcNxl2OZP4cgQaY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GQt01RW/UDfaWRsHElcp/StUkvGOgWJ7WonNrLyvKCkPxe2mKQuV0T8YnKMRly5LW7sJhDxOdiPnegVWBO1Vft9l23kmNzmsLwXEDrrI2Ji60ptT7jLEU9x6uP9mtINfIY5aScimib2rowbFv7cA1C+CpA+N84CQlilPPZ19DR8= 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=MaO09uGB; arc=fail smtp.client-ip=40.107.223.84 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="MaO09uGB" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BzrSEryT5G+t2fHSpNHK57IXeSdbYkNPtPFfoRnoHxITMUCodf+edaEMMTQf6Z+RASx80lehZH0JJSQd4ZEsN+rNkqbKDLQbDTaZVrqUgfkLcphfctFTFj/xNuWNcuqOawMpSMSEQVjaCJqNKdKZslUaLWYOYbXqBuBmiNzh33S9bjeouTbS26MvWZgj/Q9MYuunmw6htBZwlFJVpBA3C5cl7yTp0f0Rz8OGm3eqzBxe0c4Aa/J827D42VrJ+NmvODCdu6oyE4VCNFQ5dc+uJKdjGnU2CC9qgiYI7PrFr4UfaQiwcL/k4QfM8KtSD/djiC+JxjK1he3p4myClQBXtg== 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=sURvzpHMy88oDCY13Fv9Uuz0UyXjf6snuAz4mtFxzoY=; b=j0a2L0B/b3jsn7ADoC4u7IODBxee2smvzgHwWSXM5ejQ6dgtWERWz2o8oCymoRL9hNHCUmDC0v+kv/K0wfw4088L3yQ2PajCeNRLVJQDoBWrM+nrXfZK8W2e6MunqdExSpxvlw8xRKWexDY84E+24kM+e2pBS4jNSCM/TbvpL9B4lopMFgqySwCXGVGwZEFzZCiyDMXDITA0SnO+ci51uM+kboTICYEgLfebZk4T8FBELZPb9Ch9R+rO8UEIHwUU+fklSuX6WdAdJM1HGLcdwbR40dxMqdm0CfRFMm223VO7TcQW5rRZA3AM96bDbr697F4BrFqFTMhnJdEQMoZEUg== 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=sURvzpHMy88oDCY13Fv9Uuz0UyXjf6snuAz4mtFxzoY=; b=MaO09uGBiESGZpewXP7yi3mZdMY5KQ+cfW41KX9kNralW69LuDk3djG8hBIpiJzd+E51h8aHAIKlIjuZPQrSne7OKs01hTKclHNqpas8vYYEwZokYm4px6sWayVW+XKVIuue0emnkWD4V/qCADqUnwyNsTRGK+tlJRuNGvnkQiw= Received: from BYAPR06CA0018.namprd06.prod.outlook.com (2603:10b6:a03:d4::31) by CY5PR12MB6346.namprd12.prod.outlook.com (2603:10b6:930:21::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8835.18; Wed, 11 Jun 2025 21:24:19 +0000 Received: from SJ1PEPF00002319.namprd03.prod.outlook.com (2603:10b6:a03:d4:cafe::df) by BYAPR06CA0018.outlook.office365.com (2603:10b6:a03:d4::31) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8769.18 via Frontend Transport; Wed, 11 Jun 2025 21:24:19 +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 SJ1PEPF00002319.mail.protection.outlook.com (10.167.242.229) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8835.15 via Frontend Transport; Wed, 11 Jun 2025 21:24:19 +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; Wed, 11 Jun 2025 16:24:14 -0500 From: Babu Moger To: , , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v6 3/8] x86/resctrl: Detect io_alloc feature Date: Wed, 11 Jun 2025 16:23:28 -0500 Message-ID: <8861ecc4aa962909faf07985448a333a75ca7c33.1749677012.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: SJ1PEPF00002319:EE_|CY5PR12MB6346:EE_ X-MS-Office365-Filtering-Correlation-Id: 33f1d805-5cc9-4d48-6743-08dda92e53a0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|82310400026|7416014|376014|921020; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?RddrmAjKgVa3Q6A3zbcWoeFjynlq5LS/KqT6h/yAOdab6h6gXyNPIVvMV5EK?= =?us-ascii?Q?n4wkZsPVEZNFFKnqC5yjYpLOtoLVXMHbbvyRFa87C3p4MWt9ZVgZcgGr9RY0?= =?us-ascii?Q?r+A/kYffa4mZTMaYwaeddnzVlxC+8axM3QjYXbUVwhkFMszuzjbCP0VKXbCV?= =?us-ascii?Q?cj28jEssBcOhZ9taE8QjglZPvXs4Aide6o/pmHtqqtkrzlZKr4Z/3bYDXxca?= =?us-ascii?Q?kuyQQi2VgLQ2w8Qwo5d8gamRYbirfAeOnc+wP+TImafn9LeMRx55stGLGUyv?= =?us-ascii?Q?nuRa/QUZl2LE+vrz49tS7f43GG8HyVokFykIcErrX1NuW4otdb3O92hpz2yw?= =?us-ascii?Q?LHhFz0Juj22B6v5X6ehzK446A92Aax8ZWfClRtd1VqdElvj/Q4TIitE2grTo?= =?us-ascii?Q?gmHLI0w2gnqMHGx7P/axgJDLxFMSvBvrFiaqFk8Gtc/EgsGH3xhJcqEw55HF?= =?us-ascii?Q?t4eCn59rL+dBhuE8vOLu8/35rAmQ+VbXFbOF5h86PlNiSG0+3v76Kql5fw9+?= =?us-ascii?Q?e3Q+VEFVr/uM5g4PvdA1Nlom+lDMc81W5v26T1Ijk8nHJ63+M10kYzbRnbBw?= =?us-ascii?Q?FycDS1a5Pzv2U4c9/CK6LV5EVIYdo40mbXWPHoyUKRsqRfcMGu9EQPgafwsD?= =?us-ascii?Q?GDhG21gvQnsuXKHjoccXembqINL7nmwhXl6864GHh6kTn3qAdrI8suBckCC7?= =?us-ascii?Q?W7Iuljy+RZfk2+K5sLWx10kroRC0T54cVbD1sua11K1EgPEfJJbyzGpzyMCJ?= =?us-ascii?Q?V+v7WYh8e/ln8PAmRsh10nh+0MeKgUy+2O+AT8h/E35NdrGxmUj1GDhVfSt8?= =?us-ascii?Q?8aMR9GWj9YSvefzpdL2oG5eJcs8pzyl73ZQwjZL345lDE6gt8vjlESbN8scB?= =?us-ascii?Q?PsUpiW6peCrShIzdzUCXP5Tv+LsdRXNBeEdVnbjIy/YWvz9Gwkq4v9Vz6CwI?= =?us-ascii?Q?Yuk+aE42ohP/JCqaSeaGQMymPbTWEslpwEr/nq5B/4u0iV9OPpB/Kq79wgnY?= =?us-ascii?Q?h+x0irxE9G7XgNxTt6ccwPA1VxkUC4HUACGK8hZFMF+QP4QgLEh6ZoGRF5Tb?= =?us-ascii?Q?AwVVvaSvQGwSO2d7hIf9shvVRvU3A3I/kpgOL0OyOb3msZZ136uObegq4QD5?= =?us-ascii?Q?CM9ttgXJACKTQsCzr9pRPyw7iP5jR8q9Px8htGDFPP9Mf3dBgeJcLqwI1loz?= =?us-ascii?Q?LahMydNDUDGt+/7Z8ZWiYi80u8caxAnsvYBKVI9AQyLpcR25IvLJyWLb6A8A?= =?us-ascii?Q?agiXokmkbIYgslHCNNRaqj2oYjjEHrKMX8pNS7qS+SvQATajpG6AD46YYEKV?= =?us-ascii?Q?XPRWAhBpyHviONykFA3RyZBVm2L0UhtqqujWiC7Mc01Py0iHXaHdQma4/z1W?= =?us-ascii?Q?XJHU3DMZkewD4THThHs3vlJ03h99MIpBQrxSbk/3CM1JI0U4S0U2u+8MJUp7?= =?us-ascii?Q?yERVxmmOKbAo+q/57fTKPynRZ+5I1Nzc/btr1eXrEKoEummiesHZOFFFu7ii?= =?us-ascii?Q?0kn8jufLq0lUumE4/OJ2b0HH3PkTgj7iVmU0XWF3H21AwdpCrzmiuok9Hw?= =?us-ascii?Q?=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)(36860700013)(82310400026)(7416014)(376014)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2025 21:24:19.1822 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 33f1d805-5cc9-4d48-6743-08dda92e53a0 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: SJ1PEPF00002319.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6346 Content-Type: text/plain; charset="utf-8" Smart Data Cache Injection (SDCI) is a mechanism that enables direct insertion of data from I/O devices into the L3 cache. It can the demands on DRAM bandwidth and reduces latency to the processor consuming the I/O data. Introduce cache resource property "io_alloc_capable" that an architecture can set if a portion of the L3 cache can be allocated for I/O traffic. Set this property on x86 systems that support SDCIAE (L3 Smart Data Cache Injection Allocation Enforcement). Signed-off-by: Babu Moger --- v6: No changes. v5: No changes. v4: Updated the commit message and code comment based on feedback. v3: Rewrote commit log. Changed the text to bit generic than the AMD specif= ic. Renamed the rdt_get_sdciae_alloc_cfg() to rdt_set_io_alloc_capable(). Removed leftover comment from v2. v2: Changed sdciae_capable to io_alloc_capable to make it generic feature. Also moved the io_alloc_capable in struct resctrl_cache. --- arch/x86/kernel/cpu/resctrl/core.c | 7 +++++++ include/linux/resctrl.h | 3 +++ 2 files changed, 10 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 326c679ade5c..a3d174362249 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -274,6 +274,11 @@ static void rdt_get_cdp_config(int level) rdt_resources_all[level].r_resctrl.cdp_capable =3D true; } =20 +static void rdt_set_io_alloc_capable(struct rdt_resource *r) +{ + r->cache.io_alloc_capable =3D true; +} + static void rdt_get_cdp_l3_config(void) { rdt_get_cdp_config(RDT_RESOURCE_L3); @@ -840,6 +845,8 @@ static __init bool get_rdt_alloc_resources(void) rdt_get_cache_alloc_cfg(1, r); if (rdt_cpu_has(X86_FEATURE_CDP_L3)) rdt_get_cdp_l3_config(); + if (rdt_cpu_has(X86_FEATURE_SDCIAE)) + rdt_set_io_alloc_capable(r); ret =3D true; } if (rdt_cpu_has(X86_FEATURE_CAT_L2)) { diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 9ba771f2ddea..0e8641e41100 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -191,6 +191,8 @@ struct rdt_mon_domain { * @arch_has_sparse_bitmasks: True if a bitmask like f00f is valid. * @arch_has_per_cpu_cfg: True if QOS_CFG register for this cache * level has CPU scope. + * @io_alloc_capable: True if portion of the cache can be allocated + * for I/O traffic. */ struct resctrl_cache { unsigned int cbm_len; @@ -198,6 +200,7 @@ struct resctrl_cache { unsigned int shareable_bits; bool arch_has_sparse_bitmasks; bool arch_has_per_cpu_cfg; + bool io_alloc_capable; }; =20 /** --=20 2.34.1 From nobody Sat Oct 11 00:35:49 2025 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2046.outbound.protection.outlook.com [40.107.243.46]) (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 055AD244674; Wed, 11 Jun 2025 21:24:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.46 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749677075; cv=fail; b=K0FZBkYV0f5hHq10B3mrJhN5q51d2WsmLWhWl7SE5hcNbwzEfkHHWBGkBsABokz2iAJtwl/EENqqpMMcHFFvrY5Pg+vmd4lo1bVSDMFEbDqanqjs7PgvGzT5N0U3t5ER/zw6lTiQ2pdFsK6M0h8xF1kIIxQoG15Nf/sQh7Ibggc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749677075; c=relaxed/simple; bh=zeTfgCcBlCZASP9dH44ugFKhq+EcaQiUHB1OtV/gFVs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tRmbPGt3NtjQTeizX4e8mYyXXolWLPaORm0myP8C9JJoAt96J/DWfKw8QrJS0ZqE3RSsDol/jDX2gR/+dbEHwUrSRDuoWJ4ihwJbs+RuHSlZzfhxTR9RZCpTafXiyMCMpMxez6g+GV4sGLXiGgSYF/a84UGsTpdeJGpxnLbZeyk= 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=Os7kGKnK; arc=fail smtp.client-ip=40.107.243.46 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="Os7kGKnK" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=mWK0KfYlChVYamTHGwN3S64Q3tC6dppgEd28bxuUJIr9gMfrI+Sxs8geRMUp0uJ7jLr8FRSjp21hDJB563JCYZSlOnyKiJR4Sq1aL5YIuCbaOari8U3LnAimcyF06FPi1QYgs0GtGq1xLuDLSl0IAyOMQt98AuevJzxieLY49ZZD77cPnNP+6vx+JjFBN1OpgmLOCkFXvlCYxDP/DAU3F+ZuVHPYFXQPYMXzvU2QOETmZfPOBfe+xb3dqsk8DLoCuVgxIX4p9eF+jmb6UXyHXtmQJz8m6p3GXkuGt4HOO3G+sdaIzmha6j/28lO1gVxFs3oiJmUlOxUk/TnagNxQJg== 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=9zVWCFNmU//CttTxPHIjI51Zv4hegM63lyqq0FcL/mw=; b=FRGNIrmrrdAL4TitxfU2CjiYRLVrZbg/WKBxlt3W0tKwVV5SUdf7UyeQIP1JhrB3qdme+UHhpvjxh38mOd1DsyeiG6K/RL/l3gBc4Aac7tT8K2UUtU/Qhq+l0MbD1Xkn+2vI338Em+mvsphuELaON7yqvYLgJRO4KzlEFdwQ4Uc9SMUQYa0adKqu+Dd9POWfmiOovXoAsa2AqQ+t4ws5cDN4xhLeLzU6J5e6yNv1aRCNi1zkH0JMQNRBkTYqRDq/SMOenXyawMihwy+uC+g0if1vp38OE8YBrQEgO7cE+RDMATreafqFit1aCPGzh9CgQuFgnYLMJz/oVv0jgeCL/g== 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=9zVWCFNmU//CttTxPHIjI51Zv4hegM63lyqq0FcL/mw=; b=Os7kGKnKszMCzLMTpMImjzktPcn6/TFhtlQGoAyJfzSXA2VuAxz7c7QsB/RnxwwQMVd4FpUV8EX0YIuchPT37AuWi25Ek79+1yZgPtTgWLefDhTW93Of9F1Uz9jAyI0cg9O4Qnez6povV1oVY9oatOVWxyc2Hm4lCmUYQ9enzb0= Received: from SJ0PR03CA0354.namprd03.prod.outlook.com (2603:10b6:a03:39c::29) by CY5PR12MB6574.namprd12.prod.outlook.com (2603:10b6:930:42::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8792.36; Wed, 11 Jun 2025 21:24:28 +0000 Received: from SJ1PEPF0000231E.namprd03.prod.outlook.com (2603:10b6:a03:39c:cafe::76) by SJ0PR03CA0354.outlook.office365.com (2603:10b6:a03:39c::29) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8792.35 via Frontend Transport; Wed, 11 Jun 2025 21:24: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 SJ1PEPF0000231E.mail.protection.outlook.com (10.167.242.230) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8835.15 via Frontend Transport; Wed, 11 Jun 2025 21:24:28 +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; Wed, 11 Jun 2025 16:24:24 -0500 From: Babu Moger To: , , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v6 4/8] x86/resctrl: Implement "io_alloc" enable/disable handlers Date: Wed, 11 Jun 2025 16:23:29 -0500 Message-ID: <548b542ff537936cc8a20f721f6f2472189c536d.1749677012.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: SJ1PEPF0000231E:EE_|CY5PR12MB6574:EE_ X-MS-Office365-Filtering-Correlation-Id: 7eef140c-0d2a-4aba-088e-08dda92e58e8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|7416014|36860700013|376014|921020|13003099007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?OUpj+kDIqw8caybAgcMKR8OG1Gly8WUfWoHLwvPsstbBWPAFTZDwdGHKSSLe?= =?us-ascii?Q?8cCmaj0/Ui4xxFdiZT5tBukIde9BHh9J3rDJfO5T155n7tnWdrWqyT8zAOFw?= =?us-ascii?Q?/F5OmPN1iq0VgBzQ5YOrqIq6i96+SjFlZ8xdqOZbYVUxakMlGVbhr7Wk/Utv?= =?us-ascii?Q?1r6Fm5sjWgCO8xEq7XgPHG+FuqHyzR6gIazNEkKEM15gXzANR+t3xqiBcQBy?= =?us-ascii?Q?1P00E7cmTCXWtb/KxjEc99LiYaEbam3oV1SqMWL7+pgE6RcaWeGuErNVB1Eu?= =?us-ascii?Q?2+VPX32lC0YpKcmACI1dSvR/q8Qr0owNA0WvwTniEXuly9aIL6nBZ1k0rbrM?= =?us-ascii?Q?iIo50t1f3STd51qC3mFCxT5Pd2w7icmd126lkALY2Ibivt9LKYHwUf9guqhA?= =?us-ascii?Q?xC3PbE4NptRRMpo9oj28OEDS88hUuIM0r/as+feRwVHlT2113Wm94Cb8JH9D?= =?us-ascii?Q?GhcVhCr0+2WTLGUQkqh8z/fH+YoRYX2XGK2o3m6Ne6V9WU+gZd6Z0MXBSzhy?= =?us-ascii?Q?IKd9mav4AqH86f6BEeq8ip1LIqOi4LRldK3HHcE8SVyVD67DWYhS93QKigi/?= =?us-ascii?Q?JtGu904PO4UeiZcWaccAQ4LeErDCSSqUjB2tmQLETtySIYJLeAxz1XwHCzSj?= =?us-ascii?Q?ebL7mbEe6eDV9rNXVMRkqJhqVR4NHXOxTcmSGmjNOOyh9gLdrfU2ux5yhkCE?= =?us-ascii?Q?Xo+N0m1fv6uNl0C9Lyn4cQZ6b6a5kuJd6eFygIByrLGu0oJoFwQG7L9IMAC/?= =?us-ascii?Q?ecLW0z9QwglUD1JDFQXBcNc1CIzrvgEuP4/R+BbONNP6IvE4LlY++pTVWIyR?= =?us-ascii?Q?GmsyphWrP5qXiNdrM7LDctgCABzanl8TzzHURcMLMI+c13kGGeWU4PW92Bb6?= =?us-ascii?Q?Rxbtexailsj1eI5OV/rYK/M0quG3fIBCrh1HxpTymzyVvA8D+FVvoAMnSwQE?= =?us-ascii?Q?tgY/k/htfiZKofcSrrXj6ncu+TDqbT+8occoSSmiwawxL/O00psjddnKfg4q?= =?us-ascii?Q?LAly4jUWhjxZf5dInNLkILa1Z5slwaAJk4z5llQ3kudc3bTb3777cwelVa/E?= =?us-ascii?Q?F0ZVWPO3VONz5puiAQ8+DSCXjvaup66C5hUeCH1mISKLuB2y74a/szsP4mC7?= =?us-ascii?Q?rT9kK/SNq6vOv14lrVgN213YYYFd1IJ0G+BWwIkGyKPuM2PlBiBBex6euDY0?= =?us-ascii?Q?fzWiMIevHfMjqF3Jyqt4GZb+YJSpKA7ixENOJLwct4yqDWN8ZvU3iUW0ed76?= =?us-ascii?Q?FWFFl0ovx9Dsgrk4gUhECs4X+5hZTA3Xn4SUzx0D6i+AN/uOQmLcfqD9cU+d?= =?us-ascii?Q?do9lWTqNimXvvGAxOV3cBNncnydvwSX9roTpEQ3lN9u3YkxzRTcE0n9gvAGq?= =?us-ascii?Q?aLpcEJewuZrLVkV1G3TR07ZtXRfiITY2VHTaHnq/oydf+zxkmi1PFerX/k0y?= =?us-ascii?Q?qvDXuqOvsFiaBD6Gsy0Sm8ltqxboV/4Gp5GsPv3Y0nBpAcf+1Jv5SCelP3Nr?= =?us-ascii?Q?z6depU92KJklcUkgb+Dk33i3ajEjAjDIErZhw6yJe0tZgPm31iFVvGUVRw?= =?us-ascii?Q?=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)(7416014)(36860700013)(376014)(921020)(13003099007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2025 21:24:28.0395 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7eef140c-0d2a-4aba-088e-08dda92e58e8 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: SJ1PEPF0000231E.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6574 Content-Type: text/plain; charset="utf-8" "io_alloc" enables direct insertion of data from I/O devices into the L3 cache. On AMD, "io_alloc" feature is backed by L3 Smart Data Cache Injection Allocation Enforcement (SDCIAE). Change SDCIAE state by setting (to enable) or clearing (to disable) bit 1 of MSR L3_QOS_EXT_CFG on all logical processors within the cache domain. Introduce architecture-specific handlers to enable and disable the feature. The SDCIAE feature details are available in APM listed below [1]. [1] AMD64 Architecture Programmer's Manual Volume 2: System Programming Publication # 24593 Revision 3.41 section 19.4.7 L3 Smart Data Cache Injection Allocation Enforcement (SDCIAE) Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D206537 Signed-off-by: Babu Moger --- v6: Added lockdep_assert_cpus_held() in _resctrl_sdciae_enable() to protect r->ctrl_domains. Added more comments in include/linux/resctrl.h. v5: Resolved conflicts due to recent resctrl FS/ARCH code restructure. The files monitor.c/rdtgroup.c have been split between FS and ARCH dire= ctories. Moved prototypes of resctrl_arch_io_alloc_enable() and resctrl_arch_get_io_alloc_enabled() to include/linux/resctrl.h. v4: Updated the commit log to address the feedback. v3: Passed the struct rdt_resource to resctrl_arch_get_io_alloc_enabled() i= nstead of resource id. Renamed the _resctrl_io_alloc_enable() to _resctrl_sdciae_enable() as i= t is arch specific. Changed the return to void in _resctrl_sdciae_enable() instead of int. Added more context in commit log and fixed few typos. v2: Renamed the functions to simplify the code. Renamed sdciae_capable to io_alloc_capable. Changed the name of few arch functions similar to ABMC series. resctrl_arch_get_io_alloc_enabled() resctrl_arch_io_alloc_enable() --- arch/x86/include/asm/msr-index.h | 1 + arch/x86/kernel/cpu/resctrl/internal.h | 5 ++++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 40 ++++++++++++++++++++++++++ include/linux/resctrl.h | 21 ++++++++++++++ 4 files changed, 67 insertions(+) diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-in= dex.h index b7dded3c8113..b92b04fa9888 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -1215,6 +1215,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/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 5e3c41b36437..cfa519ea2875 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -37,6 +37,9 @@ struct arch_mbm_state { u64 prev_msr; }; =20 +/* Setting bit 1 in L3_QOS_EXT_CFG enables the SDCIAE feature. */ +#define SDCIAE_ENABLE_BIT 1 + /** * struct rdt_hw_ctrl_domain - Arch private attributes of a set of CPUs th= at share * a resource for a control function @@ -102,6 +105,7 @@ struct msr_param { * @mon_scale: cqm counter * mon_scale =3D occupancy in bytes * @mbm_width: Monitor width, to detect and correct for overflow. * @cdp_enabled: CDP state of this resource + * @sdciae_enabled: SDCIAE 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. @@ -115,6 +119,7 @@ struct rdt_hw_resource { unsigned int mon_scale; unsigned int mbm_width; bool cdp_enabled; + bool sdciae_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 885026468440..3bdcd53b3ce3 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -229,6 +229,46 @@ bool resctrl_arch_get_cdp_enabled(enum resctrl_res_lev= el l) return rdt_resources_all[l].cdp_enabled; } =20 +inline bool resctrl_arch_get_io_alloc_enabled(struct rdt_resource *r) +{ + return resctrl_to_arch_res(r)->sdciae_enabled; +} + +static void resctrl_sdciae_set_one_amd(void *arg) +{ + bool *enable =3D arg; + + if (*enable) + msr_set_bit(MSR_IA32_L3_QOS_EXT_CFG, SDCIAE_ENABLE_BIT); + else + msr_clear_bit(MSR_IA32_L3_QOS_EXT_CFG, SDCIAE_ENABLE_BIT); +} + +static void _resctrl_sdciae_enable(struct rdt_resource *r, bool enable) +{ + struct rdt_ctrl_domain *d; + + /* Walking r->ctrl_domains, ensure it can't race with cpuhp */ + lockdep_assert_cpus_held(); + + /* Update L3_QOS_EXT_CFG MSR on all the CPUs in all domains */ + list_for_each_entry(d, &r->ctrl_domains, hdr.list) + on_each_cpu_mask(&d->hdr.cpu_mask, resctrl_sdciae_set_one_amd, &enable, = 1); +} + +int resctrl_arch_io_alloc_enable(struct rdt_resource *r, bool enable) +{ + struct rdt_hw_resource *hw_res =3D resctrl_to_arch_res(r); + + if (hw_res->r_resctrl.cache.io_alloc_capable && + hw_res->sdciae_enabled !=3D enable) { + _resctrl_sdciae_enable(r, enable); + hw_res->sdciae_enabled =3D enable; + } + + return 0; +} + void resctrl_arch_reset_all_ctrls(struct rdt_resource *r) { struct rdt_hw_resource *hw_res =3D resctrl_to_arch_res(r); diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 0e8641e41100..06e8a1821702 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -531,6 +531,27 @@ void resctrl_arch_reset_rmid_all(struct rdt_resource *= r, struct rdt_mon_domain * */ void resctrl_arch_reset_all_ctrls(struct rdt_resource *r); =20 +/** + * resctrl_arch_io_alloc_enable() - Enable/disable io_alloc feature. + * @r: The resctrl resource. + * @enable: Enable (true) or disable (false) io_alloc on resource @r. + * + * This can be called from any CPU. + * + * Return: + * 0 on success, or non-zero on error. + */ +int resctrl_arch_io_alloc_enable(struct rdt_resource *r, bool enable); + +/** + * resctrl_arch_get_io_alloc_enabled() - Get io_alloc feature state. + * @r: The resctrl resource. + * + * Return: + * true if io_alloc is enabled or false if disabled. + */ +inline bool resctrl_arch_get_io_alloc_enabled(struct rdt_resource *r); + extern unsigned int resctrl_rmid_realloc_threshold; extern unsigned int resctrl_rmid_realloc_limit; =20 --=20 2.34.1 From nobody Sat Oct 11 00:35:49 2025 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2046.outbound.protection.outlook.com [40.107.236.46]) (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 5884A1BD9CE; Wed, 11 Jun 2025 21:24:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.46 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749677086; cv=fail; b=Y9vMO6v0BfF1jyNiaSzPUKu/qq0udSW3w3QW8W3OW+Oj4eMru/inzvRMh0p5HE/U6Gev6ZrNy8lNRsElH9XsEkUo0USe8ya602PmXwUi3bl8AsThmJTNiQJxM75H86OST3MkaJ1EbV0oORJT7Qyg9G8PaGXp4vWzlHiHRCa1PbE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749677086; c=relaxed/simple; bh=okbKyjN/UHnW54RjACMzc0Im7fimRCV3cmiXpE4X8SU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HitzRx04RMX0IlKfARifdiElInvCMTrk6w8AO3J5dKVixnCZGUAOvfDoFj1mcSxlbrWwgH9QPxk7huQJM5mjRki6/oAyV+JsNzUCyiq1o46dkJaaTnzSAUbgZy9mv/6ud4aF6u58zLf34jMgvIH+Odjxkxvbdl/FyOLe/x6IZt4= 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=c3+/5yqk; arc=fail smtp.client-ip=40.107.236.46 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="c3+/5yqk" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GjDB+uiS1AV+gp9Mp2sAAPri6c0Zs3CX9wwlO5gFbfLQOWuaUpRnkPVj+AUnw1HHw2MDEuEKWYwSBoA+3xEQLYWl94nsdW2bDzJxCYhD6qsr96LH06AGmSdbY3Gu8WdizdnaUcS4i54JvcdEXwwcrfrZL++LxsMBeS5drllkWsiIudR3F2Z/YUfzVM3+t3RSpLKdDOAXWAjYtza53wcaoriLnLRGLC1KwImbkpBOzpl9oyIQIVgaNeAPRrUHppUepoRgGKmrtSY58KB4X4UJNUjE1wlcAJrXJ0oPTZbSJecz2qtO1OKLIi2nD4JLSEtcsyoyBHCaV1FgE3Uj2m9MRw== 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=7e53JyH8A/fnDNi8zN3PRjRibeHYRW5mkb8V0Om9WIk=; b=FyO0lXqldntCob7Hm8jgoJhZ1LK/1VeYFrnzjO3+iTwSyUKH2sa0coAw7LXxiSOq22jSGcHVBlTwA5k9ZvFbUAElU/GX3EA/R6oaCvGjXt/cbU6mSqgn/cCNitH0SIAOrgWi9XkN20UcHXROnJYvN6pFgp1bTtLe2gWYdd00rfgaMcUMYLvU9IJQiKbM+yc6LwZpaC3fpla1ERkeNFUPrzrazB4a299APjHHnyVMdYoTjUdI83bag6O/4b4uwdHC6d1elWDqiTeTp8p4fq1sG+kVZ2dxHWklzEQlcOYaLEYlXgZXsRcBJj5Qe4oZQYIPye7TuqxJWhdqUgny1an5cA== 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=7e53JyH8A/fnDNi8zN3PRjRibeHYRW5mkb8V0Om9WIk=; b=c3+/5yqks6cNVj3EgP5jGMyq1O9FE4fucNbdtpKuOXAVw97eOvlaFDEB/2q71rCnOn/p+lAWOwimyyJPh0ijDQvcHU/ll3HWgUKMaB2sCbJZAzqiNnlAKupdhwMPNNRfUgyOebHhWnYrzTeQVovUIJ+HGkfT3HvEuTaefNMAX4M= Received: from SJ0PR03CA0347.namprd03.prod.outlook.com (2603:10b6:a03:39c::22) by PH0PR12MB8098.namprd12.prod.outlook.com (2603:10b6:510:29a::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8835.19; Wed, 11 Jun 2025 21:24:38 +0000 Received: from SJ1PEPF0000231E.namprd03.prod.outlook.com (2603:10b6:a03:39c:cafe::dd) by SJ0PR03CA0347.outlook.office365.com (2603:10b6:a03:39c::22) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8792.19 via Frontend Transport; Wed, 11 Jun 2025 21:24: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 SJ1PEPF0000231E.mail.protection.outlook.com (10.167.242.230) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8835.15 via Frontend Transport; Wed, 11 Jun 2025 21:24: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; Wed, 11 Jun 2025 16:24:34 -0500 From: Babu Moger To: , , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v6 5/8] fs/resctrl: Add user interface to enable/disable io_alloc feature Date: Wed, 11 Jun 2025 16:23:30 -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: SJ1PEPF0000231E:EE_|PH0PR12MB8098:EE_ X-MS-Office365-Filtering-Correlation-Id: 05cf3ec0-34c9-4475-651d-08dda92e5eb5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|36860700013|376014|7416014|921020|13003099007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?429xKJCTpFlViQ1mjvJ9VBHVb20XfPF3ycz0MyAYhiLeFvDjCldyKQD3mcE1?= =?us-ascii?Q?PQiBCimSrMh7JWO6Jgip8t03qft9Mu5Q5Bj8k18V0xlBX72h+L3dI+DHZElF?= =?us-ascii?Q?vChK9W5Tx5AaiPkWWmJnL0qZDjdiwTVqXqu6yJyVX6kfR1ZeezopPAJY4Ewv?= =?us-ascii?Q?+lx2xTqfoczAQ5/qHQKjfgVKcyeVH7KVgXfuM6e1hQOss9/oEjpwBn2xzqFW?= =?us-ascii?Q?pEeFmdsqnEJRInRV4gjaXgna5ACuNtOwsw5GDkpgPZ4eaV5hL8G25ZmkOb68?= =?us-ascii?Q?lUBmeLCnmNNg2hnd3wCt9L5aqrwfvY24a3w9fjz54+J01IsS/hjtCyF0zz58?= =?us-ascii?Q?njyjCNOYAqv4ywQ2X/rdkRKDOIgJ4oofsS742J9MY8okbdPDHUKseF2+ER5c?= =?us-ascii?Q?6vGHZGNDoXrw2EXi7XLKoLDZBMEId4hn6PIUgb5iUm+y3cWliJMSqfKCZa+E?= =?us-ascii?Q?dFpHi0UboWzeg0QPc2fRUjf5x57N8td0Q7D7wIKGm07JytV0n4yNblwSLq3w?= =?us-ascii?Q?GfRqNvyZilQ4aDFW3K33RGZPbv75+GkbuVtnmrYuEUqFlsiNjAlD7gzbKZzZ?= =?us-ascii?Q?7NAZ74VSX3ZZly/IqqwTwNBP1J9ac050wbQHOPIyb2SJ2EgW+68aFyPYPcz5?= =?us-ascii?Q?of52UrKXOs2TR6kWVTQ7OrphQBuLif2GeYh9lQaaVILoSz+emleW/z8LJ/mx?= =?us-ascii?Q?4oPXktiUA9wwewgaX0VU4PjJd9j7zr09wsEX6tgUKgvRkoWdwJrn2gLt7JFa?= =?us-ascii?Q?mTfz3xojXvBiTekXeiN4Cq2nEdyawkt3+Qa6AogtCjlLRBqQhWnBoIDvbvFV?= =?us-ascii?Q?rvQCWSY3ZVMTuIAfiNbUw0yfLF01j6UV8mZfxc7I85jyJqo2J3kZpX4lFM+j?= =?us-ascii?Q?Qau7ieLST5gHF0sWIKY3hXa9bijfq30LajSyNaNBFFbqsJUU2nguZ5EDO5yv?= =?us-ascii?Q?sdqRGB1/qK3f0hZn4EgLS3Mu8IuTonjc6txqOxuC+vukplty2VyHa6OqOW5T?= =?us-ascii?Q?cUOfqsfZMgNRwhikU3XuapkOS2gtrJFHTQWtN1qB/LUxKSY1oHHE8JdorAVI?= =?us-ascii?Q?YeIKA0gPN6wlmQnuMIfHrXwY+HO4V/n4p3EzBURTyMb0DtueDhUgtNXsLhbX?= =?us-ascii?Q?BIbVjNRZTulfIzZ3bcg/Alz+urMagSBCBnYCccXmlHsAdUbx27CAaMk59vJ0?= =?us-ascii?Q?sbk0CBKtiLOGgJBEeYWZn9PzsHCzVFZyOwhTK3LSPHsta7Q5vliaJtXwwK5J?= =?us-ascii?Q?XQ4qPjeuK6wOcNHmtl0lrhZ/svfc0fwYFzd8uMe+pHmUQwZPxYnoNhjkXHB3?= =?us-ascii?Q?K+tth5zUNtsDV3YTYxWGYaBjJmV8JKhDAKBpOYkfxJvts7PYtOWLDciQJshO?= =?us-ascii?Q?r+sV2uo7cDS4JbMzXSwGXAUBSyIcBLVDlo0KbOvVkU25CS9vi1Jvt2REwmqq?= =?us-ascii?Q?rzfpSpR0dOwuYy6jif8SE9EMTwCAvgQ6+AIP+XWijNS2vabQCvHyUs9QsR7+?= =?us-ascii?Q?Y3ReCNvuQROK9qQ=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)(36860700013)(376014)(7416014)(921020)(13003099007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2025 21:24:37.7747 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 05cf3ec0-34c9-4475-651d-08dda92e5eb5 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: SJ1PEPF0000231E.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB8098 Content-Type: text/plain; charset="utf-8" The io_alloc feature in resctrl is a mechanism that enables direct insertion of data from I/O devices into the L3 cache. On AMD systems, io_alloc feature is backed by SDCIAE (L3 Smart Data Cache Injection Allocation Enforcement). When enabled, SDCIAE forces all SDCI lines to be placed into the L3 cache partitions identified by the highest-supported L3_MASK_n register as reported by CPUID Fn0000_0010_EDX_x1.MAX_COS. For example, if MAX_COS=3D15, SDCI lines will be allocated into the L3 cache partitions determined by the bitmask in the L3_MASK_15 register. When CDP is enabled, io_alloc routes I/O traffic using the highest CLOSID allocated for the instruction cache (L3CODE). Introduce user interface to enable/disable "io_alloc" feature. Signed-off-by: Babu Moger --- v6: Changed the subject to fs/resctrl: v5: Resolved conflicts due to recent resctrl FS/ARCH code restructure. Used rdt_kn_name to get the rdtgroup name instead of accesssing it dire= ctly while printing group name used by the io_alloc_closid. Updated bit_usage to reflect the io_alloc CBM as discussed in the threa= d: https://lore.kernel.org/lkml/3ca0a5dc-ad9c-4767-9011-b79d986e1e8d@intel= .com/ Modified rdt_bit_usage_show() to read io_alloc_cbm in hw_shareable, ens= uring that bit_usage accurately represents the CBMs. Updated the code to modify io_alloc either with L3CODE or L3DATA. https://lore.kernel.org/lkml/c00c00ea-a9ac-4c56-961c-dc5bf633476b@intel= .com/ v4: Updated the change log. Updated the user doc. The "io_alloc" interface will report "enabled/disabled/not supported". Updated resctrl_io_alloc_closid_get() to verify the max closid availabi= lity. Updated the documentation for "shareable_bits" and "bit_usage". Introduced io_alloc_init() to initialize fflags. Printed the group name when io_alloc enablement fails. NOTE: io_alloc is about specific CLOS. rdt_bit_usage_show() is not desi= gned handle bit_usage for specific CLOS. Its about overall system. So, we ca= nnot really tell the user which CLOS is shared across both hardware and soft= ware. We need to discuss this. v3: Rewrote the change to make it generic. Rewrote the documentation in resctrl.rst to be generic and added AMD feature details in the end. Added the check to verify if MAX CLOSID availability on the system. Added CDP check to make sure io_alloc is configured in CDP_CODE. Added resctrl_io_alloc_closid_free() to free the io_alloc CLOSID. Added errors in few cases when CLOSID allocation fails. Fixes splat reported when info/L3/bit_usage is accesed when io_alloc is enabled. https://lore.kernel.org/lkml/SJ1PR11MB60837B532254E7B23BC27E84FC052@SJ1= PR11MB6083.namprd11.prod.outlook.com/ v2: Renamed the feature to "io_alloc". Added generic texts for the feature in commit log and resctrl.rst doc. Added resctrl_io_alloc_init_cat() to initialize io_alloc to default values when enabled. Fixed io_alloc show functinality to display only on L3 resource. --- Documentation/filesystems/resctrl.rst | 34 ++++ fs/resctrl/rdtgroup.c | 216 +++++++++++++++++++++++++- 2 files changed, 248 insertions(+), 2 deletions(-) diff --git a/Documentation/filesystems/resctrl.rst b/Documentation/filesyst= ems/resctrl.rst index c7949dd44f2f..03c829b2c276 100644 --- a/Documentation/filesystems/resctrl.rst +++ b/Documentation/filesystems/resctrl.rst @@ -95,6 +95,11 @@ related to allocation: some platforms support devices that have their own settings for cache use which can over-ride these bits. + + When the "io_alloc" feature is enabled, a portion of the cache + is reserved for shared use between hardware and software. Refer + to "bit_usage" to see which portion is allocated for this purpose. + "bit_usage": Annotated capacity bitmasks showing how all instances of the resource are used. The legend is: @@ -135,6 +140,35 @@ related to allocation: "1": Non-contiguous 1s value in CBM is supported. =20 +"io_alloc": + The "io_alloc" enables system software to configure the portion + of the L3 cache allocated for I/O traffic. + + The feature routes the I/O traffic via specific CLOSID reserved + for io_alloc feature. By configuring the CBM (Capacity Bit Mask) + for the CLOSID, users can control the L3 portions available for + I/0 traffic. The reserved CLOSID will be excluded for group creation. + + The interface provides a means to query the status of the feature. + + Example:: + + # cat /sys/fs/resctrl/info/L3/io_alloc + disabled + + Feature can be enabled/disabled by writing to the interface. + Example:: + + # echo 1 > /sys/fs/resctrl/info/L3/io_alloc + # cat /sys/fs/resctrl/info/L3/io_alloc + enabled + + On AMD systems, the io_alloc feature is supported by the L3 Smart + Data Cache Injection Allocation Enforcement (SDCIAE). The CLOSID for + io_alloc is determined by the highest CLOSID supported by the resource. + When CDP is enabled, io_alloc routes I/O traffic using the highest + CLOSID allocated for the instruction cache (L3CODE). + Memory bandwidth(MB) subdirectory contains the following files with respect to allocation: =20 diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 1beb124e25f6..bbc032b4d0e9 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -70,6 +70,7 @@ static struct seq_buf last_cmd_status; static char last_cmd_status_buf[512]; =20 static int rdtgroup_setup_root(struct rdt_fs_context *ctx); +static int rdtgroup_init_cat(struct resctrl_schema *s, u32 closid); =20 static void rdtgroup_destroy_root(void); =20 @@ -232,6 +233,19 @@ bool closid_allocated(unsigned int closid) return !test_bit(closid, closid_free_map); } =20 +static int resctrl_io_alloc_closid_alloc(u32 io_alloc_closid) +{ + if (__test_and_clear_bit(io_alloc_closid, closid_free_map)) + return io_alloc_closid; + else + return -ENOSPC; +} + +static void resctrl_io_alloc_closid_free(u32 io_alloc_closid) +{ + closid_free(io_alloc_closid); +} + /** * rdtgroup_mode_by_closid - Return mode of resource group with closid * @closid: closid if the resource group @@ -1030,6 +1044,29 @@ static int rdt_shareable_bits_show(struct kernfs_ope= n_file *of, return 0; } =20 +/* + * resctrl_io_alloc_closid_get - io_alloc feature uses max CLOSID to route + * the IO traffic. Get the max CLOSID and verify if the CLOSID is availabl= e. + * + * The total number of CLOSIDs is determined in closid_init(), based on t= he + * minimum supported across all resources. If CDP (Code Data Prioritizatio= n) + * is enabled, the number of CLOSIDs is halved. The final value is returned + * by closids_supported(). Make sure this value aligns with the maximum + * CLOSID supported by the respective resource. + */ +static int resctrl_io_alloc_closid_get(struct rdt_resource *r) +{ + int num_closids =3D closids_supported(); + + if (resctrl_arch_get_cdp_enabled(r->rid)) + num_closids *=3D 2; + + if (num_closids !=3D resctrl_arch_get_num_closid(r)) + return -ENOSPC; + + return closids_supported() - 1; +} + /* * rdt_bit_usage_show - Display current usage of resources * @@ -1058,20 +1095,23 @@ static int rdt_bit_usage_show(struct kernfs_open_fi= le *of, struct rdt_ctrl_domain *dom; int i, hwb, swb, excl, psl; enum rdtgrp_mode mode; + int io_alloc_closid; bool sep =3D false; u32 ctrl_val; =20 cpus_read_lock(); mutex_lock(&rdtgroup_mutex); - hw_shareable =3D r->cache.shareable_bits; list_for_each_entry(dom, &r->ctrl_domains, hdr.list) { if (sep) seq_putc(seq, ';'); + hw_shareable =3D r->cache.shareable_bits; sw_shareable =3D 0; exclusive =3D 0; seq_printf(seq, "%d=3D", dom->hdr.id); for (i =3D 0; i < closids_supported(); i++) { - if (!closid_allocated(i)) + if (!closid_allocated(i) || + (resctrl_arch_get_io_alloc_enabled(r) && + i =3D=3D resctrl_io_alloc_closid_get(r))) continue; ctrl_val =3D resctrl_arch_get_config(r, dom, i, s->conf_type); @@ -1099,6 +1139,24 @@ static int rdt_bit_usage_show(struct kernfs_open_fil= e *of, break; } } + + /* + * When the "io_alloc" feature is enabled, a portion of the + * cache is reserved for shared use between hardware and software. + */ + if (resctrl_arch_get_io_alloc_enabled(r)) { + io_alloc_closid =3D resctrl_io_alloc_closid_get(r); + if (resctrl_arch_get_cdp_enabled(r->rid)) + ctrl_val =3D resctrl_arch_get_config(r, dom, + io_alloc_closid, + CDP_CODE); + else + ctrl_val =3D resctrl_arch_get_config(r, dom, + io_alloc_closid, + CDP_NONE); + hw_shareable |=3D ctrl_val; + } + for (i =3D r->cache.cbm_len - 1; i >=3D 0; i--) { pseudo_locked =3D dom->plr ? dom->plr->cbm : 0; hwb =3D test_bit(i, &hw_shareable); @@ -1803,6 +1861,142 @@ static ssize_t mbm_local_bytes_config_write(struct = kernfs_open_file *of, return ret ?: nbytes; } =20 +static int resctrl_io_alloc_show(struct kernfs_open_file *of, + struct seq_file *seq, void *v) +{ + struct resctrl_schema *s =3D rdt_kn_parent_priv(of->kn); + struct rdt_resource *r =3D s->res; + + if (r->cache.io_alloc_capable) { + if (resctrl_arch_get_io_alloc_enabled(r)) + seq_puts(seq, "enabled\n"); + else + seq_puts(seq, "disabled\n"); + } else { + seq_puts(seq, "not supported\n"); + } + + return 0; +} + +/* + * Initialize io_alloc CLOSID cache resource with default CBM values. + */ +static int resctrl_io_alloc_init_cat(struct rdt_resource *r, + struct resctrl_schema *s, u32 closid) +{ + int ret; + + rdt_staged_configs_clear(); + + ret =3D rdtgroup_init_cat(s, closid); + if (ret < 0) + goto out_init_cat; + + ret =3D resctrl_arch_update_domains(r, closid); + +out_init_cat: + rdt_staged_configs_clear(); + return ret; +} + +static const char *rdtgroup_name_by_closid(int closid) +{ + struct rdtgroup *rdtgrp; + + list_for_each_entry(rdtgrp, &rdt_all_groups, rdtgroup_list) { + if (rdtgrp->closid =3D=3D closid) + return rdt_kn_name(rdtgrp->kn); + } + + return NULL; +} + +/* + * When CDP is enabled, io_alloc directs traffic using the highest CLOSID + * linked to an L3CODE resource. Although CBMs can be accessed through + * either L3CODE or L3DATA resources, any updates to the schemata must + * always be performed on L3CODE. + */ +static struct resctrl_schema *resctrl_schema_io_alloc(struct resctrl_schem= a *s) +{ + struct resctrl_schema *schema; + + if (s->conf_type =3D=3D CDP_DATA) { + list_for_each_entry(schema, &resctrl_schema_all, list) { + if (schema->conf_type =3D=3D CDP_CODE) + return schema; + } + } + + return s; +} + +static ssize_t resctrl_io_alloc_write(struct kernfs_open_file *of, char *b= uf, + size_t nbytes, loff_t off) +{ + struct resctrl_schema *s =3D rdt_kn_parent_priv(of->kn); + struct rdt_resource *r =3D s->res; + char const *grp_name; + u32 io_alloc_closid; + bool enable; + int ret; + + ret =3D kstrtobool(buf, &enable); + if (ret) + return ret; + + cpus_read_lock(); + mutex_lock(&rdtgroup_mutex); + + rdt_last_cmd_clear(); + + if (!r->cache.io_alloc_capable) { + rdt_last_cmd_puts("io_alloc feature is not supported on the resource\n"); + ret =3D -ENODEV; + goto out_io_alloc; + } + + io_alloc_closid =3D resctrl_io_alloc_closid_get(r); + if (io_alloc_closid < 0) { + rdt_last_cmd_puts("Max CLOSID to support io_alloc is not available\n"); + ret =3D -EINVAL; + goto out_io_alloc; + } + + if (resctrl_arch_get_io_alloc_enabled(r) !=3D enable) { + if (enable) { + ret =3D resctrl_io_alloc_closid_alloc(io_alloc_closid); + if (ret < 0) { + grp_name =3D rdtgroup_name_by_closid(io_alloc_closid); + rdt_last_cmd_printf("CLOSID for io_alloc is used by %s group\n", + grp_name ? grp_name : "another"); + ret =3D -EINVAL; + goto out_io_alloc; + } + + ret =3D resctrl_io_alloc_init_cat(r, resctrl_schema_io_alloc(s), + io_alloc_closid); + if (ret) { + rdt_last_cmd_puts("Failed to initialize io_alloc allocations\n"); + resctrl_io_alloc_closid_free(io_alloc_closid); + goto out_io_alloc; + } + + } else { + resctrl_io_alloc_closid_free(io_alloc_closid); + } + + ret =3D resctrl_arch_io_alloc_enable(r, enable); + } + +out_io_alloc: + mutex_unlock(&rdtgroup_mutex); + cpus_read_unlock(); + + return ret ?: nbytes; +} + /* rdtgroup information files for one cache resource. */ static struct rftype res_common_files[] =3D { { @@ -1955,6 +2149,13 @@ static struct rftype res_common_files[] =3D { .seq_show =3D rdtgroup_schemata_show, .fflags =3D RFTYPE_CTRL_BASE, }, + { + .name =3D "io_alloc", + .mode =3D 0644, + .kf_ops =3D &rdtgroup_kf_single_ops, + .seq_show =3D resctrl_io_alloc_show, + .write =3D resctrl_io_alloc_write, + }, { .name =3D "mba_MBps_event", .mode =3D 0644, @@ -2062,6 +2263,15 @@ static void thread_throttle_mode_init(void) RFTYPE_CTRL_INFO | RFTYPE_RES_MB); } =20 +static void io_alloc_init(void) +{ + struct rdt_resource *r =3D resctrl_arch_get_resource(RDT_RESOURCE_L3); + + if (r->cache.io_alloc_capable) + resctrl_file_fflags_init("io_alloc", + RFTYPE_CTRL_INFO | RFTYPE_RES_CACHE); +} + void resctrl_file_fflags_init(const char *config, unsigned long fflags) { struct rftype *rft; @@ -4249,6 +4459,8 @@ int resctrl_init(void) =20 thread_throttle_mode_init(); =20 + io_alloc_init(); + ret =3D resctrl_mon_resource_init(); if (ret) return ret; --=20 2.34.1 From nobody Sat Oct 11 00:35:49 2025 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2042.outbound.protection.outlook.com [40.107.243.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 744E7247293; Wed, 11 Jun 2025 21:24:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.42 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749677094; cv=fail; b=ViNJ5GeNuRrXvdFiZ6pk+G6A6ijBpuaDO7k7slO/NLSM03Swtw2OiBBrfmY65hUuXU5LiEqpEDA5Zxm/DHBxwtJQouM86fPT/yqI7ciVb4zKrDfdEHkffO8mw6SoFvkP9LRA/0sPSbEy35gjtj0FxcDTHyBtsjvUeMeDKHjOXUk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749677094; c=relaxed/simple; bh=LzaXgX5VkP1y3UQh6X2/3szwoQomvPDJ95u3Mis5VZk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Ds03q54arp8Ar8i8jM2DyRWVyPsMDsJwujiNhFrSHOOE9TUOrTj1EvPElX4XHNOj+RjWWHmvHIIJQ2Ta6+gLiteQgeY7uc1/JWAz84KTwqcYA2r81v5OWORl3ztzFE3V0wg2dLDwp1MwaNlj1l4uOBSQavaT6vuSCl6+LvNHBWo= 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=awr109e9; arc=fail smtp.client-ip=40.107.243.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="awr109e9" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=MG59eVpKpfumn5UnXuH40MQl88pb0sYBETWA/424FYXqrugYo86v/+2BDrsN0N0oON0SDlykz1QqKRb13W8yxLsWs/6Ncc4JPYElO1yGL/rZMhK9pB1JgAyMcawuQ/Ag+nlTM35uU3rHpfV9Iz7J5NJPfRVYhdBgHarp3hthzWaN2DyQWkW46yYsrz2V4RIXlBtlr9dcoATzXIK0vCZ/tZONLq2ZgGvVR6SKRiOpxBVbL1PZAXE9/Dj2L42Jk5k0S0KgqAMSt/fuHei5WAOdmYOLz4QmF19AR+XLkORFedt+x/nFROVCIBj/xB2Itk7ppEt67qJOnfZp2EPyGemiGg== 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=y2Fc3RxzJUbOZXb5/P/Dttx2ymd5AJN7J7FKJC6HrEE=; b=AMRIHKiQ9tXsRJ1VOzemKzhJUw5TBbahUoRbPR+Lm+iOl63RLZVs6S8wCNHRL3CW93lUVk9qeoVyeSH4pYYmjxAyyaVscDek4Qyp916bRGdLRZefov+CChz1/m733L0exVqd1hSqpU2HIFQbD3O/1VQLKgz5TFn0QlWOoIzCwFZyNFAY47ffb6qXtgI1I4tHtuFTeMxvzEGNitimRyeAseA7qRqBaVSXyiPaQDQkFqdXX3E/leKSukAn4XbC6dCF4zjGUnFWm/LzjA1M8f2rCx3OqPBPe1Hth/mgZlLiMojpSJ5PV5q+imVqp92kl9XwmnDKOVqTAJvPhb6waJU/Zw== 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=y2Fc3RxzJUbOZXb5/P/Dttx2ymd5AJN7J7FKJC6HrEE=; b=awr109e9MWKEhJynZ/gaPsvPGX04oJaUKMpu+KiWEjnT+hN3tl2g2o5vfxMlsMkzCE0Q7Dz6VeDyD9NjRkDas+bkzJibDuN6GhOdvok5KR7YAO688coWMGbODXCmotnIk6fKlljQ628v06tlyItmiRCzKPe6uNf1A8M2/fTOZMQ= Received: from SJ0PR13CA0025.namprd13.prod.outlook.com (2603:10b6:a03:2c0::30) by SJ2PR12MB8133.namprd12.prod.outlook.com (2603:10b6:a03:4af::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8792.37; Wed, 11 Jun 2025 21:24:48 +0000 Received: from SJ1PEPF000026C8.namprd04.prod.outlook.com (2603:10b6:a03:2c0:cafe::e1) by SJ0PR13CA0025.outlook.office365.com (2603:10b6:a03:2c0::30) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8835.17 via Frontend Transport; Wed, 11 Jun 2025 21:24: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 SJ1PEPF000026C8.mail.protection.outlook.com (10.167.244.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8835.15 via Frontend Transport; Wed, 11 Jun 2025 21:24: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; Wed, 11 Jun 2025 16:24:44 -0500 From: Babu Moger To: , , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v6 6/8] fs/resctrl: Introduce interface to display io_alloc CBMs Date: Wed, 11 Jun 2025 16:23:31 -0500 Message-ID: <16cebf7069e11e07c0d9e343aa72363325befafd.1749677012.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: SJ1PEPF000026C8:EE_|SJ2PR12MB8133:EE_ X-MS-Office365-Filtering-Correlation-Id: fba200c0-05a7-4e63-7df9-08dda92e64ae X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|7416014|376014|82310400026|921020; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?q5hotpuY+jDV8h6xGlsoLa+hXpk2E31w3q1cVjzLm08+kh676BeVLIW25cI1?= =?us-ascii?Q?sLRjKwR/tyJdly512y/IqYquv7c+vt2mwhgqEfY85HInLJV4v92JxbqBs2ti?= =?us-ascii?Q?rAqUbmByc/IagoGbMdP1qDMCzgHEOJ3KI+KFX21oRHnOraKfMFotLlTSZjBu?= =?us-ascii?Q?1Rb/rJOwoAe0Nqq3LaivEtmK4bixRiuz4hKnoy/GZ8W4eX5HIeaaCOj/epZv?= =?us-ascii?Q?aDgboZ9BA5skRlv26Hj4vU253+UDXPTNYFYVvk1JtiLAd5pjVXUhUb19k+rE?= =?us-ascii?Q?5Il/UJ7Ib4az6RQy/HgjjtcFgsyEX1xCkEwdCKBrKrUpfJ/x29jHYoEkiafo?= =?us-ascii?Q?H2phydI2e9sdU/goVUcI36X5sDMjGOnicUyBrA69JG+6WRU7PdJITN1U4M6L?= =?us-ascii?Q?G1DHvPFQ+7CEjAfv5SZkMXsJFrEs5bRVkLWmGfTZH3PnCJp6VfpkW/nY36HO?= =?us-ascii?Q?7uKuxhJoAzn2ZVNr+NjP1BHT3zeTRLHzEtBRERzHCUYp8nhEYmIZ4UWk3DM1?= =?us-ascii?Q?2Bzs5EOWnoWGGn+okObSWmZjDfu8DgCAKg+YbS1GasXNPqO7459t7Cq0XJaJ?= =?us-ascii?Q?Pg2/itzMCAbXbcwCS01WZqJx7imYrcevXsPWoef+uIn64RC0Ufv9zUnnT/Y6?= =?us-ascii?Q?YosULV1bUzk4Ml8ctFwl3wJOmxEJWEqup/1O3OmZuRAxf6g4GATcW2p7Vr2H?= =?us-ascii?Q?3v3fmJ57QKa+QF9MxeTnMQfeK6cohL8DQImX86sL0Vw4WVmB+C2IxEeBl7Dg?= =?us-ascii?Q?kbHHjoTb8rS3ZgLdZ7ULCBCsemn33tYz1xc63oM/3+1Os5Z9bmRF8TNm9kiY?= =?us-ascii?Q?heh4Ypy2X0soc8l+RBEPMaH5BSnbQd/fGolZOLgeBoxVNkKt1gGpAHmFe4Oc?= =?us-ascii?Q?4qVfKfokYDYKU5nPXDPkTdMSk7xBM7cnaLVks9QkASmrbBUsLi9i/ysMfoR7?= =?us-ascii?Q?7wnSVl0i1Rt9HXFDkOsKzAe0YAd/UTqxTkJxrCsVmKjxjWZHMLCLaQqzvkzj?= =?us-ascii?Q?iY/VqbCeViBlQtllarXt7cebTKVFxwBOhDbCZBantL31AyVUEYU68SUID3sA?= =?us-ascii?Q?cxJmEgDRV3cU0mjQE3fGfoT9KuDdi2zU1LJLrlKrq+1fKR/z7CWW/xjG31xH?= =?us-ascii?Q?Isv8VtlqmyYZmyEOhvE7SzNfqzdIykPXpI3cVg95z04nsFTkomxFOkxDVzO1?= =?us-ascii?Q?pim/Q7YaX/6mPlJ4XhGi7MKbwIvWMUsYVA9lzyFnnX3W8yDhtWG1np2Rantr?= =?us-ascii?Q?NSzDiFbvZBgsY+yD9EVWRrORjhOh9zX93VXNSUiHxFh5NSZ78iEMLUHOszwu?= =?us-ascii?Q?BrNqje1ZSaN6838BMX0JimC9G+vP33pd3s+p6t/tRjevYfxQGUqN4+HqHMm2?= =?us-ascii?Q?cWwD3n0D2yC+8awgRQtWntYahSGhTlddak3XTQTy85eV8NVhwWm0bEWp2LQD?= =?us-ascii?Q?/6uDVDDyT7O5pPhj2EINO1hftZD5e9aThfoqGig3y6M1XMGXoeochVe9NKVA?= =?us-ascii?Q?6Ux8aNGeyShBpOp7b7VBOwlqWrygiVsNyMTsDq3OUzZ0ZAQIHwo5Tivd0A?= =?us-ascii?Q?=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)(1800799024)(7416014)(376014)(82310400026)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2025 21:24:47.7965 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fba200c0-05a7-4e63-7df9-08dda92e64ae 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: SJ1PEPF000026C8.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8133 Content-Type: text/plain; charset="utf-8" The io_alloc feature in resctrl enables system software to configure the portion of the L3 cache allocated for I/O traffic. Add the interface to display CBMs (Capacity Bit Mask) of io_alloc feature. The CBM interface file io_alloc_cbm will reside in the info directory (e.g., /sys/fs/resctrl/info/L3/). Displaying the resource name is not necessary. Pass the resource name to show_doms() and print it only if the name is valid. For io_alloc, pass NULL to suppress printing the resource name. When CDP is enabled, io_alloc routes traffic using the highest CLOSID associated with an L3CODE resource. However, CBMs can be accessed via either L3CODE or L3DATA resources. Signed-off-by: Babu Moger --- v6: Added "io_alloc_cbm" details in user doc resctrl.rst. Resource name is not printed in CBM now. Corrected the texts about it in resctrl.rst. v5: Resolved conflicts due to recent resctrl FS/ARCH code restructure. Updated show_doms() to print the resource if only it is valid. Pass NUL= L while printing io_alloc CBM. Changed the code to access the CBMs via either L3CODE or L3DATA resourc= es. v4: Updated the change log. Added rdtgroup_mutex before rdt_last_cmd_puts(). Returned -ENODEV when resource type is CDP_DATA. Kept the resource name while printing the CBM (L3:0=3Dfff) that way I dont have to change show_doms() just for this feature and it is consistant across all the schemata display. v3: Minor changes due to changes in resctrl_arch_get_io_alloc_enabled() and resctrl_io_alloc_closid_get(). Added the check to verify CDP resource type. Updated the commit log. v2: Fixed to display only on L3 resources. Added the locks while processing. Rename the displat to io_alloc_cbm (from sdciae_cmd). --- Documentation/filesystems/resctrl.rst | 13 +++++++ fs/resctrl/ctrlmondata.c | 8 +++-- fs/resctrl/internal.h | 2 ++ fs/resctrl/rdtgroup.c | 51 ++++++++++++++++++++++++++- 4 files changed, 70 insertions(+), 4 deletions(-) diff --git a/Documentation/filesystems/resctrl.rst b/Documentation/filesyst= ems/resctrl.rst index 03c829b2c276..b31748ec8c61 100644 --- a/Documentation/filesystems/resctrl.rst +++ b/Documentation/filesystems/resctrl.rst @@ -169,6 +169,19 @@ related to allocation: When CDP is enabled, io_alloc routes I/O traffic using the highest CLOSID allocated for the instruction cache (L3CODE). =20 +"io_alloc_cbm": + Capacity Bit Masks (CBMs) available to supported IO devices which + can directly insert cache lines in L3 which can help to reduce the + latency. CBMs are displayed in the following format: + + =3D;=3D;... + + Example:: + + # cat /sys/fs/resctrl/info/L3/io_alloc_cbm + 0=3Dffff;1=3Dffff + + Memory bandwidth(MB) subdirectory contains the following files with respect to allocation: =20 diff --git a/fs/resctrl/ctrlmondata.c b/fs/resctrl/ctrlmondata.c index 6ed2dfd4dbbd..ea039852569a 100644 --- a/fs/resctrl/ctrlmondata.c +++ b/fs/resctrl/ctrlmondata.c @@ -381,7 +381,8 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file= *of, return ret ?: nbytes; } =20 -static void show_doms(struct seq_file *s, struct resctrl_schema *schema, i= nt closid) +void show_doms(struct seq_file *s, struct resctrl_schema *schema, char *re= source_name, + int closid) { struct rdt_resource *r =3D schema->res; struct rdt_ctrl_domain *dom; @@ -391,7 +392,8 @@ static void show_doms(struct seq_file *s, struct resctr= l_schema *schema, int clo /* Walking r->domains, ensure it can't race with cpuhp */ lockdep_assert_cpus_held(); =20 - seq_printf(s, "%*s:", max_name_width, schema->name); + if (resource_name) + seq_printf(s, "%*s:", max_name_width, resource_name); list_for_each_entry(dom, &r->ctrl_domains, hdr.list) { if (sep) seq_puts(s, ";"); @@ -437,7 +439,7 @@ int rdtgroup_schemata_show(struct kernfs_open_file *of, closid =3D rdtgrp->closid; list_for_each_entry(schema, &resctrl_schema_all, list) { if (closid < schema->num_closid) - show_doms(s, schema, closid); + show_doms(s, schema, schema->name, closid); } } } else { diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h index 9a8cf6f11151..14f3697c1187 100644 --- a/fs/resctrl/internal.h +++ b/fs/resctrl/internal.h @@ -374,6 +374,8 @@ void rdt_staged_configs_clear(void); bool closid_allocated(unsigned int closid); =20 int resctrl_find_cleanest_closid(void); +void show_doms(struct seq_file *s, struct resctrl_schema *schema, + char *name, int closid); =20 #ifdef CONFIG_RESCTRL_FS_PSEUDO_LOCK int rdtgroup_locksetup_enter(struct rdtgroup *rdtgrp); diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index bbc032b4d0e9..0c2d2cf4baa1 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -1997,6 +1997,46 @@ static ssize_t resctrl_io_alloc_write(struct kernfs_= open_file *of, char *buf, return ret ?: nbytes; } =20 +static int resctrl_io_alloc_cbm_show(struct kernfs_open_file *of, + struct seq_file *seq, void *v) +{ + struct resctrl_schema *s =3D rdt_kn_parent_priv(of->kn); + struct rdt_resource *r =3D s->res; + u32 io_alloc_closid; + int ret =3D 0; + + cpus_read_lock(); + mutex_lock(&rdtgroup_mutex); + + rdt_last_cmd_clear(); + + if (!r->cache.io_alloc_capable) { + rdt_last_cmd_puts("io_alloc feature is not supported on the resource\n"); + ret =3D -ENODEV; + goto cbm_show_out; + } + + if (!resctrl_arch_get_io_alloc_enabled(r)) { + rdt_last_cmd_puts("io_alloc feature is not enabled\n"); + ret =3D -EINVAL; + goto cbm_show_out; + } + + io_alloc_closid =3D resctrl_io_alloc_closid_get(r); + if (io_alloc_closid < 0) { + rdt_last_cmd_puts("Max CLOSID to support io_alloc is not available\n"); + ret =3D -EINVAL; + goto cbm_show_out; + } + + show_doms(seq, resctrl_schema_io_alloc(s), NULL, io_alloc_closid); + +cbm_show_out: + mutex_unlock(&rdtgroup_mutex); + cpus_read_unlock(); + return ret; +} + /* rdtgroup information files for one cache resource. */ static struct rftype res_common_files[] =3D { { @@ -2156,6 +2196,12 @@ static struct rftype res_common_files[] =3D { .seq_show =3D resctrl_io_alloc_show, .write =3D resctrl_io_alloc_write, }, + { + .name =3D "io_alloc_cbm", + .mode =3D 0444, + .kf_ops =3D &rdtgroup_kf_single_ops, + .seq_show =3D resctrl_io_alloc_cbm_show, + }, { .name =3D "mba_MBps_event", .mode =3D 0644, @@ -2267,9 +2313,12 @@ static void io_alloc_init(void) { struct rdt_resource *r =3D resctrl_arch_get_resource(RDT_RESOURCE_L3); =20 - if (r->cache.io_alloc_capable) + if (r->cache.io_alloc_capable) { resctrl_file_fflags_init("io_alloc", RFTYPE_CTRL_INFO | RFTYPE_RES_CACHE); + resctrl_file_fflags_init("io_alloc_cbm", + RFTYPE_CTRL_INFO | RFTYPE_RES_CACHE); + } } =20 void resctrl_file_fflags_init(const char *config, unsigned long fflags) --=20 2.34.1 From nobody Sat Oct 11 00:35:49 2025 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2064.outbound.protection.outlook.com [40.107.243.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 5B62823717C; Wed, 11 Jun 2025 21:25:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.64 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749677105; cv=fail; b=Cel43k6OV729+IEWVBd4G73FtLIjje5vRBlfxcDo+TgF7PNIKX6YbRjAObkQNuuCG1lzuxlJF59jj43SVbi0gjT85eR6ZqCN74Tgav5YLiE4YTw8wULXNYW37/oonBqHZXz31IBvGu8bL75Lb8kpmZbiqimP6BdpM/ghmWpUXT8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749677105; c=relaxed/simple; bh=LWOoJ56LkcUcJT3e2AWppW34ruQ47JszQMeh6uH7Hho=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=M8kcm9es35v3+pOtiynqPl7E4vIkPi+oIQVTiZMd8/xiTa9Xu9EWZKb4vd/cz4wyEqAmSK+EZjWKGBwflyNRBE83ZxR5J/cAj1vQKlBZ8MdffSwlC/r3TYPh5yFK1B2Et3vzpYk8IX/HEuUVWYBA2TZBllhI+gKBvSmN6u4Npeo= 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=r6FhU/Zk; arc=fail smtp.client-ip=40.107.243.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="r6FhU/Zk" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=p5aH3+WJy1NGqvEShwpYKW1TBOoZHp1yi2uMD2Z+pDqJQB9wE4BdGLWqub2k/3eQDnLlhE0AQCPa3mAMJhjmOkC+TtOevlWzedE1GPWKzzG3/cOkLNZjout/oDUZAsRKCBIRP7TbBDJAbYp3fUpdnN56BfWJXUPyngb+ezVCMlLDgkAtEdSFP2gewNe4wpZjeKm0aFsZSKGvlDKq2fTSwye8RaL8JvL/Fa4/AtspggR64bzd7A0fIEJrmTa3a1l3kcvSMdBQxLQNPePdMTTqmOdB64yRLXtp2fpdCs6qCsP3Hie9ckV/GrAbwANMj8WnEmI3qcw4M6gAR9LLa6DWtA== 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=tDhCvh0g3P8U0UaN9SYBEj2rFKbmA7fxzLDnY9pKGGA=; b=hfBFjOF0YZEFrML/qkO+jrT+6eNHMU5NB1ZzmpSnN7ZiCs6KboDoxa4CxP6sMkbfp/xPjAVNKlIV1GgfMorZE0aw6DTILMARahxSYIV8oEtLMOZac0RJHd8nq1HYqcwsHNZscpPYYanVqs8MWrzunKYLA7cKtA+RpHUQlVPEGk9Kt4PoeCbEfgektpHgHviOty3AOJ2LchMHrzZIPkv+ALOhHXu5Z9lYg5lPtSQkT3t7SkUZpW4Xk/xjGOzucef+5v6ZDr3u7GxstDtk87qlrfiMw/pM04G3ISiKS2G+DjllizfyKvcVqlzOI6A3DGLsm2QCI+ow9EiAwv5Pawnt8A== 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=tDhCvh0g3P8U0UaN9SYBEj2rFKbmA7fxzLDnY9pKGGA=; b=r6FhU/ZkOeC2Vr/xRLJ78J0fdSlREyCKDOSdo8NXdndS6oKage6wf1hpmJx09udz9b4YutP3YNZvNNWnzSRoz5uVGZsVNPQf46zXvkO9NwKbttTszfD2d0+UZ53NXFrsKkdpFAyDTJkW3kvdgmjjtvFE7T+3FfqD81sYRPLr6YU= Received: from PH7PR13CA0011.namprd13.prod.outlook.com (2603:10b6:510:174::26) by CYXPR12MB9428.namprd12.prod.outlook.com (2603:10b6:930:d5::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8835.18; Wed, 11 Jun 2025 21:24:58 +0000 Received: from SJ1PEPF000026C5.namprd04.prod.outlook.com (2603:10b6:510:174:cafe::a9) by PH7PR13CA0011.outlook.office365.com (2603:10b6:510:174::26) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8835.19 via Frontend Transport; Wed, 11 Jun 2025 21:24:57 +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 SJ1PEPF000026C5.mail.protection.outlook.com (10.167.244.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8835.15 via Frontend Transport; Wed, 11 Jun 2025 21:24:57 +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; Wed, 11 Jun 2025 16:24:54 -0500 From: Babu Moger To: , , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v6 7/8] fs/resctrl: Modify rdt_parse_data to pass mode and CLOSID Date: Wed, 11 Jun 2025 16:23:32 -0500 Message-ID: <8ffa8b31f471750464235f6df21971f7353b7015.1749677012.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: SJ1PEPF000026C5:EE_|CYXPR12MB9428:EE_ X-MS-Office365-Filtering-Correlation-Id: e0288446-6703-4818-509f-08dda92e6a6d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|7416014|376014|1800799024|921020; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?BNUZObchYHKJdSq0YZwr7WcvvhP738xNOBMMVooERm/GgRnkm4bz7VQGd3mY?= =?us-ascii?Q?YBtLWg9NL46lrQmuhASXII5ecj7IySdZ5OHhsY12wi/Hzu+r0WsS911O+HDm?= =?us-ascii?Q?8z0IwHRJ2ca9uFkSVNtPHYjDbFKgI6yKvBLLT2sFIRaAxdGL0JDQNDz8SeqE?= =?us-ascii?Q?4DjMdxWyzgLVpiUja3y+nUVEgkKVB3CJBNDYwdUuV24YvDFN8F9uJmbeXjz7?= =?us-ascii?Q?2StjVKs1Mk/7gjjjtvMfs1Fqssj9/50Y5F2tB8FKQR9SUv+YTP7dkSbFayUH?= =?us-ascii?Q?LVdYZNtMbZkUvNmZJohZ2HMuxvVeqsoxYgmNWP6JqyUqDFfHht2V9tGrj5cq?= =?us-ascii?Q?aGiwl6DJ8pNEdlrbbBG94XMLsWKPU58+PdDjizkG5jGaRf5by92J7uOaO7LC?= =?us-ascii?Q?1wQ4aQFyUCDS/V6crjEw8m5UJlGSyOtlipK5SX8Weegi6GvHFrKg32NePAwG?= =?us-ascii?Q?YNc3zvMpkRvskWIWnlhlj/c/RLWcz4ZIqdq28MPuuGMxGdGUxxvJnFn55GTK?= =?us-ascii?Q?I4m62z/ciqZx5HzE/Orexfy6DVx6T8SLiNzqOoL88SWGO/MLVkQ/NylndMWc?= =?us-ascii?Q?E73C4Vxc65nXxB7xzOi4Mv3yYm1QePlJedgg8mf8AICpTbbTuneLSzn2NaGF?= =?us-ascii?Q?JbGitvProINs8vdc9IG0nWFTKQYhYxCVyGuWXEXtlEZY7/zBTD+hAX7ImIS+?= =?us-ascii?Q?zqQLuJJl/acxra7xmVLALBULQsNujZpqxfE5bBKkfR43p/9uO4h5iIq2nLgp?= =?us-ascii?Q?xkAQ0CTDmz+z8BN9lylWQA6r/4LLPWoYkxKZne6dgzrsEJVlDADjkqR4MxnR?= =?us-ascii?Q?FHNQrp8IkrDb/Ih91bD7WvaTWa/iTPAAh4LU7lFwxIKbfM5Gzoog/V4hUz/o?= =?us-ascii?Q?m7fqO2iOLfWy5TIIOG5TV2dhIG60I6UgmsTeonRPSFkbVcxkLh3QI7bapcoZ?= =?us-ascii?Q?U1bInviriqU0jOveCRMSrK4u8sN/MktYUG3qPdL47Dt/6k44hb6ZbNqyxoa9?= =?us-ascii?Q?mk2v6b9L6vzusiAZNBMSKFKE+vXF5SkA9B5UNECp18MRdNjKpXHJ7GRscuxI?= =?us-ascii?Q?iHFflzp/6pf/nSjIo4yihTmtn2q26gqnk3RzKqnd9GjGXiWhhy2zYEod5XG+?= =?us-ascii?Q?Xe515xgd8zn8e6n8TSWIFwPWmghuroVaxwGd8CnJGNI7F68HUlPGwdTujndG?= =?us-ascii?Q?ZOAjAn/MZDp0yl6oiDCT49FsX5dsPmBx1uuzF/hca3pAzpTEQ6gPDR/Z43Hh?= =?us-ascii?Q?jrNEu6kaZ74RLSjLrGLYinC/b/y3vK8d4FOhJLWeuMWTJHRdnf13iDKBtDeU?= =?us-ascii?Q?pbCSDoTKcD/kilv8UvLPf3AxUnUnqkuPBIdTKH2UakjUL8S1q8GQRTxkORW2?= =?us-ascii?Q?IIyzYNhJwNu1A7xKERgd5WrSeQlTlT6QKDOGlRggXXsWK/IGb7ZlMavCRmhP?= =?us-ascii?Q?VHvk6aS3LGYX3lnM4HZTDYqvWoZzoaVp9oseFbBf/XK2niUHcuZbZXBCe7b5?= =?us-ascii?Q?uR1yr4bANucgkPEbGdltSpGiCEHVOx7LrtX5lsuqScpEpiVDQakZ/w3jJw?= =?us-ascii?Q?=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)(7416014)(376014)(1800799024)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2025 21:24:57.4346 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e0288446-6703-4818-509f-08dda92e6a6d 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: SJ1PEPF000026C5.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYXPR12MB9428 Content-Type: text/plain; charset="utf-8" The functions parse_cbm() and parse_bw() require mode and CLOSID to validate the Capacity Bit Mask (CBM). It is passed through struct rdtgroup in rdt_parse_data. Instead of passing them through struct rdtgroup, pass mode and closid directly. This change enables parse_cbm() to be used for verifying CBM in io_alloc feature. Signed-off-by: Babu Moger --- v6: Changed the subject line to fs/resctrl. v5: Resolved conflicts due to recent resctrl FS/ARCH code restructure. v4: New patch to call parse_cbm() directly to avoid code duplication. --- fs/resctrl/ctrlmondata.c | 29 +++++++++++++---------------- fs/resctrl/internal.h | 6 ++++++ 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/fs/resctrl/ctrlmondata.c b/fs/resctrl/ctrlmondata.c index ea039852569a..6409637b4de6 100644 --- a/fs/resctrl/ctrlmondata.c +++ b/fs/resctrl/ctrlmondata.c @@ -23,11 +23,6 @@ =20 #include "internal.h" =20 -struct rdt_parse_data { - struct rdtgroup *rdtgrp; - char *buf; -}; - typedef int (ctrlval_parser_t)(struct rdt_parse_data *data, struct resctrl_schema *s, struct rdt_ctrl_domain *d); @@ -77,8 +72,8 @@ static int parse_bw(struct rdt_parse_data *data, struct r= esctrl_schema *s, struct rdt_ctrl_domain *d) { struct resctrl_staged_config *cfg; - u32 closid =3D data->rdtgrp->closid; struct rdt_resource *r =3D s->res; + u32 closid =3D data->closid; u32 bw_val; =20 cfg =3D &d->staged_config[s->conf_type]; @@ -156,9 +151,10 @@ static bool cbm_validate(char *buf, u32 *data, struct = rdt_resource *r) static int parse_cbm(struct rdt_parse_data *data, struct resctrl_schema *s, struct rdt_ctrl_domain *d) { - struct rdtgroup *rdtgrp =3D data->rdtgrp; + enum rdtgrp_mode mode =3D data->mode; struct resctrl_staged_config *cfg; struct rdt_resource *r =3D s->res; + u32 closid =3D data->closid; u32 cbm_val; =20 cfg =3D &d->staged_config[s->conf_type]; @@ -171,7 +167,7 @@ static int parse_cbm(struct rdt_parse_data *data, struc= t resctrl_schema *s, * Cannot set up more than one pseudo-locked region in a cache * hierarchy. */ - if (rdtgrp->mode =3D=3D RDT_MODE_PSEUDO_LOCKSETUP && + if (mode =3D=3D RDT_MODE_PSEUDO_LOCKSETUP && rdtgroup_pseudo_locked_in_hierarchy(d)) { rdt_last_cmd_puts("Pseudo-locked region in hierarchy\n"); return -EINVAL; @@ -180,9 +176,9 @@ static int parse_cbm(struct rdt_parse_data *data, struc= t resctrl_schema *s, if (!cbm_validate(data->buf, &cbm_val, r)) return -EINVAL; =20 - if ((rdtgrp->mode =3D=3D RDT_MODE_EXCLUSIVE || - rdtgrp->mode =3D=3D RDT_MODE_SHAREABLE) && - rdtgroup_cbm_overlaps_pseudo_locked(d, cbm_val)) { + if ((mode =3D=3D RDT_MODE_EXCLUSIVE || + mode =3D=3D RDT_MODE_SHAREABLE) && + rdtgroup_cbm_overlaps_pseudo_locked(d, cbm_val)) { rdt_last_cmd_puts("CBM overlaps with pseudo-locked region\n"); return -EINVAL; } @@ -191,14 +187,14 @@ static int parse_cbm(struct rdt_parse_data *data, str= uct resctrl_schema *s, * The CBM may not overlap with the CBM of another closid if * either is exclusive. */ - if (rdtgroup_cbm_overlaps(s, d, cbm_val, rdtgrp->closid, true)) { + if (rdtgroup_cbm_overlaps(s, d, cbm_val, closid, true)) { rdt_last_cmd_puts("Overlaps with exclusive group\n"); return -EINVAL; } =20 - if (rdtgroup_cbm_overlaps(s, d, cbm_val, rdtgrp->closid, false)) { - if (rdtgrp->mode =3D=3D RDT_MODE_EXCLUSIVE || - rdtgrp->mode =3D=3D RDT_MODE_PSEUDO_LOCKSETUP) { + if (rdtgroup_cbm_overlaps(s, d, cbm_val, closid, false)) { + if (mode =3D=3D RDT_MODE_EXCLUSIVE || + mode =3D=3D RDT_MODE_PSEUDO_LOCKSETUP) { rdt_last_cmd_puts("Overlaps with other group\n"); return -EINVAL; } @@ -262,7 +258,8 @@ static int parse_line(char *line, struct resctrl_schema= *s, list_for_each_entry(d, &r->ctrl_domains, hdr.list) { if (d->hdr.id =3D=3D dom_id) { data.buf =3D dom; - data.rdtgrp =3D rdtgrp; + data.closid =3D rdtgrp->closid; + data.mode =3D rdtgrp->mode; if (parse_ctrlval(&data, s, d)) return -EINVAL; if (rdtgrp->mode =3D=3D RDT_MODE_PSEUDO_LOCKSETUP) { diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h index 14f3697c1187..10a3188ffa54 100644 --- a/fs/resctrl/internal.h +++ b/fs/resctrl/internal.h @@ -201,6 +201,12 @@ struct rdtgroup { struct pseudo_lock_region *plr; }; =20 +struct rdt_parse_data { + u32 closid; + enum rdtgrp_mode mode; + char *buf; +}; + /* rdtgroup.flags */ #define RDT_DELETED 1 =20 --=20 2.34.1 From nobody Sat Oct 11 00:35:49 2025 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2070.outbound.protection.outlook.com [40.107.244.70]) (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 CF83F244667; Wed, 11 Jun 2025 21:25:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.70 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749677121; cv=fail; b=MGrVpdX4jk0mbaqfB2e5pg3PnwL88H49QnKWEnhhxTpzvtwCxET3uBHhMbN1axYlIL2Uc+egUv4Vmm+fSK3CmNlUrwI/7+3sjO7hbm9NZVwFPW4GQifKYMUMxGCo/szqmanWVaZjiQYCnjbzJzi/Dk9/sGl05tbZIXOSfDIKw+c= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749677121; c=relaxed/simple; bh=Jsa4HbK4S6FURQbRN/ne9XaHlbZsmdM/c5YYbi4h/0k=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=saGSwCOc/0kpxi+azr/IL4WX2WFS6BVSKVbVpgdzwOnO66q4wsaufzgf+vSqgadGuCMcgHepxX+G6uD5iqvaVmcYr3KTPkOKrx4+G7NbNTOwq9IM8RNhTh/sgl0yvCRWIMFmq7uHKa/MAuihISQextalhrZjFdCgkBwVBLhG3D4= 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=suAyCSXX; arc=fail smtp.client-ip=40.107.244.70 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="suAyCSXX" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lef/KEc9wLkDF2GT22xY9+v9cgluRzcbJUABQq20wgNk6TJ4DQAJuxcyM3rN5W0sAL7fTVj7EeaDVfSwsb9jVe2y3bqPFZg9GpP97usrQBYg4SHPwvACa//tYBKDZIh6OE+HKaQcGCkCJBJQztHTBxNM/T1x7XRVvgwOyiMDOX+WXVPA6OCIBCtDtNzgVxqYMZ/WHUTPPw5zB2BwE+Vh1i4MOv9gbf4DR+HtCcWorjF+KO0fJ6k21Lr16Jk+3DSVOSZ39YUkOF/wAcGpymC6ddrYFOx2ZGj1Zn5Xa5RYzpbK96BDK7OU1OGjhoboYWFmBRd6O89nwsi77lJpxklheA== 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=aoqNfEXCQvOFMsyE29PDc+vGXUGybL1Tiw2FUfG1Ae8=; b=bbOTVrSZauk2FhdDsQNRJ7kXK/jcEvmAbdYnxC96V1E6dRHiMLVGVwzchXqtLK7DiRHdVb8nQRj291vMpoMhX2VBjI3PTGBFTppl5lVnXNsNvIA0adrD9YJVAIweUykvWpJxF6G1XyMlXeVWOUr49xdGBbCWls3s6eBSXLrT/j7ErkucEP21S+Aw1hqHs2Dqol9TG3L6yDRAVeqtqZdLVyysT4OrbEBxDbK4oAChwYeRbjOaaS6nqYLe6CPU7uMNnmzlsMSaUz6z539rgQnez3GbCo9X25F9W5yoo0Pd/y9EkgmNNylGYiFm79PMfOIO2pYEpuRTgPulwzg/s2yPWQ== 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=aoqNfEXCQvOFMsyE29PDc+vGXUGybL1Tiw2FUfG1Ae8=; b=suAyCSXXShTV5Fui9R5YbWH3KYbRxbZqCqn0WpCJKOmkPe3YSRzSqRR4JtSAg7SJi3UQ9hHJ7Lwm0l+PadKJa/mLVaaflLILmm0j5vY0buImS7dUcAefZp2Br55kA3j8QkfUxDGL5dJVJ17r0wFD9CgBWVKI0RF2FmbliBiKn6g= Received: from MW4PR04CA0219.namprd04.prod.outlook.com (2603:10b6:303:87::14) by SJ2PR12MB8184.namprd12.prod.outlook.com (2603:10b6:a03:4f2::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8835.19; Wed, 11 Jun 2025 21:25:11 +0000 Received: from SJ1PEPF000026CA.namprd04.prod.outlook.com (2603:10b6:303:87:cafe::5) by MW4PR04CA0219.outlook.office365.com (2603:10b6:303:87::14) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8835.19 via Frontend Transport; Wed, 11 Jun 2025 21:25:11 +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 SJ1PEPF000026CA.mail.protection.outlook.com (10.167.244.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8835.15 via Frontend Transport; Wed, 11 Jun 2025 21:25:10 +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; Wed, 11 Jun 2025 16:25:03 -0500 From: Babu Moger To: , , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v6 8/8] fs/resctrl: Introduce interface to modify io_alloc Capacity Bit Masks Date: Wed, 11 Jun 2025 16:23:33 -0500 Message-ID: <6f8158ba0eebf41c9ec59e82dcdc28d4d3151c3b.1749677012.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: SJ1PEPF000026CA:EE_|SJ2PR12MB8184:EE_ X-MS-Office365-Filtering-Correlation-Id: a8324ddb-3d63-42b3-d4e6-08dda92e726c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|7416014|376014|82310400026|921020; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?0tQ3xPkvsVAD1u60ssN8KLuioknvUhYz2/g9eb4B5z62noPSFYJAH6vljF6C?= =?us-ascii?Q?BFZOxl9e4qcky1R3gzXo7fQpIogqqL4cTrHVf1zzhzmfleniO4G3ZaKk5lf0?= =?us-ascii?Q?6jCzvhzpF7WTttPdPQVhiclTpfj16Dn/y2Pd9n2zQtH3o6he2StDYau66uGW?= =?us-ascii?Q?M4BSlK1Uf4EO/N3qyZF7ZXV0CXmjTbg0O/4n6XHOKApZxSJ97CotW9QHcSL1?= =?us-ascii?Q?Z75s/glj/TLV53ggKhkg91sLN/wiIJepABBlt5gzn1Naxt7zFU22KDHnK7ZJ?= =?us-ascii?Q?ylRTDbwMxXN3AyTrqi4qzNABrElSwEJmfcPi2uyiub+76rChH8DnlnAjNDSK?= =?us-ascii?Q?KIC/urIlGp0sWsIFm/VqU8V46ssX546Cm0eZIuZavftXwfY5AT0nSlIbFWs2?= =?us-ascii?Q?YJvvKBdT24+GA5pGYhavKtB0SyhQGOLHODNOqSnkPbw2/CWrLsZboSLGa+xH?= =?us-ascii?Q?iYx/D/l5z/niCD450hyiiEqCNbdgnxlrooo8lZ0UWymEVuCgGZREv2TpY7Ze?= =?us-ascii?Q?Nx5irSuWmTAW/BZK9DNQLRjDNEU5g0poLmxVyIxTpWjfE21K3seHTLFTQM/J?= =?us-ascii?Q?WesqdnOOPb6GQfokLFJsStOX3BrYY0f4wgSyKqW4YlC6W+SxfXKwWi/M/5Sw?= =?us-ascii?Q?wAGcnB+n0nFoILHqg/HiW3gZN97jsKuTKswcGrD2CN2qXBuKZprCfSkJ1Pau?= =?us-ascii?Q?KAUN4kzc4iT1v8XI5zKPBDU1R7IS68lh4rFYzMDGONNMXVuAb4bjQPe9zPk9?= =?us-ascii?Q?0D/I4ofUIjXI0PuSf9ZXW+r492x7yWvQMHcTxmfzdsrf6DlPUV/5qYVAssAV?= =?us-ascii?Q?jKPAAic71BecQdZA4opTUMk52i1mFKnSXtUoUXeGvSzbqW/WnNR7b6/OS4RN?= =?us-ascii?Q?GIZbQSit6EmUJip+p0fpCq3CTjp6EyEjt0QUKx8cXqBa+LQo33Xb6vSlxtXw?= =?us-ascii?Q?nK6E+1T4lFswKIGP6XE7qy506eYe5e9yKiTeMt3fSA+yoLQqpUGoIuajv0Ml?= =?us-ascii?Q?eolYLI5tLaTMofyTltPlSPHQFoNfdLa4hHHZ2PbegIIkZPm27jzQLrJc2ZgF?= =?us-ascii?Q?UUGX2LvDrOPve7OCsD50ANDFWe1jBG1Nlzo0l/V2seXHagGXFbqzt+PUzC8i?= =?us-ascii?Q?NdDnvb0f+gh8s9CMqE/llb2s8QHXFbRgi/bfHtQ8CtrGK9LUGwM76oTXWaxh?= =?us-ascii?Q?tEq/T/k21glDwuDuQRhZYBnl4JUhjYWPyyBv+G7GzwC9U3mc9JtBJdSp6NHi?= =?us-ascii?Q?QWKa9kbPyOp0I6rHVZkZb2uxxoUp9GjNQAd+tYodG4T60s76kUNMi9BHrCy6?= =?us-ascii?Q?nkbyOUeYrfMXv2SJWO3lfickdBuNdnR5rtRuZ9PTDuGiaLgtmQHX+8mX0rhi?= =?us-ascii?Q?xbOA4IARJrb/sYJJeNoDWwdRgkXsbpIHhHoBO+FTcNjFHGHRslPYyvX7InDQ?= =?us-ascii?Q?UTrvyae3h/6IBlAD63tMYmA4YNZDdqqOy2rvQL20N8IObNWdaV7ZU/3XUXMV?= =?us-ascii?Q?DJKkklGSXMLino1Rb8ofVgnxshDLHzRT0KaJ+JOekZkoPoYQdAsdwYyZRQ?= =?us-ascii?Q?=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)(36860700013)(7416014)(376014)(82310400026)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2025 21:25:10.8539 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a8324ddb-3d63-42b3-d4e6-08dda92e726c 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: SJ1PEPF000026CA.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8184 Content-Type: text/plain; charset="utf-8" "io_alloc" feature is a mechanism that enables direct insertion of data from I/O devices into the L3 cache. By directly caching data from I/O devices rather than first storing the I/O data in DRAM, it reduces the demands on DRAM bandwidth and reduces latency to the processor consuming the I/O data. "io_alloc" feature uses the highest CLOSID to route the traffic from I/O devices. Provide the interface to modify io_alloc CBMs (Capacity Bit Mask) when feature is enabled. Signed-off-by: Babu Moger --- v6: Updated the user doc restctr.doc for minor texts. Changed the subject to fs/resctrl. v5: Changes due to FS/ARCH code restructure. The files monitor.c/rdtgroup.c have been split between FS and ARCH directories. Changed the code to access the CBMs via either L3CODE or L3DATA resourc= es. v4: Removed resctrl_io_alloc_parse_cbm and called parse_cbm() directly. v3: Minor changes due to changes in resctrl_arch_get_io_alloc_enabled() and resctrl_io_alloc_closid_get(). Taken care of handling the CBM update when CDP is enabled. Updated the commit log to make it generic. v2: Added more generic text in documentation. --- Documentation/filesystems/resctrl.rst | 13 ++++ fs/resctrl/ctrlmondata.c | 4 +- fs/resctrl/internal.h | 2 + fs/resctrl/rdtgroup.c | 89 ++++++++++++++++++++++++++- 4 files changed, 105 insertions(+), 3 deletions(-) diff --git a/Documentation/filesystems/resctrl.rst b/Documentation/filesyst= ems/resctrl.rst index b31748ec8c61..ae1157dcb4a3 100644 --- a/Documentation/filesystems/resctrl.rst +++ b/Documentation/filesystems/resctrl.rst @@ -181,6 +181,19 @@ related to allocation: # cat /sys/fs/resctrl/info/L3/io_alloc_cbm 0=3Dffff;1=3Dffff =20 + CBM can be configured by writing to the interface. + + Example:: + + # echo 1=3DFF > /sys/fs/resctrl/info/L3/io_alloc_cbm + # cat /sys/fs/resctrl/info/L3/io_alloc_cbm + 0=3Dffff;1=3D00ff + + When CDP is enabled, io_alloc directs traffic using the highest CLOSID + linked to an L3CODE resource. Although CBMs can be accessed through + either L3CODE or L3DATA resources, any updates to the schemata are + always routed through L3CODE. + =20 Memory bandwidth(MB) subdirectory contains the following files with respect to allocation: diff --git a/fs/resctrl/ctrlmondata.c b/fs/resctrl/ctrlmondata.c index 6409637b4de6..f3e5e697945c 100644 --- a/fs/resctrl/ctrlmondata.c +++ b/fs/resctrl/ctrlmondata.c @@ -148,8 +148,8 @@ static bool cbm_validate(char *buf, u32 *data, struct r= dt_resource *r) * Read one cache bit mask (hex). Check that it is valid for the current * resource type. */ -static int parse_cbm(struct rdt_parse_data *data, struct resctrl_schema *s, - struct rdt_ctrl_domain *d) +int parse_cbm(struct rdt_parse_data *data, struct resctrl_schema *s, + struct rdt_ctrl_domain *d) { enum rdtgrp_mode mode =3D data->mode; struct resctrl_staged_config *cfg; diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h index 10a3188ffa54..755f23934295 100644 --- a/fs/resctrl/internal.h +++ b/fs/resctrl/internal.h @@ -382,6 +382,8 @@ bool closid_allocated(unsigned int closid); int resctrl_find_cleanest_closid(void); void show_doms(struct seq_file *s, struct resctrl_schema *schema, char *name, int closid); +int parse_cbm(struct rdt_parse_data *data, struct resctrl_schema *s, + struct rdt_ctrl_domain *d); =20 #ifdef CONFIG_RESCTRL_FS_PSEUDO_LOCK int rdtgroup_locksetup_enter(struct rdtgroup *rdtgrp); diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 0c2d2cf4baa1..f6c44fae4b72 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -2037,6 +2037,92 @@ static int resctrl_io_alloc_cbm_show(struct kernfs_o= pen_file *of, return ret; } =20 +static int resctrl_io_alloc_parse_line(char *line, struct rdt_resource *r, + struct resctrl_schema *s, u32 closid) +{ + struct rdt_parse_data data; + struct rdt_ctrl_domain *d; + char *dom =3D NULL, *id; + unsigned long dom_id; + +next: + if (!line || line[0] =3D=3D '\0') + return 0; + + dom =3D strsep(&line, ";"); + id =3D strsep(&dom, "=3D"); + if (!dom || kstrtoul(id, 10, &dom_id)) { + rdt_last_cmd_puts("Missing '=3D' or non-numeric domain\n"); + return -EINVAL; + } + + dom =3D strim(dom); + list_for_each_entry(d, &r->ctrl_domains, hdr.list) { + if (d->hdr.id =3D=3D dom_id) { + data.buf =3D dom; + data.mode =3D RDT_MODE_SHAREABLE; + data.closid =3D closid; + if (parse_cbm(&data, s, d)) + return -EINVAL; + goto next; + } + } + return -EINVAL; +} + +static ssize_t resctrl_io_alloc_cbm_write(struct kernfs_open_file *of, + char *buf, size_t nbytes, loff_t off) +{ + struct resctrl_schema *s =3D rdt_kn_parent_priv(of->kn); + struct rdt_resource *r =3D s->res; + u32 io_alloc_closid; + int ret =3D 0; + + /* Valid input requires a trailing newline */ + if (nbytes =3D=3D 0 || buf[nbytes - 1] !=3D '\n') + return -EINVAL; + + buf[nbytes - 1] =3D '\0'; + + if (!r->cache.io_alloc_capable) { + rdt_last_cmd_puts("io_alloc feature is not supported on the resource\n"); + return -EINVAL; + } + + cpus_read_lock(); + mutex_lock(&rdtgroup_mutex); + + rdt_last_cmd_clear(); + rdt_staged_configs_clear(); + + if (!resctrl_arch_get_io_alloc_enabled(r)) { + rdt_last_cmd_puts("io_alloc feature is not enabled\n"); + ret =3D -EINVAL; + goto cbm_write_out; + } + + io_alloc_closid =3D resctrl_io_alloc_closid_get(r); + if (io_alloc_closid < 0) { + rdt_last_cmd_puts("Max CLOSID to support io_alloc is not available\n"); + ret =3D -EINVAL; + goto cbm_write_out; + } + + ret =3D resctrl_io_alloc_parse_line(buf, r, resctrl_schema_io_alloc(s), + io_alloc_closid); + if (ret) + goto cbm_write_out; + + ret =3D resctrl_arch_update_domains(r, io_alloc_closid); + +cbm_write_out: + rdt_staged_configs_clear(); + mutex_unlock(&rdtgroup_mutex); + cpus_read_unlock(); + + return ret ?: nbytes; +} + /* rdtgroup information files for one cache resource. */ static struct rftype res_common_files[] =3D { { @@ -2198,9 +2284,10 @@ static struct rftype res_common_files[] =3D { }, { .name =3D "io_alloc_cbm", - .mode =3D 0444, + .mode =3D 0644, .kf_ops =3D &rdtgroup_kf_single_ops, .seq_show =3D resctrl_io_alloc_cbm_show, + .write =3D resctrl_io_alloc_cbm_write, }, { .name =3D "mba_MBps_event", --=20 2.34.1