From nobody Tue Oct 7 10:00:52 2025 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2055.outbound.protection.outlook.com [40.107.236.55]) (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 30D76EAF6; Thu, 10 Jul 2025 17:16:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752167812; cv=fail; b=E6w6DW7A6NKVGwA4qLp6JnrDdjQ2WGV6o/TbUR+DJuiGSCIOb589wrm1U6xWJrTrmfQZkYnycXOMeW/R7v4P1tQVQ1w81C/00PXqsK4VT4Jalt7wd/W3zYTY9ql8Q3f5vC/+novMXp4ggbhzg6g7Nc4HK3kg8OKMUGibqTROc/Y= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752167812; c=relaxed/simple; bh=lwB+bj2flAzhjaaiNbl+g11vlFbgnsdeTJwelOnX9RA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ls75ABuDxKblLOn9pRrE9IzG5aZNCYHgtS+tdGePpwDY46X7oGWQTdLD8Y7FsNzA7O8j60WbS4Li6g1RZFkKmw1bAaWCKavWrEDa3tARWs+wEkpz8Wrcgqmlea1mT5jIHfsvKHcCdwSaO/4HBy4wjm18wVeDtNVJoarzraxXlCM= 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=kfK5Tq/i; arc=fail smtp.client-ip=40.107.236.55 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="kfK5Tq/i" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=isDhFS6R3gvp9VcIIb5ojGi6L+8C5eZG5vDZiwhmGWA/8F98iSdX/ShZRloLD3/GS0XHx/BQ8PtTanB6IFOUzZHFKuDKyz4yBIfVQBQR7SEy13N5GqxEh57oJvcS3TIZyE02csnmU7MapBVyfoEfQCfJOEBipcmVUmaQW2o7lo1ct/niCPqJPI9e/9gQpUSsQius3RogS/MCGJp8BR8Ay6Pi8GVSNJ/5g6WYYA9+qupS/BQIihiGdR+I8F5E6pPbpI5uimvr4M/znZUFanx6fLh01TkbuMhZTLQOcBLQS8mi0M9LUWN2E2V8Txv4xcnEjxZIB0ajHebCMb/MJ5rh5Q== 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=Y7fBgOIQOjbLVirG1MLe/l0O+DIC3gAfrJG8lhgJHWw=; b=l3rPXqcyIArs88EnzytXR4IP7rvbszlbYkOK5hJvkD+WWQIBjXnXw3B2OXCVmsShVDSp2Wj/QXtYkT7HnhxKxMbbG94vWIQesLWXsVE8rhwVtwi5rU6LGOQfj0KMPzwl2eppKvh45wjedxnAeSKdvlsdvBJVx26tBtEginAk+/JuYGZUR6Zl6ttVGx2z6zbh2Xd1U8WgPQxXoSHLRwHVgCoB8VBVAQsK144hPgXmJP6vcxNUCY1riQJIjCCUhmspFLuo7cWr6q/TBzKAsOMpmx0FN2+JdERCgMA5flJ9SB+K8pOQni4zRG2lNuQec53Cd2ag8t1I4XegDXm/nmJOJA== 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=Y7fBgOIQOjbLVirG1MLe/l0O+DIC3gAfrJG8lhgJHWw=; b=kfK5Tq/iGHOA3xldPIFVuvC4oJL71uI9VPV5MJ8Kg12ClnT7GT99929GF2mh33oYD5xqLRcB/ojuB9pAo96C828uD5Ju0FLPn22RXRiK532L9yGEvYM9viWjaMhaAmdm/2teP/gU37+D9q6wvXj5qXl2nQ46DOfMvfefIIDRPe0= Received: from MW4PR04CA0202.namprd04.prod.outlook.com (2603:10b6:303:86::27) by SJ2PR12MB9238.namprd12.prod.outlook.com (2603:10b6:a03:55d::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8901.27; Thu, 10 Jul 2025 17:16:44 +0000 Received: from SJ5PEPF000001CC.namprd05.prod.outlook.com (2603:10b6:303:86:cafe::2b) by MW4PR04CA0202.outlook.office365.com (2603:10b6:303:86::27) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8922.22 via Frontend Transport; Thu, 10 Jul 2025 17:16:42 +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 SJ5PEPF000001CC.mail.protection.outlook.com (10.167.242.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8922.22 via Frontend Transport; Thu, 10 Jul 2025 17:16:41 +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; Thu, 10 Jul 2025 12:16:39 -0500 From: Babu Moger To: , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v7 01/10] x86/cpufeatures: Add support for L3 Smart Data Cache Injection Allocation Enforcement Date: Thu, 10 Jul 2025 12:16:15 -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: SJ5PEPF000001CC:EE_|SJ2PR12MB9238:EE_ X-MS-Office365-Filtering-Correlation-Id: 06053634-978b-45bb-251f-08ddbfd589c5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|7416014|376014|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?zVIGxZpR25P3JhSzXpf2WJ6VxhPRnjo3dGXP4VTBiLpC5HQI4V0QBxTQprRv?= =?us-ascii?Q?pEq+X1jEXiyakirE5qd6QwSerfIyaXQR+GanFVnDrePLHIE5w+T0BcAbNYln?= =?us-ascii?Q?NehwvNolQXq9fxt0yXc3q+NUklDPJxPE3bSqn1WjfOaJLEgTYTQgNCFg1Uzk?= =?us-ascii?Q?oVxlGTJ2kv6MLLFw2PZOM+QOg3svIqaq/LqnMti5gQZXsXKAmy7ajBYKuM3B?= =?us-ascii?Q?kNgbCtUP99bo4IUw5Ug//ydtrC24ECX2n9v6ECbWjBwDeXGkH/f1bETWDiAN?= =?us-ascii?Q?G4g7NrevKAe7nq6GuAsfrugdlTt6L3guxk2BRdyyoZfiJh4zeCfqge0YPvgr?= =?us-ascii?Q?7Kvbp9qb1LPyGKhwWlkB4N+Y/vTP7ZmF+absXujX2zg9SNtSGfcoa82lNVQ/?= =?us-ascii?Q?ZsTwLTeEUrVg82gG/oz2XbQF5vxkCHf9zJNhy2ecavMV2ndoy5SS/Y4SF5ZU?= =?us-ascii?Q?EPRvu2fCmwS7/Fs9Fz1X5CRQNblp1xyjGBUlbE4J5uOerw4ChEs+l6g1HBqi?= =?us-ascii?Q?jxiNIb0ZtoxhvgahTHFFbxYRONnzXtbSmyjyisWB6uiWi9lVv79l4fSHV1yt?= =?us-ascii?Q?o+L9pHD7yqqzg/t+YDlKB1pqwfa1kNPCgnj0kbiWTVGb4jJEURX5IHS5UQrb?= =?us-ascii?Q?Ocey1MZ6H+k+pEudTebACJOtKBUsh0ZMu16JJ7+c4C30NZ6Wo1nkYfTaDJwg?= =?us-ascii?Q?ROi+r1wwsY7maHtXT/Lg6BhFTC2foXZJ1plIaMAqBxESDdCr7EGG51AKKUG6?= =?us-ascii?Q?+y0oi4obJBqSa8TBJh74J+36HomcRCtfTwovFCUaCM51a+1c/G8N+vHSLXAl?= =?us-ascii?Q?3Hzp7f0IVAE65ligM50Y0epVFo0iUpWsXIgQci6gIRh2hBu+LPUfNXCY1Etn?= =?us-ascii?Q?yOxewL0ZBQ3Cx7d3vup0uxll2eGSeRSs9j/yOvcSrnnloTUGkt/wYvTUF980?= =?us-ascii?Q?uoCVkZ6OGbC64nfe9HjqMItdhDkA3H8Oxed0Tm2sbFHk/FCmW1RBVfBSRViv?= =?us-ascii?Q?YNojfJWrBFDuzCEPUmqeoqufyN7SW/1inEsDRsZVRu6dVtPYMsAgQ0Hd17Ad?= =?us-ascii?Q?TAxqc+5Q6oGMbchTzag0BUa6U83Lcu/y1UJGCQ/5NIEtnNoN2HQpW3BEBJpc?= =?us-ascii?Q?WtS3ovtxw8ldZ+9vNaLPojxIFdn6egOV7UkTkGNoejfJWOPn8Jd/VvyG6TQ3?= =?us-ascii?Q?LCXPrOwXb05TS36x9YlmuFak3TcPvIlfv76+2bzQ5GtahDDMYSlUVj7oeE7S?= =?us-ascii?Q?RoyKq3zQNah3L0Aoma6ufBeJSII4CDgEAcYI/pRutACiUqWwnFlboSVLM8B8?= =?us-ascii?Q?DMYy+slP8jRrmk9PCPPBMyu9e+KFa2kE+MdGKb3V3dtawi8sn+ZS4GJPq9qP?= =?us-ascii?Q?NtJnXaP9gzdNURBkfcz9iEbs/U0rWpZpvHqf6YDA3Ewoxv9N7qMIh7QRvHc7?= =?us-ascii?Q?9d2L1W56qSZDfsKreiyeCiWKh4YNXLgIopWF1smuAtT2Y2MerupvQvl2TVSr?= =?us-ascii?Q?m0yCBlwmz7XTQyZgmpdVOQGDxicBOuyHBYIg/oIgHe83DUVrO2hMxZZbIA?= =?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)(36860700013)(7416014)(376014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jul 2025 17:16:41.5512 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 06053634-978b-45bb-251f-08ddbfd589c5 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: SJ5PEPF000001CC.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB9238 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 Acked-by: Borislav Petkov (AMD) Reviewed-by: Reinette Chatre --- v7: No changes. Fixed few conflicts in arch/x86/include/asm/cpufeatures.h arch/x86/kernel/cpu/scattered.c 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 602957dd2609..db020bd60edc 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -494,6 +494,7 @@ #define X86_FEATURE_TSA_SQ_NO (21*32+11) /* AMD CPU not vulnerable to TSA= -SQ */ #define X86_FEATURE_TSA_L1_NO (21*32+12) /* AMD CPU not vulnerable to TSA= -L1 */ #define X86_FEATURE_CLEAR_CPU_BUF_VM (21*32+13) /* Clear CPU buffers using= VERW before VMRUN */ +#define X86_FEATURE_SDCIAE (21*32+14) /* 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 b4a1f6732a3a..b22bfe81d262 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_TSA_SQ_NO, CPUID_ECX, 1, 0x80000021, 0 }, { X86_FEATURE_TSA_L1_NO, CPUID_ECX, 2, 0x80000021, 0 }, { X86_FEATURE_AMD_WORKLOAD_CLASS, CPUID_EAX, 22, 0x80000021, 0 }, --=20 2.34.1 From nobody Tue Oct 7 10:00:52 2025 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2078.outbound.protection.outlook.com [40.107.92.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 02EC72741D3; Thu, 10 Jul 2025 17:16:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.78 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752167815; cv=fail; b=DgYyw2dSgEi+6eMq4WRESq1Uy0VRfTKeZD2r8LYV2/TcrHwkSlEK50P7/JazPyu0MJe7N+e+zLexaQczGqGW+YRZfFrup1+/yq5aRjDhFP/35/vp/5icJhVm3qxDvzuM3diV2NaaztGGbP1LuTuPR/jmk9YUcVlQo2i+KiCMey8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752167815; c=relaxed/simple; bh=YddKltoFt7FVA79q5akDasErb+YWdf+quOvJ6Oc7gto=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=clpNNSYn5c9owhUgLn1MAWgo1x93HgK8tTI2tmcO4y4TSiKKmy+S2IMqE+ufGtOUn9cPjKfA6uk89ogt/LghAlQZhemImp2QoNHWtO6tLXSfXeMD+tmvz2x8dj1DaVkkz0iipz+FxV+WxoR4d1n9TSQU/ZcLZKO4wa1IFakLH6g= 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=whZMpKOh; arc=fail smtp.client-ip=40.107.92.78 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="whZMpKOh" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=L4isRVKiLImCVyO2hEjEk7ihTK2vfyz1aTiw3YykMgQuBAcV5uYd3zVbl9gP6QKBBWAY+gjq6Tpxrbf7XtlPTNt2jWF6LzhIeWKnFHOiAGWhg0Ps4Wkjn7iYF/XkNH1XYsFxDKdaXiTGqTAek24fBk4zZFdrmsECl/f7c0ibIzV5G3uPxqdrKq6tIl2t9NE5nHZlGpGLPMu+pNESq0K3C0KiAnLEBdPdWrGKaarYdqEdZfUPMroWq+nuqflBCecSxaYvw9UEoEukXqRLgF7fHRrfElGIbuzX2RAnPhrvvxh5SJ3oeJd99ckZ4BH5OEnMNebdE7H3LICvQQix5TDLpQ== 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=T9ZhiYYKahYO8iixfeniz6AMzC0pG21egg3sut6+rP4=; b=KKzrjWVBQ+xaJ9TvkHv0DynYC+8QXcu8gy28+W/7itpxDDbJtBv03XPcpZxqt3xNZ9ediZW7S1kn7BYPlmMAR2S8CCnbw94PeeGZc79Au3vNyP2VKivalrGp6A8jJ23LPeLFzau+yWJMGpy/LMENsZtKuPcqS4CalxGUntH2PFbCQ2xv3t0SDvsTXoPho2jCBXg+iktKMyDET8aplCq9CoFd3sOjWu3RajmSlM8RNB+7mErFmkH7Luyo0hC3MH0naQmdY+xYewr3kgSmg+FmXl5suyBOFYPDBoMYAy4AKvwidW5Yl/ogzxwacUnAnkFTFhAYYoa2zeVfmt0Ls/K+Lw== 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=T9ZhiYYKahYO8iixfeniz6AMzC0pG21egg3sut6+rP4=; b=whZMpKOhWTzGsyuc4p6wRQFjpmXsALUIUr6KxotEhjE8bvmD8yahHVLb1JpxEmHhWkv6haHXzBv1/g7vEoQTavz37PF3jS5QeiDLkDmdPMN0W4ZFPZCUpgAxoNqzKE1M3fst6i27VDvIWGkS8iHKyZ+nYbnyOU+qWtHxkx3GOKg= Received: from MW4PR04CA0050.namprd04.prod.outlook.com (2603:10b6:303:6a::25) by LV8PR12MB9449.namprd12.prod.outlook.com (2603:10b6:408:204::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8901.28; Thu, 10 Jul 2025 17:16:51 +0000 Received: from SJ5PEPF000001C8.namprd05.prod.outlook.com (2603:10b6:303:6a:cafe::46) by MW4PR04CA0050.outlook.office365.com (2603:10b6:303:6a::25) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8922.22 via Frontend Transport; Thu, 10 Jul 2025 17:16:50 +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 SJ5PEPF000001C8.mail.protection.outlook.com (10.167.242.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8922.22 via Frontend Transport; Thu, 10 Jul 2025 17:16:50 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 10 Jul 2025 12:16:47 -0500 From: Babu Moger To: , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v7 02/10] x86/resctrl: Add SDCIAE feature in the command line options Date: Thu, 10 Jul 2025 12:16:16 -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: SJ5PEPF000001C8:EE_|LV8PR12MB9449:EE_ X-MS-Office365-Filtering-Correlation-Id: e5f8cb55-59be-4f10-7c78-08ddbfd58f20 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|7416014|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?GKN3ihFcoOYdgixWVF63nHCAq3xAUq4r6SXeYZQajqEl3Ti/BhynKkb+lZtZ?= =?us-ascii?Q?d2cqlXn1VvyxUYzZ2Jm8tegngcCVVkQZIQW1BhOC505TeXbmdZjmVsiyfv0X?= =?us-ascii?Q?86P400d9wjpK/S1VlGV2lVsyx0+IZxz/4+aRwXVce777BFK3usc4YieEimZu?= =?us-ascii?Q?juPqhm3enGvSDVaJzfzKhcVvBkzJkZDzLWuL7NAffjb7OpwVclZfvgtmWbDe?= =?us-ascii?Q?lakKaWtW1gNShsfERk+PZ36OP6aiPWEqnaL/8R/w2RBZ+JpeVtjjLcIZ68ON?= =?us-ascii?Q?oQ3OBi/Q++RJXVa783R0e6CtySMyiJdSljLyM8kv3B/Bk2tpfEIhs2TxOpvo?= =?us-ascii?Q?4LWDUyVpv94jEHaS7mBjcF6r4a/4tbXINltYyf1jPCYa6xE4p+cLhbJCFt0i?= =?us-ascii?Q?5X7F5PECVPR95W5WWRDyvuxBvks4tGRhrXToEOwE3+NSirp+uhWgBd/QwzEh?= =?us-ascii?Q?/7gxX+3tG9kpZaAMlKo76XgcURWq/N+k+dtFjenGoeFlBJYYPDU5h2sB2zjB?= =?us-ascii?Q?XS0RCxNP++/rrEqXa/GkcBJGaLyHo5ohwe+mJwUQ73+v3kJoKAaOE057RcZG?= =?us-ascii?Q?X8cd73pJ5HDj+c9KXOIDLs0tMuQzqOz1+3OXqpFEoeNNKLvcMAp6hI3aR44Z?= =?us-ascii?Q?vLEoBDcM9WDRF+6V5f0zS8nnV9b5fwzuWoTOPoVoJxk1SSVWHuXxV63/W9tr?= =?us-ascii?Q?96Y/+pwaY1gPI1qHWzoywI1PqDwTeLFs69VW/WrZupbw0kdPgSooiAFllg3z?= =?us-ascii?Q?307b2XPlGbwNL57Y/nbw/WR9gWQDzoft8+FuoN8BrXBddKxVHoh/LwUokmEJ?= =?us-ascii?Q?5vQ0AjH154NbPnzLGaqX5SIO2UTZmxm9yC3TWFhyGIHt5hwdchDV0EyG28Xw?= =?us-ascii?Q?XqYULyqP0tVH8EbPSxZXW75pNI95peGmf9+NEEW9O4y4r4Is1S4qdrvLB4v6?= =?us-ascii?Q?e9eFAgN6YQ4TXloZ3jR6aLDI/2apQ8WTBxoTMZUCIPVZAHVMc/mS4F9s8m4p?= =?us-ascii?Q?7CTdpzw3HtpZU6jmzt8Ym8CxiAPywFph6Et6Ah4dz+dSQEt0ehu9SDjrKj/B?= =?us-ascii?Q?LoKZXT+1W7rlfcT4MURJJFWeFyQPVGMghcfPsNxbaZXZbkgkCBpz4d6fVOo7?= =?us-ascii?Q?a4s1MIuaFJitgCW7H49WQpr8SfF4WVH2wunp3tTkeiYpXX3JwzGj2lMOllMa?= =?us-ascii?Q?z5ke8b1tkKFhPNin151Aj4IUW6U65+0CgaIS20nfwRnmcGY1xW5lqpc3k5nE?= =?us-ascii?Q?tNirgx1pu/KQCexnmM2rVSax1ooy7O2i4SLfWcbU/b86ez2Hjs5JKqcbYIRT?= =?us-ascii?Q?128ft+i6aydvVo2dm3SV/F87BaAYjgHflm6C101LC0W4x06BqLUwBpcU+QCL?= =?us-ascii?Q?loPTK1Ooa7SxTot7pOj+J2emW6YVmuZBnbOPyYK8x6bOtp3nP6qO6iaWYrMc?= =?us-ascii?Q?g/6be/PGclq4ELK1p1oiISgB2i+nieOnJbWsEZevNKEXlMkxuXS4denbUoEA?= =?us-ascii?Q?BZEYhEb2jrsqPF0+uTxG9kYB1HZ1lQVvEP1W?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(7416014)(376014)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jul 2025 17:16:50.5373 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e5f8cb55-59be-4f10-7c78-08ddbfd58f20 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: SJ5PEPF000001C8.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV8PR12MB9449 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 --- v7: No changes. v6: No changes. v5: No changes. v4: No changes. v3: No changes. v2: No changes. --- Documentation/admin-guide/kernel-parameters.txt | 2 +- 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 07e22ba5bfe3..aa1c5948bec2 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 187d527ef73b..f6d84882cc4e 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -707,6 +707,7 @@ enum { RDT_FLAG_MBA, RDT_FLAG_SMBA, RDT_FLAG_BMEC, + RDT_FLAG_SDCIAE, }; =20 #define RDT_OPT(idx, n, f) \ @@ -732,6 +733,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 Tue Oct 7 10:00:52 2025 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2081.outbound.protection.outlook.com [40.107.92.81]) (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 E755E274B2A; Thu, 10 Jul 2025 17:17:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.81 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752167823; cv=fail; b=A6M7CUZnW/ffloqbPRtFiW3229uS//blBaUmGdSaUzxKveFYMXTA1UVZuq4fvzdbjQ7u4W4X97BgbxLxWgTkO0hIKVI8gcDaMUki7D2f1XcJ7zZTI31LbSZ5YDPA3gzeYc9d2Sic1YOlInUBhZNiD2kH8CbhgjbqN+XqJrgt1EM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752167823; c=relaxed/simple; bh=SWJ7SVjPYEsR8uN2PivcKTONHMwGGUJCqOSqEigbZtc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=CjkK2NBjaTAefB/UmTIpkj6Imi8NIMejK/J4lfbC0hp1greYa0GHZTmjAZ8NcW+LWlOZCDzFoqllJIAGT/cxyjjrM+qpouWD5yJtJh9G540hEg45+tq15Jp73JOZ3cgHTnHBRc08lgEed8FO4vTWDz6grOJg1pGpFv/6ggFylZQ= 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=XPJV8V/4; arc=fail smtp.client-ip=40.107.92.81 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="XPJV8V/4" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cz1YHU42ubs2ySUHwHj54CkUZcICtEGyBpUo3vk+4JThYVcua0DPI0bKUXd83mY4KjPW8LLjZ7KWnYNmybty4kz4hfI3J5CkW+nvivDvB+s5itl+LGptv+ZVbT5v+qpz97WCo0KwofvbeQLC66vlrdfrHvJM3bi0OgNuShQ+PLaTQBGfY3qBORO4RDhr0JGTwyYWxGXADOJ5LlvHy0QszXIkWlXK8+cLPR41gt2fT076nUEvNkvPiURUdRT5m9C/GC/HaPX4dAnGopsI/WJI79FFvsjagM/evKMaT3J2B63IJMn51ciKHLYqepA1l8uWPTqPjpG4v05nhp4TDwFlfw== 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=wlj6z9xppHdazIjOylpjfqmKb6BtZs9xxp2akWYx2sQ=; b=RE4LfrfkztBQtDEom+tf9GulkFw6E4EUhKrP3gLo5BT2nHyHFNciPaAJcpCBstjBLvXlbdE6k1p4iumSGXFNzxXPY1fhCzxn14nJts+/oM08iOA48yn+MTPi+4aAvRuSrKmher7qqDSczZKgWbNpLiTWoQfxr/hWySejHTT7RjcreLyEGRUF41BIM0uh/W0V4T5EgPn2xeP0V3w638B2erioArxnO+NgUgV9qzFoe76mhJMHpQZdVogRs3k2ZDoj/rPGOG5+qz84GbzSZr7sUL3h4NM/quHQwboldfO2Ute4jR2kRR1IuFuB0TX4q20eXctgVjVF6/hi+Y957hGxdA== 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=wlj6z9xppHdazIjOylpjfqmKb6BtZs9xxp2akWYx2sQ=; b=XPJV8V/46odMJND/h0MGGryD8UlA4+aKoR5ciIRlgTUb9Vzmb1U4QZZ3MHFprtAXgBY6ubkqqg1x8w+GRZF31mRvFV0rSZKIquR6aNd7BhYzczSo6/OQXML/uNKYLbNyfGRFCDPOtd7zDzZ5Y4H6p8Tpd2LUn9piMEQ4CI4VkcE= Received: from MW4PR04CA0206.namprd04.prod.outlook.com (2603:10b6:303:86::31) by LV9PR12MB9806.namprd12.prod.outlook.com (2603:10b6:408:2ea::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8901.28; Thu, 10 Jul 2025 17:16:59 +0000 Received: from SJ5PEPF000001CC.namprd05.prod.outlook.com (2603:10b6:303:86:cafe::d5) by MW4PR04CA0206.outlook.office365.com (2603:10b6:303:86::31) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8922.22 via Frontend Transport; Thu, 10 Jul 2025 17:16: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 SJ5PEPF000001CC.mail.protection.outlook.com (10.167.242.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8922.22 via Frontend Transport; Thu, 10 Jul 2025 17:16:59 +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; Thu, 10 Jul 2025 12:16:56 -0500 From: Babu Moger To: , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v7 03/10] x86,fs/resctrl: Detect io_alloc feature Date: Thu, 10 Jul 2025 12:16:17 -0500 Message-ID: <998f42d5c92cce9d7d83bcd54d25761242839b4a.1752167718.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: SJ5PEPF000001CC:EE_|LV9PR12MB9806:EE_ X-MS-Office365-Filtering-Correlation-Id: 5c8ccb06-163b-4e50-ee7e-08ddbfd5944e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|36860700013|7416014|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?vV40I+TDepr15nAPCsPhzJXGxBAUQEjE/zWt4/9QLp52ZBk5vtBzlBLmWZyx?= =?us-ascii?Q?l6IH5vY88CwzJX2qVfLT0DiVl7m+QGlbvjKeU2AdrF9gMQ1xoTReHzVXQD6+?= =?us-ascii?Q?LPbumRjmlF5f/KLRKecZT7FZmVaKs6E5AczSU77rSGnEMDyn39AUQoHriGWw?= =?us-ascii?Q?VL3RmwsLakfJxCvXeD3E3UWMcdoyPeC3KOeaCZX1QD4CqUqQidzTUoiLoD07?= =?us-ascii?Q?jVl+0DS5c35X6+HqLlmWYW0K+KM99o6K+/yvSffLzsSJetx7Vnf0TsKNTUkF?= =?us-ascii?Q?A18C70GrXRr+HBzQGZo67g1/PCa7yq0ITH5J2/aWdGSfM7iG1DYcD9pFC6lG?= =?us-ascii?Q?rPYp9qcOqu9O4BYFvynFBUOQW5cihe3Q46rSLbD3gilQYTVJeByxnD16A6RQ?= =?us-ascii?Q?oUM/kZfDPCCYyWFEGnyo7ktwLau/tY4XyyhiYp0soSKDQTSVNBVSq2VsnnYg?= =?us-ascii?Q?MS3n/Y2njydDyBukOEiDxuCWh2++hDZAaDEVcSOo5LfGjALRlUieoUyRPN5W?= =?us-ascii?Q?wRLFiHpPzAFRMAOFydiJtcYxLhpiIacXjRrblFHefHXNtt5/kclbg06F+PHd?= =?us-ascii?Q?53oWgPPAtAqXoCpuFSxbc7X0FbVGmWyBtChUOHhBd2bH+G7tonvlfvc4yHrj?= =?us-ascii?Q?npMMYBY/zg2IqsQzRUjVRnNYvPbr/m7wFeP+7uRXFUNP0G/KiYalKzCSlZsU?= =?us-ascii?Q?eqW6Vkf5gtxoHInXbVCPgeRIaNE3sesx09+KHqMHPKLgUwEEQjkOteLJP5Q7?= =?us-ascii?Q?DEvtA2Xg1ip5UvY72Alc9WjCzkb6dBC7AXInRUeh8WH1xfgjlV8eBspfRKjC?= =?us-ascii?Q?U6L8zUcSyb2Ik2A4eJIepECFYIUqTxiVu2c2wpK9qf0POKeT+cDaaiRtclXc?= =?us-ascii?Q?xippVqrRftTeoqI7DGYMbdtFrwPM4CQgro5vnMBWF3Sqflu7Ou+MadPWi5ub?= =?us-ascii?Q?dnalAf7aZOE+N9pMdadNf/gGJz4XVvb4QMN39li2ywBSELYBqoB5GCBfskX9?= =?us-ascii?Q?IWMAC6RLamNLk6aikIF+jy4yA+U9tMpg/ffJ6IeyOoXK+hLNoFXRK95FukzJ?= =?us-ascii?Q?yIB/oRSbW5v3VgxYXHRwWr6f4r6It/+mzH6c0vEe0/H07LzoY4QnAp6d+7sG?= =?us-ascii?Q?CF5TeyEmpnUYIP9zWMnVu7bv0bPQqXs7B2S4DcmfZRYcrnRcPsic5/AdSZ9u?= =?us-ascii?Q?UnPdVAM/SYIhu/6cXiOpWfl/hKA4GyP45R//xANRbDL0cqa/LlN3QOlNQiY5?= =?us-ascii?Q?F9fAh/O8hUonLb2Ktb2FQtc4AsCyRlTeGiJ4YdGJFTKeoc8tyuvP2hjXxF8F?= =?us-ascii?Q?R4up3Gj22QL3WsT3dicb5td20M6Hi6M8iU0yCiCm8H2VhxHzbY3LxuY1/eZk?= =?us-ascii?Q?LuQqbO5AcSoTf2dd2gwrSLyz/yJipKcJhcDFNGeoBOnF14Q8vNKUYbpfgkwo?= =?us-ascii?Q?Ap5zW0oSEMKUpejskFHU3GaD0FiC+7z0SYIOF7PhHuU8CxoD4OmoV5kh7bMc?= =?us-ascii?Q?mxkDZZcRe3GMb0Fnp77KhWPv6J/6lZPY5F77?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(36860700013)(7416014)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jul 2025 17:16:59.2323 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5c8ccb06-163b-4e50-ee7e-08ddbfd5944e 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: SJ5PEPF000001CC.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV9PR12MB9806 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 reduce 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 cache can be allocated for I/O traffic. Set this property on x86 systems that support SDCIAE (L3 Smart Data Cache Injection Allocation Enforcement). This property is set only for the L3 cache resource on systems that support SDCIAE. Signed-off-by: Babu Moger Reviewed-by: Reinette Chatre --- v7: Few text updates in changelog and resctrl.h. 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 f6d84882cc4e..1d1002526745 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); @@ -842,6 +847,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 6fb4894b8cfd..010f238843b2 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 configured + * 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 Tue Oct 7 10:00:52 2025 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2048.outbound.protection.outlook.com [40.107.243.48]) (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 EDF512F0031; Thu, 10 Jul 2025 17:17:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752167838; cv=fail; b=QB/+eBk3S8hfHL/AnyVq5vEifRjus74iRKrgj2kvJ3ZwDk6LghuJ+N035+9mtc6WmEONcWM8eYDvrKeNzuvmDo00fyGz8/r1BjoRda3DYUTmYfTS9c46jxVoW3fqDYWryvnJtfmh0PqxeoyLghJHcjKE2+9kS9Zi0rMJuby5OUs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752167838; c=relaxed/simple; bh=CtFPG53SruBnOFqOPjRqaGnkxXgOM2t3WkxIUYnd80M=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=AwgYQXUM9txJu6L4EffEG+aXij5E0ktUXS+flX3MVCs3t0l6yrtyn9neXgrgn93JeNki07aicUMOJm7oWDSvSaBYHxEKdsMMQklAiAUG9IQLJ0vQBFLo+m3aexjtftROSJm5HI/OilPYYWAk6CUiJapTblYC/2M27h/B6anu/Rk= 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=pFuayQji; arc=fail smtp.client-ip=40.107.243.48 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="pFuayQji" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RIvNcNIZAOvh2KoGMg4D1k9XNIW5s2JxGX5LALWOTGHFO7uU9Thp45KG24oeoZeK8/Yu/FTsE07Qx7t4yD7i40V9/eIArMpTLHcdTdit6Io9Mo2MLhCWqmdulfxHPoQ6UWft0qVYNox4O4uURGGLjzMOdc9IfKSWAKlx8/GJ2RMp3zRuJhnie9jYV2Bzm5tDIv6Zx+TQt8khg2C0you/Lq0W0yb8URp2Yc7asMd4FlIQiBKIb4BEk8Gg+rEEviCfNYPGbEsQKxhbpjySUPB+rB+g2iPnXPfCrMISz/HFhBJ9Vmt+mLczD9PCDfRBdnUOJ3ejHyAH68EYX+jlstEIbw== 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=/YdhvRVw0woybG2Qywt5dBp2TBJkMg75wyBIffsggIg=; b=DX/Rf1OWXH4LCbfsurFi6VW3KKo0HN19j1kyFuz9Lhp+h/ab+y7KZ1gIPBbd29wiz/g0T8CdYCEMdzzZe6kcEN91hISMI2hNPXuiqJJTtz5xY+zASqnQxpssVNNM64m7r0gYLqM/+JRp82FAgPVN4M6Wn/dIY1C/7r7ON8+YUw61eCZmpuyD9A1+wWPAbqNEaMDvEe7jmjmWu3TiL5oJtdqC8nH3bqYWYEfkfDXWE2Hng1xvr8HuqSyfLqkBMDHaJYtaYV3DhbhNMrmN8V6Od7Iom/3OdHkRFJxmwqsuz2PTkoztmx6V5phw6VSRr91zVzFChPYJd7bicnwJKvG7og== 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=/YdhvRVw0woybG2Qywt5dBp2TBJkMg75wyBIffsggIg=; b=pFuayQjiTk/gNM59Hdrru/jnAOV2GyenSwXYcQGv1q0bodeDvll+40zij3py90V2p3Q9FquopZ+qotQMY3dDCMaTO2mi0TwbdbJFR59kYMNPlVmY76T3ykyBbeef38QmzvCF+I8N1pd+TLwPN+o7xfLiyUfO56pKibnJ0skXdF0= Received: from BY3PR05CA0027.namprd05.prod.outlook.com (2603:10b6:a03:254::32) by DM4PR12MB5964.namprd12.prod.outlook.com (2603:10b6:8:6b::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8901.26; Thu, 10 Jul 2025 17:17:11 +0000 Received: from SJ5PEPF000001CE.namprd05.prod.outlook.com (2603:10b6:a03:254:cafe::5) by BY3PR05CA0027.outlook.office365.com (2603:10b6:a03:254::32) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8922.20 via Frontend Transport; Thu, 10 Jul 2025 17:17: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 SJ5PEPF000001CE.mail.protection.outlook.com (10.167.242.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8922.22 via Frontend Transport; Thu, 10 Jul 2025 17:17:11 +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; Thu, 10 Jul 2025 12:17:05 -0500 From: Babu Moger To: , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v7 04/10] x86,fs/resctrl: Implement "io_alloc" enable/disable handlers Date: Thu, 10 Jul 2025 12:16:18 -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: SJ5PEPF000001CE:EE_|DM4PR12MB5964:EE_ X-MS-Office365-Filtering-Correlation-Id: 31d180d7-779d-40ff-39c2-08ddbfd59b71 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|376014|7416014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?yImplYSrsnVP3iYmFp2z7XgfTiVgdbRKarVMD/prSf0BHNRsoFhatTYpo+8K?= =?us-ascii?Q?DsBQpZSegLgZKOLdzlUa4SPFH0iAgwaUHLs9dEmWVfAWGIsuYi4+FncTtUxh?= =?us-ascii?Q?VKYqEE0Jb9BHyVzZPDonRWJ1dbBjFddasggfOVuX2LNndl0UpnMQy/3E8WY2?= =?us-ascii?Q?qYRt91GsKENazkhu+eGqM6eiQ66x3hDLCd3UGMzp0OMi2dVoWgNC444J+6yE?= =?us-ascii?Q?3EYuf12XjfnpITlEezo28H1tgRqJIpnAcMaohXgBu771zYGv79CdkOaaDp9d?= =?us-ascii?Q?JWR6SCix1sxbS6iAF9idYjI7t72vKyycqvVfJJgmBquxfNEwXdqXTw8GTWTx?= =?us-ascii?Q?yQ9fsUfky5Lbrp5Q6RAX05GRI9sLBTFchD2gHmaRSgkyRXELVWtJ96FqfiGX?= =?us-ascii?Q?/i35SgsgZ0I7AMQFYgG/HhbjKgozsIyPoI5TY5xN2BjNN1rlF0gs+O6IOvf0?= =?us-ascii?Q?LuE9dlrt4Xv8uiB+5DA62fJhmTLULoyn5CSzOK1Yb1V6kEJd1QCkvXlXzJUw?= =?us-ascii?Q?fMNcSbkWxlWno0lgonJdBGGV5IW7nfzhmht+Z00K7+yH1lOUunlEkaCPsN2N?= =?us-ascii?Q?yBNGJ3abPE/auZu1Xi1DL8YUdDhyAPE1XX8wshjweocR4YH8RqUzuWafl7NG?= =?us-ascii?Q?viPDAS5GL3D9yUq1pYYmQnXa/3kX7ixuaifP3f08HTje4YI0XiHM2SlPNHnA?= =?us-ascii?Q?ljtgCwuLKqFXc+jWz+KE6OV/dhUr40G+zV3NKdt9J8YBzMQPqvrX5RvWM/nc?= =?us-ascii?Q?b/1RtqX/v3l+L1EXiJTQM8/2H31Nr9/SKXdinWZnzk20QPjDKHOH/MKnHKbI?= =?us-ascii?Q?iH/e9gsS670c2xwuTlHnHJqtIkpC7M5Pau52J4oyIs15z17x/QdgFYzLVtDk?= =?us-ascii?Q?bceBO5ibT7R18cmZl1slCRDxAzt8uv3JT+n6Q2e+5Q6K1FnRYoGB8UVmyLXE?= =?us-ascii?Q?zMFFP2suRcmj2WXdS+050zOawwi65oIPMBMPvEpsLg6AwgDFYMgARXsW+Qe0?= =?us-ascii?Q?Sg/BBHWIb4z22MLKJ5N4V7tS3WSrAacgDqe4J58jPrURduqal8fGkMrtMvTK?= =?us-ascii?Q?ovnSOeFouiBqyKLO1UQckPcSLkjdRPDFJ4qI8gIl29snlZQL2XeSVbMuvhc0?= =?us-ascii?Q?0PFDIiMiTQ2kdmkIhD1UgtMVhn6Hp/66i2PiaPlCfnRygRW+0+ZE27o35lNg?= =?us-ascii?Q?tNanxRz8fVLRFvsplaOd/TmZPnfkrk38a7r31yin8cQ3OQC5t9bbKA31UmsG?= =?us-ascii?Q?HbMPC84q7LWCLEBElfhbT/4KEsJfdwXQ33YHahl5Nq+EY0j9zQAAZVshCEb9?= =?us-ascii?Q?WUlxYuAB7x3+F9ud8ScgzQ5LmhW79zYwns5Ov4bxyH7IoXnEeyBK3Qj7oybQ?= =?us-ascii?Q?BypEHQlKbS6QnYG4TIiw5hJxQxcUFHJJ3DlaqZSQBU41RIY1snnj5LJYC6F6?= =?us-ascii?Q?5lgucxd0tPBOll/TnWuU71zPmqxJHKlaVKVQLkat8ttrIHUOGx0vftuxrzxd?= =?us-ascii?Q?yXb9twvnSTwVG7qH5dUNanCRoSIZccoUFN3WefMwGiZg3IkpjvN9pdnATA?= =?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)(376014)(7416014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jul 2025 17:17:11.2006 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 31d180d7-779d-40ff-39c2-08ddbfd59b71 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: SJ5PEPF000001CE.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5964 Content-Type: text/plain; charset="utf-8" "io_alloc" enables direct insertion of data from I/O devices into the cache. On AMD systems, "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 call 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 --- v7: Removed the inline for resctrl_arch_get_io_alloc_enabled(). Update code comment in resctrl.h. Changed the subject to x86,fs/resctrl. 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 7490bb5c0776..c998cf0e1375 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -1222,6 +1222,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..70f5317f1ce4 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 (backing "io_alloc") 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..c165ac333336 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 +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 010f238843b2..d98933ce77af 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, <0 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. + */ +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 Tue Oct 7 10:00:52 2025 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2042.outbound.protection.outlook.com [40.107.236.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 AF8C11CD1E1; Thu, 10 Jul 2025 17:17:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.42 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752167842; cv=fail; b=OjG7V9OEKsicZv4VNgK1Yo/ldp8dC4eaOOxUy+sEa3Zv8quswOyA8bCFBdEcod15EES3WClgtv2ZiMzC7m1qKaXxfi0rovToA62aKTwVgbAdKQ4OE/z5SM/ujlykVmBEQuOTHK/m/w06l7SaczzV34g5nrdchk99gUwHS1bVD/8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752167842; c=relaxed/simple; bh=OwEUAu/0xb925wTjYb3WEu/8cTJMDhOv1KvRqeP550A=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ApJM8KIPKG9axONa2t4qaIjg+ozbhe/NFueCvndfdRi6E0WYyDWKC9daqCwkb3hMCZ0qU0EDTIvMsWseVEBF7fUB3FLxGd8LDBcVoNmJgQmW/MbzeEvHZduWYSw2V6M3WE+bN8ct6X1CWx4MPUkwmQvMJCE9LRLek7pMwKGfhdg= 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=l4nS3WIS; arc=fail smtp.client-ip=40.107.236.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="l4nS3WIS" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=q9PfiLWvfpk4QGX6GNmRAyUQXkpfVyN7CQAhvVwGl0TllObnte0F7vgl27uUZJyf22VsfZOTH4FGlYSHtmCI15I0SBZvk3mH4EOPrdUiDHs6qruF6BWzz8ZzLeBR/pR5fGop0TXVQ9RjZcADTHUk3dhFEaZRrOsVy2zJqKySlAJgubRT2jO17HE23RAJxYYDVhR2Bq5xp45+/G65Z/woh5HYW5yMIFdHFtZ8ZgQD0a/v1X2nXiPiLySqLnAfIbIja9bztscxE7AROa9HLu5KvJJZwzKPlubnf4vEJuII5vsKgBE+nhEldW10NSlL9LBaSDd/UemWZ4VMt6wYsUZHsw== 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=+rC6SOebXpZBo7aUiDxqTC2Mk7tOUhNkqdKyRSybbio=; b=uLSzI2yssNSO4Fam3TYGCx4mYYryCrN/iCa21sQeJ7oN21r8yMCW6zeY5fVIPS6umoksRzYWOWOujFgDmSc0M0TSlpKt3AMQQYja+sLC4ZiA35WRURUvJx0X3nFeiSw3YRlAItmwcqmkWj4Rk3vDj3Vi7o/zU1ArcFSBWGMw95Txa2viWkNUIkp/rJEnsO+bqsH7RaJ+cZR2x45GY0yfCf4rX3KnpFhKn+2m5ctwBOJWP2iyustWzlJcfA9XgiRcH1oAfycLbs75mlqza6gubSTunV6NfdB8rhqiIgYYLmE9USPrSi432yODFOkgR5mBLgB0OIlqeP+zbCQXCSyk7A== 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=+rC6SOebXpZBo7aUiDxqTC2Mk7tOUhNkqdKyRSybbio=; b=l4nS3WISL2fbuNUijgiEaCotvT2zUBoCC9+6F0KlyTy1rwqFzcTVnRtiK5jLOQkom9+3mVPkr9YTve3XVSZpQkX4mFpD0A2hDSoIIF/VRMf+U1AHK4erWQzLlWHVpOBGXA44GYeHkFhMfIR6WpoDSMEOHnYwp4DOCzsdQSudc/Q= Received: from SJ0P220CA0003.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:41b::34) by DS7PR12MB6070.namprd12.prod.outlook.com (2603:10b6:8:9e::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8901.25; Thu, 10 Jul 2025 17:17:17 +0000 Received: from SJ5PEPF000001CF.namprd05.prod.outlook.com (2603:10b6:a03:41b:cafe::dc) by SJ0P220CA0003.outlook.office365.com (2603:10b6:a03:41b::34) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8922.25 via Frontend Transport; Thu, 10 Jul 2025 17:17:17 +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 SJ5PEPF000001CF.mail.protection.outlook.com (10.167.242.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8922.22 via Frontend Transport; Thu, 10 Jul 2025 17:17:16 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 10 Jul 2025 12:17:13 -0500 From: Babu Moger To: , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v7 05/10] fs/resctrl: Update bit_usage to reflect io_alloc Date: Thu, 10 Jul 2025 12:16:19 -0500 Message-ID: <87e1a53201f3e539fc917a5d901f09bce432f720.1752167718.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: SJ5PEPF000001CF:EE_|DS7PR12MB6070:EE_ X-MS-Office365-Filtering-Correlation-Id: c18dade4-af13-4e33-3c5a-08ddbfd59ea4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|376014|7416014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?k3cDdQ52X5OOAH4lKFkcsRabYDZYMcy5QhBd0cNEdb9g/BBRuzZBTwnB1VE4?= =?us-ascii?Q?7qY+aZlNaUtvXWvzRhrMB87YQBgiHG7BRUxl1ovx2Y9cNdQ/siPUILMh1ujm?= =?us-ascii?Q?iOs7omtEQW4h3mT96N/OECRA1ledHKoufL+b7NbYm5PObJVOv4k1i1ca4/Nk?= =?us-ascii?Q?CV9K1EbcD3Ld/5DqgiQcHbvgYIHbmQvo+trBZ69KvzA9mmSiStcmFM1OHVVI?= =?us-ascii?Q?goPDH8KalPFa3RkIlOBDAetIHJIIQJnxz7uYT2RNdCzmXczBORdf9dDNHimz?= =?us-ascii?Q?I4ndqf0uaBKX/ah8JBFGIMHx1LnA3vCyHQuqNP+K/RnfX5j2Waxbal67Cz25?= =?us-ascii?Q?N0M8+BR6NxJpMCkckZ31lDi4Rhw1x1pj1mGuqfLHrgFQ2rNufb2ZCXB1cMOo?= =?us-ascii?Q?Hf7H1zAb6VsjU+tpFXQ9rAAZFD9SPsFw7E6CerrAtl9So0pej59aCNNYco+e?= =?us-ascii?Q?liVYPZEzZPG1k7bKnYHGJitdod9eBs7yvXXr4/gNYe905k/Vw2wqpZKcGIuW?= =?us-ascii?Q?A0EiGBakyQwBCUP6mLIQlQiacu29XmZDHV16e7lronCtMGt22DJfylzbI9DA?= =?us-ascii?Q?k1LIHr4owg0qirZmNv3WXN5eM9oL7gZpKWIvqz+l5cSu4GwarkeKCvv50VG5?= =?us-ascii?Q?RMbmHb/za0uEc9BP+DRjtSKhCsAvLf9CAh+pSHeM1o5nzsSfL1NppULsRjXm?= =?us-ascii?Q?ZB+yIecaczCDLwMhCAzsvtRweJccfLBCQFObHpX2Tg0/wj8PWz+UXBfwbkns?= =?us-ascii?Q?ilQG1BABun7Te3QtGGpYePskNgkzuw/7t+vyK7OmsfVy1lTyx/VVIasNpiF4?= =?us-ascii?Q?W9eNNX5fP2zKamBl+IFm6j2BVDkhonBcJ6YhIQEM7Ryc2JOAeEgQU6bTwkol?= =?us-ascii?Q?nEz8cjuNwbQK9tYvZr8b8q9aoZ0yB+0w49xhCcFUYnzlKyDaL8k04DGuSGFA?= =?us-ascii?Q?1gAC8OQQ5RDLl+0S+FDlg12dMv2iI4dIcOAPRl1y9bU0+qZwOV6sSP0ZJDLP?= =?us-ascii?Q?7z4/27xicFz4tetmvnpuEuliw3BA5gs7lndMGyL+/AJeS41PLew5ynTUCZir?= =?us-ascii?Q?7Yb/3utWvZXZHU0lLMTvAXlTOHUpTK/BosB7S6s//yMMeR2JvVuSJWQXg/E3?= =?us-ascii?Q?6+PDx2XnFr2hj9iImMa0Zgbhc7CfKFE10ge7pcByH8Rg7qcvdNymzFHBmI8C?= =?us-ascii?Q?UL2c0ucrb0H+9CWkZ8+LNqCnv5BB/UO7j1AL04qrhwHTE6GJf1N9YQV7Zctu?= =?us-ascii?Q?GASS4xwYdHv4HgQp51/AHa+cM34CTNcyW0gRstevHqrSMakkohUGlzVsHXlp?= =?us-ascii?Q?kVavQN+BO7jdkSz/JSEiD6hzdp/ftlnt63NVS02NMNGX22S8c61NMTDP3x+r?= =?us-ascii?Q?niohajVxIQIwOlRZaCLsLQgGMM+OCxBs7NvwyZxHO76ehTqvNIGyJkIYKc2J?= =?us-ascii?Q?rbqplMJI5in2UFsjX0G21ZziNoqYl5TPjD9CjWxsxZ5EEESbrEMhhisWHnWm?= =?us-ascii?Q?mw4OV7fLrBoqY4MHU2OEvO041y9Qkg0Dh2FB?= 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)(376014)(7416014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jul 2025 17:17:16.5693 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c18dade4-af13-4e33-3c5a-08ddbfd59ea4 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: SJ5PEPF000001CF.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6070 Content-Type: text/plain; charset="utf-8" When the io_alloc feature is enabled, a portion of the cache can be configured for shared use between hardware and software. Update the bit_usage representation to reflect the io_alloc configuration. Signed-off-by: Babu Moger --- v7: New patch split from earlier patch #5. Added resctrl_io_alloc_closid() to return max COSID. --- Documentation/filesystems/resctrl.rst | 20 ++++++++++----- fs/resctrl/rdtgroup.c | 37 +++++++++++++++++++++++++-- 2 files changed, 49 insertions(+), 8 deletions(-) diff --git a/Documentation/filesystems/resctrl.rst b/Documentation/filesyst= ems/resctrl.rst index c7949dd44f2f..c3c412733632 100644 --- a/Documentation/filesystems/resctrl.rst +++ b/Documentation/filesystems/resctrl.rst @@ -89,12 +89,20 @@ related to allocation: must be set when writing a mask. =20 "shareable_bits": - Bitmask of shareable resource with other executing - entities (e.g. I/O). User can use this when - setting up exclusive cache partitions. Note that - some platforms support devices that have their - own settings for cache use which can over-ride - these bits. + Bitmask of shareable resource with other executing entities + (e.g. I/O). Applies to all instances of this resource. User + can use this when setting up exclusive cache partitions. + Note that some platforms support devices that have their + own settings for cache use which can over-ride these bits. + + When "io_alloc" feature is enabled, a portion of the cache + can be configured for shared use between hardware and software. + + "bit_usage" should be used to see which portions of each cache + instance is configured for hardware use via "io_alloc" feature + because every cache instance can have its "io_alloc" bitmask + configured independently. + "bit_usage": Annotated capacity bitmasks showing how all instances of the resource are used. The legend is: diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 77d08229d855..a2eea85aecc8 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -1030,6 +1030,20 @@ static int rdt_shareable_bits_show(struct kernfs_ope= n_file *of, return 0; } =20 +/* + * resctrl_io_alloc_closid() - io_alloc feature routes I/O traffic using + * the highest available CLOSID. Retrieve the maximum CLOSID supported by = the + * resource. Note that if Code Data Prioritization (CDP) is enabled, the n= umber + * of available CLOSIDs is reduced by half. + */ +static u32 resctrl_io_alloc_closid(struct rdt_resource *r) +{ + if (resctrl_arch_get_cdp_enabled(r->rid)) + return resctrl_arch_get_num_closid(r) / 2 - 1; + else + return resctrl_arch_get_num_closid(r) - 1; +} + /* * rdt_bit_usage_show - Display current usage of resources * @@ -1063,15 +1077,17 @@ static int rdt_bit_usage_show(struct kernfs_open_fi= le *of, =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(r))) continue; ctrl_val =3D resctrl_arch_get_config(r, dom, i, s->conf_type); @@ -1099,6 +1115,23 @@ 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 configured for shared use between hardware and software. + */ + if (resctrl_arch_get_io_alloc_enabled(r)) { + if (resctrl_arch_get_cdp_enabled(r->rid)) + ctrl_val =3D resctrl_arch_get_config(r, dom, + resctrl_io_alloc_closid(r), + CDP_CODE); + else + ctrl_val =3D resctrl_arch_get_config(r, dom, + resctrl_io_alloc_closid(r), + 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); --=20 2.34.1 From nobody Tue Oct 7 10:00:52 2025 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2056.outbound.protection.outlook.com [40.107.237.56]) (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 4BD3C283FE8; Thu, 10 Jul 2025 17:17:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.56 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752167854; cv=fail; b=MgevljN0/v1hSunm68dRFKP6KMkcD6Dl5kR5vzkxHWJHAjOouRJAu8LEfSbV5sZ26unNtUn9cBpY18gpefYBLRhhbEzBhs/vmuBgyx0AH7f/S/WjhCKw8aAM9uNObUzJbbtva1cpcoUy8Cs0cGtAGF7f9AEBPz2EE8iCf7yI+A4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752167854; c=relaxed/simple; bh=V8+4wGdzlpg6dxsnR69OAOqG3AcD/mTTn/CQ3PR3ueA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=NL8fEXmQKSNvdKj9ts34LH6FWDUMe4GWo92ZYUZgrAwG14HcpHtco4tMMYeX9kM/rphcM5PFlvk+1qjXQdUzPwBLx5dOufYNpfs2dcx5PrkwqTWcRCAd1Vls6CdJF4MoG0jA6At7SyBU40RWhbFVGEHricZiaFxKQsXa5Dfn0mg= 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=u6rLxkBx; arc=fail smtp.client-ip=40.107.237.56 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="u6rLxkBx" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xRki59XuqTlFKPN8e35f2r6YZk6Ri8t1K74b5hqZUleiQFyMfGqgc72fs2vg+GorLsGRT8nOrRqd9jsOPbr1PPggjwyvJ6EcPCQNdZdEnmaLDru7x4puuYqD67YcjwwM/72ZQC6rF24uqv1Q8WUac0qsgdhI5yUiwjZsCY3NYKtJbahpyaHmMmv9QrVk6+uN5P0AS2xaP7Mmp3V9Tr700qotfQFsQpfmP3sXFKTXBz5yjVTeoInViwE3hO2CqLfNnkjhUS9o8VIqMCP33XqBoKkLh4y8A5mbniQf3trV4UCakUDX/IGUO8+FvU3CYxILjvkOxNbK/2dF1PhEjceWUQ== 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=HBxWTFuCGMLtlLH17fPKlxPmwu0YsnWGlBQB9upxxWc=; b=SvhRMCjEsD/hhr6Ztl12Ard3FSXktvrI/PAwsFqJvsJzkob6S9mMERjyd52/R3tChjvcQ7zlcX5qBOhWl0Bl5rvEFEWdvvTbr0XMuNU5odOek6FoO2m8xRdxrD0JjjfdtqdLmIjvqP7ITQKLavrKvK3LTP7gCnLBaZnAfRaXZ7cZpu6nvpzokYvsE25HoyYmVPWI1xc9p7ePnLe3w4ati1baWNeXHJBE42sst3sRf35d8pluT7ixp06a6P0UzQB8+dRPSXqX0CgS2D6zcjI9F/z+OqD2TvEzET8L6oDtKlbtt9W5U/DRZ6rNpL9Ql51UWdkeaxjjBOjLGEbz7tukSA== 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=HBxWTFuCGMLtlLH17fPKlxPmwu0YsnWGlBQB9upxxWc=; b=u6rLxkBxNQRYxyW8wKUMiTQH83uFWVtO4nLEgdRvWmSc98qLuLnmOwTVxrt8pP2Luh7dJW9U27ETQKpEOzCdVvInO2jJyMX5K+LJW1/mT9YuPZG38WJuT3rQtOH8/bE8eYosI4aWFQfQveLhLVUgbFki/OGBgm0/YHRZOHOPr2s= Received: from MW4PR03CA0152.namprd03.prod.outlook.com (2603:10b6:303:8d::7) by MN2PR12MB4223.namprd12.prod.outlook.com (2603:10b6:208:1d3::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8901.27; Thu, 10 Jul 2025 17:17:26 +0000 Received: from SJ5PEPF000001C9.namprd05.prod.outlook.com (2603:10b6:303:8d:cafe::e4) by MW4PR03CA0152.outlook.office365.com (2603:10b6:303:8d::7) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8922.21 via Frontend Transport; Thu, 10 Jul 2025 17:17:26 +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 SJ5PEPF000001C9.mail.protection.outlook.com (10.167.242.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8922.22 via Frontend Transport; Thu, 10 Jul 2025 17:17:26 +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; Thu, 10 Jul 2025 12:17:22 -0500 From: Babu Moger To: , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v7 06/10] fs/resctrl: Introduce interface to display "io_alloc" support Date: Thu, 10 Jul 2025 12:16:20 -0500 Message-ID: <4e275fadf59e36e38ac60406a19cdf67d640f7d2.1752167718.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: SJ5PEPF000001C9:EE_|MN2PR12MB4223:EE_ X-MS-Office365-Filtering-Correlation-Id: 3a69a2af-b84c-4ef3-95dd-08ddbfd5a44b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|1800799024|7416014|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?VoqG3SLsgPtj1q1bwOUEsNTBJ1mkxkIrQiUVKSJ0DIJEqwRFcyOuX2XkSZ+H?= =?us-ascii?Q?sD/H7No6Zf6o6JhL9nDBrOY2mNJkw/NTMEyQ2KXhuiDuiHrbvtlyVs+GI8nE?= =?us-ascii?Q?O8OiM2WxJxEnVceeHBWHzW5jEw2xQ65tqSUzBKNsnTAqLSZS51CzqZft9+Zb?= =?us-ascii?Q?ByqpY8pVZwkVhaj0BvYXXpSd44641Vk44MJKnp1kgwpbD3cAYQKs2o6w7vtW?= =?us-ascii?Q?sVSmTR5JPUitf6HncQuuPepRWyoETbXCaYMzV0jV5p8RjaC2qlTHFBJmOdPB?= =?us-ascii?Q?CM+dNZTYcwYbwMWsH7+2YQ2luA5/3G5Rfok1cpTUpg4ycduwxdsW1C4NgTjY?= =?us-ascii?Q?wkBIOeM/uNZYV8sLzl38k3pfHtK+D9tyoJ6Mx+z3qSCIzgYUAsihACLue04p?= =?us-ascii?Q?poA+XWG5gK+JoUir7jj701bciqwMtbrzvtitjv2Ur/MwwDHTRFeLzwuI3OBx?= =?us-ascii?Q?cpwHpfk12VdmgrN8dEq5dw7omCtxVYqD5txl3X+ldQLJyrRt9yMu5CCdbDEi?= =?us-ascii?Q?tBeeYQS0LolOFjOQW5EpRffeoNWWgcXtcWL+VjU7qyPLtvg8VrjNvY12p/P0?= =?us-ascii?Q?B7WuLL3K551jmIuo4r2R4JUwBF9DL76l59ho5UU7T+cmQJxZghxeHBWx+Cp7?= =?us-ascii?Q?P0jmsDvHQPzt7E+1vU4PTgzRcz5AKkuGXFD74s0S+NGQBSgFllBamNWm/DUS?= =?us-ascii?Q?NVvGtYpIy1VkBM47SJURvxqQcgYz4nyI/mrgKoY+vxYh1Mk0njG57JHysvb2?= =?us-ascii?Q?CrIU1LmmkofAiHWotc4TqQaollRUqkptxaQbm0jFnPYl24oa5om3OwLIYz1X?= =?us-ascii?Q?d60qsYLZ4bCumfzEZGHXdv5sn0ba7vSn6nFB3oA/omLFEKLF24UeRR7JGLRt?= =?us-ascii?Q?I4DvxlddyaCgIPMxtgRhn+3MlJx9fVLXNzhv3aEvv4NgnPdv7V6T4Xd/plGz?= =?us-ascii?Q?hPuR0zp3FfAJ73whpxWin1e7q+//ioFok5poV39WAtjUQJfMzatDAwkRBq9V?= =?us-ascii?Q?bYpjhXYPP4Lb++vYwdD2A060UMN+pn1xhbM4YIN5Jo0G6t3AEycp+kk4k4sM?= =?us-ascii?Q?z7TsjB+dzyiub4Ni3nVO4dAxEt8nfiJcdexOD3gNwAId8qNmYMYPgm6k/OxZ?= =?us-ascii?Q?nojPvm+3ddydeRlN8XI+EF2bD3wlVlGYCkqkiyKGWc9aAb1uGl/+kxI4IWgs?= =?us-ascii?Q?Eh3rmUar4PZ4/kAC8cyNwJ/oQZdspgNrsX6waieEJ09rzN9MzGiYppojzFNO?= =?us-ascii?Q?vUZY1Tg6MpxOO+nPpikIobD6erjngpHV3B5G9Xf3o3saGnU8kA3M5N6vOtdK?= =?us-ascii?Q?xs97npDX+LIrqN/hyfKo+Mt80GvgSFFIaA2CqZAz7z9XldpxD4J7SuJCGGOm?= =?us-ascii?Q?q7J/0ItJ2rN6wq/h32KqYZl9AcTVqm12Qv5JS56Zcq6F4+/VFWbu0lmXM3/k?= =?us-ascii?Q?SCMVO3/2BrlEyD7Z9ZdXhH58KQhVVXou6kBonHWXzXg1RNmpcHOlcMpkDrrk?= =?us-ascii?Q?VX7clpBxwUHd+5Gw7+dUTO+6R2fjXOf3ELjK?= 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)(36860700013)(1800799024)(7416014)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jul 2025 17:17:26.0539 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3a69a2af-b84c-4ef3-95dd-08ddbfd5a44b 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: SJ5PEPF000001C9.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4223 Content-Type: text/plain; charset="utf-8" "io_alloc" feature in resctrl allows direct insertion of data from I/O devices into the cache. Introduce the 'io_alloc' resctrl file to indicate the support for the feature. Signed-off-by: Babu Moger --- v7: Updated the changelog. Updated user doc for io_alloc in resctrl.rst. Added mutex rdtgroup_mutex in resctrl_io_alloc_show(); 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 | 25 +++++++++++++++++ fs/resctrl/rdtgroup.c | 39 +++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/Documentation/filesystems/resctrl.rst b/Documentation/filesyst= ems/resctrl.rst index c3c412733632..354e6a00fa45 100644 --- a/Documentation/filesystems/resctrl.rst +++ b/Documentation/filesystems/resctrl.rst @@ -143,6 +143,31 @@ related to allocation: "1": Non-contiguous 1s value in CBM is supported. =20 +"io_alloc": + "io_alloc" enables system software to configure the portion of + the cache allocated for I/O traffic. File may only exist if the + system supports this feature on some of its cache resources. + + "disabled": + Portions of cache used for allocation of I/O traffic + cannot be configured. + "enabled": + Portions of cache used for allocation of I/O traffic + can be configured using "io_alloc_cbm". + "not supported": + Support not available on the system. + + The underlying implementation may reduce resources available to + general (CPU) cache allocation. See architecture specific notes + below. Depending on usage requirements the feature can be enabled + or disabled: + + 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 a2eea85aecc8..d7c4417b4516 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -1836,6 +1836,28 @@ static ssize_t mbm_local_bytes_config_write(struct k= ernfs_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; + + mutex_lock(&rdtgroup_mutex); + + 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"); + } + + mutex_unlock(&rdtgroup_mutex); + + return 0; +} + /* rdtgroup information files for one cache resource. */ static struct rftype res_common_files[] =3D { { @@ -1926,6 +1948,12 @@ static struct rftype res_common_files[] =3D { .kf_ops =3D &rdtgroup_kf_single_ops, .seq_show =3D rdt_thread_throttle_mode_show, }, + { + .name =3D "io_alloc", + .mode =3D 0444, + .kf_ops =3D &rdtgroup_kf_single_ops, + .seq_show =3D resctrl_io_alloc_show, + }, { .name =3D "max_threshold_occupancy", .mode =3D 0644, @@ -2095,6 +2123,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; @@ -4282,6 +4319,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 Tue Oct 7 10:00:52 2025 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2056.outbound.protection.outlook.com [40.107.236.56]) (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 AB121283FE8; Thu, 10 Jul 2025 17:17:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.56 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752167860; cv=fail; b=dKYhjyXaW5ihxUL6RK7QHK3qAxJjXz2O9oG6EckqS9TBNGrWwvwj57R9bKQIsQkEzsvQ1yWg3M2jXZmMAcBnPDHcr/bDhkcX8o24yH+ibXSdwbz4i3x8TsmRk0B9j+XSfD0PUSGO8TiHODexURZ2CP7X84tVKX0p1+YfbdgXx7o= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752167860; c=relaxed/simple; bh=tAgU/IpAMLZ0uOWuYxuamRRCPpOUyNkzCATYforqGM8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=EJHXJvztm7M2Xpm99M6JsLk8nOzYfUMMswdF4euW1qzSPyGfXmvqcT2jcE+5ibcPVEMKVhV4P4fOnp22EXohkPP4sQacRsWOnFyVYbA2HTNNhS0ykl/so3ZXtALzveBMGsVPNtTYPdnpb4/mFL6a5wjEL0dz2Zyy2fw5qkpPn78= 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=Ye3Nd1F7; arc=fail smtp.client-ip=40.107.236.56 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="Ye3Nd1F7" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=iQto2cTQJUpc9OPY/KVHFpgvOkR8zo2fAHuO5lHX/MR76AHTz0X/TFHub2TLVklPBR7rBuCNWNzaoeqFOhBYcDeHmuLFj7D4lAnTtI4so3QlJCVxyymoqa/uXm1TaNBPYAnzXHaGZgy2TdXjBTN3TcYqHmZIOxBEi5iKJeNHjefiC4LxNXDCZT9oqPz5rzOWMZ0QgdHAORt5RftEwb/VzgsxYWmrGIaH35a9xF2wJuBcXE76ukvzRYBhULbBLA6n1bVrznnMmewNlgVU6bBeBvVpYTtN3OznDvLHAREm8cpFBrv7aIYwRj51lwW95gOFHZ7yzSlKVctMQnbp4thr8A== 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=Ljb36zA6ZY2UCJn8p7Z3w3nKL2ggr4DXoVcKYeZp5Jg=; b=cKBJYWKTr4xW0q2RJ7mvr8Nr2T1jqoKLh5+udmJQPeH7y4SCjXYjpfz2zJW0rg93CIheRoAFLucW8PtPluC2AAzDotgJ9aKGxAtMRiXlR1JPxM/TD9bbf6LEzXE4sMZnXIBN4hnrZgChqK8ZkvvCTTokAOfoQvbaZgkEYqrl4kQ5dir45ifZ+keepHNZCS6gofMRmJ+0k7djkKiKuSWLqiEggJkILwnX+XlsbV1gmo8xbEQbTVAfa+vWSmYDiHHSDit9Qbtjs/zTaNe7veey2b+1P6ByaHEGbrJsr1H3SCcSeuKqcK6UkyWN/vHgzgaWmcNKe7G2z9SI2hqnh+YLcQ== 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=Ljb36zA6ZY2UCJn8p7Z3w3nKL2ggr4DXoVcKYeZp5Jg=; b=Ye3Nd1F7k2ZraBPuiv0BQU2npnR3c5bUFom+T4cyOswiJWr55qp5j4tw0iZYvTjqfM7WqMXXZMcPWRaTe05rfbx7p6AgPx9LlfGJmsn+p0HP5z1srO8+NVeJzguvnpiq6t93pu4Iw0mHDFuwh22vAzrZw/2LT4i9VrzSsguVCzs= Received: from MW4PR03CA0158.namprd03.prod.outlook.com (2603:10b6:303:8d::13) by DM4PR12MB7598.namprd12.prod.outlook.com (2603:10b6:8:10a::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8901.26; Thu, 10 Jul 2025 17:17:34 +0000 Received: from SJ5PEPF000001C9.namprd05.prod.outlook.com (2603:10b6:303:8d:cafe::33) by MW4PR03CA0158.outlook.office365.com (2603:10b6:303:8d::13) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8922.21 via Frontend Transport; Thu, 10 Jul 2025 17:17:33 +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 SJ5PEPF000001C9.mail.protection.outlook.com (10.167.242.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8922.22 via Frontend Transport; Thu, 10 Jul 2025 17:17:33 +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; Thu, 10 Jul 2025 12:17:31 -0500 From: Babu Moger To: , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v7 07/10] fs/resctrl: Add user interface to enable/disable io_alloc feature Date: Thu, 10 Jul 2025 12:16:21 -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: SJ5PEPF000001C9:EE_|DM4PR12MB7598:EE_ X-MS-Office365-Filtering-Correlation-Id: 82612caf-9ba5-4e08-ee82-08ddbfd5a8e1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|36860700013|376014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?3Wmeyk9l4zgsjG61Dv8KK8PwbViDYA2FqVZhtf3jZNFQnCXzQ+wvDGGd3CPV?= =?us-ascii?Q?FmwYCx9VRTLn8zQNexvkLtInebm+ht6NWZ3Yv9Rylbws/WnOqQu6l214B1tJ?= =?us-ascii?Q?VIcijiHTR/pmTTC8sw9+YU8x5LaCeZq0pdbx8X5shJgb5YSspExx0cR1/ly0?= =?us-ascii?Q?vMjJpEr/vMXq0GGoXzrs/9Dv9w9G3Pf3BiJnh23msUMwVXeBG6WelM16DyHu?= =?us-ascii?Q?wCb5IjwHRMWxPy161DZAytxiZGMCN7KkxfhCU63v/03Am/65cti61Lauw6wx?= =?us-ascii?Q?1ds/oKjCv7mY1XUvIZwKqaUkiGnJkhuIx+cNe8a3Bv/xAOBlAr7DUcMyUoAg?= =?us-ascii?Q?8NwqmH4KXHRHflJcr+P+6VvOah3b+0KIPEiYkuz+2YcRJvG9bA05Fx55aAnT?= =?us-ascii?Q?QKcGA7zCXy37SAcmWxuE9q//aNQzO2ZUjk8OkVt05yjGj7aW90S+2uPt602b?= =?us-ascii?Q?UXhD+LkuPhDE9UxTYfJBxbQaNgQ68ZPaW3EsJVkh1nUTyreyaepzoF0PWMTU?= =?us-ascii?Q?KDh3EfDAiDLNjgc2ANsW5jmm7OLnZvgr7dhWzcB3Sv856++35Hp6UpuOOTV8?= =?us-ascii?Q?BiLBFQh4em8QoT/MOvOSBBmjVJ7vxvcIzi4fBHNeZDwVmeZw/SDhn+A43Ttm?= =?us-ascii?Q?hnX6L8VqUWNlvYICqJzXAkpHpNuVCOPAP/Nj1Qm+ETDM4f44fAfrn92R3POi?= =?us-ascii?Q?nLx3/zx7aJXMrrIrq5p3fdBwHuCnIa8MANZUF3vkZgb82Bet99Mll3d3teuE?= =?us-ascii?Q?LFFIJjNAdNekWaXDsAsMP5lZWYwswXtgD8IOchJQjcc09hsq8yv5RiCsYcEt?= =?us-ascii?Q?PJW2iQUfw42gZ+CxO5EIFdfoJVh+8dsEz7zS5ntSYP+9uBMU+MsZUDqWxnfS?= =?us-ascii?Q?mb6nom/4Gm+aQCoMhnFjbw1PaBlPUN3B0ZEIKGDl7CNt6LrGODso3mQtQ0kP?= =?us-ascii?Q?QNYVMmVVfJs3JvK936Ack2ln1jmFk0Ssmwmd2BXMNJItvT6cgHod0mJn1q23?= =?us-ascii?Q?Nryqt20ES1rDA6odn2qT4GWjCluBrFpqlWX1ab3q1Z3xN/rUtWeaVt4CDdVK?= =?us-ascii?Q?gN5QsVxujJ1X0mxoCKz4Xsv6xTBkTnX1kgXZTX3ePJiEqDucP0wPyt+T+xYj?= =?us-ascii?Q?bmoojTZNJ/15J6cEYBDiSHXxCc3IrB/3meU8mTQKqs4oryCU18Y1P6M+eel6?= =?us-ascii?Q?p4fIfLqVmo0Eksr34bC3Ba17AGWefVRKL5TUs3aCATZ5ZkJJdn0CipbfUL3R?= =?us-ascii?Q?ef+wL+PVIJIdVqsflDE5NCBukl8lZQu4oOT0/Y8OdFsFPq/NYSsYfjPmcgQ/?= =?us-ascii?Q?qPH2/GQ7EIoSnWb71H5EZtrc6nYKcul7vFHuL7hxXT5frn5L3o5CicP7/LFx?= =?us-ascii?Q?npEG3jns+9jotsmIktqyfVTUMYbVHfwY1bFtV5phaQfFbCiZ0U7HHHhKSsy/?= =?us-ascii?Q?jmTiPlZBbWgkhx2I3RFu1frP5lG10TdJJBvwADhdu4KDEHADX/2skRFge6pw?= =?us-ascii?Q?CBLsYbB2S+K6a48a7zj/Gm8p2BKuraPz1Wi+jvDuYSQU2biB5liJUqY9Dw?= =?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)(7416014)(36860700013)(376014)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jul 2025 17:17:33.7417 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 82612caf-9ba5-4e08-ee82-08ddbfd5a8e1 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: SJ5PEPF000001C9.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7598 Content-Type: text/plain; charset="utf-8" "io_alloc" feature in resctrl enables direct insertion of data from I/O devices into the cache. Introduce user interface to enable/disable io_alloc feature. On AMD systems, io_alloc feature is backed by SDCIAE (L3 Smart Data Cache Injection Allocation Enforcement). When enabled, SDCIAE directs all SDCI lines to be placed into the L3 cache partitions specified by the register corresponding to the highest CLOSID supported by the resource. With CDP enabled, io_alloc routes I/O traffic using the highest CLOSID assigned to the instruction cache (L3CODE). Signed-off-by: Babu Moger --- v7: Separated resctrl_io_alloc_show and bit_usage changes in two separate patches. Added resctrl_io_alloc_closid_supported() to verify io_alloc CLOSID. Initialized the schema for both CDP_DATA and CDP_CODE when CDP is enabl= ed. 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 | 8 ++ fs/resctrl/rdtgroup.c | 149 +++++++++++++++++++++++++- 2 files changed, 156 insertions(+), 1 deletion(-) diff --git a/Documentation/filesystems/resctrl.rst b/Documentation/filesyst= ems/resctrl.rst index 354e6a00fa45..189c1ccb92d6 100644 --- a/Documentation/filesystems/resctrl.rst +++ b/Documentation/filesystems/resctrl.rst @@ -157,6 +157,14 @@ related to allocation: "not supported": Support not available on the system. =20 + The feature can be modified by writing to the interface, for example: + + To enable: + # echo 1 > /sys/fs/resctrl/info/L3/io_alloc + + To disable: + # echo 0 > /sys/fs/resctrl/info/L3/io_alloc + The underlying implementation may reduce resources available to general (CPU) cache allocation. See architecture specific notes below. Depending on usage requirements the feature can be enabled diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index d7c4417b4516..06c854caa55c 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,16 @@ bool closid_allocated(unsigned int closid) return !test_bit(closid, closid_free_map); } =20 +static bool resctrl_io_alloc_closid_alloc(u32 io_alloc_closid) +{ + return __test_and_clear_bit(io_alloc_closid, closid_free_map); +} + +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 +1041,16 @@ static int rdt_shareable_bits_show(struct kernfs_ope= n_file *of, return 0; } =20 +/* + * resctrl_io_alloc_closid_supported() - io_alloc feature utilizes the + * highest CLOSID value to direct I/O traffic. Ensure that io_alloc_closid + * is in the supported range. + */ +static bool resctrl_io_alloc_closid_supported(u32 io_alloc_closid) +{ + return io_alloc_closid < closids_supported(); +} + /* * resctrl_io_alloc_closid() - io_alloc feature routes I/O traffic using * the highest available CLOSID. Retrieve the maximum CLOSID supported by = the @@ -1858,6 +1879,131 @@ static int resctrl_io_alloc_show(struct kernfs_open= _file *of, return 0; } =20 +/* + * Initialize io_alloc CLOSID cache resource CBM with all usable (shared + * and unused) cache portions. + */ +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; + + ret =3D resctrl_arch_update_domains(r, closid); + +out: + 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; +} + +static struct resctrl_schema *resctrl_get_schema(enum resctrl_conf_type ty= pe) +{ + struct resctrl_schema *schema; + + list_for_each_entry(schema, &resctrl_schema_all, list) { + if (schema->conf_type =3D=3D type) + return schema; + } + + return NULL; +} + +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); + enum resctrl_conf_type peer_type; + struct rdt_resource *r =3D s->res; + struct resctrl_schema *peer_s; + 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_printf("io_alloc is not supported on %s\n", s->name); + ret =3D -ENODEV; + goto out_unlock; + } + + io_alloc_closid =3D resctrl_io_alloc_closid(r); + if (!resctrl_io_alloc_closid_supported(io_alloc_closid)) { + rdt_last_cmd_printf("io_alloc CLOSID (ctrl_hw_id) %d is not available\n", + io_alloc_closid); + ret =3D -EINVAL; + goto out_unlock; + } + + /* If the feature is already up to date, no action is needed. */ + if (resctrl_arch_get_io_alloc_enabled(r) =3D=3D enable) + goto out_unlock; + + if (enable) { + if (!resctrl_io_alloc_closid_alloc(io_alloc_closid)) { + grp_name =3D rdtgroup_name_by_closid(io_alloc_closid); + WARN_ON_ONCE(!grp_name); + rdt_last_cmd_printf("CLOSID (ctrl_hw_id) %d for io_alloc is used by %s = group\n", + io_alloc_closid, grp_name ? grp_name : "another"); + ret =3D -ENOSPC; + goto out_unlock; + } + + /* Initialize schema for both CDP_DATA and CDP_CODE when CDP is enabled = */ + if (resctrl_arch_get_cdp_enabled(r->rid)) { + peer_type =3D resctrl_peer_type(s->conf_type); + peer_s =3D resctrl_get_schema(peer_type); + if (peer_s) + ret =3D resctrl_io_alloc_init_cat(r, peer_s, io_alloc_closid); + } + + if (!ret) + ret =3D resctrl_io_alloc_init_cat(r, 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_unlock; + } + + } else { + resctrl_io_alloc_closid_free(io_alloc_closid); + } + + ret =3D resctrl_arch_io_alloc_enable(r, enable); + +out_unlock: + mutex_unlock(&rdtgroup_mutex); + cpus_read_unlock(); + + return ret ?: nbytes; +} + /* rdtgroup information files for one cache resource. */ static struct rftype res_common_files[] =3D { { @@ -1950,9 +2096,10 @@ static struct rftype res_common_files[] =3D { }, { .name =3D "io_alloc", - .mode =3D 0444, + .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 "max_threshold_occupancy", --=20 2.34.1 From nobody Tue Oct 7 10:00:52 2025 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2080.outbound.protection.outlook.com [40.107.94.80]) (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 0B16725B2FF; Thu, 10 Jul 2025 17:17:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.80 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752167869; cv=fail; b=aCPm6PS5PgzFdn56mhsUmbZkA8RylJCGwr2LuUPwVWLlPBzt6SKWXp8kBNZT8awpdFk8TK2IxoA/Og3+9lKbm/2iWiGC7oJys/li21QwlhsgoSq2DPx03dHTY1plO37ceK+f1+570RNwQ05odImqRZRZSv4dkBgDmsylkPBSl1c= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752167869; c=relaxed/simple; bh=qUD+RXcheNeow3UNRRgSzbkQ9VusjPjs52rFV3F/RUk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PEjVrXCbwcjzwtdWf2whOTT9bNS7jop5Rn255UrpMKrTPTBB7OJMBu4ThC9faToku1AFkBSO0rZW0tXvCnGXEVDsLaedUSdfH32HrLsLAJbhhabSffeQl4E5u6ME8efU0pF6c4fGgPcIo8/kOtdUwVAPp8UeLO+Gj8Kzs+uA64I= 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=zGo5fRm6; arc=fail smtp.client-ip=40.107.94.80 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="zGo5fRm6" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=N3nt0QkVO1oD2CSrSNlhAGjo93F78/MIr/52ZdCyU6+AmmmxSYGIC7+IepWeKW5TsRGQ9V8Zlxo1Ju8VD55thiEL4sFxyUNkbA2VjCVzmDtDr166XESVZ0Iz77fsezkWnyGdnThjjq45/q8HSUejiHpeZq5CQHcxH2+DlQyYtZveh5LFjkPjUF3OzWPz7qYjvgoSPa0SWqzi9QPGKDxGt6WFMiQGlLoZ+hUAoFo36RbzAiyBefkmrgPoYKqui6cddUKaL1XKvscJg4fd4BVhxaTUjOWu8PPQNt0qneCRZ1r8WKD0s/ri4tSfhPOlkvU7NkC260bhOpimCWuwStK35A== 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=vcaH3fvVhZMcE6IzwsIWEdyNo3Qoq2nv4iMFRUM6IaQ=; b=VU8KWiuJ+U9XXFhV6lBo+48XYLUocladQPDhpXdZPOJL5PaHMX4hZbZ8dYG3PEA3w7cJFtfsNIjunZKSY7AbDegRl5bsXt3QRPAizxXwDPCSWpCmrQ3bfimGHoFcJYFEH9MJaS2lZc4X2tn9/ufL8LkhOirgC0gc8uYDwMvqHgBoCmM0Nw8eUkfnQznNEFzgBk6BO2h+mDntPm4bVTVihdw7UPKEnpYkiCuxWbA+QITvW4IyJAY7pcqJXtC89WQDu/rBbj+f621dlZXAkAYgNd1kChYLDaq/X7+/NbGKwKPjtphDk07FR0lknlpVF59x6zgx/llyPWbsaa4ADXbfiQ== 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=vcaH3fvVhZMcE6IzwsIWEdyNo3Qoq2nv4iMFRUM6IaQ=; b=zGo5fRm6CDg3LRlosR3wo/41H6MMiMq3ILl3AuesNwecquCmHZpPFV2/UAQm/hOw3QbmASozuk73PXjD+l7Fje7CvyM6Fzn95mymBJIOBlHXRmFm4nft8n6LWvSil1i+2sJlwg7qZXrffBZ+d/5M7KAiB5DhJkY30rJRIUUlyoE= Received: from BY3PR05CA0022.namprd05.prod.outlook.com (2603:10b6:a03:254::27) by PH7PR12MB6809.namprd12.prod.outlook.com (2603:10b6:510:1af::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8901.27; Thu, 10 Jul 2025 17:17:42 +0000 Received: from SJ5PEPF000001CE.namprd05.prod.outlook.com (2603:10b6:a03:254:cafe::e6) by BY3PR05CA0022.outlook.office365.com (2603:10b6:a03:254::27) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8922.20 via Frontend Transport; Thu, 10 Jul 2025 17:17:42 +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 SJ5PEPF000001CE.mail.protection.outlook.com (10.167.242.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8922.22 via Frontend Transport; Thu, 10 Jul 2025 17:17:42 +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; Thu, 10 Jul 2025 12:17:39 -0500 From: Babu Moger To: , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v7 08/10] fs/resctrl: Introduce interface to display io_alloc CBMs Date: Thu, 10 Jul 2025 12:16:22 -0500 Message-ID: <7ca0bdcc27d4033d04131e2feca5921f85df0ac2.1752167718.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: SJ5PEPF000001CE:EE_|PH7PR12MB6809:EE_ X-MS-Office365-Filtering-Correlation-Id: 640969c4-2891-428a-c583-08ddbfd5adff X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|7416014|1800799024|82310400026|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?C6jHU9jWMDAjTc91ie3kserWeuevDu1TsAThdCxityr8zTVbUUKzZxzifJDI?= =?us-ascii?Q?N+kanDmLqMRNgG3c0Mx4hipy3suS4XpjkaMARz+4qoW/6T87Pc8w3vbJeKok?= =?us-ascii?Q?3WUC1IndXklbcrFOZGqdY439JPpFEAllTOqFGaeOxk+KaEQEs3N2nHULLvvW?= =?us-ascii?Q?hCAXXaWW+9f87WdxGdp0vsSYfEnS8yC4oe/YZe7lkl/YIzmxvwR2mIJCr3TE?= =?us-ascii?Q?qRcMKE5skqAGhJI6f1B/GMqTC4rV6iRd2PWWi53vivChHTi7/n7HTn7HbmAv?= =?us-ascii?Q?Q7aZIbuytJcpJ6TT6ecLDPzLyHeyjq1LPEd0Fa4VIl+DOZyub7NdGHxEEnGu?= =?us-ascii?Q?gm4mZx0TvG9gy0PL9BaW7XeTvvB7ZXsYih9GXH9vC17W/QgXGxOPuBDhf4k3?= =?us-ascii?Q?q7KYajr2XSEDu+iTk8T2GjTVTLJiyZcxV8An2JGR21QYQ2tHAy7gswfLVrTk?= =?us-ascii?Q?b8myyAx5dsEkVfP2cZKfuhSILIhgaZEn6EQX1A1wAd8uncaFjoUFYO6AAYhy?= =?us-ascii?Q?tRKzwGrs5Tliv5Z9uLHDuKWs65icg0oyNWGmtRJelmx5Pnf/2ZNjk+WODK2/?= =?us-ascii?Q?RSki8j0s3fEXs4sAQGUUdWSKWtjKyTC+Vsmc3g8cpES1/+q4WCUj9o1MONeL?= =?us-ascii?Q?E0TL++SBU6CCoa3rG7bhuq2SbYjss2NPmiX6JfLxfJLzA5uUpC+wzinarowT?= =?us-ascii?Q?SGt6G/r5GxvHS7bj2nKsknJ2qPNHnCjVtp0D3qVfiHT7GDXp/1OGN/nEInWb?= =?us-ascii?Q?2ZP7vXzgdm0Z9+iDNYWMmZqaa05B5iNmpdRBXV965dTNJ8EQemhFThGraFxV?= =?us-ascii?Q?8K3KKhOF0uWvyj/ED8RzGWpokenAylS/oS6sl35L/W09CWyV1smWOzk5spw9?= =?us-ascii?Q?1ZKi7TOOH2PHx9RvTTeZI0qQ7Vu8fEjMNOcIGT2P6cHK+I3AKu0jLPxyrMML?= =?us-ascii?Q?f+H1BzdyLkMeErTPfTf5rqMmw95+Vsy+TjOBPTMP4Tck5mPzHr26DXCgy4Ap?= =?us-ascii?Q?C43kDg9k4MhCoOFJaTFx2hbakV5Fu2G0wP2qOkLNdj/ZCXRrnq0XRidtuZtW?= =?us-ascii?Q?DtqmQMdBGEwvuL7gFmatSll+Og9RAQ5yb3PHH5AIBrp0HtkcbjDYSsuIPK+L?= =?us-ascii?Q?KoU9TiagCzFFTy9r4uBjDflIlnt8xOAbWjafE2SrWHxTivm0U6S0ya/w6dPg?= =?us-ascii?Q?lHOvTNXKIAHZSZmSOhH0SCmhQAo9BaWzbIpYaae8A+npctKQtBEDSN3nmp/u?= =?us-ascii?Q?hXuxFlGXlsmyLH4tb0llZteTsxGecrgl9hN9z0hyW+bXps8blIQch2UtQ168?= =?us-ascii?Q?4MMSfrSN0f+LRHgECqNJZKSjWY0bZNCrKEaiP37YQPRLh4HBRIwxgvS2dwpq?= =?us-ascii?Q?N6dt+tTSQa+VNn7H7jIcM4ZjbEbKsGgnY/H/UEZ9VmB4vdJSJr15geqJDi5q?= =?us-ascii?Q?Q8RJOYGFdq0BjjgW+gwsvuT9h8tgOf9jglMVZWsKpehXx3W0J/sIq5HOYj1c?= =?us-ascii?Q?u/MrN6YbjPqUAMnZwZuMbjCzRBy14Fkp3bKO?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(7416014)(1800799024)(82310400026)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jul 2025 17:17:42.3332 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 640969c4-2891-428a-c583-08ddbfd5adff 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: SJ5PEPF000001CE.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6809 Content-Type: text/plain; charset="utf-8" The io_alloc feature in resctrl enables system software to configure the portion of the cache allocated for I/O traffic. Add "io_alloc_cbm" resctrl file to display CBMs (Capacity Bit Mask) o fio_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 --- v7: Updated changelog. Updated use doc (resctrl.rst). Removed if (io_alloc_closid < 0) check. Not required anymore. 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 | 18 +++++++++++ fs/resctrl/ctrlmondata.c | 8 +++-- fs/resctrl/internal.h | 2 ++ fs/resctrl/rdtgroup.c | 43 ++++++++++++++++++++++++++- 4 files changed, 67 insertions(+), 4 deletions(-) diff --git a/Documentation/filesystems/resctrl.rst b/Documentation/filesyst= ems/resctrl.rst index 189c1ccb92d6..c22a9dd667cd 100644 --- a/Documentation/filesystems/resctrl.rst +++ b/Documentation/filesystems/resctrl.rst @@ -176,6 +176,24 @@ 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": + CBMs(Capacity Bit Masks) that describe the portions of cache instances + to which I/O traffic from supported I/O devices are routed. + + CBMs are displayed in the following format: + + =3D;=3D;... + + Example:: + + # cat /sys/fs/resctrl/info/L3/io_alloc_cbm + 0=3Dffff;1=3Dffff + + When CDP is enabled "io_alloc_cbm" associated with the DATA and CODE + resources may reflect the same values. For example, values read from and + written to /sys/fs/resctrl/info/L3DATA/io_alloc_cbm may be reflected by + /sys/fs/resctrl/info/L3CODE/io_alloc_cbm and vice versa. + 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 d98e0d2de09f..e78828b0408a 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 0a1eedba2b03..3d4a3d7696d0 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 06c854caa55c..008657e43656 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -2004,6 +2004,38 @@ 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; + int ret =3D 0; + + cpus_read_lock(); + mutex_lock(&rdtgroup_mutex); + + rdt_last_cmd_clear(); + + if (!r->cache.io_alloc_capable) { + rdt_last_cmd_printf("io_alloc is not supported on %s\n", s->name); + ret =3D -ENODEV; + goto out_unlock; + } + + if (!resctrl_arch_get_io_alloc_enabled(r)) { + rdt_last_cmd_printf("io_alloc is not enabled on %s\n", s->name); + ret =3D -EINVAL; + goto out_unlock; + } + + show_doms(seq, s, NULL, resctrl_io_alloc_closid(r)); + +out_unlock: + mutex_unlock(&rdtgroup_mutex); + cpus_read_unlock(); + return ret; +} + /* rdtgroup information files for one cache resource. */ static struct rftype res_common_files[] =3D { { @@ -2101,6 +2133,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 "max_threshold_occupancy", .mode =3D 0644, @@ -2274,9 +2312,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 Tue Oct 7 10:00:52 2025 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2086.outbound.protection.outlook.com [40.107.236.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9C4D42F0E29; Thu, 10 Jul 2025 17:17:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.86 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752167878; cv=fail; b=HNZk/xlmNsMeCFmi6p/ZI5Qc4rP6jHXJXbRtDgXy1gI3QHGrc6KEMqsr1qQuCFTUjQy8n8zXjGqACEtPFiHUpZd9YArwvZtml3F9/TaFz0PFALvQOOPCnTKviwsixllAMFWbR6BpuWj4idG6NK3gXPo0d/omfgmkNAr3VSdmRns= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752167878; c=relaxed/simple; bh=fEcwk45JFtqQRINDWFLFJ+ovaazjRhOQA+8HFHyZal8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TZe9LDQtGjSxQNjJFD2dfbYhSAup6KXyk1C6PyzrhdSe5gGfs0qeuceXCnKNLRdKkD64w0S/mvTXlyu1rBCR7fhRiF1LMieODuVebEY1wZoJs9vh59r91Ky1ShqJWF3UTzsVPWQC1DNUiw2q+jYu9NCyQdeQI1EMZ5JpH51mnro= 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=0x9F3kAJ; arc=fail smtp.client-ip=40.107.236.86 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="0x9F3kAJ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Y8jE5x34u3hnW32crZEn0o4VyjYZnMRGCWHkkBObwcm7GlSl9j1Z5939KUthdrX0pFzYcAGgxOYMUKtd/kBnSaUUBb+VuKnTr2cnbN8rfIHtUU4ivHakukDnDf2/8hj3+FNmlHPBJDc4pM9dKMVGHXSQ+rQnuKHEbehNEEXSl4+VVs2+b7oQPerSi08JXSXF2YXaifOOQNrxTajPAwY8/aLjVu4CELQbCqoszkMfabPIvAMTjBviqGypan2m/YpsC969mvbDo99QhkD/vmGhtNWdi3gSu+QjrIl9E9CiolYVJmCMiqJRG5hHHbd3/2ejrM0ON8x9wrVLxMWkdcYUwA== 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=w2WFa9QrcD3l21hhVJtfD2p++5zKYeVJiCNYfaHWTlw=; b=io2Z/qvfUaTjQ3x2wCUdml4/6Ttxx0ZT23uZ2NokTiJNJkBkIBYa+xcdLXw49SsDkap0rPFzJukRdHa0q/Rd+NJZ5g3cP2ADjm2v3VuFn/csEiZveUPx2yDqdUcD6xHNbmF1OtHhpj2+Zp5Pps+T/udXcLADYt2ybqcB56973A1qfWrl4Syg2hOEGKQqU39UCPA3d7DEnHrqc9yCc/PwJUZkscGhGcY6+6uv/P66eNPsv8p8xzALLjSpZjQxGuh7Idjx6YFnew7FFuS3j8Zi4B6fYPaqDKR2Wmd/ukvHPCZl+5OWpmUrYvTv9N9h2CcjM0MRjczjqoSzV2E9JNYPbw== 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=w2WFa9QrcD3l21hhVJtfD2p++5zKYeVJiCNYfaHWTlw=; b=0x9F3kAJtlaWCKHdpn0g6s90MRzrRcNz0UtMK/nWqlV/tP/j1UU2vZC0Xx5ZQW7x63+Il/GGkKwiG3DSOo1sfEakbbBTStcoXGAyej1hyjMQjxhL9GFmy0wDWkJ1ZnrjZ7TfheVDQdwQdCXfQJanxdkRrywkNQilFLZuBMXhI8s= Received: from SJ0PR13CA0134.namprd13.prod.outlook.com (2603:10b6:a03:2c6::19) by SA3PR12MB7880.namprd12.prod.outlook.com (2603:10b6:806:305::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8901.26; Thu, 10 Jul 2025 17:17:51 +0000 Received: from SJ5PEPF000001CA.namprd05.prod.outlook.com (2603:10b6:a03:2c6:cafe::2d) by SJ0PR13CA0134.outlook.office365.com (2603:10b6:a03:2c6::19) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8943.5 via Frontend Transport; Thu, 10 Jul 2025 17:17:51 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ5PEPF000001CA.mail.protection.outlook.com (10.167.242.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8922.22 via Frontend Transport; Thu, 10 Jul 2025 17:17:50 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 10 Jul 2025 12:17:48 -0500 From: Babu Moger To: , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v7 09/10] fs/resctrl: Modify rdt_parse_data to pass mode and CLOSID Date: Thu, 10 Jul 2025 12:16:23 -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: SJ5PEPF000001CA:EE_|SA3PR12MB7880:EE_ X-MS-Office365-Filtering-Correlation-Id: 193ffc1e-4562-4591-00cf-08ddbfd5b329 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|7416014|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?SiTNQrdLmV4gp0xiAxOMqCNBDPKeAHMH+5paB2xS/wiJDnVwz1czftNhv65b?= =?us-ascii?Q?e5XyS4izqZGgyKoCr1tKbVG2/px92sh8Q/sT/pV2uiKqnFgQ/RYelkFYKPZL?= =?us-ascii?Q?r0VzIVeM76ZY8omS2YWHipG7YUq6jBlUQHenwkA4TMG5Yo2B/ye1xjimzyid?= =?us-ascii?Q?A2VD3Ch6FKTtZxaXoIrAmCgieFDFX8z8OqKSG2WQjCzq6cykTs1FapHh6O6t?= =?us-ascii?Q?Ifkn7PvBEbykQxeUv2DwSgS1k3H9IQ61T9/cZ35gkSAuLlT66nExqGijKsCa?= =?us-ascii?Q?qz/oGkJQ+5ddEfSBgip7RdejyvLm77g9Mh1JLlinGCjEgbFD54qwoCAxkjJF?= =?us-ascii?Q?+LL6VDS1UQV5g/2QRsbxBIcOVM9ZYoSTXLczqwNLIk4UDma/5nTcuVaDADwH?= =?us-ascii?Q?z55sxARq0NgAh8IcVDayfLsJyWSkwJxymVEp1AZnwSo/Z7h5ySxtmDQc1NCT?= =?us-ascii?Q?CKLsAF5haueQ6Sn6FlhGWdjJbuGRviE5S/qy5rhXsWMBpsArhE2mHie7+o2i?= =?us-ascii?Q?BjEQzaa6OX10MoECD8tuTckIhhB8sReYshF+I0JMAWSsEsyNFDXi74WJlLhK?= =?us-ascii?Q?nMZf8fqIgfWRQ3TOgrzCF04p4ru6Hk28XzLESbITX4nNMCHfK+9S8ya/w8LH?= =?us-ascii?Q?2Qqm7ZWGPtk/iMoy1zz0ZUIHbo4z2SbAQq7vwoXN3K7N+rHW5qfoKcUGYpzT?= =?us-ascii?Q?P/ezXbQCjCUPonJRgsRxA1wO9F2zsVPrnA3l5vAqRzSEMBYkZvJHnUXtEPkn?= =?us-ascii?Q?A8EnO6ai8fk3X+LUHVzxjIg2iVfDwu0yI8VDZKRFemvmh9IEyxcbLtAR8DbB?= =?us-ascii?Q?/jy0nmqYdLnQtQ047EV+KCQz+ZnjC791twOew7aA2EYYGvYq5ZDK2ZxNd13V?= =?us-ascii?Q?v6idEE+6o7/9TPon3Xux9r+7YrtmIyBtkrXcjLb43cb4V5EclgrgjcyBOyOo?= =?us-ascii?Q?cbkGFv1M9QZnZXg6Ep/9oGxEgQpQskd2vMeB1mjODtRJMJrsLwb4fGGB3+r9?= =?us-ascii?Q?oON+lO0WUmkENyXahdS5mB85shvVpOPxzvD29UtawiFIwElZQmSGEzfrNHWi?= =?us-ascii?Q?TaJA0WAcuDVA94OrysYQA0kAQXO4b+CO5sUwt5T7rV8g7vMKKAvolIZu5iE8?= =?us-ascii?Q?5SyUNAaieD9bSCcx5+WF6/00AsoAkWZMzmRaW7F3+bQIAd7TS8/dcGO7kjqz?= =?us-ascii?Q?WMEFJzjBLJBIylmfN6ZYf0sc/r+bwBHVr8NUKdMw9dNEwHKfHaogII3SI1d4?= =?us-ascii?Q?HTg+JpQwvGIVZJR3aGzSI/y9b/XwB83asdsyG0vIyLraccjdalSmFB4V/KZ5?= =?us-ascii?Q?BTCIM1T+OzpLrdpTmnnjj2ikrlo2oj1aEfhya8UkfDWodlw7bMYe7lQBqxA1?= =?us-ascii?Q?P9m6IVitTxn2w2wAfFHXvfKRGsFWaC8N07gJ7vew95jJLVkKyyDZEq5Cpr9w?= =?us-ascii?Q?kN16kpB8hOXz2uD/I2NoCEELILoK6lgAM1qjvuUByMrMahygvJaJTB5P1Zqm?= =?us-ascii?Q?5Lr4L1YqumkkbugUyZ9UpYaXYYCDrNr9foX9?= 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)(376014)(7416014)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jul 2025 17:17:50.9938 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 193ffc1e-4562-4591-00cf-08ddbfd5b329 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: SJ5PEPF000001CA.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB7880 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. This can be simplified by passing the mode and closid directly, instead of through the rdtgroup struct. Doing so also facilitates calling parse_cbm() to verify the CBM within the io_alloc feature, since io_alloc does not have rdtgroup context. Signed-off-by: Babu Moger --- v7: Rephrase of changelog. 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 e78828b0408a..5c16557fb7a8 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 3d4a3d7696d0..ab76a1e2e679 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 Tue Oct 7 10:00:52 2025 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2079.outbound.protection.outlook.com [40.107.244.79]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 045322F19B3; Thu, 10 Jul 2025 17:18:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.79 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752167893; cv=fail; b=igv+cAJl5yl1Oo91v/RrxnXQCqDmGq4DJ1uSegkZgB8bk70WzCJG49i+8nWOMAwviykzvnXZsxkulEvcsHhNoZdpcb5Bl2q+Mi/6Fa9lawXxaeo7C0Ks1ME3f2zf9uLdJjfknDFiroUfAtC7FSWspm0OV/NjYm4XMxG09rzTAdM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752167893; c=relaxed/simple; bh=dMsC3i6V0gWuV7YWdK9jAPL74ZChVb+p7niD5XsUrKM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Ybgo5aSFDn3WqsTvEcWgMKx1cti21HXyp9IW5YDCncUqYLOYym7jZaKsG1n08w/McDS0SVgOgZVfv76RHkO8aCcWZVnhLsbCsmkIqXm8nEL+E4ZzcDzFLWhKzvt2z0nhptbZJBXqdDjqy/G+s3ATpSEZ0MDNUnXl4KV/u5mOIIY= 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=AbClu1Kc; arc=fail smtp.client-ip=40.107.244.79 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="AbClu1Kc" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=J5NaWyUb5LSqUqKt4xkCggtwOUI/KGzSOVV0jU8vBlxhrJAf3uXINI2hQPTPsl9r7exg24c3P1RZ+Ye9P+XsUsUE7XxdZ+v7kAMGo2RHw4BMecT1YIsELgUyj7o/3gIZn5JFPpCmC02K0zwMPLYQymTf5QCJlPB+GvNMKbbf+Tw/PZQ2l8KoZUT32+pmBVnnbwEYQPnVN52MD7NDVz0w3++OHSZnQM+4MnwgG28uGjep06PvQ+5efFDxrOkpIOeLe47j1RwfmcR0vDJ5snWOzKi0SirEwPj4T42DfeXg1hHuXGKX6buJl2U0VtlMQH358JR6RWo/c/wkrn4nhNqRYg== 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=D1P99AnkPN8ifVdABFqhQegfd9GPMuB2TA74NLuutgI=; b=fnLOU0xabhvLqub/Kb1DMaLOXoHmWXjgEGneJoKFqbnW2mzNKZTfy63zrqMwvd5XG42Qnti3VYUHRqtGC+7BoAj41Ta1ro29s5jxEzhMSXzBT81mPYwKvJWSrNVeI5mowu1/YPbPrh3NZPfgIp5si7siIJA+eL8w/qSHma4Wt2ISNWkLPyZAjYuV+K3hE9CJgtaJ1unGK+aT3wX8NRJkhISDbNtU2IKu9/4S3fNvBzXECDo3n2SVVkEaUFuxUW7xxfLdepwyd5N0vB4E/m4F/v24TUJoYqa0JspuHyVAMNAisVxaZOOJ4ybQvSxBhBTKcUiofhNOguccVkrhMRcwFg== 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=D1P99AnkPN8ifVdABFqhQegfd9GPMuB2TA74NLuutgI=; b=AbClu1KcS/3fi8xJwuWP9ygbZ3MVaMSqtpjhpmuC5RNIsNzR+0yBeXde73vU7SUTSBJ7F3oNE6Cp3VWwPTMBB4PKoO4qdPv7g3D8qAENlSFefppNCBA+vpwaydzul9UQGIJnb5LDYPIVXfPb1W/HyJDMVPiKQTjqurg9yGbOtlI= Received: from BYAPR02CA0056.namprd02.prod.outlook.com (2603:10b6:a03:54::33) by MN2PR12MB4438.namprd12.prod.outlook.com (2603:10b6:208:267::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8901.28; Thu, 10 Jul 2025 17:18:03 +0000 Received: from SJ5PEPF000001CD.namprd05.prod.outlook.com (2603:10b6:a03:54:cafe::63) by BYAPR02CA0056.outlook.office365.com (2603:10b6:a03:54::33) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8922.22 via Frontend Transport; Thu, 10 Jul 2025 17:18:02 +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 SJ5PEPF000001CD.mail.protection.outlook.com (10.167.242.42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8922.22 via Frontend Transport; Thu, 10 Jul 2025 17:18:01 +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; Thu, 10 Jul 2025 12:17:57 -0500 From: Babu Moger To: , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v7 10/10] fs/resctrl: Introduce interface to modify io_alloc Capacity Bit Masks Date: Thu, 10 Jul 2025 12:16:24 -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: SJ5PEPF000001CD:EE_|MN2PR12MB4438:EE_ X-MS-Office365-Filtering-Correlation-Id: 094daa52-fc69-4e56-a5db-08ddbfd5b9a4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?FeL3GvqLfMzfhW85MnlyBttvAc3Z797krvsYi5hA//WmrYSwjJae82+9b9dg?= =?us-ascii?Q?6kbV8d1ldkU65Y6OIR+EjaSethfWTVedpQnEVOT6k/K/cHCbB7C4ymgIyzmJ?= =?us-ascii?Q?wUZkINbf/iya0nxdVMX2znyztij2cTlODN51zQm6cCQZIsdc/5M2RgA+Eqjn?= =?us-ascii?Q?eoCrw1D2LJsSHzpAQcFEWHmxE3B0KXEcbcWf8J4euV15bqJI/Jn953uQmOZo?= =?us-ascii?Q?v2jIj7WXZu9W/Z6hlRyUjnlvl7I4+6hnNp77VizG9hLkO53ir1czqOCrb54L?= =?us-ascii?Q?KJBbinE0UPQUKYSk58RpgQcQKDcXSy9skSAjTYAjXYrElIDQ1RCBuL7qIMTj?= =?us-ascii?Q?FOhnbdhgR3jy5v8zYEd8J9SlKB3BrtBoMwkKPgCGLA29XQEkFzdufKudW5C8?= =?us-ascii?Q?xyCcOujLdirB/c+sg9xc2FwD6yiTujr764ToYv+85jqL6dpilaseFbgRl6nT?= =?us-ascii?Q?OAiAxBYs/wxhsJcfJg6mmim+rdIs5H3Un0IsatCEXZoZfADogVKU5p8Spmta?= =?us-ascii?Q?wWq7V5jexZhzMwkqW0LjrkTaBOMKhe300VEB9i7YazGE9m+wJ64qqwpI/hjv?= =?us-ascii?Q?jSzRQuGOw3s8hNvHC5KaPj0+SLpAKZ7950fZdoPTZk/1mC6FK9/DgKi3VBUF?= =?us-ascii?Q?n9bWG/z6dCOP3OSWapGLFi3V1L4Pf2c+ABclAauiteHEl73crr2YXf9dSSPf?= =?us-ascii?Q?Su7hi93P13JmFMV1TCIILeIWUerW5d0IhupS4XD/T6RYsow7LRwgs4VuogbE?= =?us-ascii?Q?bMhP7OrxxwmtbG1wBtJlpfRV4Og/ysLDxBiDDdprIQvRazZ7+D4k9Dh5zMHv?= =?us-ascii?Q?KwPJL2LU3tyPeiYk5i5XaOoM1muFCnQytWQgQCn0p1kJcBV5eU2YJChq1NzE?= =?us-ascii?Q?tgaCGxRy9ZzAeGijpW3h7pvjm4VU0kYhjkq7MbBKOua0lgZyV4UqjCi0zKiJ?= =?us-ascii?Q?SPFnDU5YXW7A+zj6eMh950oKklANLjNuoNZ05Yf0bB4dTnsn0GcHxnvAvwpW?= =?us-ascii?Q?qfvjiTp1d62vPXsaBJxRy9Gajr/DHGWkHsDT3Ndfa7CugZ+t5v9ESZDKyXvT?= =?us-ascii?Q?PFyC7XAOx7Ipxs8KYnHlHxvz5cOZwGA7QcvO6kdYr5OlnlUCqYa0OXQkMzSQ?= =?us-ascii?Q?gGBlEIlfLUJdPf0tiqvuE93qkd9xZIeDflgQbg5jPTTCDSLBGcQTaK+ww/0b?= =?us-ascii?Q?LwcMZ/2F+o2rRPeKnia88KlrZB5du6MLj73fZ2QfYkfanOJ2KHpBfVUztRf8?= =?us-ascii?Q?/sAvzLKVApC8+VZQAA/2avbT4uh/RSbVHLAbxAJ7Xo7rDyxP7zqTQplF97Lu?= =?us-ascii?Q?WweYBQL2+Aw2+GTpNVojriKxny+r91LWOTWhvkWXlARefUe6f/uzLqqTAgIW?= =?us-ascii?Q?OlKD4KAbi6SA2DHkBcs2rcfFeTrzeeiQOso1cyHzO06rASmP0aw2dRTn4DPQ?= =?us-ascii?Q?NrqSkTIDlbpk/K0DRIfsmgLHdxXD1aQB3ebfKGaBQ21hSLeYeUgsZbT7883g?= =?us-ascii?Q?LlPK/zsHs8fxZ2aZbsS55iNqtKZas5SpXBNA?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(1800799024)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jul 2025 17:18:01.8710 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 094daa52-fc69-4e56-a5db-08ddbfd5b9a4 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: SJ5PEPF000001CD.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4438 Content-Type: text/plain; charset="utf-8" "io_alloc" feature enables direct insertion of data from I/O devices into the 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. Provide the interface to modify io_alloc CBMs (Capacity Bit Mask) when feature is enabled. Update the CBMs for both CDP_DATA and CDP_CODE when CDP is enabled. Signed-off-by: Babu Moger --- v7: Updated changelog. Updated CBMs for both CDP_DATA and CDP_CODE when CDP is enabled. 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 | 8 ++ fs/resctrl/ctrlmondata.c | 4 +- fs/resctrl/internal.h | 2 + fs/resctrl/rdtgroup.c | 112 +++++++++++++++++++++++++- 4 files changed, 123 insertions(+), 3 deletions(-) diff --git a/Documentation/filesystems/resctrl.rst b/Documentation/filesyst= ems/resctrl.rst index c22a9dd667cd..b9c3ffdec27f 100644 --- a/Documentation/filesystems/resctrl.rst +++ b/Documentation/filesystems/resctrl.rst @@ -189,6 +189,14 @@ related to allocation: # cat /sys/fs/resctrl/info/L3/io_alloc_cbm 0=3Dffff;1=3Dffff =20 + CBMs 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_cbm" associated with the DATA and CODE resources may reflect the same values. For example, values read from and written to /sys/fs/resctrl/info/L3DATA/io_alloc_cbm may be reflected by diff --git a/fs/resctrl/ctrlmondata.c b/fs/resctrl/ctrlmondata.c index 5c16557fb7a8..23c72a5ac043 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 ab76a1e2e679..011564e69ed5 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 008657e43656..1093ec5e385b 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -2036,6 +2036,115 @@ static int resctrl_io_alloc_cbm_show(struct kernfs_= open_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); + enum resctrl_conf_type peer_type; + struct rdt_resource *r =3D s->res; + struct resctrl_schema *peer_s; + u32 io_alloc_closid; + char *peer_buf; + 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'; + + cpus_read_lock(); + mutex_lock(&rdtgroup_mutex); + + if (!r->cache.io_alloc_capable) { + rdt_last_cmd_printf("io_alloc is not supported on %s\n", s->name); + ret =3D -EINVAL; + goto out_unlock; + } + + rdt_last_cmd_clear(); + rdt_staged_configs_clear(); + + if (!resctrl_arch_get_io_alloc_enabled(r)) { + rdt_last_cmd_printf("io_alloc is not enabled on %s\n", s->name); + ret =3D -EINVAL; + goto out_unlock; + } + + io_alloc_closid =3D resctrl_io_alloc_closid(r); + + /* + * When CDP is enabled, update the schema for both CDP_DATA and CDP_CODE. + * Since the buffer is altered during parsing, create a copy to handle + * peer schemata separately. + */ + if (resctrl_arch_get_cdp_enabled(r->rid)) { + peer_type =3D resctrl_peer_type(s->conf_type); + peer_s =3D resctrl_get_schema(peer_type); + peer_buf =3D kmalloc(nbytes, GFP_KERNEL); + if (!peer_buf) { + rdt_last_cmd_puts("Out of Memory - io_alloc update failed\n"); + ret =3D -ENOMEM; + goto out_unlock; + } + + memcpy(peer_buf, buf, nbytes); + + if (peer_s) + ret =3D resctrl_io_alloc_parse_line(peer_buf, r, peer_s, io_alloc_closi= d); + + kfree(peer_buf); + } + + if (!ret) + ret =3D resctrl_io_alloc_parse_line(buf, r, s, io_alloc_closid); + + if (ret) + goto out_unlock; + + ret =3D resctrl_arch_update_domains(r, io_alloc_closid); + +out_unlock: + 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 { { @@ -2135,9 +2244,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 "max_threshold_occupancy", --=20 2.34.1