From nobody Wed Nov 27 12:26:58 2024 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2044.outbound.protection.outlook.com [40.107.236.44]) (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 CDF231A0BFF; Wed, 9 Oct 2024 17:40:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.44 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728495624; cv=fail; b=Rpyl4xwb7JAmIuFHLSmMt78IMi8bknHVhuzffRn11Ofs0ExTm/WDHk/4Uk/xdJTv/IhuEqGZrXMk5qlrX7afxtvOcEMRt8YNWAojpabk5KPvJEXSAcFCz64N3IVDn9YSjW3gHBbBypNeDDxLGYloSFsJUG9xKZUcXvEeswcJoLU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728495624; c=relaxed/simple; bh=Jv4eoGJ0CHRCbeTKocu7+5nm/tukVvda/K7YFiGJSnw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=gz9/cRp+XkkfQz5rb2PSlFvijJtn3WLWRcrtYORLW75rgBG9RwHu8ka5FFi5KZevPPzHQxdRaiFPgVsZcikJEGdo9AD7EIbR6B6tr5S6+BNoNWB6NG4fnUWKYGk8YlsV/4IDUwjzhBv/0aU0PyExoi5N3zC74KvyxYmtWajNUXM= 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=nSk7T3vM; arc=fail smtp.client-ip=40.107.236.44 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="nSk7T3vM" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xSOfdAFxTCDBAHgb2cC2HjJOsHeB8mq9aXxBPSNm71FMDIPHwv88Uy6Gutp5nXeWSJnCfYvoyt5rzktoqpkyh+qRhrBdPCVsh3Gdnk1PKuDGNoWwJf62ZBP7V8NF52Hf/xLqzyzbOmI7V0yjqt+cHoF2xzxeX6a+HKamgmFeLz3+DoA3jbvFDna4A4J7nEkAcX+egXFZdDMuqlHhmwtEm8Kb13e7VRuwIUZDgOZkOKJQa3+1vyxrFLqSAx0nRoiDk7MyBfUyn7sM+G9IEmfkPIGixUvjNcxWdERmi3tiALJ3mEZmqSm+FON6xq3pc7U+Mq9+IVax/Ud3QsoUDTBraA== 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=QYXwWbFbOAMzyU8p0RiypVSRJ96oTrGVa1KxZXLRpNw=; b=AyM1GT/FCk0Rq6Nax4t73D4Axqw/ABD2D+Aj1qr7lnDMeL6V521eW7We5a6QiV54EFz60nBWwjAFN1ImZtyswXt8pbespBvAb++ueMrBUKx7/1yrLNYEjKzPtzkRar7zXi4hR9APiWqHyCUoT3wcpCHW7gjATQmFJ1Ki+bmv+JFL6rGSDCxUGZdN4kOB/H1fRpx5Km2OCbcCfXxLOyRFljV4hKOvpVn4qKkC9I4YbtH1dQk6MYfgS5awDP5lenbhKZV2qAJrgo4Qrto/K4gHa4G65C9+e8grWXhTZdmMJerQxncOVjy4/+nLaiUC6Rspv+rxK68Rzkfg9K4r8iwZ4Q== 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=QYXwWbFbOAMzyU8p0RiypVSRJ96oTrGVa1KxZXLRpNw=; b=nSk7T3vMfWr564Z4BWCf2ipUgcma/am39GQk9DVeuzgOuHd1hYJ6kVPTB94tKZfMGDsa6BRWqvPlRDZ17I+iA385ldhE5pS9bLL0hC2RGjpt9Wpr5MgT1sxWyJRBIlaObAHLFjn7nti5xhI1dhDfd7XXIEXcdIK7NiMT61V+gcI= Received: from SJ0PR13CA0169.namprd13.prod.outlook.com (2603:10b6:a03:2c7::24) by PH7PR12MB6787.namprd12.prod.outlook.com (2603:10b6:510:1ad::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.24; Wed, 9 Oct 2024 17:40:14 +0000 Received: from SJ1PEPF00001CDC.namprd05.prod.outlook.com (2603:10b6:a03:2c7:cafe::a3) by SJ0PR13CA0169.outlook.office365.com (2603:10b6:a03:2c7::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.16 via Frontend Transport; Wed, 9 Oct 2024 17:40:14 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ1PEPF00001CDC.mail.protection.outlook.com (10.167.242.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8048.13 via Frontend Transport; Wed, 9 Oct 2024 17:40:13 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 9 Oct 2024 12:40:11 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v8 01/25] x86/cpufeatures: Add support for Assignable Bandwidth Monitoring Counters (ABMC) Date: Wed, 9 Oct 2024 12:39:26 -0500 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00001CDC:EE_|PH7PR12MB6787:EE_ X-MS-Office365-Filtering-Correlation-Id: 73a33f69-0ad3-4ccb-47ef-08dce8896e5d 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?BVEuEGdTcZNdn+aDjtLu6F+Wnh440SD478PNkACHCE2rj62oMcB8hh6jTK6H?= =?us-ascii?Q?TuNARbyrzbh44JE8tV88zj3biZL7kldCjVG/91O+zc6EWQF9hGcNFWgujaMr?= =?us-ascii?Q?8XnwlZ8+tbverF0Gzz7y+aPuUqmZhvIhxCryj2vPKgHbC9LFVrLr+PBu7A3s?= =?us-ascii?Q?b8mx2EvGKSkXwmjVQP9gReMVgSBJ12QNqfT81VsapeZlzJj5GnmHNRaQuOnn?= =?us-ascii?Q?VOGvyITEtvUU4hcrUKktkkq3yMdL9a1UaQDd90EOWUraUJSNkFfdkv9XgQ6w?= =?us-ascii?Q?l4no8On3mjCk4r0ywqA/bVFYrNWdhgQvEgB9ZCeaphGPIMpLRNFq32nxYL+R?= =?us-ascii?Q?7xX08YjvFxLVVRlIqkTXeJRX2UxFoDk3cGYd0wsAdqvIz3EDhNhkZhoxVtG8?= =?us-ascii?Q?JIpQjBzCFMBmJeF5L511kgqV0SkCtHzwLWjoyE/Ul+oECTtKA5p1ftU1YQ1Z?= =?us-ascii?Q?SX5GeomwCMmv2lXN4hdMwSrghUmrc6yS//luIH4xcpNdPsv192ra52bcB37J?= =?us-ascii?Q?qLaWys/nRilG6OVaLRmWo7IfUxKhEixb61sjWa9U7ZYQenEk7LE5g68lEDzy?= =?us-ascii?Q?DiOvIz7lEmU6hovJpWJeW21aYdKUsENW9VldJX30PSrfOM11cNc02mdqM5dr?= =?us-ascii?Q?qLM1cWDgp37RoJeYaHQS8y2lWbdIGsnIP0UBQPTrkhyVFd4G5UXNUBcX6+sR?= =?us-ascii?Q?wsYXL9z5l+E+0y/V1hsjloFIZpY/79mcLmJterIdEDlcshZ4TeSrQtLzlpSV?= =?us-ascii?Q?xoIOUW6YA/SXzNSVDuRKZPIV9uPATcddMb26Ue6L9tdVxeP48ZLeBTFurWKP?= =?us-ascii?Q?GOp1Qoi/pHgc+FX3tGj2R2OErDbDgYua30KG+0KIAaAeCpCBjIQ2UvQmcgQ5?= =?us-ascii?Q?2y0CLCD/oQm3JdYOO0+z2AmxRGsP1kU3kl9FIQ8m5Klcp1kdpZ/4H4pN1etg?= =?us-ascii?Q?ltfe53GPfGSMb3JzC7VCH06Y0p3S3D92Zh57TfEsltWl3EzLFDUeeG/NTuMl?= =?us-ascii?Q?wx/h73wdTS/RbQXz0WnicWjj9wyjyI3mmFDDhop6uGxetcH3t81PR2tJZX12?= =?us-ascii?Q?KX8VZoiV3mA1ccNHZ9MnETJIkRxAna/kHJ7D6I4U+c5OmbJI+RhGnbQ+atS3?= =?us-ascii?Q?ZdBzRwIkspVyRmr430OGQ+TEzOJE05ggR3aDCiLR2ec4+dkl0sn+sRkVBa0g?= =?us-ascii?Q?//tpXjWb+CYPouTo4iYosT77i1BHVIJ72DRFluf+3VSrniZNTsFF0aflasx/?= =?us-ascii?Q?GiiXNGtcMD05hodphEk0mK+uHft8U+dlcA5clots7veA9NAlF2nByTxw01v4?= =?us-ascii?Q?j8vnBArDEYPpEenDYRsb570YMhZqMYB4n5h3UpCGdeujitP3yr6zmEFxtAWL?= =?us-ascii?Q?zGlU4+Xq1BOGFc9P8Wq7497Or2hS?= 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: 09 Oct 2024 17:40:13.8132 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 73a33f69-0ad3-4ccb-47ef-08dce8896e5d 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: SJ1PEPF00001CDC.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6787 Content-Type: text/plain; charset="utf-8" Users can create as many monitor groups as RMIDs supported by the hardware. However, bandwidth monitoring feature on AMD system only guarantees that RMIDs currently assigned to a processor will be tracked by hardware. The counters of any other RMIDs which are no longer being tracked will be reset to zero. The MBM event counters return "Unavailable" for the RMIDs that are not tracked by hardware. So, there can be only limited number of groups that can give guaranteed monitoring numbers. With ever changing configurations there is no way to definitely know which of these groups are being tracked for certain point of time. Users do not have the option to monitor a group or set of groups for certain period of time without worrying about RMID being reset in between. The ABMC feature provides an option to the user to assign a hardware counter to an RMID, event pair and monitor the bandwidth as long as it is assigned. The assigned RMID will be tracked by the hardware until the user unassigns it manually. There is no need to worry about counters being reset during this period. Additionally, the user can specify a bitmask identifying the specific bandwidth types from the given source to track with the counte= r. Without ABMC enabled, monitoring will work in current mode without assignment option. Linux resctrl subsystem provides the interface to count maximum of two memory bandwidth events per group, from a combination of available total and local events. Keeping the current interface, users can enable a maximum of 2 ABMC counters per group. User will also have the option to enable only one counter to the group. If the system runs out of assignable ABMC counters, kernel will display an error. Users need to disable an already enabled counter to make space for new assignments. The feature can be detected via CPUID_Fn80000020_EBX_x00 bit 5. Bits Description 5 ABMC (Assignable Bandwidth Monitoring Counters) The feature details are documented in APM listed below [1]. [1] AMD64 Architecture Programmer's Manual Volume 2: System Programming Publication # 24593 Revision 3.41 section 19.3.3.3 Assignable Bandwidth Monitoring (ABMC). Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D206537 Signed-off-by: Babu Moger Reviewed-by: Reinette Chatre --- Note: Checkpatch checks/warnings are ignored to maintain coding style. v8: No changes. v7: Removed "" from feature flags. Not required anymore. https://lore.kernel.org/lkml/20240817145058.GCZsC40neU4wkPXeVR@fat_crat= e.local/ v6: Added Reinette's Reviewed-by. Moved the Checkpatch note below ---. v5: Minor rebase change and subject line update. v4: Changes because of rebase. Feature word 21 has few more additions now. Changed the text to "tracked by hardware" instead of active. v3: Change because of rebase. Actual patch did not change. v2: Added dependency on X86_FEATURE_BMEC. --- arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/kernel/cpu/cpuid-deps.c | 3 +++ arch/x86/kernel/cpu/scattered.c | 1 + 3 files changed, 5 insertions(+) diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpuf= eatures.h index dd4682857c12..4c514cb245ff 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -473,6 +473,7 @@ #define X86_FEATURE_CLEAR_BHB_HW (21*32+ 3) /* BHI_DIS_S HW control enable= d */ #define X86_FEATURE_CLEAR_BHB_LOOP_ON_VMEXIT (21*32+ 4) /* Clear branch hi= story at vmexit using SW loop */ #define X86_FEATURE_FAST_CPPC (21*32 + 5) /* AMD Fast CPPC */ +#define X86_FEATURE_ABMC (21*32 + 6) /* Assignable Bandwidth Monitoring C= ounters */ =20 /* * BUG word(s) diff --git a/arch/x86/kernel/cpu/cpuid-deps.c b/arch/x86/kernel/cpu/cpuid-d= eps.c index 8bd84114c2d9..7e4d63b381d6 100644 --- a/arch/x86/kernel/cpu/cpuid-deps.c +++ b/arch/x86/kernel/cpu/cpuid-deps.c @@ -70,6 +70,9 @@ static const struct cpuid_dep cpuid_deps[] =3D { { X86_FEATURE_CQM_MBM_LOCAL, X86_FEATURE_CQM_LLC }, { X86_FEATURE_BMEC, X86_FEATURE_CQM_MBM_TOTAL }, { X86_FEATURE_BMEC, X86_FEATURE_CQM_MBM_LOCAL }, + { X86_FEATURE_ABMC, X86_FEATURE_CQM_MBM_TOTAL }, + { X86_FEATURE_ABMC, X86_FEATURE_CQM_MBM_LOCAL }, + { X86_FEATURE_ABMC, X86_FEATURE_BMEC }, { X86_FEATURE_AVX512_BF16, X86_FEATURE_AVX512VL }, { X86_FEATURE_AVX512_FP16, X86_FEATURE_AVX512BW }, { X86_FEATURE_ENQCMD, X86_FEATURE_XSAVES }, diff --git a/arch/x86/kernel/cpu/scattered.c b/arch/x86/kernel/cpu/scattere= d.c index c84c30188fdf..87f63e6b2994 100644 --- a/arch/x86/kernel/cpu/scattered.c +++ b/arch/x86/kernel/cpu/scattered.c @@ -49,6 +49,7 @@ static const struct cpuid_bit cpuid_bits[] =3D { { X86_FEATURE_MBA, CPUID_EBX, 6, 0x80000008, 0 }, { X86_FEATURE_SMBA, CPUID_EBX, 2, 0x80000020, 0 }, { X86_FEATURE_BMEC, CPUID_EBX, 3, 0x80000020, 0 }, + { X86_FEATURE_ABMC, CPUID_EBX, 5, 0x80000020, 0 }, { X86_FEATURE_PERFMON_V2, CPUID_EAX, 0, 0x80000022, 0 }, { X86_FEATURE_AMD_LBR_V2, CPUID_EAX, 1, 0x80000022, 0 }, { X86_FEATURE_AMD_LBR_PMC_FREEZE, CPUID_EAX, 2, 0x80000022, 0 }, --=20 2.34.1 From nobody Wed Nov 27 12:26:58 2024 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2059.outbound.protection.outlook.com [40.107.94.59]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A56091E0DAF; Wed, 9 Oct 2024 17:40:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.59 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728495630; cv=fail; b=Np9uog6CkpYi+3gUEDB84jfxuGHnNt4iicOesFJPZlJoNolp2ExjwO7TM6shJfKmk6e+0m8rIShkqYwIAHzCICYhQ4y+50lbpcFmR/6PI+D3Seo8HwyHuHMzZgvXied2mMbUVrDwP0KgOlsKUptHFxCNJrWvdpofSb2ZGQNkPHE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728495630; c=relaxed/simple; bh=I4NN8i1sjzhSnsYb2HBT67gF1okYyT4exWDeHTELKSQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=S7jTAy0vulrgjHRb6YqVP8ZmMhpsSBiSw5gtc7i4Vp22Z8SfLH89EmkH1dWEFcqdK7xKP3JDJZksMOSdWa2PVKOPCMd+gty8yaRROvo7SNqT8jr6UA2R1lbGlyFCkwDLtcy9KkspemKqXBmziAZ9wMtQ6aF36csQiIYe+vamEKA= 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=NeQLhjqY; arc=fail smtp.client-ip=40.107.94.59 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="NeQLhjqY" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Pz54MFtycJtKlUyfBPUkn3ONtpCit4lR1T0bKlZkf1aPiOK/YCeqg22+O9yVQAX5+aJOIoaydZMNF2v0z36S3lngdHetbJ4W+YOlLuJRTHb9VHOqcy1Tqa3d4lQSWhqG070Tu7AuPCNrOmVsKgYO58oRivXkiMQYFSCRHFo+Dk/QWHwc2FSTERs++C47j/eC6wwd8wOGvuYXko9Giap1lyymGRtDYFAwmchGhhQ8TZXnEZ5mCEPT+xkGp8BBmzfntyajEYICqgvCylknuwbtF6XwTSRR/SrsnapMdLJlaxW+qiEKyo9tfgM6JmCq7f77oNBC6IxxEfrxZA7veBcwhw== 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=d1AEeRNQzKG9qu5cDjxygzIcqOydi54hLdsycK1NSJo=; b=d6AJzh1axk7a8RP1XVvvBuBttIDgvmS5V8vNPuTyaHkMEuyXSzpNC/aQn0T/2RHCXUHXjN+SGbBlOanRXYIi9ty94tF/NSCZm2C2aCXNc7tlLmh1dXfBii4yIHBYCNIuaMp22f2MrBnK4XvB2dWstBLbechefdBE3jIfyYojXvkxmQ5/7JkjeH0pjmAPkBZpDJKF7C6njvEHijYSuq65dyHw+toQ5wzFT5ViRbYb2pO9M9eOp4xqRbG/qMA5J4fXQu0gA2bLoZ5+d2Zgqxe8UyAlly/4bqnLyO3X+VX/E1yGj/sJiwwkey++Hgj//f2Sz6xAMTBDrABECv5GqiOyvg== 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=d1AEeRNQzKG9qu5cDjxygzIcqOydi54hLdsycK1NSJo=; b=NeQLhjqYpe2i5e4V+xLsblUKioskU6/JejPXIb4UpW5pPRmiCv1IQGrLCDQtH35pftU6aMkXhtbaXT3Yk+vXZA41nT1vrRrouDk8I4T5g/HJymHCOcnBE5VhgjhjUENcDNPqqoF8BqAnny++Z120zmpLHXa5kYh9LOaYPLEeu7o= Received: from SJ0PR13CA0124.namprd13.prod.outlook.com (2603:10b6:a03:2c6::9) by IA1PR12MB8285.namprd12.prod.outlook.com (2603:10b6:208:3f6::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.16; Wed, 9 Oct 2024 17:40:23 +0000 Received: from SJ1PEPF00001CE2.namprd05.prod.outlook.com (2603:10b6:a03:2c6:cafe::ce) by SJ0PR13CA0124.outlook.office365.com (2603:10b6:a03:2c6::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.7 via Frontend Transport; Wed, 9 Oct 2024 17:40:23 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ1PEPF00001CE2.mail.protection.outlook.com (10.167.242.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8048.13 via Frontend Transport; Wed, 9 Oct 2024 17:40:22 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 9 Oct 2024 12:40:19 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v8 02/25] x86/resctrl: Add ABMC feature in the command line options Date: Wed, 9 Oct 2024 12:39:27 -0500 Message-ID: <4ad8817bfdd13e048f93b5868e888a799f8c538d.1728495588.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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00001CE2:EE_|IA1PR12MB8285:EE_ X-MS-Office365-Filtering-Correlation-Id: c1d241f3-16cf-4730-0ed9-08dce88973b3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|376014|1800799024|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?fDi2Stg+hhqMR55KdoVxAVam2i/lPqiHMkntgIZOa3Q4b+rXBr7nJCPQIdjV?= =?us-ascii?Q?23Wgg1ueRqsVEGyiRSOJHS4ZJnM4ZoaXmeEoq744AsTH1qmSu6uaZukREaK+?= =?us-ascii?Q?Sf/oWSVHPSVzNTkOUeVrqYisr8gitZm/m41hHaKqjvc/MWG7M8ASL3da0XD7?= =?us-ascii?Q?IsK1Z0G2y5SZ5nhKLyyVc4rOcpIxY5w1viw4T8eVjYvgyHGBYcpAUN4T38RH?= =?us-ascii?Q?wGKaj85MTLoRleh9ouFwqFADS2l9vITiIOdkve7tHnU4syTzQFSXrXirb0xG?= =?us-ascii?Q?DhJcUZJSLqt06vz7GbSICcq0cj4cH0l88iHkCpNvn2Ym96EpMyzWBfBGqUpj?= =?us-ascii?Q?9TEu3/L2Z9g1ad0Wx/w1RRZd2YtErShu60J+sold8Pv0JkEqLMP4M2Yzll5C?= =?us-ascii?Q?7M7GVGxaHl4wGu1TsNrUiZLraZVbn71hVZhnv8FjtREIBCsU1AnGuObNJAPb?= =?us-ascii?Q?zAXhGpF9IxIu9sGUmi0eCmGoLPigw7v9xuhlyhoTfGzSdgWp/MjpZpgsVJBd?= =?us-ascii?Q?ZcpQ1c3msA/nC4/uXK1spTdNbYGe2W88EzJuImOhintm/27RLezuK7LXNX5G?= =?us-ascii?Q?QxSrqsiNO6AV+ibSopx1hznp279ywLZlNg9WeXyoSn/EEzA4nYjp+dUWvVC3?= =?us-ascii?Q?BtSO8lbFAn4gIbGIX5I+7QcgqGhohE/1p6mv/M1R0N3huAj1ul74I/L1NVvw?= =?us-ascii?Q?RgE3zvfiRlpXKL9JfE6ot7li1eMjxWz/JlRjS1jpokKhk7qW1zK6qqDeUM1v?= =?us-ascii?Q?qJ6LDxsQrSgOkrPfqXV5AyIIePRaHtZDcDmfZjb/pky+9bHi2l08w3+Xaew6?= =?us-ascii?Q?vujkK/DPZk0DSLYdE28asrMR9vSl6+/BHkAH9cShPQV+Kx4UhFyZss6tjDUk?= =?us-ascii?Q?FAMt2Rx/Rx5Xjym0lrbz8rM3fmi4xqRpaG2ObHoaK9WaoeiCOKJtqoCcDvEz?= =?us-ascii?Q?zQcQiDUDw5lhM23IKeCDF0cqK/1A/Qz49pcxZMT9jnq5HPDtEAG++1vQezwe?= =?us-ascii?Q?J24U/b/lZby84exlb3wXmPF7jZWzti/EmSMr8oveB35G/EJyNupVnhU9t8e/?= =?us-ascii?Q?jqMLDMwJUC6C73zF3YhmggvTRCvLkNHV9p8KkGMGYNEU6L6VKRqn+o63OyIr?= =?us-ascii?Q?YInSX+saDI87FwevhYznsy5lmd1jU7waBTlu8Tyvs5NACNQYxRtd730GQfk4?= =?us-ascii?Q?kFjI9CcfrmD48vOr1qA/8bjwy7XyZqDISZVOZ4xwD4rzEkJ9v6GNESvOEu6B?= =?us-ascii?Q?Xy40lWk6s+co4nR1ePatn9NllDuq8jIRJJH4idtdkId0B34KjRm01gbggcSG?= =?us-ascii?Q?LtVSiIEPTXBBnKtTnsP52Q//iWaRdAfkAh9Dp0Y6fb9Xs0JE86cfah35+4n0?= =?us-ascii?Q?lf+LsPhQj7A3spYPfKkQ1d+Jim8T?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(82310400026)(376014)(1800799024)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2024 17:40:22.7639 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c1d241f3-16cf-4730-0ed9-08dce88973b3 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: SJ1PEPF00001CE2.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB8285 Content-Type: text/plain; charset="utf-8" Add the command line option to enable or disable exposing the ABMC (Assignable Bandwidth Monitoring Counters) hardware feature to resctrl. Signed-off-by: Babu Moger Reviewed-by: Reinette Chatre --- v8: Commit message update. v7: No changes v6: No changes v5: No changes v4: No changes v3: No changes v2: No changes --- Documentation/admin-guide/kernel-parameters.txt | 2 +- Documentation/arch/x86/resctrl.rst | 1 + arch/x86/kernel/cpu/resctrl/core.c | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentatio= n/admin-guide/kernel-parameters.txt index 1518343bbe22..b3b3ca564220 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -5677,7 +5677,7 @@ rdt=3D [HW,X86,RDT] Turn on/off individual RDT features. List is: cmt, mbmtotal, mbmlocal, l3cat, l3cdp, l2cat, l2cdp, - mba, smba, bmec. + mba, smba, bmec, abmc. E.g. to turn on cmt and turn off mba use: rdt=3Dcmt,!mba =20 diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/re= sctrl.rst index a824affd741d..30586728a4cd 100644 --- a/Documentation/arch/x86/resctrl.rst +++ b/Documentation/arch/x86/resctrl.rst @@ -26,6 +26,7 @@ MBM (Memory Bandwidth Monitoring) "cqm_mbm_total", "cqm_= mbm_local" MBA (Memory Bandwidth Allocation) "mba" SMBA (Slow Memory Bandwidth Allocation) "" BMEC (Bandwidth Monitoring Event Configuration) "" +ABMC (Assignable Bandwidth Monitoring Counters) "" =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D =20 Historically, new features were made visible by default in /proc/cpuinfo. = This diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 8591d53c144b..668148ceda0b 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -809,6 +809,7 @@ enum { RDT_FLAG_MBA, RDT_FLAG_SMBA, RDT_FLAG_BMEC, + RDT_FLAG_ABMC, }; =20 #define RDT_OPT(idx, n, f) \ @@ -834,6 +835,7 @@ static struct rdt_options rdt_options[] __initdata =3D= { RDT_OPT(RDT_FLAG_MBA, "mba", X86_FEATURE_MBA), RDT_OPT(RDT_FLAG_SMBA, "smba", X86_FEATURE_SMBA), RDT_OPT(RDT_FLAG_BMEC, "bmec", X86_FEATURE_BMEC), + RDT_OPT(RDT_FLAG_ABMC, "abmc", X86_FEATURE_ABMC), }; #define NUM_RDT_OPTIONS ARRAY_SIZE(rdt_options) =20 --=20 2.34.1 From nobody Wed Nov 27 12:26:58 2024 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2053.outbound.protection.outlook.com [40.107.93.53]) (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 16C1F1D3631; Wed, 9 Oct 2024 17:40:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.53 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728495638; cv=fail; b=ZvZX4sRO+K/TQSzQIpQDIWLkWcH+03AIMTS8mw5z/JHg9/lFhEeDHGaAVoQZ6uHlUO93QGOE599VkDe3bguYx77sJw1g1lyO8qf5EeUKGjSmIBzw8SWNrWkMQF5RacWzaWZ1k8iy5S9MuIbXCOfsy3GNWz1bERD0rEmogCNLEJo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728495638; c=relaxed/simple; bh=50OF/Af4vnYAnh8YBlTdBAqV5yU+r/Y8ou8Pae2GEos=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZixEf7OylIbY9ZNK+YwFQNXaWpjRNBXWxMqYbliNwi+TqkP8noqPITxdNnWG9imlQ2I6hCwTfH+WdKQj38Y4p3zCy5ZNX/5LqEZ1Fu4Z5NQBBIsXRz0yjgyLyFUyCqr+1N0SqU5Pnj+ywo+1+nmqbYFvusYHN6GyEcPCJdFvDwE= 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=r2kPzpG8; arc=fail smtp.client-ip=40.107.93.53 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="r2kPzpG8" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nw9buNm4azdH9z6N4ikeGl5C6oiUoQBfVZpb7tqsiScWhtVgmgGhuLJ487qjduXYcSQGFmsMfP/j+OxnvDTPUC9nTE/geL/yxWPAjtz5wBgAoSixdgXwYxrYw4twjfo+qL4EjB5Lnoo9a8AN0YMPlSQg6VzTZ/BKwjRffUkxnNG47nz6pOnNYs588+SoTqdaYSjFHjywoB8QC1qVGmuEeQmTgO/NirB6HjDIjdg7RxZ8e+leGg5NNCFDvBHAPoRnYFYbxv+CaAVO9z0a7cqnTPQTYUEr9eHRG5vpEUqPcHID8s/3x8H0wPNhh51ZSv8qNhnI2HfEN+laYS3jmw11PA== 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=WOPxvjdgUFOCMbRC+vTYbtH1ymCbMDz59ENsF93yn/M=; b=LEQx+QvjJFbidXfQwbfln7t9m6qRebhjvV6TxLi7GclEQeFIJIFn/TRt5bEMJmdP/D4iA/Qv0R7+j59eE14Q0ELC+583SAXz4iKcFYzTI3mTFlUFJsFSewcGaoIlgiVnhYpiaJwmaBXrRRhpRYlt4aYoAUzDjmsbQqHoA47UXWu1gHzyvuX7EgTCX9D/oePC886WNt4hM9NEbr+hPICalyR3UpQflEsRKoabUYeXzwJncDQGOGxFHzsCD2sCEVHMTV+I0wiidwmncHGYYFZ56CjdIYSzdt0t8J79Q3k7ElAivBVqAnIxEp7ruXrP/I/dpYd23OJID1l77O4GiZ/VRg== 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=WOPxvjdgUFOCMbRC+vTYbtH1ymCbMDz59ENsF93yn/M=; b=r2kPzpG8vUsNQTeeKhzPfoAmT5shZGdWqYbc35CO+DkMfqFYp6fZMHLcek8ffmoCoZN2GtQEWg2szs4ubo/lEhbDBE91QgfoXCuzj2nYW2xaq52BbzRQ+IuWFtwX+/IoRFtETgBfBQGR44RKMl7m0aX6ttcaGiRrl7e6hj3G+To= Received: from SJ0PR05CA0187.namprd05.prod.outlook.com (2603:10b6:a03:330::12) by MN2PR12MB4302.namprd12.prod.outlook.com (2603:10b6:208:1de::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.18; Wed, 9 Oct 2024 17:40:29 +0000 Received: from SJ1PEPF00001CDD.namprd05.prod.outlook.com (2603:10b6:a03:330:cafe::cb) by SJ0PR05CA0187.outlook.office365.com (2603:10b6:a03:330::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.15 via Frontend Transport; Wed, 9 Oct 2024 17:40:29 +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 SJ1PEPF00001CDD.mail.protection.outlook.com (10.167.242.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8048.13 via Frontend Transport; Wed, 9 Oct 2024 17:40:29 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 9 Oct 2024 12:40:27 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v8 03/25] x86/resctrl: Consolidate monitoring related data from rdt_resource Date: Wed, 9 Oct 2024 12:39:28 -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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00001CDD:EE_|MN2PR12MB4302:EE_ X-MS-Office365-Filtering-Correlation-Id: 747aa346-a7f6-4508-a849-08dce88977ba 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?/owLoLwmhrW4l02+v8XNgT63iknrQibsUQ3Y+rNjyudokoLNPKHt4wr/jzsf?= =?us-ascii?Q?naOc64e2HkPN+cmmZacHcGODHGAZIxhPbko1tEU61fmC5tJFgvPZw19Nn7bi?= =?us-ascii?Q?z+O9KMzZjru8oKecawBtnLdVFe6jhJNSFNvuu8nYFZVVnk8YJnWCMBWDTCMg?= =?us-ascii?Q?kWky3ChlvzKMEUlwkE0OD9iGctwdZK+4103woemDK8TE9pwj5ccJBm3SIllb?= =?us-ascii?Q?HU6pCBzAYxeZrrDKsiNQB/OJAPZWf+UhN6MXEZ2lH7oGEyPnjbFTA+WEYlDq?= =?us-ascii?Q?HnrbyegOuv05zpIdKy+b2PP8NPxdz+WAor9J+cx3TWMOGzSpyJ6w9SC3evD6?= =?us-ascii?Q?N+6t87XtC+sR1BDolxnaG1+D14oFvwG0HyUndE6DlktO18PFnHZ7MCJT1suQ?= =?us-ascii?Q?LxFwvNShndCxwv+p368iERT32ObhHkIzSrBCmtoVuagUu3sRpGQh1RvqKWg6?= =?us-ascii?Q?9E98o0v2GKkyLlCLG0RqFUZEs0UzfV6hjtsZVCE3rB3uUvqqkxsme95tBNlJ?= =?us-ascii?Q?vWD0bJkHl8LnzT7Pv2mlHegFCssmInBUXtEd4QNeK4QuDeSUziZU8inbgqiU?= =?us-ascii?Q?xOi3pt9gjiw7gQz2GqOE8qXh0zZDLajt5enk+8IZt6jdFmOOE3crqhbBglva?= =?us-ascii?Q?8ZhSFTAyZxeUuPdYVfdT9UpOhx0qEU8kctH334VKcysW4AEVLWxikxwxxGAp?= =?us-ascii?Q?Vuw39F+IgrNLGLZmmHhfUR34ho9oJnAlA3mh5JoRTvaU9aajjBnuOaHdAPsZ?= =?us-ascii?Q?DSB8F89qIxGMnwNFsXqgP+f4mqRbXJ9KhsKU0WepZ9pnmQOE/1pSw+lT1IWM?= =?us-ascii?Q?2gZ7lF9J1ZIiB2fIQe6///KnqN2hJs50gCYbvUrFRWbp7oukz1q4wud5dVus?= =?us-ascii?Q?N4DJxujKmRJR84o5MqRgzjHSNcf43YCd7Xvag17iBFjldn5cLzOrWGppAZ8c?= =?us-ascii?Q?P5GVHJ3Wrtu+NF1J5MiHNBXN6k6djFkpuh2CigsQ7iLd+6n8sx+myp2wUKNZ?= =?us-ascii?Q?QkW17fyCmr/CcxezXgdHH0mslDMfCyoQL2IvF+OLW9YZlPb1zQ60q7l9dzCE?= =?us-ascii?Q?r/Lnkv3MgJuZeTNPDePWz4TvQ50Fg/JKXhy0+SZTUnEuL5IFN5doGlaYJ3IJ?= =?us-ascii?Q?KNrwdgWTykt4ABBlEBsmonmnBsifLSSVbhYtJ+5lONunn1JU5g3CM6RBXYsT?= =?us-ascii?Q?qRElVDU9TmtuwvQPaPgAQvgydElroM3PD5G35aKbJMrorVT8MsnmDJbTFscd?= =?us-ascii?Q?hqJf4nctg13PJEgu61b9MVgrp5pAfCeHHfXRZ2ivcUHg8b2rgGATzBzP3Qqf?= =?us-ascii?Q?zHldGQ97lpK+k4oAXasyDj0aZzaB94bNh3uXSBHjqVIlFf9D625/B0ZsU9P9?= =?us-ascii?Q?qGI+vCM=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: 09 Oct 2024 17:40:29.5246 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 747aa346-a7f6-4508-a849-08dce88977ba 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: SJ1PEPF00001CDD.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4302 Content-Type: text/plain; charset="utf-8" The cache allocation and memory bandwidth allocation feature properties are consolidated into struct resctrl_cache and struct resctrl_membw respectively. In preparation for more monitoring properties that will clobber the existing resource struct more, re-organize the monitoring specific properties to also be in a separate structure. Suggested-by: Reinette Chatre Signed-off-by: Babu Moger Reviewed-by: Reinette Chatre --- v8: Added Reviewed-by from Reinette. No other changes. v7: Added kernel doc for data structure. Minor text update. v6: Update commit message and update kernel doc for rdt_resource. v5: Commit message update. Also changes related to data structure updates does to SNC support. v4: New patch. --- arch/x86/kernel/cpu/resctrl/core.c | 4 ++-- arch/x86/kernel/cpu/resctrl/monitor.c | 18 +++++++++--------- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 8 ++++---- include/linux/resctrl.h | 16 ++++++++++++---- 4 files changed, 27 insertions(+), 19 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 668148ceda0b..73bfc8d7a438 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -124,7 +124,7 @@ u32 resctrl_arch_system_num_rmid_idx(void) struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; =20 /* RMID are independent numbers for x86. num_rmid_idx =3D=3D num_rmid */ - return r->num_rmid; + return r->mon.num_rmid; } =20 /* @@ -625,7 +625,7 @@ static void domain_add_cpu_mon(int cpu, struct rdt_reso= urce *r) =20 arch_mon_domain_online(r, d); =20 - if (arch_domain_mbm_alloc(r->num_rmid, hw_dom)) { + if (arch_domain_mbm_alloc(r->mon.num_rmid, hw_dom)) { mon_domain_free(hw_dom); return; } diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 851b561850e0..795fe91a8feb 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -222,7 +222,7 @@ static int logical_rmid_to_physical_rmid(int cpu, int l= rmid) if (snc_nodes_per_l3_cache =3D=3D 1) return lrmid; =20 - return lrmid + (cpu_to_node(cpu) % snc_nodes_per_l3_cache) * r->num_rmid; + return lrmid + (cpu_to_node(cpu) % snc_nodes_per_l3_cache) * r->mon.num_r= mid; } =20 static int __rmid_read_phys(u32 prmid, enum resctrl_event_id eventid, u64 = *val) @@ -297,11 +297,11 @@ void resctrl_arch_reset_rmid_all(struct rdt_resource = *r, struct rdt_mon_domain * =20 if (is_mbm_total_enabled()) memset(hw_dom->arch_mbm_total, 0, - sizeof(*hw_dom->arch_mbm_total) * r->num_rmid); + sizeof(*hw_dom->arch_mbm_total) * r->mon.num_rmid); =20 if (is_mbm_local_enabled()) memset(hw_dom->arch_mbm_local, 0, - sizeof(*hw_dom->arch_mbm_local) * r->num_rmid); + sizeof(*hw_dom->arch_mbm_local) * r->mon.num_rmid); } =20 static u64 mbm_overflow_count(u64 prev_msr, u64 cur_msr, unsigned int widt= h) @@ -1083,14 +1083,14 @@ static struct mon_evt mbm_local_event =3D { */ static void l3_mon_evt_init(struct rdt_resource *r) { - INIT_LIST_HEAD(&r->evt_list); + INIT_LIST_HEAD(&r->mon.evt_list); =20 if (is_llc_occupancy_enabled()) - list_add_tail(&llc_occupancy_event.list, &r->evt_list); + list_add_tail(&llc_occupancy_event.list, &r->mon.evt_list); if (is_mbm_total_enabled()) - list_add_tail(&mbm_total_event.list, &r->evt_list); + list_add_tail(&mbm_total_event.list, &r->mon.evt_list); if (is_mbm_local_enabled()) - list_add_tail(&mbm_local_event.list, &r->evt_list); + list_add_tail(&mbm_local_event.list, &r->mon.evt_list); } =20 /* @@ -1186,7 +1186,7 @@ int __init rdt_get_mon_l3_config(struct rdt_resource = *r) =20 resctrl_rmid_realloc_limit =3D boot_cpu_data.x86_cache_size * 1024; hw_res->mon_scale =3D boot_cpu_data.x86_cache_occ_scale / snc_nodes_per_l= 3_cache; - r->num_rmid =3D (boot_cpu_data.x86_cache_max_rmid + 1) / snc_nodes_per_l3= _cache; + r->mon.num_rmid =3D (boot_cpu_data.x86_cache_max_rmid + 1) / snc_nodes_pe= r_l3_cache; hw_res->mbm_width =3D MBM_CNTR_WIDTH_BASE; =20 if (mbm_offset > 0 && mbm_offset <=3D MBM_CNTR_WIDTH_OFFSET_MAX) @@ -1201,7 +1201,7 @@ int __init rdt_get_mon_l3_config(struct rdt_resource = *r) * * For a 35MB LLC and 56 RMIDs, this is ~1.8% of the LLC. */ - threshold =3D resctrl_rmid_realloc_limit / r->num_rmid; + threshold =3D resctrl_rmid_realloc_limit / r->mon.num_rmid; =20 /* * Because num_rmid may not be a power of two, round the value diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index d7163b764c62..f9f3b5db1987 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -1097,7 +1097,7 @@ static int rdt_num_rmids_show(struct kernfs_open_file= *of, { struct rdt_resource *r =3D of->kn->parent->priv; =20 - seq_printf(seq, "%d\n", r->num_rmid); + seq_printf(seq, "%d\n", r->mon.num_rmid); =20 return 0; } @@ -1108,7 +1108,7 @@ static int rdt_mon_features_show(struct kernfs_open_f= ile *of, struct rdt_resource *r =3D of->kn->parent->priv; struct mon_evt *mevt; =20 - list_for_each_entry(mevt, &r->evt_list, list) { + list_for_each_entry(mevt, &r->mon.evt_list, list) { seq_printf(seq, "%s\n", mevt->name); if (mevt->configurable) seq_printf(seq, "%s_config\n", mevt->name); @@ -3057,13 +3057,13 @@ static int mon_add_all_files(struct kernfs_node *kn= , struct rdt_mon_domain *d, struct mon_evt *mevt; int ret; =20 - if (WARN_ON(list_empty(&r->evt_list))) + if (WARN_ON(list_empty(&r->mon.evt_list))) return -EPERM; =20 priv.u.rid =3D r->rid; priv.u.domid =3D do_sum ? d->ci->id : d->hdr.id; priv.u.sum =3D do_sum; - list_for_each_entry(mevt, &r->evt_list, list) { + list_for_each_entry(mevt, &r->mon.evt_list, list) { priv.u.evtid =3D mevt->evtid; ret =3D mon_addfile(kn, mevt->name, priv.priv); if (ret) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index d94abba1c716..3c2307c7c106 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -182,16 +182,26 @@ enum resctrl_scope { RESCTRL_L3_NODE, }; =20 +/** + * struct resctrl_mon - Monitoring related data of a resctrl resource + * @num_rmid: Number of RMIDs available + * @evt_list: List of monitoring events + */ +struct resctrl_mon { + int num_rmid; + struct list_head evt_list; +}; + /** * struct rdt_resource - attributes of a resctrl resource * @rid: The index of the resource * @alloc_capable: Is allocation available on this machine * @mon_capable: Is monitor feature available on this machine - * @num_rmid: Number of RMIDs available * @ctrl_scope: Scope of this resource for control functions * @mon_scope: Scope of this resource for monitor functions * @cache: Cache allocation related data * @membw: If the component has bandwidth controls, their properties. + * @mon: Monitoring related data. * @ctrl_domains: RCU list of all control domains for this resource * @mon_domains: RCU list of all monitor domains for this resource * @name: Name to use in "schemata" file. @@ -199,7 +209,6 @@ enum resctrl_scope { * @default_ctrl: Specifies default cache cbm or memory B/W percent. * @format_str: Per resource format string to show domain value * @parse_ctrlval: Per resource function pointer to parse control values - * @evt_list: List of monitoring events * @fflags: flags to choose base and info files * @cdp_capable: Is the CDP feature available on this resource */ @@ -207,11 +216,11 @@ struct rdt_resource { int rid; bool alloc_capable; bool mon_capable; - int num_rmid; enum resctrl_scope ctrl_scope; enum resctrl_scope mon_scope; struct resctrl_cache cache; struct resctrl_membw membw; + struct resctrl_mon mon; struct list_head ctrl_domains; struct list_head mon_domains; char *name; @@ -221,7 +230,6 @@ struct rdt_resource { int (*parse_ctrlval)(struct rdt_parse_data *data, struct resctrl_schema *s, struct rdt_ctrl_domain *d); - struct list_head evt_list; unsigned long fflags; bool cdp_capable; }; --=20 2.34.1 From nobody Wed Nov 27 12:26:58 2024 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2072.outbound.protection.outlook.com [40.107.92.72]) (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 D13FD1E0481; Wed, 9 Oct 2024 17:40:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.72 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728495649; cv=fail; b=TwgD4ma6ZjC2av/o9zckMUa9u1U4XtqRlcEmb8lh9lzplC4ZBK/nNhJAEelDVFF41Ih7KjPwtjyke2OTVrdFuDx9bxo4x7izelh3pTBk5an9eOPzDNLHcgWr8YvHMmabKrvNfJJar0YbdkjhKBr7OOO6m6hRlmPZ6SwRS1Hbz64= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728495649; c=relaxed/simple; bh=plfYM9dVyl9WOxEilD7d8swDJL9fdOF0R7wfFRiWQSg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=feMrFsORB7UU3cIFLPHvkNzzFT7raZSnYG8PeG/ers3dLxtMgOtaFBo0STsVDREG5XU+Nay92+O/enEz30pefBHHsGFCqCdj9ig9zzFyvjGmEPNOIf6kWqF8eGBfE10Sk+EMjWdObzt2uG+tlt1tRzzyB8tw4fUkv7Fll1HWFJA= 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=4CusasqO; arc=fail smtp.client-ip=40.107.92.72 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="4CusasqO" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=G/W8DPePaMh5zFJieodbAKaxBAZI/hAjOwgpC3HqJUla88/nqGysuAGoXCU0MzMCMsXwoWfGnUQ3lxS2+D8d4XZBfdyT6BY9bAAkgt7z8r1w2tcizAvNUKJ2AYtlp487Vp13CL9GBI68nOObUhLzsCR/JUb3HJbpeWBEwJ+xav5Z9/Ncsx8IPwzYfbCN+4IWvhXVXZtpdTXnQlSFEyxXfVJFuN7pC+ddFKqNJuZL+h+2CZpDE3Tjv5vM0EU5g7LYKHj3qFMNJAfnOVCTeH7kLFm43/AO/r8qab4hH9yKGoea26AZ+DktRoiCe8EMA15HP6pI5Pry1LtmcIQ1Wd97Yw== 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=V5iInP2Tkkz3/7r2BzSbTyn+iu2rS++fnxHlAYMpXd0=; b=MtLxskY/twYWh8I/G7AkaqlnxdV/PiEcWkXIqv0pn5qVC/khP2ZSFBywEZsEo7m4iyTgZRDCx2d8AYktN+zLYG86spOb3HAQzKsq63u1dDqH5B1eVjBn461s/jebdnRtWkg389S9T6/K8LXUl0+GUO1YLJZjbk+qMDJpPdrXjmSN/VjkEKEJt6nZxGXlTWmRBrQDy7k9ZYNvKHS4MqVcm7qa/iXhnRap3En8FcdfAunusbn2sZK37LFUtPLa+O4zqwgMd1ua4SbGB0UAo3oDM957vqTJTh4hY0zPpCltwouHNSTcZScvfZC7wDAyiUys+XwPJp+X5/OpkCrgx4GhKQ== 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=V5iInP2Tkkz3/7r2BzSbTyn+iu2rS++fnxHlAYMpXd0=; b=4CusasqOjX9TZkarEPEDU/jpPLQyXPN0EZJeIe++ry8qRq2rtanfEK7ZkLZ80900h1tBTQz02L54JfvC9SsHoYaBnwOH1gq+RZoLBgSQq9LqL03+ZlLSeveaJ7r/Rx8v2DxTV0jWsuPYNxB+PxZUDVY1m1QnQFDQWqO9xnPIpm4= Received: from SJ0PR13CA0131.namprd13.prod.outlook.com (2603:10b6:a03:2c6::16) by IA1PR12MB6603.namprd12.prod.outlook.com (2603:10b6:208:3a1::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.23; Wed, 9 Oct 2024 17:40:38 +0000 Received: from SJ1PEPF00001CE2.namprd05.prod.outlook.com (2603:10b6:a03:2c6:cafe::d6) by SJ0PR13CA0131.outlook.office365.com (2603:10b6:a03:2c6::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.16 via Frontend Transport; Wed, 9 Oct 2024 17:40:37 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ1PEPF00001CE2.mail.protection.outlook.com (10.167.242.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8048.13 via Frontend Transport; Wed, 9 Oct 2024 17:40:37 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 9 Oct 2024 12:40:35 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v8 04/25] x86/resctrl: Detect Assignable Bandwidth Monitoring feature details Date: Wed, 9 Oct 2024 12:39:29 -0500 Message-ID: <797226b0c121bca6b6e6c3bf535a70aef2c4989c.1728495588.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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00001CE2:EE_|IA1PR12MB6603:EE_ X-MS-Office365-Filtering-Correlation-Id: e4f746fd-dc13-499c-aae1-08dce8897ca8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|7416014|376014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?OgyAgMp5oPMNwE+pHK0/114ndBITvx/hDjPwTji1mjG6usoHnd+8jpFehh/p?= =?us-ascii?Q?BDY37jCgltSPnNVbRxADM+UkuwRjdApat1g1btkTLCxEK2tBSbcyKxhlX9QO?= =?us-ascii?Q?1ZdaA8o+4h7lIf4n2XPn+aF0j7FIjL0+/vrOe0t76A4hDQx1sL1PF0Jn1vWC?= =?us-ascii?Q?2CDOC3xVAJO0GctT8fOFCTEwkbBqJitnCQmnYxwrDkOqMzXJIvYlkc7GayRk?= =?us-ascii?Q?ylxn6isp38/zsbxeDoTK3eScc9Qw/zxUT0ze0SAsc8Xhaq94b238RL9K9K+w?= =?us-ascii?Q?kSuEXKk9SBSKjYCcvEB4u3kI3D1dt77aAH7IpLM+8Hoq6RfzG3mvQ/C4NQFv?= =?us-ascii?Q?Z8co+iL4JiVQzSn5RT96xCmXniJ5jDIUt6SYHwPaFgWqutVpXZDQfYW7G6Rj?= =?us-ascii?Q?NXGZu6sTgsAi1PfKFYvrevkA+eCd2ukOTK1Y2zkdpHPl3CSZfoZQCeOo2qCa?= =?us-ascii?Q?IssBi1UrHcxzJ/3quMnWC+0CLJ/lh/9GNo51A3I3sdBFwWiRoAthTLN6G6ct?= =?us-ascii?Q?Nsc4yt5YRR76E3HvIsP/keDHVH2DuKIbjMFNAxybYmiT8AsFqRp1+8N0yF8m?= =?us-ascii?Q?HXxV3ocyPyvr8QVRnuYYnq0KLgMlyLJtUdJKFLwWtK4mCeSpZTqxBN6KKqNt?= =?us-ascii?Q?hUD6uMUfo3RXqmrkKemsk8NrYb9DeH9UU+zqOpuxfgBwmYFl79y1K6L4g9gB?= =?us-ascii?Q?TkPHiLejtL6bPv0wRUn20bTkbxATWSiYE3bQIZKCoXFqJvo9yLvLcBKrzkkH?= =?us-ascii?Q?h/Xycsh2pThmLl2u4viVdWn0CDqsnmW12AK5QLZzRp+QtqlkL4fHTbSJgHaW?= =?us-ascii?Q?UjpESHdHB7eZjL1Cgn3Se1kuy/7CQT/Z/mwScT2QLQWqwdHzMuK7e4jdrh8c?= =?us-ascii?Q?hyqLK9BcrKzjUmW+DEowj6yjk+YMYwL3upj/6vHJKa1p3u89x1HMS3smr5Xn?= =?us-ascii?Q?x+H29mQ9ONCMS0d80c7iLw45MIe/Iw51tzlr+oNnAFQBH5jQyOCnU/NIbsKh?= =?us-ascii?Q?AUcG83nipiFy08VES1l35zSn2h2+z7Vzektd4xe+MhEDZFSkLsfy+Mmg/G2G?= =?us-ascii?Q?Lj2R0LhHqsads/Rrzuaggy80l3LRc1utNu/G4MSYNP3TnlpzHCLrov2ReXb+?= =?us-ascii?Q?xk6drOwOT2Im6JYC8kr5/oOivyi6axzJy4+Xlj0XOSQW0Jlo8AMWUpdZXiF5?= =?us-ascii?Q?DOjJmYiOVfL8UjQco43wzKG3ZZNa5Q4EaYBM2s4NBipJ6sgLuS84zzCe64SR?= =?us-ascii?Q?GI7F91o+/8HESlFzkSfjKPSN8WrN0VrmaDRmWmWvnfCvu4vIKvgjhv30IIW2?= =?us-ascii?Q?HVAjsmO+c1wumWKT9uX/I67sToBBlaZc1kifkgxgmQDa2SRwCD0EQKQTPP7i?= =?us-ascii?Q?Vvb+m7tyTOZjhYWsZhTBh6ed4MnZ?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(1800799024)(7416014)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2024 17:40:37.7797 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e4f746fd-dc13-499c-aae1-08dce8897ca8 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: SJ1PEPF00001CE2.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6603 Content-Type: text/plain; charset="utf-8" ABMC feature details are reported via CPUID Fn8000_0020_EBX_x5. Bits Description 15:0 MAX_ABMC Maximum Supported Assignable Bandwidth Monitoring Counter ID + 1 The feature details are documented in APM listed below [1]. [1] AMD64 Architecture Programmer's Manual Volume 2: System Programming Publication # 24593 Revision 3.41 section 19.3.3.3 Assignable Bandwidth Monitoring (ABMC). Detect the feature and number of assignable monitoring counters supported. Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D206537 Signed-off-by: Babu Moger Reviewed-by: Reinette Chatre --- v8: Used GENMASK for the mask. v7: Removed WARN_ON for num_mbm_cntrs. Decided to dynamically allocate the bitmap. WARN_ON is not required anymore. Removed redundant comments. v6: Commit message update. Renamed abmc_capable to mbm_cntr_assignable. v5: Name change num_cntrs to num_mbm_cntrs. Moved abmc_capable to resctrl_mon. v4: Removed resctrl_arch_has_abmc(). Added all the code inline. We dont need to separate this as arch code. v3: Removed changes related to mon_features. Moved rdt_cpu_has to core.c and added new function resctrl_arch_has_abm= c. Also moved the fields mbm_assign_capable and mbm_assign_cntrs to rdt_resource. (James) v2: Changed the field name to mbm_assign_capable from abmc_capable. --- arch/x86/kernel/cpu/resctrl/monitor.c | 6 ++++++ include/linux/resctrl.h | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 795fe91a8feb..41a8b587f4f5 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -1229,6 +1229,12 @@ int __init rdt_get_mon_l3_config(struct rdt_resource= *r) mbm_local_event.configurable =3D true; mbm_config_rftype_init("mbm_local_bytes_config"); } + + if (rdt_cpu_has(X86_FEATURE_ABMC)) { + r->mon.mbm_cntr_assignable =3D true; + cpuid_count(0x80000020, 5, &eax, &ebx, &ecx, &edx); + r->mon.num_mbm_cntrs =3D (ebx & GENMASK(15, 0)) + 1; + } } =20 l3_mon_evt_init(r); diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 3c2307c7c106..511cfce8fc21 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -185,10 +185,14 @@ enum resctrl_scope { /** * struct resctrl_mon - Monitoring related data of a resctrl resource * @num_rmid: Number of RMIDs available + * @num_mbm_cntrs: Number of assignable monitoring counters + * @mbm_cntr_assignable:Is system capable of supporting monitor assignment? * @evt_list: List of monitoring events */ struct resctrl_mon { int num_rmid; + int num_mbm_cntrs; + bool mbm_cntr_assignable; struct list_head evt_list; }; =20 --=20 2.34.1 From nobody Wed Nov 27 12:26:58 2024 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2062.outbound.protection.outlook.com [40.107.243.62]) (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 7E66E1E0DC9; Wed, 9 Oct 2024 17:40:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.62 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728495655; cv=fail; b=sFlvpjXDzr/oQLp4h5W5ewhkIJ5M7NZ9Xv2rhYOL+Bw6GLCL3lNe0rEwMtoB4C64P109JReHQ/IlyDRYZ5zqsNus81xXTkZtohpII53YiMPTeiKL4Kh9zeG3WrG32rwAOgafqB8a+lzyVJfNeQM5SvshwiTm+mRIDtdtOACp1kU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728495655; c=relaxed/simple; bh=YFA94wQ+PjaIuG4pZJrTVayaCQ/G7h9ZtXfYfyzrxgo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=g+cUx29RAe8GC1Mc4eNprXK5E3TPtZKsA+ZZGZ4/9KGeZFZdaeaAX+CW5NfZ3JpkcFXS2hQZSBtfqjbbc+W4ufOiGTV/jhlmUWFQItXpqElpa9JTavYWasG6oXsMxzT1TVawFp4Ufu9/C4qTK7yfP6UKGm34XQzfULZK83Xi8Z8= 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=uE4IaPAd; arc=fail smtp.client-ip=40.107.243.62 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="uE4IaPAd" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=d8bTzhEbHSMCRjjJgj3gQnLchtabNpvGlyA5eff0PADuZmk5CrBRxsSgmklsebIVlDOU5Y4yPdM6Lc4sTJYOQ4Zp0M+ZqEEBUnl2pXRqXx20JGKBiZlPPfOKbUR9KncLWExB5DoIvHBFTuUBNJITkuSeLj9OY93JzpMQMG1i6PbcjSdLcnVoH6L9nPzutBO+6bavnxeip5sWSjuzlBgbY2L5ZtzkkUQcag4MPLoM3GuQnLCdrdv6HTMDBkB1nU0uG0vD5e/qAHD87yZRa6jaPPywuSdMifAhzCqYTts3Y47YUBQBH435RN4khj9vK0UkUgge/JAUSGAEuqm4kBvTvw== 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=zptC0EhgCU8BnFQtcxNOa/dCGfMWkbirpe9ax5Kc+DU=; b=s0tfm2yLfBAbklZVl4EqaGtt4Iipato5Pxbeg7DzQFjze+avWwiuRS3R6zn3htSfQs87QpPROflJVa/a2B/1i4biPOpuRncXFN2jtdtDmg1HFD9QjvOjnIZDBiKqluj0Vls0R+MZXC0qxCKR3RM4vAqhZOyaMpDg0WGuPG5cde/XdgYjWNvorVn4AxdzUUJqvuhSZMAXZIzAZmOrJ8ne9jutDFZnluRmdrUt3E1XC0zZBJQhGadi8Yku1aTgq4AX5/AhMnqykd9xtmyPNWykV0m7TOMkft13kPZJa/PWg1LBa4ILgR3Ll0oQyrL+gDZ31C7TieeoghbtsHT3hILjgQ== 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=zptC0EhgCU8BnFQtcxNOa/dCGfMWkbirpe9ax5Kc+DU=; b=uE4IaPAdDZ/Bkn/JWvWyOjqnSXyW+1s+0IMl1enomkqEPcFBOD2New7E9lw0PuclTZxbF63bb5ZGY065iO7vgWcBTjdVyA82zbVsZ+xuLf+46VzgKvgFgW/9S5GkaNVr7JmoklVrzX9YLU6gqijlp9zPh9g7hPECblr/G6iOM2Q= Received: from MW3PR05CA0022.namprd05.prod.outlook.com (2603:10b6:303:2b::27) by CYYPR12MB8872.namprd12.prod.outlook.com (2603:10b6:930:c8::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.24; Wed, 9 Oct 2024 17:40:45 +0000 Received: from SJ1PEPF00001CDE.namprd05.prod.outlook.com (2603:10b6:303:2b:cafe::20) by MW3PR05CA0022.outlook.office365.com (2603:10b6:303:2b::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.7 via Frontend Transport; Wed, 9 Oct 2024 17:40:45 +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 SJ1PEPF00001CDE.mail.protection.outlook.com (10.167.242.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8048.13 via Frontend Transport; Wed, 9 Oct 2024 17:40:45 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 9 Oct 2024 12:40:43 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v8 05/25] x86/resctrl: Introduce resctrl_file_fflags_init() to initialize fflags Date: Wed, 9 Oct 2024 12:39:30 -0500 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00001CDE:EE_|CYYPR12MB8872:EE_ X-MS-Office365-Filtering-Correlation-Id: 892697e7-eeec-4c01-fa34-08dce889811c 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?/qlOugF4FBcMC8iFcphJNTS+piap/5ZApbok6py3f419xvRTes9HWz04Epzu?= =?us-ascii?Q?WO1pbwYf3XYMuRr6JmZ5PgLy7lpEESi6C4rnxu3VwEbsJ/BBkl8mLpRIhCix?= =?us-ascii?Q?Alk7yT9p2n5d/MVCr+MiHmYpRDsrgR2kDUL3b8Nziy2nTTvSZ8mMyQlGxdRM?= =?us-ascii?Q?BNEyUsGw3cspTrzEey54KjNTRvK4+q+1Ik/64DFqcEkCbGqAI0QY8/Q58nE5?= =?us-ascii?Q?JgYbG3rISVecDa+iin2YFHwjtHZgIWgKzXxwv/rMET98qO/VHRjP7DBb/nH8?= =?us-ascii?Q?jyZgDsjQVOIM/Uiszzrl+4uS6VCj0WHzvh4kJiJLDQam90BSqbfALM4xCJvg?= =?us-ascii?Q?y8i0tmZ79lTc6Xzxx7Io0l3XLSWUk23yop4nlUW9DEQzEPviWxPvkcOF9ylw?= =?us-ascii?Q?HKZz8WdX0/lyKL69oZ3nAh/zutQ5ANqttIFXTIi4MfHfyceNCPernOu61wqb?= =?us-ascii?Q?0kWm1XcUwRA71Gm2LHuCtQjNA0JmSPd0TDNRijObh3lIIaLQXdeuqnj41pJ0?= =?us-ascii?Q?NPB4Wz1gO0lPu12KWl3hgpPiIbXcUBZHVP3lcjRhTztn5ZXe9p61xcoTDYI1?= =?us-ascii?Q?hMndhFL2Eh/9Qukdil4GBBCrBHXmYDybDec8JxZ5cGgiSuidi5mDXW2IOvOw?= =?us-ascii?Q?KQUEU9CZo6ohubWmbXKMXRKn949QdSLYg6c9+MoV5s5KJWRfl+VIYr6mBinS?= =?us-ascii?Q?wDDcmm+UrxDHRNP2/E2ver7GmypDcwS86rVt9EqKwv6HTj1NhufburfKSEh+?= =?us-ascii?Q?dOQvZzdB1S+Vk20WRfVxRGH9EYE3bZweHGBENz4cSqiCp6/42T9VdBuiy1RD?= =?us-ascii?Q?11obbTQsU2O4Y5NDKAXFrYWHaP6RzBGCRapObn/KAYJrKEUk66nFwYHDvusP?= =?us-ascii?Q?foQ1p4vyNIegWHU1rG+GWbx5pZ0JbrJtcBijIls7zNM+m53Uoch8hlBDIvt2?= =?us-ascii?Q?eJ8Y+k93K8Pq3ajf8JjAQruHEOYzGVmSeYKbq90c+Ns0iv/2ecLLIZW8FaLw?= =?us-ascii?Q?3jGS7Ae9FSwlpeMJdm7ggtyoFj2ofPHodgNmtxy0fytL8hRrJdqWokENWjBv?= =?us-ascii?Q?X1+Cr9y7/Ev4eTFTzRDD76ToUUXMOaYJNjujf3rX8MGSz1YDveU4p8uGkIhR?= =?us-ascii?Q?t1oBwqJY22VXS4bBuMoB2h70P7RpDjJzPdQIQT0YKSpfyGRe0/kGj8mmuNzO?= =?us-ascii?Q?VQzuq3VSVXLSTnwxAJSrk5ougbS6JlO3+7Z9J7uYYZxLMTPFoW6q6x7kmDE3?= =?us-ascii?Q?SOGL/LDUOumeP1rt/bgxKrvutgOZqVw2WheNqpZvaUICHYIe+0pXr1Gndfd1?= =?us-ascii?Q?9P6OR2UZHR1b8Et7hJgO8pA54opBrLuKVhw6QVNsKTE7Um1a8pLJ+kXhXuXj?= =?us-ascii?Q?MRQAgKzHoheYXGmk39SwEuXZEh8B?= 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: 09 Oct 2024 17:40:45.2685 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 892697e7-eeec-4c01-fa34-08dce889811c 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: SJ1PEPF00001CDE.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYYPR12MB8872 Content-Type: text/plain; charset="utf-8" thread_throttle_mode_init() and mbm_config_rftype_init() both initialize fflags for resctrl files. Adding new files will involve adding another function to initialize the fflags. This can be simplified by adding a new function resctrl_file_fflags_init() and passing the file name and flags to be initialized. Consolidate fflags initialization into resctrl_file_fflags_init() and remove thread_throttle_mode_init() and mbm_config_rftype_init(). Signed-off-by: Babu Moger Reviewed-by: Reinette Chatre --- v8: No changes. v7: No changes. v6: Added Reviewed-by from Reinette. v5: Commit message update. v4: Commit message update. v3: New patch to display ABMC capability. --- arch/x86/kernel/cpu/resctrl/core.c | 4 +++- arch/x86/kernel/cpu/resctrl/internal.h | 4 ++-- arch/x86/kernel/cpu/resctrl/monitor.c | 6 ++++-- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 16 +++------------- 4 files changed, 12 insertions(+), 18 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 73bfc8d7a438..186d8047578b 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -234,7 +234,9 @@ static bool __get_mem_config_intel(struct rdt_resource = *r) r->membw.throttle_mode =3D THREAD_THROTTLE_PER_THREAD; else r->membw.throttle_mode =3D THREAD_THROTTLE_MAX; - thread_throttle_mode_init(); + + resctrl_file_fflags_init("thread_throttle_mode", + RFTYPE_CTRL_INFO | RFTYPE_RES_MB); =20 r->alloc_capable =3D true; =20 diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 955999aecfca..2bd207624eec 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -647,8 +647,8 @@ void cqm_handle_limbo(struct work_struct *work); bool has_busy_rmid(struct rdt_mon_domain *d); void __check_limbo(struct rdt_mon_domain *d, bool force_free); void rdt_domain_reconfigure_cdp(struct rdt_resource *r); -void __init thread_throttle_mode_init(void); -void __init mbm_config_rftype_init(const char *config); +void __init resctrl_file_fflags_init(const char *config, + unsigned long fflags); void rdt_staged_configs_clear(void); bool closid_allocated(unsigned int closid); int resctrl_find_cleanest_closid(void); diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 41a8b587f4f5..2f3bf4529498 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -1223,11 +1223,13 @@ int __init rdt_get_mon_l3_config(struct rdt_resourc= e *r) =20 if (rdt_cpu_has(X86_FEATURE_CQM_MBM_TOTAL)) { mbm_total_event.configurable =3D true; - mbm_config_rftype_init("mbm_total_bytes_config"); + resctrl_file_fflags_init("mbm_total_bytes_config", + RFTYPE_MON_INFO | RFTYPE_RES_CACHE); } if (rdt_cpu_has(X86_FEATURE_CQM_MBM_LOCAL)) { mbm_local_event.configurable =3D true; - mbm_config_rftype_init("mbm_local_bytes_config"); + resctrl_file_fflags_init("mbm_local_bytes_config", + RFTYPE_MON_INFO | RFTYPE_RES_CACHE); } =20 if (rdt_cpu_has(X86_FEATURE_ABMC)) { diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index f9f3b5db1987..7e76f8d839fc 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -2020,24 +2020,14 @@ static struct rftype *rdtgroup_get_rftype_by_name(c= onst char *name) return NULL; } =20 -void __init thread_throttle_mode_init(void) -{ - struct rftype *rft; - - rft =3D rdtgroup_get_rftype_by_name("thread_throttle_mode"); - if (!rft) - return; - - rft->fflags =3D RFTYPE_CTRL_INFO | RFTYPE_RES_MB; -} - -void __init mbm_config_rftype_init(const char *config) +void __init resctrl_file_fflags_init(const char *config, + unsigned long fflags) { struct rftype *rft; =20 rft =3D rdtgroup_get_rftype_by_name(config); if (rft) - rft->fflags =3D RFTYPE_MON_INFO | RFTYPE_RES_CACHE; + rft->fflags =3D fflags; } =20 /** --=20 2.34.1 From nobody Wed Nov 27 12:26:58 2024 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2074.outbound.protection.outlook.com [40.107.243.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C05261E1A07; Wed, 9 Oct 2024 17:40:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.74 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728495660; cv=fail; b=VsjerQa2n/3+KzI170Qz/NEDUOFgQ8mZV9rpQ8pT1v4hlQTFCOX/aIx8arHq7a2jU6/8bqEHqbuzu7xluqvF+EgF3BCWzeAlrsBIlDBUNfxTUEzhdlMABy7SMvY/PZqs9VKsUXMj6fGEpa9PFg6H6njzwnZDvnK5fj06awOFZNU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728495660; c=relaxed/simple; bh=yNXUjueksUzOnpP6UAfao9Z4EsJi+u12iKkcBxP/n+Q=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=S3x16exD3N2FdGI/KCAUMy6p6i9P53LcWgXSqoyfnGz75v3XCIrdfvpkHMzE1w4eNiI3Uj+zVmHX6PnrzOvI2MdZbrGdHgOrZEcZR2zDRWjlyGQufqYI8KoSip6BuyJnNX9TpKgyXBNOTxrcxUIvPVrLoBPN9hERwW1CvDEt0OM= 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=ZweOXa2U; arc=fail smtp.client-ip=40.107.243.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="ZweOXa2U" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=OTN8OfjDqvOedw1E4Vplj3000o0WhQsArXOW9mBfQoQ89bUt1K4nS+U6vEkGGtvObAnr8PmbX8x+zlB/l3EKhWgE5LIpUsKsPVL9zg8cBuA0wjMGHFD9JfDzAgtaCPHFi9LTKAFdRRFkZn5lf+eNabhbyvasovHwHejgoQEX4PtcejygSP1cLrr8eoYkRdSvxEC0UjSUMTLcJwyCAweyImOiq9//GVce/PjAZnOAaIox6oa34fsraZAkXM0rn0lpnH7zH6xK71xhURGk5E0yjff9sZVM9a/EtyHf0dGTwma/TDZtJ3jmGGoVFkQf6s9sqwxZgndLUoZ73pE1ebm+3g== 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=/KcNLlcQm85NvyRJ2mo1C6yPDC2OI0lHKhCXrqtD4fY=; b=y1GzU+TzkwhwOxRDw3efoi8wh2YHpRkQv1EO59tQLxGWa/H3Xt85rhiFEnJuG1I2ohR9qZbqUafsZfPGgocjVw5Fyf7JM6p2eEzSYhFoJX/J1D/d0IUyweu9ygIH7CgOUXfi3rX89QTrjtokBfPNbM40uL4fRQDKLvuFQR0K3L8KxLTYROw0SzMV4yAaEC4q0JUcJEadbeBDwdTAwW0TwZ2fsjfoXMwZ2xMKHqB9mowaOuc38N42PZfe9n+Jt45n3e0PgTHNlNWtFUr5fv0p2/vnFT8YikiwkU55DbjMFDjKD9xZCwc+YqZPtbJ2oeVtpvUwJfy2sv+N6vTjn25g9A== 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=/KcNLlcQm85NvyRJ2mo1C6yPDC2OI0lHKhCXrqtD4fY=; b=ZweOXa2U5ysitjXdFyUKbXfMij8gotENZmSEiQ9zJx2mRm0H3BsMjzLip+sKxhSMPga8D7CZgo/xtnIwSd0ljsee/WWcgsROm38EAj8YrUebuB5guFyjFexZu9XTI7CTq2VBF9AHvmd/4ysvSpI0dX59AMBT2/j4T6YkZewAM7w= Received: from SJ0PR13CA0172.namprd13.prod.outlook.com (2603:10b6:a03:2c7::27) by MW4PR12MB6777.namprd12.prod.outlook.com (2603:10b6:303:1e9::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.16; Wed, 9 Oct 2024 17:40:53 +0000 Received: from SJ1PEPF00001CDC.namprd05.prod.outlook.com (2603:10b6:a03:2c7:cafe::2f) by SJ0PR13CA0172.outlook.office365.com (2603:10b6:a03:2c7::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.16 via Frontend Transport; Wed, 9 Oct 2024 17:40:53 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ1PEPF00001CDC.mail.protection.outlook.com (10.167.242.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8048.13 via Frontend Transport; Wed, 9 Oct 2024 17:40:53 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 9 Oct 2024 12:40:51 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v8 06/25] x86/resctrl: Add support to enable/disable AMD ABMC feature Date: Wed, 9 Oct 2024 12:39:31 -0500 Message-ID: <66b9a99a06b3cdd208dd8c490c47342bafc62ae9.1728495588.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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00001CDC:EE_|MW4PR12MB6777:EE_ X-MS-Office365-Filtering-Correlation-Id: f0d9c61c-f7ff-4546-e4eb-08dce88985cb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|7416014|36860700013|376014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?q8QKU81Knr6VmNXogoBbZfAVmJzJAjYtEhDJ4kcBZpcSi32tTiIpnlWzOqNW?= =?us-ascii?Q?IaixAWIY1SeeImS7o4xrhHTtBSfRlkvbXEzv/BjSsALx3m3K9aUPspzPtZ3c?= =?us-ascii?Q?o0N/bHFLV/OjfWHlWMvvKKSq7K+UpED37X2Kixg7rAnTlFlzqkX5zn8MR9nn?= =?us-ascii?Q?wzT4kJ+TW82b6gDMW/J+5zCkwWMh+FsDPyNeLj4K2RE78wB8U4hVPffZdMFp?= =?us-ascii?Q?grRBImW31LyxAN7kH1aB6ucTfw2OsKzng95IbIQJBojGiM81QcWcu032Pxyq?= =?us-ascii?Q?IVhuj0c0U9UqUXjxgQsOS1OHVNPOiCOMGs7DnVGnJYPes1nVISqMekf1839e?= =?us-ascii?Q?gUR42iGPJiviVMmRQ4rhlQscgK/mA5vBZQlmk8ybsn1hI0TILxUyVZnmV82m?= =?us-ascii?Q?CPnxMlfc8RCx2Oi7qJ9uTKX2TfgcNWXm4OujHlCxmXEooKAAY67ZE53gyuC9?= =?us-ascii?Q?0DJLrGHtmHv+GL2hy7atrOu+XKGF8Ak5n9qeHextAKRcBhu6BqFZN1j4tFvC?= =?us-ascii?Q?twVeMuGTIWAlgouiACG4x/JdNDvz6usw3tiYPezkRg9Z6qK9WfbbsunS08FB?= =?us-ascii?Q?lsHX/KUAkv8fWqKxUkFD54QIVuoKJeLiTEqI6bvFR74F/KSbazjaovILChXh?= =?us-ascii?Q?qLLFxUuDRmpHQEh+Sfu8Jx0AFIA70/OJ5KMxKDaCfqe2t/CRcFKHig6FNc5Q?= =?us-ascii?Q?+fhvwiTdUhRwb/0JuXRjE+Z70848oPH3b4Vn4Afpv7EIV0mHOouc0jhjANRg?= =?us-ascii?Q?ls34BjyJgJSvVEDHG5XD1RyXA+UevlMHkxCEx5/XWGvffrpXq9foDyJcqKRg?= =?us-ascii?Q?jBfQZuFDobKn1sdx5ZjRPKlydcE06lUdr4hndQhNKtH5d2A4Ei+iYm6ZbrOm?= =?us-ascii?Q?fNSw6vHmJpTMHOFZ3YyC5wrEJY5Kbf8om0MA064KqWpsfpu4oy0pjEEPH+wC?= =?us-ascii?Q?W9s+O/q8TkJOYY7U0+mKlIuwi8wYrlxm9wRwr7dPWQIXyLjKbYi7FQQjj1DK?= =?us-ascii?Q?ETWImSHHgcw9H1cNfei0XJ2V84Rok9dANxtOW0yZyaqBzxwoc+eYeHAdeM7m?= =?us-ascii?Q?S1JhzvnnPK3AuUhj05TKlADdBCI4v4w2g1TCLj+/3/EoEyI7OySisP7v36I2?= =?us-ascii?Q?IlrND6cNT5O1ePxwhUfjKUJjsS1VJxDzqRyr5x+eB687Ck0UOcV6fe6htGjN?= =?us-ascii?Q?fhUcsF02JOaYzdLraGO8l6t42OtkMTWdPyENX1PEJWCvPf6yIVelc2D8rYr4?= =?us-ascii?Q?W3WMoyUW2tK+PQIZV/L6WNMVSbqAw6v7oOd85jbHhbDsNERWQColSPFIz1BW?= =?us-ascii?Q?62hattnBFvIyuUQs45YqEbRrAjDxX6k97yEPRCvQFvEHWtO7Qeuihjiyx90K?= =?us-ascii?Q?y7Dodx+cdeAljCTKJQ+VvcZTjys+?= 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)(36860700013)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2024 17:40:53.1257 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f0d9c61c-f7ff-4546-e4eb-08dce88985cb 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: SJ1PEPF00001CDC.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB6777 Content-Type: text/plain; charset="utf-8" Add the functionality to enable/disable AMD ABMC feature. AMD ABMC feature is enabled by setting enabled bit(0) in MSR L3_QOS_EXT_CFG. When the state of ABMC is changed, the MSR needs to be updated on all the logical processors in the QOS Domain. Hardware counters will reset when ABMC state is changed. The ABMC feature details are documented in APM listed below [1]. [1] AMD64 Architecture Programmer's Manual Volume 2: System Programming Publication # 24593 Revision 3.41 section 19.3.3.3 Assignable Bandwidth Monitoring (ABMC). Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D206537 Signed-off-by: Babu Moger --- v8: Commit message update and moved around the comments about L3_QOS_EXT_CFG to _resctrl_abmc_enable. v7: Renamed the function resctrl_arch_get_abmc_enabled() to resctrl_arch_mbm_cntr_assign_enabled(= ). Merged resctrl_arch_mbm_cntr_assign_disable, resctrl_arch_mbm_cntr_assign= _disable and renamed to resctrl_arch_mbm_cntr_assign_set(). Moved the function definition to linux/resctrl.h. Passed the struct rdt_resource to these functions. Removed resctrl_arch_reset_rmid_all() from arch code. This will be done from the caller. v6: Renamed abmc_enabled to mbm_cntr_assign_enabled. Used msr_set_bit and msr_clear_bit for msr updates. Renamed resctrl_arch_abmc_enable() to resctrl_arch_mbm_cntr_assign_enab= le(). Renamed resctrl_arch_abmc_disable() to resctrl_arch_mbm_cntr_assign_dis= able(). Made _resctrl_abmc_enable to return void. v5: Renamed resctrl_abmc_enable to resctrl_arch_abmc_enable. Renamed resctrl_abmc_disable to resctrl_arch_abmc_disable. Introduced resctrl_arch_get_abmc_enabled to get abmc state from non-arch code. Renamed resctrl_abmc_set_all to _resctrl_abmc_enable(). Modified commit log to make it clear about AMD ABMC feature. v3: No changes. v2: Few text changes in commit message. --- arch/x86/include/asm/msr-index.h | 1 + arch/x86/kernel/cpu/resctrl/core.c | 5 ++++ arch/x86/kernel/cpu/resctrl/internal.h | 5 ++++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 36 ++++++++++++++++++++++++++ include/linux/resctrl.h | 3 +++ 5 files changed, 50 insertions(+) diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-in= dex.h index 3ae84c3b8e6d..43c9dc473aba 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -1195,6 +1195,7 @@ #define MSR_IA32_MBA_BW_BASE 0xc0000200 #define MSR_IA32_SMBA_BW_BASE 0xc0000280 #define MSR_IA32_EVT_CFG_BASE 0xc0000400 +#define MSR_IA32_L3_QOS_EXT_CFG 0xc00003ff =20 /* AMD-V MSRs */ #define MSR_VM_CR 0xc0010114 diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 186d8047578b..49d147e2e4e5 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -405,6 +405,11 @@ void rdt_ctrl_update(void *arg) hw_res->msr_update(m); } =20 +bool resctrl_arch_mbm_cntr_assign_enabled(struct rdt_resource *r) +{ + return resctrl_to_arch_res(r)->mbm_cntr_assign_enabled; +} + /* * rdt_find_domain - Search for a domain id in a resource domain list. * diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 2bd207624eec..a45ae410274c 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -56,6 +56,9 @@ /* Max event bits supported */ #define MAX_EVT_CONFIG_BITS GENMASK(6, 0) =20 +/* Setting bit 0 in L3_QOS_EXT_CFG enables the ABMC feature. */ +#define ABMC_ENABLE_BIT 0 + /** * cpumask_any_housekeeping() - Choose any CPU in @mask, preferring those = that * aren't marked nohz_full @@ -477,6 +480,7 @@ struct rdt_parse_data { * @mbm_cfg_mask: Bandwidth sources that can be tracked when Bandwidth * Monitoring Event Configuration (BMEC) is supported. * @cdp_enabled: CDP state of this resource + * @mbm_cntr_assign_enabled: ABMC feature is enabled * * Members of this structure are either private to the architecture * e.g. mbm_width, or accessed via helpers that provide abstraction. e.g. @@ -491,6 +495,7 @@ struct rdt_hw_resource { unsigned int mbm_width; unsigned int mbm_cfg_mask; bool cdp_enabled; + bool mbm_cntr_assign_enabled; }; =20 static inline struct rdt_hw_resource *resctrl_to_arch_res(struct rdt_resou= rce *r) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 7e76f8d839fc..6bfa8312a4b2 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -2402,6 +2402,42 @@ int resctrl_arch_set_cdp_enabled(enum resctrl_res_le= vel l, bool enable) return 0; } =20 +static void resctrl_abmc_set_one_amd(void *arg) +{ + bool *enable =3D arg; + + if (*enable) + msr_set_bit(MSR_IA32_L3_QOS_EXT_CFG, ABMC_ENABLE_BIT); + else + msr_clear_bit(MSR_IA32_L3_QOS_EXT_CFG, ABMC_ENABLE_BIT); +} + +/* + * Update L3_QOS_EXT_CFG MSR on all the CPUs associated with the monitor + * domain. + */ +static void _resctrl_abmc_enable(struct rdt_resource *r, bool enable) +{ + struct rdt_mon_domain *d; + + list_for_each_entry(d, &r->mon_domains, hdr.list) + on_each_cpu_mask(&d->hdr.cpu_mask, + resctrl_abmc_set_one_amd, &enable, 1); +} + +int resctrl_arch_mbm_cntr_assign_set(struct rdt_resource *r, bool enable) +{ + struct rdt_hw_resource *hw_res =3D resctrl_to_arch_res(r); + + if (r->mon.mbm_cntr_assignable && + hw_res->mbm_cntr_assign_enabled !=3D enable) { + _resctrl_abmc_enable(r, enable); + hw_res->mbm_cntr_assign_enabled =3D enable; + } + + return 0; +} + /* * We don't allow rdtgroup directories to be created anywhere * except the root directory. Thus when looking for the rdtgroup diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 511cfce8fc21..f11d6fdfd977 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -355,4 +355,7 @@ void resctrl_arch_reset_rmid_all(struct rdt_resource *r= , struct rdt_mon_domain * extern unsigned int resctrl_rmid_realloc_threshold; extern unsigned int resctrl_rmid_realloc_limit; =20 +int resctrl_arch_mbm_cntr_assign_set(struct rdt_resource *r, bool enable); +bool resctrl_arch_mbm_cntr_assign_enabled(struct rdt_resource *r); + #endif /* _RESCTRL_H */ --=20 2.34.1 From nobody Wed Nov 27 12:26:58 2024 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2045.outbound.protection.outlook.com [40.107.94.45]) (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 D03D11CB514; Wed, 9 Oct 2024 17:41:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.45 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728495667; cv=fail; b=kxw4sW2suQXF01ogAKjXxjTJfMKRG3nYgPTV7d39SKnuqQS22vg6mqmbs9MDJIy0L4sVBwcprXijCbUnGeJylIlylHD3pqDfIGm1At9TliwRkz40w9cBgjwbg5LMUQhUzyf8MM2z2/8J0krNnUS4n27uNjFbFTErSQ0Pt7W+9Yw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728495667; c=relaxed/simple; bh=Feu6ddTDj54QR/C8nRIHNyHvyoc0ErG9QNFT3HkQ6ig=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ned6vpcrV/fG9C4+o61A6swRMogvsdAkGzp3pN7jAnSnbPatNwS4BlHMao1gtvmmGTsx0O/BHwN9/BSkETub9Ek5VsIiBvc8LW2qbFjgIB5XvUlg6+vRVlcc1pt4As7FB62SzqvYiQl4OwPOERWqBP/AWh4j8Xz0gDWqPoyddS0= 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=nLOB2nmL; arc=fail smtp.client-ip=40.107.94.45 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="nLOB2nmL" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=W59GGZdRBrfKpKtuaROl4hZxGzl3O1K5Mu5WTYF60mCZNmHv7EKtEMVU+hJMijB6RSA860BFq6oo7tg/g0Qv91/TNR4L2CSvGKjVyu6b0Z00LioyxYd1GuG10IZxEa42x4+7VQdDdL0J25VAuIwNIM6ZOQHBk1DZaUpW8MeeykPKdbmiBUInjepSZaNEZXc96Ip9HoZTvGLRQf//eZloXVN+pXkLqLZjuRbjMA6TDaLOIwZcxS5Fi5/xLskIX7TDPeuQW4wwIBdUhy+JKTGElt0oDGayFxIymO0BlPno/R8T9EkQMVlhVZlf9NFJID5yKLaBN5qDe2h/Xsg0Dhf0mA== 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=pjBoGVFn+Ct6TkVfUTvpbH/oBmv0+rT0iC0OJQP/Mv0=; b=wzTUqbRDmfyrWkvit6zZzThYINZ/C8J5VrurIsP2ohqniLlCkJ7JeDZ9y5Ccv5g2AykDQmKxfelJf7THBsV+hkk4wlc8r5JkQIoLUsyzKGQmxh2s4aKbV4GXbo/PL0RB9aPbukTDRBO5ABt2dcoFZ9VFXQEto0P97SuVSBFhE+I1/AF83whmbEgCl85ajEzsWQFFV7CuS6Xc6sM5K2bhpqD/JnY6p5a3GyamRJNl8m+VOSz/vcl2BiXrMCgyHZc5VaGFLxijKDYepuTbpcMcCDzaE563vhOMB/Ht22qvn+E+leZyv+Kp7aU6yr879EDdE5/J8TxEsamqnW5wjDP2eg== 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=pjBoGVFn+Ct6TkVfUTvpbH/oBmv0+rT0iC0OJQP/Mv0=; b=nLOB2nmLxg0Uq0xdiyOod7hvDIr2N512zqQTzdWiHjM1wWk0mlNzdFWUucad1KCWdRfsXMoHLChOt0BJVUr3ia/L3g2oda5ErK41Qm0RzbynHSaPZ0+ESa3Ljdi1qNeL2YoYqcV0SaLhfn9TJ0KbMkUaRntITBAA+mXtN+Om6bM= Received: from SJ0PR13CA0176.namprd13.prod.outlook.com (2603:10b6:a03:2c7::31) by DM6PR12MB4354.namprd12.prod.outlook.com (2603:10b6:5:28f::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.16; Wed, 9 Oct 2024 17:41:02 +0000 Received: from SJ1PEPF00001CDC.namprd05.prod.outlook.com (2603:10b6:a03:2c7:cafe::53) by SJ0PR13CA0176.outlook.office365.com (2603:10b6:a03:2c7::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.17 via Frontend Transport; Wed, 9 Oct 2024 17:41:01 +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 SJ1PEPF00001CDC.mail.protection.outlook.com (10.167.242.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8048.13 via Frontend Transport; Wed, 9 Oct 2024 17:41:00 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 9 Oct 2024 12:40:59 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v8 07/25] x86/resctrl: Introduce the interface to display monitor mode Date: Wed, 9 Oct 2024 12:39:32 -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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00001CDC:EE_|DM6PR12MB4354:EE_ X-MS-Office365-Filtering-Correlation-Id: e43023cb-8972-4ecd-fcc6-08dce8898a73 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|36860700013|376014|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?ND8nkpakGUnt2tTQqbVCDxu1GhhYHKaHgm7hCFAd2azawN+dT2yvSmuiuuPy?= =?us-ascii?Q?hZZSUAxo/UoxPefKMivyhj4M9fJgfpFo5XDtCqFj1zCU8w+L5kzgtRXWxX/H?= =?us-ascii?Q?uBXCakDmeacivr6VA3eB1hdIDUx9eF4pP92q3p+KyzbJO2kTkljg4R6k404u?= =?us-ascii?Q?czZ9NM8mW2JG1mhRUqnVVfw1dY1jk0fBW3WyKjwko0NlkbI7Q2+qDA8QhREM?= =?us-ascii?Q?RYbJiar35sv+YIpS5dzRa4ec5B56GH+CmCNzUhbV1r2Q5HSFW9m+TJS2uJCQ?= =?us-ascii?Q?mZPxzq+fkarffaIgyhcVVjZHj8LwSrHh7iRMXoivpNOFJ5wAUM83jcY3UQ7e?= =?us-ascii?Q?q/9Kl5JwjkM75bAanACG7shhw6Sw5Hek83lIFx/TaXY2Dzd1n4cUJaYmw9hA?= =?us-ascii?Q?hCQ6rJaUaEc0vYyz5YraASy9CAbtOkCsCeBs+kRZfupVK/RuiAEAI+fkS9r5?= =?us-ascii?Q?6HK3MQbn7VZnq18Ki/zVWKjlE+HwuuQkB1VdpnGjQhCtC0xSSYhRj+2Mm0Hd?= =?us-ascii?Q?ZIsmlRP3ctG20zcPFiPKBL3Kx7ddn31ez5ItnIzgv0jTYIDVAA1ppu8MgjHG?= =?us-ascii?Q?cegrG5ICxnW5oGrh2XF85VdKgx2sXC+Nn0szypCdm1K+FgWhuYm1CYD0uZ3Y?= =?us-ascii?Q?g8NTd5GevHO+6gAw2V8lgAD3hRubx4tjd+c4hnec0gWKAlpykJ8T3Rt8aVRr?= =?us-ascii?Q?uS1GgE0qMSSFy2yDsJlWRY3lqD4SZFnGeIy39kAGZhWkH53NSGyufmS/1JgU?= =?us-ascii?Q?hP+ROoRBhfk9H3oeIKdklxn0r3lntI5hSR4L72tRo8nNwXqftKGBfDwl8ahI?= =?us-ascii?Q?lHWUZ3NUsxJQEjZjIZe8t4PWsRcUkFuGCBzfa0bsi9mw193Zm41TJ9yRMYNy?= =?us-ascii?Q?kr23Momfk8CVE66uqZ9tl1KPJIenuT42eSbpQzGzwoAJP1lTBEO0e2sVPwfA?= =?us-ascii?Q?7RjwQ1LYl8PXVlGevDdjkRxZpn02dUfeFegCPnc+6MGhzdUZsEVNnmaZX9I9?= =?us-ascii?Q?gSeP65y2KlFTjYL8KvNG+12bpyLkl2/fPqEdyXHn/dk73ewgojkDJDI312NR?= =?us-ascii?Q?Dr3cX22bE/O+vq1UUvlL1bqGepGScynvG7KXY4X63UuIkqyt9lzXWn1NQUhs?= =?us-ascii?Q?fuZ/3xC64ytV1kVR6KYMNkmSkFc/S8Sy8s+PM5kPr/O1Y+H6jX7itd2la2eH?= =?us-ascii?Q?gknApb6XKRPjZIQ02McOYuCP6MU9tCcjbp/kt8vMGJzGU2uc2oBWa1BOFbsr?= =?us-ascii?Q?s2D2ihZjnkTN86Si94oC5vgtvZBq/y9DOiGQ+50FsjFOe7YdCdNqNbWMCogq?= =?us-ascii?Q?T7U6b+Zevv/sTk0gn/wJ+lJj4+aaRShvOGXcp8JA9GXmzfarFKyQo92OX0DE?= =?us-ascii?Q?qZWmDH+w/IxqmMb5vRSXpV3pZIPX?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(36860700013)(376014)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2024 17:41:00.9382 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e43023cb-8972-4ecd-fcc6-08dce8898a73 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: SJ1PEPF00001CDC.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4354 Content-Type: text/plain; charset="utf-8" Introduce the interface file "mbm_assign_mode" to list monitor modes supported. The "mbm_cntr_assign" mode provides the option to assign a counter to an RMID, event pair and monitor the bandwidth as long as it is assigned. On AMD systems "mbm_cntr_assign" is backed by the ABMC (Assignable Bandwidth Monitoring Counters) hardware feature and is enabled by default. The "default" mode is the existing monitoring mode that works without the explicit counter assignment, instead relying on dynamic counter assignment by hardware that may result in hardware not dedicating a counter resulting in monitoring data reads returning "Unavailable". Provide an interface to display the monitor mode on the system. $cat /sys/fs/resctrl/info/L3_MON/mbm_assign_mode [mbm_cntr_assign] default Switching the mbm_assign_mode will reset all the MBM counters of all resctrl groups. Signed-off-by: Babu Moger --- v8: Commit message update. v7: Updated the descriptions/commit log in resctrl.rst to generic text. Thanks to James and Reinette. Rename mbm_mode to mbm_assign_mode. Introduced mutex lock in rdtgroup_mbm_mode_show(). v6: Added documentation for mbm_cntr_assign and legacy mode. Moved mbm_mode fflags initialization to static initialization. v5: Changed interface name to mbm_mode. It will be always available even if ABMC feature is not supported. Added description in resctrl.rst about ABMC mode. Fixed display abmc and legacy consistantly. v4: Fixed the checks for legacy and abmc mode. Default it ABMC. v3: New patch to display ABMC capability. --- Documentation/arch/x86/resctrl.rst | 34 ++++++++++++++++++++++++++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 31 +++++++++++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/re= sctrl.rst index 30586728a4cd..e4a7d6e815f6 100644 --- a/Documentation/arch/x86/resctrl.rst +++ b/Documentation/arch/x86/resctrl.rst @@ -257,6 +257,40 @@ with the following files: # cat /sys/fs/resctrl/info/L3_MON/mbm_local_bytes_config 0=3D0x30;1=3D0x30;3=3D0x15;4=3D0x15 =20 +"mbm_assign_mode": + Reports the list of monitoring modes supported. The enclosed brackets + indicate which mode is enabled. + :: + + cat /sys/fs/resctrl/info/L3_MON/mbm_assign_mode + [mbm_cntr_assign] + default + + "mbm_cntr_assign": + + In mbm_cntr_assign mode user-space is able to specify which control + or monitor groups in resctrl should have a counter assigned using the + 'mbm_assign_control' file. The number of counters available is described + in the 'num_mbm_cntrs' file. Changing the mode may cause all counters on + a resource to reset. + + The mode is useful on platforms which support more control and monitor + groups than hardware counters, meaning 'unassigned' control or monitor + groups will report 'Unavailable' or count the traffic in an unpredictable + way. + + AMD Platforms with ABMC (Assignable Bandwidth Monitoring Counters) feature + enable this mode by default so that counters remain assigned even when the + corresponding RMID is not in use by any processor. + + "default": + + By default resctrl assumes each control and monitor group has a hardware + counter. Hardware that does not support 'mbm_cntr_assign' mode will still + allow more control or monitor groups than 'num_rmids' to be created. In + that case reading the mbm_total_bytes and mbm_local_bytes may report + 'Unavailable' if there is no counter associated with that group. + "max_threshold_occupancy": Read/write file provides the largest value (in bytes) at which a previously used LLC_occupancy diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 6bfa8312a4b2..895264c207c7 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -845,6 +845,30 @@ static int rdtgroup_rmid_show(struct kernfs_open_file = *of, return ret; } =20 +static int rdtgroup_mbm_assign_mode_show(struct kernfs_open_file *of, + struct seq_file *s, void *v) +{ + struct rdt_resource *r =3D of->kn->parent->priv; + + mutex_lock(&rdtgroup_mutex); + + if (r->mon.mbm_cntr_assignable) { + if (resctrl_arch_mbm_cntr_assign_enabled(r)) { + seq_puts(s, "[mbm_cntr_assign]\n"); + seq_puts(s, "default\n"); + } else { + seq_puts(s, "mbm_cntr_assign\n"); + seq_puts(s, "[default]\n"); + } + } else { + seq_puts(s, "[default]\n"); + } + + mutex_unlock(&rdtgroup_mutex); + + return 0; +} + #ifdef CONFIG_PROC_CPU_RESCTRL =20 /* @@ -1901,6 +1925,13 @@ static struct rftype res_common_files[] =3D { .seq_show =3D mbm_local_bytes_config_show, .write =3D mbm_local_bytes_config_write, }, + { + .name =3D "mbm_assign_mode", + .mode =3D 0444, + .kf_ops =3D &rdtgroup_kf_single_ops, + .seq_show =3D rdtgroup_mbm_assign_mode_show, + .fflags =3D RFTYPE_MON_INFO, + }, { .name =3D "cpus", .mode =3D 0644, --=20 2.34.1 From nobody Wed Nov 27 12:26:58 2024 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2069.outbound.protection.outlook.com [40.107.94.69]) (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 4EE381BE869; Wed, 9 Oct 2024 17:41:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.69 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728495678; cv=fail; b=FBtlgF/StCJ4vx+zk/4mAu+owHV+XfsYN3ybnEjMjnSy4fmE2uhmZ9z1DQZqeuCodAhN7cJ7LUCIsFYeNtWJoAzv1uBqvLWuz7dE7dW0zllwG3Dnzyea/ot+Sm4V+cQKmMoezqQKTp/rCex/CdVKXDAlnJCD8xmq6RxUJyAOFcc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728495678; c=relaxed/simple; bh=Ea2fmp5yG2Ao0LwFzh5ZmUfLpUtgfwLekDuPEkIDlA8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PfCtOJaSmb31u5/PfB1jYsg9hykOff++eQcUbICqnRtuMfmeAtbWCSif6/tVaakbxdDR+WiS2Fr9dcFwZ46hOz7LqZtpqlOl4sEuEAtYLwp55Gbsmvbi7d0C+McGQZIfm7lrIU8ontzuvNFDoWxI7+ins6RO2qHQsY12k/A4Iz4= 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=31PdSIyf; arc=fail smtp.client-ip=40.107.94.69 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="31PdSIyf" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hG1RP9VnIV2qgeOiQy1iIjP/fTnFdc9YWkFDZ6WZkHRUGbDiGJ8ZePej0StgvNcFvAPUEvYNeS6l2WcTEEw0oVX+vulOFwiditfzr2gaH4j+uCGpuAD2gsemn8grv+uE6JMglTfnhzzF6L10uCu9Mfd/DT8JnBGvQyMIWQTnYXSrJg6MICuvfGQ+AdizbA6mier9mDIVBDbZCFhs+JzqoHJnm7fYIwiV6uALs0fiuj8/2BnTCed59O9IMGY0HDlcusv1pVgt9HbwFIMcCpsDlNt3TAtdPt9dCsgzVZFwtU28HUAUb6orq5WG0LZGT6AvR2E75Alq21izA1EUpriXTQ== 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=0f1Vr0neq7JV8XmCCitwFoc7oxkg8ox0uKV1OWio/bE=; b=Awq3Meq6kxflo4/O3+NFOahmgztNY6pLKgIjs9SWgCJDZsSRK9sKt8dE0nHAqFbbYG86CU59Uvr7iQb6Xf07K2YsezdVqKi7Vdoz7xUdNZMGUVrVon1mzFbDxLfdjwsa52guT1vZJ8ZBnqeSd6mCxj34nagIhge17IUYeXNXmYMEszyfESqGwTttNtBYr5EQzWVoo4cd2p09m+sGAoY6qxPVpejHsoKkf5nUSIKTMK/8KYNDYYiFeUQYxrXRpVbNZ/RJJTYAjsWRuF9c/xzzA4zCNtHnI8yzAgeXzxM4d1c2aVyxaet4aMdCEFgTJs4b3dUFJxDcws2erRDEfYdIyA== 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=0f1Vr0neq7JV8XmCCitwFoc7oxkg8ox0uKV1OWio/bE=; b=31PdSIyf7ktg6Hv9GCprb479Kw65865svWJR/PDxmVVjF/U5KogJbDSMqet8gsRKodFTZZb2EqOfQvbiUSG0McLE4gOU+KRfaN8yen+iAMUxqOnC0rRNyh62xL+u3dyrutqOGQaZRni0YByFjy319YXW6iwvYK3vM8lYo8tZn3k= Received: from SJ0PR05CA0107.namprd05.prod.outlook.com (2603:10b6:a03:334::22) by DS0PR12MB8245.namprd12.prod.outlook.com (2603:10b6:8:f2::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.16; Wed, 9 Oct 2024 17:41:09 +0000 Received: from SJ1PEPF00001CE0.namprd05.prod.outlook.com (2603:10b6:a03:334:cafe::2) by SJ0PR05CA0107.outlook.office365.com (2603:10b6:a03:334::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.7 via Frontend Transport; Wed, 9 Oct 2024 17:41:09 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ1PEPF00001CE0.mail.protection.outlook.com (10.167.242.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8048.13 via Frontend Transport; Wed, 9 Oct 2024 17:41:08 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 9 Oct 2024 12:41:06 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v8 08/25] x86/resctrl: Introduce interface to display number of monitoring counters Date: Wed, 9 Oct 2024 12:39:33 -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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00001CE0:EE_|DS0PR12MB8245:EE_ X-MS-Office365-Filtering-Correlation-Id: 4410f197-965f-48ae-52f4-08dce8898f31 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|36860700013|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?7reEQfTDgiUdKA/lw+rStG/IduNAG+5XlwQ5Za44FJeOvvCay4rT0gwmqEmh?= =?us-ascii?Q?OO/iKOPHcCVRFEZdjyCtQTxuGCD8vZSZ+X7kt4Sooc956f7JhejBET60jSME?= =?us-ascii?Q?kkVhdPBfRj0m14b7C9o6o9KwEFjQEgXxdxiYJmFeL922QkfHW7OTWgpMHads?= =?us-ascii?Q?G18JnRZD9tojaBhK2wnnsSG+J5rdrhUsV37Lfc9JZPB5RnjADJo/8KXuNj5S?= =?us-ascii?Q?71nAJl9aWVyFJPNdfvfpiePHUxbNL7evoY1pAN/IEDcFNeY1+ToFMhvIo90T?= =?us-ascii?Q?/Pc0S4Tvij+AtyXZiCT/Ji7y0EgJ72nIVxqcVC4zoBI01BOnOzqvePyxvJ3T?= =?us-ascii?Q?ImASoJYsizTr14g4FqynT/Z6bB9IqezFnuLNE9GrppWOPi6PeLDIxyVuXiZL?= =?us-ascii?Q?i/0Fnpt151ukGbEqkBHFSiOTwKVqjNMtK7HjXPGA6oGD+45NTk9f4zxmIwpD?= =?us-ascii?Q?KTNnjYbuHsofXWT/pyyjRzx87xt97uoGj1O1z7MPf9lrdjT/y+KTpZOQiK2x?= =?us-ascii?Q?rtJPBX51oZ3KAUIDYDDI8CndxxGpyoAqhRJ4EECK494653wOlwqskWz+4nOE?= =?us-ascii?Q?iM5gqPB7SK7ycVzx+Qq2EM6Q8tKT2hvtFqt9oL/Q8pHwynhXRcT49TMdy5sZ?= =?us-ascii?Q?PS+KFRS2xVL3ulfFPDerhNsKAn6oJSsrZ1AeUpfoePXhcTGDvEyXX3bfzgtX?= =?us-ascii?Q?HCXdUyKb1x7RtSPJS6Z0A2IdCV/majLFNWhaK7qZe9Rlv9LARH5l8hFD9u9c?= =?us-ascii?Q?/diwy2dbvNbic2lwCqv1UhLxzaWbm08U1I4IgbrZ5q6wp6weJQnFVMCP6bmZ?= =?us-ascii?Q?1IWPKndbjUaCT/Jy1uNEB6yJPuEeJGCLN1sbSQdT/Mi+d2bdyVXX4eMG0/NN?= =?us-ascii?Q?n9DCXp6BZ5EljXXvIOFXTUzuEIjtjQVXBgl2cTLx579oBfkBw3pKEUJ2fxx9?= =?us-ascii?Q?VtyW4BM4TrJpnrpIlK8VKfC1dJhky+2T+hXk09nCJVSDXYwTe7oqsZwo0mDy?= =?us-ascii?Q?wUTC97Z0cJEGeKFLZI15d9tPVZkWF1OjUzlpl8VQV1L6ZB/rn5ovDVtisohz?= =?us-ascii?Q?/OFpQvLo/1bSoP508pXVuWZ4XbfDMJTcpb2ytw5KZUY//Dc189QjBvLkhvFa?= =?us-ascii?Q?IAMzI2haOYb2w/GJvK1XqoibNWfoaf1+3s645xaTHAnFhH1s09r/tWS71GHX?= =?us-ascii?Q?0TPWfegcvFiL8VBltV6VfSeWRN4akRE2KyW2cnlj0cTh19CiAN6voxLSNNNX?= =?us-ascii?Q?feS1d/9yHN4OecPnXCM7DT05v4IhNji1B50HqGGdMMfY3ilX67uZnlDLdUCi?= =?us-ascii?Q?3ijrqwkERdXDn5gdVUL2IQDcfdnWfsfsE6IY5YV5YHkcxFxdUwTcKQC8B90u?= =?us-ascii?Q?b/rSpZE=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(36860700013)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2024 17:41:08.8118 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4410f197-965f-48ae-52f4-08dce8898f31 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: SJ1PEPF00001CE0.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8245 Content-Type: text/plain; charset="utf-8" The mbm_cntr_assign mode provides an option to the user to assign a counter to an RMID, event pair and monitor the bandwidth as long as the counter is assigned. Number of assignments depend on number of monitoring counters available. Provide the interface to display the number of monitoring counters supported. The interface file 'num_mbm_cntrs' is available when an architecture supports mbm_cntr_assign mode. Signed-off-by: Babu Moger --- v8: Commit message update and documentation update. v7: Minor commit log text changes. v6: No changes. v5: Changed the display name from num_cntrs to num_mbm_cntrs. Updated the commit message. Moved the patch after mbm_mode is introduced. v4: Changed the counter name to num_cntrs. And few text changes. v3: Changed the field name to mbm_assign_cntrs. v2: Changed the field name to mbm_assignable_counters from abmc_counte --- Documentation/arch/x86/resctrl.rst | 4 ++++ arch/x86/kernel/cpu/resctrl/monitor.c | 1 + arch/x86/kernel/cpu/resctrl/rdtgroup.c | 16 ++++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/re= sctrl.rst index e4a7d6e815f6..1b5c05a35793 100644 --- a/Documentation/arch/x86/resctrl.rst +++ b/Documentation/arch/x86/resctrl.rst @@ -291,6 +291,10 @@ with the following files: that case reading the mbm_total_bytes and mbm_local_bytes may report 'Unavailable' if there is no counter associated with that group. =20 +"num_mbm_cntrs": + The number of monitoring counters available for assignment when the + architecture supports mbm_cntr_assign mode. + "max_threshold_occupancy": Read/write file provides the largest value (in bytes) at which a previously used LLC_occupancy diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 2f3bf4529498..7aa579a99501 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -1236,6 +1236,7 @@ int __init rdt_get_mon_l3_config(struct rdt_resource = *r) r->mon.mbm_cntr_assignable =3D true; cpuid_count(0x80000020, 5, &eax, &ebx, &ecx, &edx); r->mon.num_mbm_cntrs =3D (ebx & GENMASK(15, 0)) + 1; + resctrl_file_fflags_init("num_mbm_cntrs", RFTYPE_MON_INFO); } } =20 diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 895264c207c7..c48b5450e6c2 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -869,6 +869,16 @@ static int rdtgroup_mbm_assign_mode_show(struct kernfs= _open_file *of, return 0; } =20 +static int rdtgroup_num_mbm_cntrs_show(struct kernfs_open_file *of, + struct seq_file *s, void *v) +{ + struct rdt_resource *r =3D of->kn->parent->priv; + + seq_printf(s, "%d\n", r->mon.num_mbm_cntrs); + + return 0; +} + #ifdef CONFIG_PROC_CPU_RESCTRL =20 /* @@ -1940,6 +1950,12 @@ static struct rftype res_common_files[] =3D { .seq_show =3D rdtgroup_cpus_show, .fflags =3D RFTYPE_BASE, }, + { + .name =3D "num_mbm_cntrs", + .mode =3D 0444, + .kf_ops =3D &rdtgroup_kf_single_ops, + .seq_show =3D rdtgroup_num_mbm_cntrs_show, + }, { .name =3D "cpus_list", .mode =3D 0644, --=20 2.34.1 From nobody Wed Nov 27 12:26:58 2024 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2043.outbound.protection.outlook.com [40.107.94.43]) (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 0F55E1E1C16; Wed, 9 Oct 2024 17:41:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.43 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728495683; cv=fail; b=emFmcxB7adLP3FTHMeBzXiY5hOV2X08n912ZE4IDGf2JilORJTswGqIJCCnxEN4adujK60y/FgdKTdN/GnHzoxW92UGy1m3KJR1sG84wiSBBXe5Uu51hJv6ZGCnLUHrjFOXehT5d+q1hPHxrDZTWMaAAnAt+SWrV7q7R/coTGn8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728495683; c=relaxed/simple; bh=IfdInPu2TsJ1NH4/IwwKahGdXqaPqTHq5X7pBsyg+oc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qYqvCCX0IApTvU6U5M9QxA+yEHAVzQQXgyKhizSfARwiyv9qwdQnFGHil/EEvafusIVQBrM5O3D+P3paDFhUraiYX/5kKVBZK/9hFYtJsPPp9tV3lf8px+4zObTXb8+t87q6hjf77BjHiuQ1XDR3NWEOOZHPnU6Uab6FdQshIUI= 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=xZfbNWdC; arc=fail smtp.client-ip=40.107.94.43 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="xZfbNWdC" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tuEXff9wo/NUiuFe+03ydqCz6odiBi5YfmgCPuXGEKXNKzuOdiJTir3dVXmHVUoob0f0oRLuokWIwopr2VZXPQY/RN25qdvK6CA57igK8HoEazcki9AnnL5UgdzEdyevQqVgNCDMt0DHUvv0eGCNSRVUnnzHMIrQBA6hy3FcYMnIeDD8JCVIFOLap5B4bUWp2SSnSTtYK8fABgMEKNsYszS6P2kGAwghPRm7VWbx9qC58SSp+Bl/0UfGvnAGe6ypjLDWXniaosQOdzx5y8T/uXRKHLjWNtaea3fHx+Qhq7+2vHtTqcR+PdA9kcmb87Ynl7voJq+E+t3MGEINt7wQXw== 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=BjR4goWMOQKGd4YA+zuL0YQScjdktXzVeIDC+OGqxTY=; b=cYlvXV7t7SurF/O+rmldC5DKsa5E0YtiXoBmt+5I55Mt4UbbzHovoQSmWwQL43oQSg0VHWOZyQeJoI9aayDdMPGyZYGrUGZ5Js/Kd0s78NcsS10XJ94hhfMI2wkaNX1ZvvjP8u4m1jRBvCskGrJj3N8qCinIV0PEWBgVUmV1TnzZLHQfRcqxJZ1OoRTT/5iLB3np7vZUSziqLOmezuD2cLEPoYbNIeZQWVHP8eP5mUHvzRrqOi+m88/j3DpqJ0SXyEUVR+hNvqTSD7kP8G5k83AgvhLICZC38M28UhTJ/0OIBFB0u3yhXax7mimTzn0bvaO59+AuU0w/EtLBu1Kuuw== 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=BjR4goWMOQKGd4YA+zuL0YQScjdktXzVeIDC+OGqxTY=; b=xZfbNWdCgPvBKBFexfg5VO2Y++Wnir10/oAf0E1Er0LRFoNoaXykyn1cBV4zJvl/1OsEMxW5V/DMGdygcBbrnqM//z0xtPTERsfWm9/UaHhTyOa1Bw8MVyz8vNnDY2GtA0NI3D0FQTwuCK+45b8kNX7nbdlUjSLwIZn2U3A08nI= Received: from SJ0PR05CA0115.namprd05.prod.outlook.com (2603:10b6:a03:334::30) by LV2PR12MB5896.namprd12.prod.outlook.com (2603:10b6:408:172::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.16; Wed, 9 Oct 2024 17:41:17 +0000 Received: from SJ1PEPF00001CE0.namprd05.prod.outlook.com (2603:10b6:a03:334:cafe::6) by SJ0PR05CA0115.outlook.office365.com (2603:10b6:a03:334::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.17 via Frontend Transport; Wed, 9 Oct 2024 17:41:16 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ1PEPF00001CE0.mail.protection.outlook.com (10.167.242.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8048.13 via Frontend Transport; Wed, 9 Oct 2024 17:41: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; Wed, 9 Oct 2024 12:41:14 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v8 09/25] x86/resctrl: Add __init attribute to dom_data_init() Date: Wed, 9 Oct 2024 12:39:34 -0500 Message-ID: <03077cf67cea1b3ebb00495fd40d1535db27ff8c.1728495588.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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00001CE0:EE_|LV2PR12MB5896:EE_ X-MS-Office365-Filtering-Correlation-Id: 33c405c7-bc2e-4eb2-9385-08dce88993e0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?ny5eP8YIC1DXuHscIpbR1okkN8FRPwGSWmScGR7hCPCI/Cvn/EDUILNkSnoB?= =?us-ascii?Q?IsKlfUC6M2yLsVEej5EKXzpObVSLHM6MpCl8MN4jFXS0V3nhPBq11XFNQ3pt?= =?us-ascii?Q?9H3Z02crWlxg3Ics35u2WVx7wVaZKMy7Bafl4Nr1mgUETRfedTIViD43qT2c?= =?us-ascii?Q?ImRsN3Z4BTL38aETX1U0ievcmMxqt5Ubx3fQf265+sTLdAKs1pA1SraofnMv?= =?us-ascii?Q?gTxdm93+SDegbIbAbnvV55QrZPkQX9tf5fWFbeZviG358/xK37XfKMod/Iiq?= =?us-ascii?Q?xrkonqq2e6WqtZFcRWsUaEGIHaUqpUf6J92Qd40CqUI8Lu8kGsJpEIg6Jb4T?= =?us-ascii?Q?3wDcPs9JWfQcMS6pCtlDC8oPY3IOa6ZyWLJnsu6gn/StJDPVF2pF1rC0bBFE?= =?us-ascii?Q?0H/e1BI194staL+G01FuBC+TwuhXuvGAk22KlsFPsi+6QVM4o/7RA9X2sfNn?= =?us-ascii?Q?EzLa4UOVpJ8ELsWP5lbPt9A2urq4z5EBnWULDcmHgYEofJzZTdygJ7V7NQJ1?= =?us-ascii?Q?M7YKwjMpHuuNYuwyjKTnlm7FWoWziQbR2a/EurY5V3nu3hAOr5HZu2FUAmbH?= =?us-ascii?Q?S3V6sMOevGCM9bwwyt950Bnu+1SFzBa0U3LlQ9mcnXfGz2IycqlG1KgvdUt+?= =?us-ascii?Q?S4s4uNkqi1kbprr5eSaXXygLwj52LKq7Jm5xCib3jqVCz2Tf1d81MK5dy5c1?= =?us-ascii?Q?/W0/az9hjMw2JHDfz9/98NMQ/TLluHVygIcK3JvG5JnucsALAnbqNDPdmj8V?= =?us-ascii?Q?h+vbP+zsZqrfyWGSUcw8uBG1z8bfprN5smdx5LEKBUZ2wUGvvBZhwl+RjY3K?= =?us-ascii?Q?6rGftkANFTnUlmdXuEWvFIPE2klVb5pHUu0x/dEkoCY2YCbkWdkW00zVJN3v?= =?us-ascii?Q?WANn3HbAjxTgvST170hOIUNzc8Sp0vpIm4I/u42tUC9b6XVRX7NpwaT5yQ5D?= =?us-ascii?Q?BJ9gIEUzKZlwy2t4ReLXMvyLCwo8jg3jIDSLmrvF5440aXKjNv8PN0LMEPxK?= =?us-ascii?Q?MB6WA84qomf5yB7KnYFKj7vBLMWu2HWeVxZkekHviGcS4l2D5wwppl6VJRxE?= =?us-ascii?Q?ixpR1YDUamH+eRMOdLx1J2KXR3yJtScCbUdi9nmmHmT4cM8vOotKgLs6AjlY?= =?us-ascii?Q?qVOEWn0FUA4GXl8SfEwvEitMgwpOOqvQ17IjUs/rHMJDHFXzZwTmgv8CloY7?= =?us-ascii?Q?OsW0M0OZQYR3o0K27/YCEsq4UhNrQENTZZwWOf93FZJIbLswIROvWnDhPeHT?= =?us-ascii?Q?nxhunZIlZ+9KBKQecpCM5jvwwMSqXeUz+LX0Q6/OeoE2FfV+Y0w6Q/zizCpt?= =?us-ascii?Q?l5APoU2yy02kwkjtzmUVlA5e/y7PoNwSfCJdJ39h7PAC9weLK4pWj6dw4owi?= =?us-ascii?Q?5RwW0VItanGz7SrmnN+cIdJhmNYG?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(376014)(7416014)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2024 17:41:16.7493 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 33c405c7-bc2e-4eb2-9385-08dce88993e0 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: SJ1PEPF00001CE0.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5896 Content-Type: text/plain; charset="utf-8" dom_data_init() is only called during the __init sequence. Add __init attribute like the rest of call sequence. While at it, pass 'struct rdt_resource' to dom_data_init() and dom_data_exit() which will be used for mbm counter __init and__exit call sequence. Fixes: bd334c86b5d7 ("x86/resctrl: Add __init attribute to rdt_get_mon_l3_c= onfig()") Suggested-by: Reinette Chatre Signed-off-by: Babu Moger --- v8: New patch. --- arch/x86/kernel/cpu/resctrl/core.c | 2 +- arch/x86/kernel/cpu/resctrl/internal.h | 2 +- arch/x86/kernel/cpu/resctrl/monitor.c | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 49d147e2e4e5..00ad00258df2 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -1140,7 +1140,7 @@ static void __exit resctrl_exit(void) rdtgroup_exit(); =20 if (r->mon_capable) - rdt_put_mon_l3_config(); + rdt_put_mon_l3_config(r); } =20 __exitcall(resctrl_exit); diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index a45ae410274c..92eae4672312 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -633,7 +633,7 @@ void closid_free(int closid); int alloc_rmid(u32 closid); void free_rmid(u32 closid, u32 rmid); int rdt_get_mon_l3_config(struct rdt_resource *r); -void __exit rdt_put_mon_l3_config(void); +void __exit rdt_put_mon_l3_config(struct rdt_resource *r); bool __init rdt_cpu_has(int flag); void mon_event_count(void *info); int rdtgroup_mondata_show(struct seq_file *m, void *arg); diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 7aa579a99501..66b06574f660 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -983,7 +983,7 @@ void mbm_setup_overflow_handler(struct rdt_mon_domain *= dom, unsigned long delay_ schedule_delayed_work_on(cpu, &dom->mbm_over, delay); } =20 -static int dom_data_init(struct rdt_resource *r) +static __init int dom_data_init(struct rdt_resource *r) { u32 idx_limit =3D resctrl_arch_system_num_rmid_idx(); u32 num_closid =3D resctrl_arch_get_num_closid(r); @@ -1044,7 +1044,7 @@ static int dom_data_init(struct rdt_resource *r) return err; } =20 -static void __exit dom_data_exit(void) +static void __exit dom_data_exit(struct rdt_resource *r) { mutex_lock(&rdtgroup_mutex); =20 @@ -1247,9 +1247,9 @@ int __init rdt_get_mon_l3_config(struct rdt_resource = *r) return 0; } =20 -void __exit rdt_put_mon_l3_config(void) +void __exit rdt_put_mon_l3_config(struct rdt_resource *r) { - dom_data_exit(); + dom_data_exit(r); } =20 void __init intel_rdt_mbm_apply_quirk(void) --=20 2.34.1 From nobody Wed Nov 27 12:26:58 2024 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2078.outbound.protection.outlook.com [40.107.220.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DA2201E0B95; Wed, 9 Oct 2024 17:41:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.78 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728495696; cv=fail; b=nGSmNoqs7AIFUFsvv5HsXdA40nxNMw8PterQfEpWMfv7+d+rZqWRbiYRPkkb2YXRWRwfy099dKVyVNe6JpEnNcikHBWeezkFa4uEXdxGRsLZc3wHAj/4YNCtkThqpcoqOBnvn+oJqQSh2MPxH8LVIiNyznpYb2JdCLVLsjFWho0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728495696; c=relaxed/simple; bh=LEM1S7isFhjpobl3h9yU163KqpZt9TP5NSn+FZhBFg0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KcLXQ32b3/F4u9CLhFJldPicXDpneQoBIFylciZokW7kx48tYCrU38ZGxsplSlcoHxhXS7iVUnAPy9YdOWQW5bh7aRZoTeP0MYB5lJaL8pW/8AFkv5YKFB8ASJQdXkGLDqxu8+4e4w8lixgH8PYgEhtsytVLAnFXE+3dF/H5lEA= 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=sb4E1M4I; arc=fail smtp.client-ip=40.107.220.78 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="sb4E1M4I" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hl7WRVKXudWZ/kiSz36stMs7c8eerylemV5ClHCGZf6E9DUBkbLLsaWKo2UUPD+2C8jM4WhGSwCAyczFFwtM5z/4/hZFuyMX19t6UgSCPiSQWr0+GX52T91X4PPY4AhqsIbA4FfNQ3wMYjHeeYKegEaLMOZvHJuToMGSlQRlpgjisZHQiaLKqZrUk+bbXg1dQ8PcLP7w+zYsCuW0J5UwdJo5sseSN4hkyxlbMIj2uHLB3cJVtuBafZXg57r5JPCOq1zdxDb7M4yH9ZgCN9FZMwKbsWZ1Y5cgoCiQ5cyBqGDseCGe6xY7Gu+odjl/ZPff8EtZy79jnLzcSfgCvhaWCQ== 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=jiIeKwlKmuxdiZS1vuChAKJByBo5IbbcQioA4VxLWcc=; b=pbxF3EOA717VhubMRFaAG9n/+SOpaxskFCD3j7+PygNI7Qukuifm2zMS1cDaDQiP73vaqilY0RHArN3IWv+aCyj+QqEexn6Imt4PutpyFDOr6FLpxdqTmXP6gA8ViOaC/GiFKRexoFxWIabnVbAozO2NLh6GQEyp0rblcQNiE0Ac4/e+B7xu2OG+GAZem/s5K4Td1dnPoiP1ZZR/m1BMWr/BgXMTtYYxZaQthEmCE+x1U3Icfvupdf3ghbh4a5FwNTJA8m39aXuPi/Edpe/NbTPcDwl7LZ39l9LyuUAR/U+eQOUxgNIDOV4ec8mNgyLj1vlwD47FVDx5CjtV+vnhOQ== 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=jiIeKwlKmuxdiZS1vuChAKJByBo5IbbcQioA4VxLWcc=; b=sb4E1M4IYqJaK11Ia2V20NTCeA8qZwsgfzm5yb6WqsRNCcltwvhKJPs73/UlJH6wYwBbMeMM09E1lh3VvdFxLiiKRZOg2YAqJgCCtfJCkTjuA7MjAyB88wLL/QGJdFq0sRoh/66Gerl6S5x6L54GKOyQUWgarG4d2NdkOzrY+HQ= Received: from MW4PR04CA0112.namprd04.prod.outlook.com (2603:10b6:303:83::27) by DM6PR12MB4044.namprd12.prod.outlook.com (2603:10b6:5:21d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.16; Wed, 9 Oct 2024 17:41:26 +0000 Received: from SJ1PEPF00001CDF.namprd05.prod.outlook.com (2603:10b6:303:83:cafe::2a) by MW4PR04CA0112.outlook.office365.com (2603:10b6:303:83::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.17 via Frontend Transport; Wed, 9 Oct 2024 17:41: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 SJ1PEPF00001CDF.mail.protection.outlook.com (10.167.242.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8048.13 via Frontend Transport; Wed, 9 Oct 2024 17:41:24 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 9 Oct 2024 12:41:22 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v8 10/25] x86/resctrl: Introduce bitmap mbm_cntr_free_map to track assignable counters Date: Wed, 9 Oct 2024 12:39:35 -0500 Message-ID: <669613777b83bcd4150f2f204311e96198417495.1728495588.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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00001CDF:EE_|DM6PR12MB4044:EE_ X-MS-Office365-Filtering-Correlation-Id: 3a96c663-2d8b-4ef5-d4a2-08dce88998bc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?nYu+OM1ETZ9ZjPP0+NJq2Dc2OHmgqcDyWjNhBNI+L9QBFAEiT7OGKCgk92I+?= =?us-ascii?Q?OBcaQArGw+IwcI0FglZPe+x/FgNPXFIJRxtg8WFR9TOb/E60bI/P+FfVHMy9?= =?us-ascii?Q?No8mQfId2Hm1mP7QunuhkkmTUDl+eoNM6NYglq3oOFaJnAH9jEE87h56mN9g?= =?us-ascii?Q?Upc2211s+BrvbjFd/btim26o17nLCjwNV26TxLBPJXcyayjJOYhi3fpo64vQ?= =?us-ascii?Q?F3/0aL8vx3MUOsatUn8vvp1lk5Ch4s4uk+DWh1t3W25QY5n3JEp7Kqw8axHg?= =?us-ascii?Q?hObSbNhZ/KICsoKAXrRtRymOKIa3XIUbmDIpNUOkFCUBqfwFT9TcsLS7e//Q?= =?us-ascii?Q?DLxLNJHJgrvdtR1NBsQcYvcO7gI29cAohuLCOsmjdiY7/bDWcM66uAguPFvz?= =?us-ascii?Q?sCwtLoTCykJoZ2DD2j8FNyscbYLMfycQsRk5sErjMvRJYJY74+5xdW3rBJ5B?= =?us-ascii?Q?NT6FqNvnp4FxfPOTp0U6WzMdCDc6kncwfEv0aCx37LOTFMZt9MDo+U5PYIO1?= =?us-ascii?Q?UuxdhbHx/o6v2NOIaIl6KfqN/FVPJqJ9P789d9Y81yU58Gg18wDuW4P8+xH4?= =?us-ascii?Q?9upcd/W6zWenSubxyGqa6tyx5lPcf7RDM5oBwqw8OrGnFWhSPa+kuf8wLgwt?= =?us-ascii?Q?BVvg+MKYwirPBPFhJMIytoIAEm3uivuDDrx55UFNwb9XcWcZpVmlRaQYaUKJ?= =?us-ascii?Q?7mTMZorPdaR4M30w2RdItFHnpOn5ThunkaLxoNwVyNYpDmDgilxmDlyrykHf?= =?us-ascii?Q?Wf6IpVf9lgVeDSof5mCM1WfWruOpin80h92YER7rfQFZcEP18CVLwxGizsHb?= =?us-ascii?Q?oBWHdAP2ZbdIt+UJ7ooSdAkDG8ORVDALQA4lt27LDilofojjdxHE2V9RlCrn?= =?us-ascii?Q?oLAQi+YqhwDPho6QQImCRRpfsk7ZWm/Xeq4p/+Du01nqmNiLmBFywbSvefbm?= =?us-ascii?Q?+PXXTa4ZdgvJDdf85EgJc0wYtezj9gp5QQOYPJJzc/hGjYVuhYXbVZ3qCLIG?= =?us-ascii?Q?TBNQ5Vz1iZHgNyoiR4fOEU7rD5dNonY9igT1J940F4hjE37rfNibAcpJWGkJ?= =?us-ascii?Q?T3U7PlHKl3WlDEV/JYLJpSWC+X7a1OVc2UCg/UBQbVicwGIwuJR+stMi7H3w?= =?us-ascii?Q?gHnSsh91cqcZk6GTNP0oIf5BunR5MfWimOS2EmL5IXL6Y9oosVubpO24HLOT?= =?us-ascii?Q?oAjCYXzc6kZRWqOYtH0Zrdzs6SJ7yp36mDfIRnvzR11mEVpe//VSrNWrHsCd?= =?us-ascii?Q?Lk6hBfj1FHDTcVXYSuIS2Z7vf1aCEB7gjkEGl6HEvpgC7fQ3zbgNgtgLohjI?= =?us-ascii?Q?yGCv+y0MjDFTnvkL6Z0MgAaPPJe31V4o0eKEie3OIJ6rnvgMkWmiWwu6KzZR?= =?us-ascii?Q?edBKttpLkZjr0dTNHHt9spU1eeYq?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(376014)(7416014)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2024 17:41:24.8880 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3a96c663-2d8b-4ef5-d4a2-08dce88998bc 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: SJ1PEPF00001CDF.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4044 Content-Type: text/plain; charset="utf-8" Hardware provides a set of counters when mbm_assign_mode is supported. These counters are assigned to the MBM monitoring events of a MON group that needs to be tracked. The kernel must manage and track the available counters. Introduce mbm_cntr_free_map bitmap to track available counters and set of routines to allocate and free the counters. Move dom_data_init() after mbm_cntr_assign detection. Signed-off-by: Babu Moger --- v8: Moved the init and exit functionality inside dom_data_init() and dom_data_exit() respectively. v7: Removed the static allocation and now allocating bitmap mbm_cntr_free_m= ap dynamically. Passed the struct rdt_resource mbm_cntr_alloc and mbm_cntr_free. Removed the reference of ABMC and changed it mbm_cntr_assign. Few other text changes. v6: Removed the variable mbm_cntrs_free_map_len. This is not required. Removed the call mbm_cntrs_init() in arch code. This needs to be done at higher level. Used DECLARE_BITMAP to initialize mbm_cntrs_free_map. Moved all the counter interfaces mbm_cntr_alloc() and mbm_cntr_free() in here as part of separating arch and fs bits. v5: Updated the comments and commit log. Few renames num_cntrs_free_map -> mbm_cntrs_free_map num_cntrs_init -> mbm_cntrs_init Added initialization in rdt_get_tree because the default ABMC enablement happens during the init. v4: Changed the name to num_cntrs where applicable. Used bitmap apis. Added more comments for the globals. v3: Changed the bitmap name to assign_cntrs_free_map. Removed abmc from the name. v2: Changed the bitmap name to assignable_counter_free_map from abmc_counter_free_map. --- arch/x86/kernel/cpu/resctrl/internal.h | 2 ++ arch/x86/kernel/cpu/resctrl/monitor.c | 43 +++++++++++++++++++++++--- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 19 ++++++++++++ include/linux/resctrl.h | 2 ++ 4 files changed, 62 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 92eae4672312..99f9103a35ba 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -654,6 +654,8 @@ void __check_limbo(struct rdt_mon_domain *d, bool force= _free); void rdt_domain_reconfigure_cdp(struct rdt_resource *r); void __init resctrl_file_fflags_init(const char *config, unsigned long fflags); +int mbm_cntr_alloc(struct rdt_resource *r); +void mbm_cntr_free(struct rdt_resource *r, u32 cntr_id); void rdt_staged_configs_clear(void); bool closid_allocated(unsigned int closid); int resctrl_find_cleanest_closid(void); diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 66b06574f660..5c2a28565747 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -983,6 +983,27 @@ void mbm_setup_overflow_handler(struct rdt_mon_domain = *dom, unsigned long delay_ schedule_delayed_work_on(cpu, &dom->mbm_over, delay); } =20 +/* + * Counter bitmap for tracking the available counters. + * 'mbm_cntr_assign' mode provides set of hardware counters for assigning + * RMID, event pair. Each RMID and event pair takes one hardware counter. + */ +static __init unsigned long *mbm_cntrs_init(struct rdt_resource *r) +{ + r->mon.mbm_cntr_free_map =3D bitmap_zalloc(r->mon.num_mbm_cntrs, + GFP_KERNEL); + if (r->mon.mbm_cntr_free_map) + bitmap_fill(r->mon.mbm_cntr_free_map, r->mon.num_mbm_cntrs); + + return r->mon.mbm_cntr_free_map; +} + +static __exit void mbm_cntrs_exit(struct rdt_resource *r) +{ + bitmap_free(r->mon.mbm_cntr_free_map); + r->mon.mbm_cntr_free_map =3D NULL; +} + static __init int dom_data_init(struct rdt_resource *r) { u32 idx_limit =3D resctrl_arch_system_num_rmid_idx(); @@ -1020,6 +1041,17 @@ static __init int dom_data_init(struct rdt_resource = *r) goto out_unlock; } =20 + if (r->mon.mbm_cntr_assignable && !mbm_cntrs_init(r)) { + if (IS_ENABLED(CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID)) { + kfree(closid_num_dirty_rmid); + closid_num_dirty_rmid =3D NULL; + } + kfree(rmid_ptrs); + rmid_ptrs =3D NULL; + err =3D -ENOMEM; + goto out_unlock; + } + for (i =3D 0; i < idx_limit; i++) { entry =3D &rmid_ptrs[i]; INIT_LIST_HEAD(&entry->list); @@ -1056,6 +1088,9 @@ static void __exit dom_data_exit(struct rdt_resource = *r) kfree(rmid_ptrs); rmid_ptrs =3D NULL; =20 + if (r->mon.mbm_cntr_assignable) + mbm_cntrs_exit(r); + mutex_unlock(&rdtgroup_mutex); } =20 @@ -1210,10 +1245,6 @@ int __init rdt_get_mon_l3_config(struct rdt_resource= *r) */ resctrl_rmid_realloc_threshold =3D resctrl_arch_round_mon_val(threshold); =20 - ret =3D dom_data_init(r); - if (ret) - return ret; - if (rdt_cpu_has(X86_FEATURE_BMEC)) { u32 eax, ebx, ecx, edx; =20 @@ -1240,6 +1271,10 @@ int __init rdt_get_mon_l3_config(struct rdt_resource= *r) } } =20 + ret =3D dom_data_init(r); + if (ret) + return ret; + l3_mon_evt_init(r); =20 r->mon_capable =3D true; diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index c48b5450e6c2..8ffebd203c31 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -185,6 +185,25 @@ bool closid_allocated(unsigned int closid) return !test_bit(closid, &closid_free_map); } =20 +int mbm_cntr_alloc(struct rdt_resource *r) +{ + int cntr_id; + + cntr_id =3D find_first_bit(r->mon.mbm_cntr_free_map, + r->mon.num_mbm_cntrs); + if (cntr_id >=3D r->mon.num_mbm_cntrs) + return -ENOSPC; + + __clear_bit(cntr_id, r->mon.mbm_cntr_free_map); + + return cntr_id; +} + +void mbm_cntr_free(struct rdt_resource *r, u32 cntr_id) +{ + __set_bit(cntr_id, r->mon.mbm_cntr_free_map); +} + /** * rdtgroup_mode_by_closid - Return mode of resource group with closid * @closid: closid if the resource group diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index f11d6fdfd977..5a4d6adec974 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -187,12 +187,14 @@ enum resctrl_scope { * @num_rmid: Number of RMIDs available * @num_mbm_cntrs: Number of assignable monitoring counters * @mbm_cntr_assignable:Is system capable of supporting monitor assignment? + * @mbm_cntr_free_map: bitmap of free MBM counters * @evt_list: List of monitoring events */ struct resctrl_mon { int num_rmid; int num_mbm_cntrs; bool mbm_cntr_assignable; + unsigned long *mbm_cntr_free_map; struct list_head evt_list; }; =20 --=20 2.34.1 From nobody Wed Nov 27 12:26:58 2024 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2053.outbound.protection.outlook.com [40.107.101.53]) (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 A5E3B1E0DC4; Wed, 9 Oct 2024 17:41:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.101.53 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728495705; cv=fail; b=lXBFemBJ7hKMFcWgVOBP5rszzKdL+MhdxuPD7QuEljBV9oqmlplX0CEnvp/mdkXs/rx6DZ9kY+64G6kKREb7aC+ShJVOSZ6Fip7s8qWYFHFgBAV4PCY/CoFAAbGZQT4bZHdJZqg6AWJm+mGA4SeHMZDVi3IEIfWvzYd3Ntlaztg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728495705; c=relaxed/simple; bh=TCa+BfMmHKGFwPhDfik/QxZIicGHTdo76GMmgl9Xoew=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rZu70sk4Itfcb7zfEmZmi1RgxJVyDVrp4X6hD0NdfYNghHS5btn/r+0CxE5805vYTF+5WX+nkIq7WUZpaF1vZe/lc+FuK3OWi2WzEWqB43io3YAzh6zFR+046zWHcU9h8fqAHr82a5l0DMuOEmJOOJJQcSI1qyuzjfQk+ofEXYE= 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=BnlG1wUk; arc=fail smtp.client-ip=40.107.101.53 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="BnlG1wUk" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=So99Wnk69QnYQH07YPDXqV/UUuP97xaxsmFMAa7MMJRajsTA5iT3wI+/amZ/3cDTbj6ZA6rXF4sPzln2JRyky7CwRMmKmO7G10TBse52ag+Tfd5IcTbhOoWvKwDIobDgYTW50apPjzioGj0p1C2CJg94d0cb/MlBaz1GtaEF8/MmQZO5mdK1FY44zmRaZZx/azo+QG60+of5NpF84P0oTkQoinP86z0Yub7s8PQLdglsAj87FY12DcDYfITwevMlp2sxQQ2K45aOAs73JQrQlXZi4UU1fFnwLny2P6IYulF1tirQM9ulADWjxtcNtCITxLrdobIafhf89FslyJjAVQ== 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=HIutta4V5/XE5Gb5HQ6OT17MzEYY7LqAfnmuzsOe9uM=; b=EG/60CUZIvgB12+5jEOMGKLXfveuLxd2lm6UgyZZ/93VEHBoDo6hizeo8WyfSvBjQdEgI4DperN2ILkmNreYJJLxNi+UjvO44F9tnAmmezP7BOjQtyKyus8XfaJXauLma4XJ1oM/Vjt4S1xI4bbziydK27kYtgkEFBFmz3j9j5eSII3QGyvmmRmZNh/NGbiXuUyy3AYti0ImY3LT697k74BycfErSnawhWsJbJFfkMhxK8irtM6gWxNPFWRDWvKD0TKgDdx9LguWkcpocHVvX04iPB22kP9LDaUg06RPrGL9wymRKPx2Cr3WqDMk/i6gxoE8T5OveLOYP3R4xMMSaw== 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=HIutta4V5/XE5Gb5HQ6OT17MzEYY7LqAfnmuzsOe9uM=; b=BnlG1wUkH1UrZC1nKwztAyALlNtmYl6eOH4pGXFK7ZoGylF3c78AoPqg2QBY8aCr9uluIAvqxyQxXIurkKriFwPmNCQVz4NY8mB5+nw/oXN0WZgin4GvD1zNbx82dsr/TRiGbyHJQ8OWlrnJ9m6SdRXf/XxiRD1nOHbd33swkAg= Received: from MW4PR04CA0099.namprd04.prod.outlook.com (2603:10b6:303:83::14) by IA0PR12MB7649.namprd12.prod.outlook.com (2603:10b6:208:437::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.16; Wed, 9 Oct 2024 17:41:33 +0000 Received: from SJ1PEPF00001CDF.namprd05.prod.outlook.com (2603:10b6:303:83:cafe::2b) by MW4PR04CA0099.outlook.office365.com (2603:10b6:303:83::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.17 via Frontend Transport; Wed, 9 Oct 2024 17:41:32 +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 SJ1PEPF00001CDF.mail.protection.outlook.com (10.167.242.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8048.13 via Frontend Transport; Wed, 9 Oct 2024 17:41:32 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 9 Oct 2024 12:41:30 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v8 11/25] x86/resctrl: Introduce mbm_total_cfg and mbm_local_cfg in struct rdt_hw_mon_domain Date: Wed, 9 Oct 2024 12:39:36 -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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00001CDF:EE_|IA0PR12MB7649:EE_ X-MS-Office365-Filtering-Correlation-Id: 02957d40-67f3-4a34-8c53-08dce8899d43 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?qWH+vEtWBZTV+siAL58FrTuctayN1kvfvrtyE/o9T91E760G1xKj3Ww+DQT2?= =?us-ascii?Q?jTv69esCqo949VkC7y/NTQHWv5Fc1jMNIsJihCQE0+iJMa0WLkjcLE4D+Ebc?= =?us-ascii?Q?MNRg/OOlP0XIyqNGbQ0q19KP07S+xtqYhz2Mi4Bu6ZIngM/szsUQh4JK4Z1c?= =?us-ascii?Q?Gz+I8uZ9qiI3CXoah58022gVPNtCfaTCXHkByg6BeWZcvswuJQ9vZ2J4/kB/?= =?us-ascii?Q?10DUjGn9nUelVRpx7/d3Uep05abI3do+rFdW9pGt9XUDAEg+te8ue3FCXoGp?= =?us-ascii?Q?NXWrfpkdXzX2K9/Hyg4oxDjvTNP6uyknXLwETKkAc4NBK0DantyGpHeD1ni6?= =?us-ascii?Q?TCRufyc6Cg+NLoJy6+cB0ZYKy53UPx9TEmhHQLXhgBT5+z1Xf/kk/8GxGbzZ?= =?us-ascii?Q?Fs5qx205GCthAeCM1sbBPtMoFgXR/QU5W3xHgfLk9ktqCez4vWiNLvS5XuUm?= =?us-ascii?Q?R8UzfNpotm9HZVIUqDZrWpfe3IEUrnGAKyC9ut5LrFNsTaDsHmOZdAaZkLI4?= =?us-ascii?Q?v+sBu7aFtEsQ7NdYqCLR9aqyEKiEnIUfEiII6P+E9/mQbokR1ufAZ7TFEG8D?= =?us-ascii?Q?hiygvF50+XWroU58q/37oCP+YW44TERjYGUBYhZrjpJs0r4klsy4AFymDDB6?= =?us-ascii?Q?pC0cuh2ditVXWW6zWpNJgTjUxpHIKY/kDVtADEDDB3H+bXk+7CAoHf3NB6xh?= =?us-ascii?Q?yM/AHt4ETSDDX5VIIqUnGJQywzuwDzyqiPE+1v3KkpS+u9597zaJ5TNmMO6l?= =?us-ascii?Q?aq4Xb4QlVriK733bZH5AcTAsZ4Fu3Poj7ZVrn8QVVZljluIMWqDSqzDwEEqU?= =?us-ascii?Q?kSSx7lMrTF44Iqo9BHZ7ZFCLlrCZX+rYzkRBq+iZ+n9prSNSFK4mVvpRNvIy?= =?us-ascii?Q?Z/x8U9mVXYi6WHz85fSDP0eVClDht3JL64DrnN5lhQZ5trMVgtiKfoZiNLsR?= =?us-ascii?Q?BSs5H8PZSzHBGvpW2nyH6H4UU4W0b6wro8Whg0FZ9zAAZMwrAy/habrBjQhA?= =?us-ascii?Q?s232hAzK4N7Z/qYgNgbM78/lPFRTbCQpPOaJ3rlwNupHCVmH9kDGihiJ4U/Y?= =?us-ascii?Q?aop9TvhsFcqXSB0iZpHO+WulnCcRy4D0cz2pZyVq6tuUG7y6oxYxkuBTHbQd?= =?us-ascii?Q?WJ8pqnFj7HFiDK05Xbx0PvVDnpZRGp0kp/JqCg3IaSOifpdEFnZ9d2ElImgv?= =?us-ascii?Q?7uL9Kw3JtSB4wvwqROCNJ3fGkGx9uzQZJYmazrNHF05gnUBjagOGxwXsqOs2?= =?us-ascii?Q?Rdei1cS2fX/SeqlM0FPe40Sl4cwEm9xzz8HP/Ks9lJbwtbw93YgxiTsLFxhY?= =?us-ascii?Q?Nj1VuZ4iJC9uZaDQyTmzpkG2RHCpbYzJ0apGWxoHGQxxXmMzdfHpVGBtszmX?= =?us-ascii?Q?Q/JUFcc=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(7416014)(376014)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2024 17:41:32.4974 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 02957d40-67f3-4a34-8c53-08dce8899d43 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: SJ1PEPF00001CDF.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB7649 Content-Type: text/plain; charset="utf-8" If the BMEC (Bandwidth Monitoring Event Configuration) feature is supported, the bandwidth events can be configured to track specific events. The event configuration is domain specific. ABMC (Assignable Bandwidth Monitoring Counters) feature needs event configuration information to assign a hardware counter to an RMID. Event configurations are not stored in resctrl but instead always read from or written to hardware directly when prompted by user space. Read the event configuration from the hardware during the domain initialization. Save the configuration value in struct rdt_hw_mon_domain, so it can be used for counter assignment. Signed-off-by: Babu Moger Reviewed-by: Reinette Chatre --- v8: Renamed resctrl_mbm_evt_config_init() to arch_mbm_evt_config_init() Minor commit message update. v7: Fixed initializing INVALID_CONFIG_VALUE to mbm_local_cfg in case of err= or. v6: Renamed resctrl_arch_mbm_evt_config -> resctrl_mbm_evt_config_init Initialized value to INVALID_CONFIG_VALUE if it is not configurable. Minor commit message update. v5: Exported mon_event_config_index_get. Renamed arch_domain_mbm_evt_config to resctrl_arch_mbm_evt_config. v4: Read the configuration information from the hardware to initialize. Added few commit messages. Fixed the tab spaces. v3: Minor changes related to rebase in mbm_config_write_domain. v2: No changes. --- arch/x86/kernel/cpu/resctrl/core.c | 2 ++ arch/x86/kernel/cpu/resctrl/internal.h | 9 +++++++++ arch/x86/kernel/cpu/resctrl/monitor.c | 26 ++++++++++++++++++++++++++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 4 +--- 4 files changed, 38 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 00ad00258df2..a4f88c327b40 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -632,6 +632,8 @@ static void domain_add_cpu_mon(int cpu, struct rdt_reso= urce *r) =20 arch_mon_domain_online(r, d); =20 + arch_mbm_evt_config_init(hw_dom); + if (arch_domain_mbm_alloc(r->mon.num_rmid, hw_dom)) { mon_domain_free(hw_dom); return; diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 99f9103a35ba..86e3e188c119 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -56,6 +56,9 @@ /* Max event bits supported */ #define MAX_EVT_CONFIG_BITS GENMASK(6, 0) =20 +#define INVALID_CONFIG_VALUE U32_MAX +#define INVALID_CONFIG_INDEX UINT_MAX + /* Setting bit 0 in L3_QOS_EXT_CFG enables the ABMC feature. */ #define ABMC_ENABLE_BIT 0 =20 @@ -401,6 +404,8 @@ struct rdt_hw_ctrl_domain { * @d_resctrl: Properties exposed to the resctrl file system * @arch_mbm_total: arch private state for MBM total bandwidth * @arch_mbm_local: arch private state for MBM local bandwidth + * @mbm_total_cfg: MBM total bandwidth configuration + * @mbm_local_cfg: MBM local bandwidth configuration * * Members of this structure are accessed via helpers that provide abstrac= tion. */ @@ -408,6 +413,8 @@ struct rdt_hw_mon_domain { struct rdt_mon_domain d_resctrl; struct arch_mbm_state *arch_mbm_total; struct arch_mbm_state *arch_mbm_local; + u32 mbm_total_cfg; + u32 mbm_local_cfg; }; =20 static inline struct rdt_hw_ctrl_domain *resctrl_to_arch_ctrl_dom(struct r= dt_ctrl_domain *r) @@ -656,6 +663,8 @@ void __init resctrl_file_fflags_init(const char *config, unsigned long fflags); int mbm_cntr_alloc(struct rdt_resource *r); void mbm_cntr_free(struct rdt_resource *r, u32 cntr_id); +void arch_mbm_evt_config_init(struct rdt_hw_mon_domain *hw_dom); +unsigned int mon_event_config_index_get(u32 evtid); void rdt_staged_configs_clear(void); bool closid_allocated(unsigned int closid); int resctrl_find_cleanest_closid(void); diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 5c2a28565747..6b4cf4813a4b 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -1282,6 +1282,32 @@ int __init rdt_get_mon_l3_config(struct rdt_resource= *r) return 0; } =20 +void arch_mbm_evt_config_init(struct rdt_hw_mon_domain *hw_dom) +{ + unsigned int index; + u64 msrval; + + /* + * Read the configuration registers QOS_EVT_CFG_n, where is + * the BMEC event number (EvtID). + */ + if (mbm_total_event.configurable) { + index =3D mon_event_config_index_get(QOS_L3_MBM_TOTAL_EVENT_ID); + rdmsrl(MSR_IA32_EVT_CFG_BASE + index, msrval); + hw_dom->mbm_total_cfg =3D msrval & MAX_EVT_CONFIG_BITS; + } else { + hw_dom->mbm_total_cfg =3D INVALID_CONFIG_VALUE; + } + + if (mbm_local_event.configurable) { + index =3D mon_event_config_index_get(QOS_L3_MBM_LOCAL_EVENT_ID); + rdmsrl(MSR_IA32_EVT_CFG_BASE + index, msrval); + hw_dom->mbm_local_cfg =3D msrval & MAX_EVT_CONFIG_BITS; + } else { + hw_dom->mbm_local_cfg =3D INVALID_CONFIG_VALUE; + } +} + void __exit rdt_put_mon_l3_config(struct rdt_resource *r) { dom_data_exit(r); diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 8ffebd203c31..91ffd9d24883 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -1601,8 +1601,6 @@ struct mon_config_info { u32 mon_config; }; =20 -#define INVALID_CONFIG_INDEX UINT_MAX - /** * mon_event_config_index_get - get the hardware index for the * configurable event @@ -1612,7 +1610,7 @@ struct mon_config_info { * 1 for evtid =3D=3D QOS_L3_MBM_LOCAL_EVENT_ID * INVALID_CONFIG_INDEX for invalid evtid */ -static inline unsigned int mon_event_config_index_get(u32 evtid) +unsigned int mon_event_config_index_get(u32 evtid) { switch (evtid) { case QOS_L3_MBM_TOTAL_EVENT_ID: --=20 2.34.1 From nobody Wed Nov 27 12:26:58 2024 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2073.outbound.protection.outlook.com [40.107.236.73]) (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 E87B71E2600; Wed, 9 Oct 2024 17:41:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.73 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728495709; cv=fail; b=i8X06Uy7caWeKK/962LpK7LSFQU4Uns3C89mhCYwuwegpW1vn/m9l81u6J7f8JaA8kpmd78DQM5ocZUnX4OA/7cnRP3fA6dxxDaz5rDCX4HikrXClWGKmyFm8giutJsMhhBaw7Y8wHLfdHbZ/zBzbGHHcNsq5bFRByNw70tmOsw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728495709; c=relaxed/simple; bh=gRkDJ60P/GURFcnmnwiTefLjJ4L1TEV3bsofpWvLOho=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iG85JGHkdo+/kL//aSGTrRaOUy73Cq50BkJV332x4vvOqFHhBvW9DB/uKsmSk+sCr8Lklf1FP0Z4addNpJPDIukueAvOvTeNz974MKiEQORIEiyvdSijNkJ/VAY1Dn0kBzKnk7uAiG+OzwvR34e1hpjdeXvBtuO4IlNE/4kg/LM= 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=JIASC446; arc=fail smtp.client-ip=40.107.236.73 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="JIASC446" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=V07L+isiLTyoSTWsNL9b3YCVXHmsEqU4EsstYRXp0lyVpWK7e/KIkgNIfs0rKnnV3H+8IyZ7BfB/HkTaH7stJlBLElw3l4qnQEXLeWhMSBbsPrhlN4pgjGgkdpKgWpb17PFd5xQlqiY54yFxw7DsnbJF085aDcArU5xBRF4n516ei3XzLdRywQ2PhJm/+XL0O1crr0acB8cT7mQn+EJuBODonE7Yj5tQaVhp+0T7wd8pXC+U3fwe/aJakugx7Wam41owvKoy9T4RkwnymNI9BaHbf8mZ/9d8+FJF57yKVvV5gAOlwfu7z9JmC1sz8WE8oQfYCmALfRmWTVtYfjSBTA== 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=Ld1L2Ge2/Ngx2WYMtEfcs9zxiBrl0TgLL8XDprynbds=; b=rMd0WK2hf8Xn5jsBshUFVbJj5bhPx9rJElBQ1JpGt8oJGEe9jgg6h+LSUGOWrob+D1ObJdubuRBXUzT/foSf7yFbkxIkQRebZudLFjhs1crP0KD6u2RG4uKwQnz9mpqw+f3OXUwrtjcN1e2OAfciJdW7U3gwl2/kQUySINyDHf2SEKdV4+MUoIiWUB1UO5EPrjeaNKut67evHV3iXWOouyqqd4Un/LdW2BhkZqycvn0DB49CNHaiu+NpnRuFNprROt9Uh11M1Te8g97osz8aQBk71342JNXOD/z3iaTHGXB9D5pKxqA0g3HtwrAFTLreMtycO1HXfJSbS/zlYW+r4g== 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=Ld1L2Ge2/Ngx2WYMtEfcs9zxiBrl0TgLL8XDprynbds=; b=JIASC446dpzyOmz0xf1UKw6V5zST/w3bKZMrSKYNzg8Fwird2TbpIeiHeUgAAgQubiRnCigEn0zTyq4fysk24NPx0aU+nHOTW4igbd4Kko//znt1FzFDM5t1sOgxcARjF+zTmxUtKGO9KFrn6WjBV6omoomewoFEueSlpfTKIk8= Received: from SJ0PR05CA0075.namprd05.prod.outlook.com (2603:10b6:a03:332::20) by MW6PR12MB9000.namprd12.prod.outlook.com (2603:10b6:303:24b::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.23; Wed, 9 Oct 2024 17:41:42 +0000 Received: from SJ1PEPF00001CE3.namprd05.prod.outlook.com (2603:10b6:a03:332:cafe::df) by SJ0PR05CA0075.outlook.office365.com (2603:10b6:a03:332::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.16 via Frontend Transport; Wed, 9 Oct 2024 17:41:40 +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 SJ1PEPF00001CE3.mail.protection.outlook.com (10.167.242.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8048.13 via Frontend Transport; Wed, 9 Oct 2024 17:41:40 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 9 Oct 2024 12:41:38 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v8 12/25] x86/resctrl: Remove MSR reading of event configuration value Date: Wed, 9 Oct 2024 12:39:37 -0500 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00001CE3:EE_|MW6PR12MB9000:EE_ X-MS-Office365-Filtering-Correlation-Id: e14f62bc-a386-4fb6-4d80-08dce889a203 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|36860700013|7416014|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?Zo6A4XfH1WuxbW4pOp/eRz3kRXtFW87vc52v8q95q6pGh+fguvJ87nOV+1+A?= =?us-ascii?Q?/1ihiH2vRwtPzUqOlVsOCe+kKrFRgOHbGr5GFdm7pJTnh1vhEcyX8cYl6p35?= =?us-ascii?Q?gZTNQ/wJrG6yoDDtcOgEdZ2JugZh1WgiFb0Z+gx1Ue8clJLSrcv32VYg16iC?= =?us-ascii?Q?boF/qBe1z5NMVB1dKi6f3jLDqCUithZDzIXHtwUsTRKrofNhJc87/Xcmfn/C?= =?us-ascii?Q?RldaHDbtGUBK2+CQQwxaS8iciTtuaE7jEFySSvqxhdrSZExCee+VPLqg132+?= =?us-ascii?Q?GO8WpnfgtFZOdNH7Dx80QWq+nLP7p0QXyq1xhelca3xnsX/PZ1dOy+KvTneJ?= =?us-ascii?Q?whTkIP7gAElru02JNsqPMoi782cBePJZXvAPDLGqK6KccpGQD9rMGl+ukp/T?= =?us-ascii?Q?ltL3yWqsP/yEt26uNF0zS5U+Md6G7Oh8Mkbb8LQ9Y+9ZMDhCAAsAUKlkqQqC?= =?us-ascii?Q?YgXUmeZ3PVLPO7iAiLWMJ6aApYNEs+va9SoIfkZGRGhPuHR/RHd9TRjWgiXT?= =?us-ascii?Q?v1qootDME5w0ooquvZdg5c+4ncdZR2H0vFWUSTAvld3ktiq4l9MBsk6RrL72?= =?us-ascii?Q?9gZzmsK0Vzc6FDDr/eAf9O23eQmszn45+JZlPSZRggS/69M3ZaROHPiOCjYN?= =?us-ascii?Q?05Oi5BAa2aH+dYbbc8daPaT0ZlPTc0lBb2aQ2H/oHE1knERwMlN+NX7+NkTL?= =?us-ascii?Q?vj9KysUjcRUiTmkK0OE47kciksKcIKVHEzsFGPo1MjWYbb2lsvCQ3riz32WP?= =?us-ascii?Q?SKCCZfQIrZPsz8mtJ2jwEg0bBVRZep3UQeAJUUD19K3ritQoYRZrog91iXTb?= =?us-ascii?Q?g3md9ynwiETKadAX0RwgNdGOmgBoceWrsySmyMEqSeOm+a5nnS82h+bu3tPO?= =?us-ascii?Q?V3VDOeyyvCJcHe6gLTa7daJ7daIzw9QtVVY3Dn3R0iGU5eNSar0CURgAUn6g?= =?us-ascii?Q?JP8j5Poq5tTlyNqUslCnSPRlzzUeH2ZaUEumW9v49NNI+KXv/EhvmBaT8yu8?= =?us-ascii?Q?1eJhhNhszjhgnVBwPtH270QoD8hggSE+EiMnJldQSQrRSFTDLbJCeX6C+y3P?= =?us-ascii?Q?8a44B3R0LDDENSevnhaUscSYMIJFCrsS/JYp8cMTvLyWjOE3pIbNVO+b4IJT?= =?us-ascii?Q?ifPEnRd0bA/wVuMgi1XuT8ixmWaiY+1UvnxLLb9Jl1Jb2VDdyTOrBXhhl55C?= =?us-ascii?Q?LOa2kgBraMLm3i9RDG7DrvdcL8GuhYmdi8p508RJlsrSA46neB9/xZ7IJw0p?= =?us-ascii?Q?6fHSdC7MJUIUtr+DhiuVBdlCZwGXjK4CGw+tAidVCwwBq6UHgCO0Yt8Vl9Fe?= =?us-ascii?Q?4x2KxVDooGghLfMFHaql+QNWyyA0Q0daXE50e3Il3y43WDUP38wvgWOmb/KB?= =?us-ascii?Q?fhl9QCtduj91TSp8oCq9SfNOEFeV?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(1800799024)(36860700013)(7416014)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2024 17:41:40.4650 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e14f62bc-a386-4fb6-4d80-08dce889a203 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: SJ1PEPF00001CE3.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW6PR12MB9000 Content-Type: text/plain; charset="utf-8" The event configuration is domain specific and initialized during domain initialization. The values are stored in struct rdt_hw_mon_domain. It is not required to read the configuration register every time user asks for it. Use the value stored in struct rdt_hw_mon_domain instead. Introduce resctrl_arch_mon_event_config_get() and resctrl_arch_mon_event_config_set() to get/set architecture domain specific mbm_total_cfg/mbm_local_cfg values. Signed-off-by: Babu Moger --- v8: Renamed resctrl_arch_event_config_get() to resctrl_arch_mon_event_config_get(). resctrl_arch_event_config_set() to resctrl_arch_mon_event_config_set(). v7: Removed check if (val =3D=3D INVALID_CONFIG_VALUE) as resctrl_arch_even= t_config_get already prints warning. Kept the Event config value definitions as is. v6: Fixed inconstancy with types. Made all the types to u32 for config value. Removed few rdt_last_cmd_puts as it is not necessary. Removed unused config value definitions. Few more updates to commit message. v5: Introduced resctrl_arch_event_config_get and resctrl_arch_event_config_get() based on our discussion. https://lore.kernel.org/lkml/68e861f9-245d-4496-a72e-46fc57d19c62@amd.c= om/ v4: New patch. --- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 103 ++++++++++++++----------- include/linux/resctrl.h | 4 + 2 files changed, 62 insertions(+), 45 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 91ffd9d24883..ba90e520150f 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -1597,10 +1597,57 @@ static int rdtgroup_size_show(struct kernfs_open_fi= le *of, } =20 struct mon_config_info { + struct rdt_mon_domain *d; u32 evtid; u32 mon_config; }; =20 +u32 resctrl_arch_mon_event_config_get(struct rdt_mon_domain *d, + enum resctrl_event_id eventid) +{ + struct rdt_hw_mon_domain *hw_dom =3D resctrl_to_arch_mon_dom(d); + + switch (eventid) { + case QOS_L3_OCCUP_EVENT_ID: + break; + case QOS_L3_MBM_TOTAL_EVENT_ID: + return hw_dom->mbm_total_cfg; + case QOS_L3_MBM_LOCAL_EVENT_ID: + return hw_dom->mbm_local_cfg; + } + + /* Never expect to get here */ + WARN_ON_ONCE(1); + + return INVALID_CONFIG_VALUE; +} + +void resctrl_arch_mon_event_config_set(void *info) +{ + struct mon_config_info *mon_info =3D info; + struct rdt_hw_mon_domain *hw_dom; + unsigned int index; + + index =3D mon_event_config_index_get(mon_info->evtid); + if (index =3D=3D INVALID_CONFIG_INDEX) + return; + + wrmsr(MSR_IA32_EVT_CFG_BASE + index, mon_info->mon_config, 0); + + hw_dom =3D resctrl_to_arch_mon_dom(mon_info->d); + + switch (mon_info->evtid) { + case QOS_L3_OCCUP_EVENT_ID: + break; + case QOS_L3_MBM_TOTAL_EVENT_ID: + hw_dom->mbm_total_cfg =3D mon_info->mon_config; + break; + case QOS_L3_MBM_LOCAL_EVENT_ID: + hw_dom->mbm_local_cfg =3D mon_info->mon_config; + break; + } +} + /** * mon_event_config_index_get - get the hardware index for the * configurable event @@ -1623,33 +1670,11 @@ unsigned int mon_event_config_index_get(u32 evtid) } } =20 -static void mon_event_config_read(void *info) -{ - struct mon_config_info *mon_info =3D info; - unsigned int index; - u64 msrval; - - index =3D mon_event_config_index_get(mon_info->evtid); - if (index =3D=3D INVALID_CONFIG_INDEX) { - pr_warn_once("Invalid event id %d\n", mon_info->evtid); - return; - } - rdmsrl(MSR_IA32_EVT_CFG_BASE + index, msrval); - - /* Report only the valid event configuration bits */ - mon_info->mon_config =3D msrval & MAX_EVT_CONFIG_BITS; -} - -static void mondata_config_read(struct rdt_mon_domain *d, struct mon_confi= g_info *mon_info) -{ - smp_call_function_any(&d->hdr.cpu_mask, mon_event_config_read, mon_info, = 1); -} - static int mbm_config_show(struct seq_file *s, struct rdt_resource *r, u32= evtid) { - struct mon_config_info mon_info =3D {0}; struct rdt_mon_domain *dom; bool sep =3D false; + u32 val; =20 cpus_read_lock(); mutex_lock(&rdtgroup_mutex); @@ -1658,11 +1683,8 @@ static int mbm_config_show(struct seq_file *s, struc= t rdt_resource *r, u32 evtid if (sep) seq_puts(s, ";"); =20 - memset(&mon_info, 0, sizeof(struct mon_config_info)); - mon_info.evtid =3D evtid; - mondata_config_read(dom, &mon_info); - - seq_printf(s, "%d=3D0x%02x", dom->hdr.id, mon_info.mon_config); + val =3D resctrl_arch_mon_event_config_get(dom, evtid); + seq_printf(s, "%d=3D0x%02x", dom->hdr.id, val); sep =3D true; } seq_puts(s, "\n"); @@ -1693,33 +1715,23 @@ static int mbm_local_bytes_config_show(struct kernf= s_open_file *of, return 0; } =20 -static void mon_event_config_write(void *info) -{ - struct mon_config_info *mon_info =3D info; - unsigned int index; - - index =3D mon_event_config_index_get(mon_info->evtid); - if (index =3D=3D INVALID_CONFIG_INDEX) { - pr_warn_once("Invalid event id %d\n", mon_info->evtid); - return; - } - wrmsr(MSR_IA32_EVT_CFG_BASE + index, mon_info->mon_config, 0); -} =20 static void mbm_config_write_domain(struct rdt_resource *r, struct rdt_mon_domain *d, u32 evtid, u32 val) { struct mon_config_info mon_info =3D {0}; + u32 config_val; =20 /* - * Read the current config value first. If both are the same then + * Check the current config value first. If both are the same then * no need to write it again. */ - mon_info.evtid =3D evtid; - mondata_config_read(d, &mon_info); - if (mon_info.mon_config =3D=3D val) + config_val =3D resctrl_arch_mon_event_config_get(d, evtid); + if (config_val =3D=3D INVALID_CONFIG_VALUE || config_val =3D=3D val) return; =20 + mon_info.d =3D d; + mon_info.evtid =3D evtid; mon_info.mon_config =3D val; =20 /* @@ -1728,7 +1740,8 @@ static void mbm_config_write_domain(struct rdt_resour= ce *r, * are scoped at the domain level. Writing any of these MSRs * on one CPU is observed by all the CPUs in the domain. */ - smp_call_function_any(&d->hdr.cpu_mask, mon_event_config_write, + smp_call_function_any(&d->hdr.cpu_mask, + resctrl_arch_mon_event_config_set, &mon_info, 1); =20 /* diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 5a4d6adec974..54eacc8a9d49 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -354,6 +354,10 @@ void resctrl_arch_reset_rmid(struct rdt_resource *r, s= truct rdt_mon_domain *d, */ void resctrl_arch_reset_rmid_all(struct rdt_resource *r, struct rdt_mon_do= main *d); =20 +void resctrl_arch_mon_event_config_set(void *info); +u32 resctrl_arch_mon_event_config_get(struct rdt_mon_domain *d, + enum resctrl_event_id eventid); + extern unsigned int resctrl_rmid_realloc_threshold; extern unsigned int resctrl_rmid_realloc_limit; =20 --=20 2.34.1 From nobody Wed Nov 27 12:26:58 2024 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2085.outbound.protection.outlook.com [40.107.244.85]) (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 321841E2600; Wed, 9 Oct 2024 17:41:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.85 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728495716; cv=fail; b=TitBY8wAzP1BJH+nhodLfYwg6626aMg1GvzXc7AeVpP8FHl2tF9O4lig+fLH79gbj7VUXdi0N9YBH6KTpWCz2DZJXJ07gTk1zRDLqYj5sgkxbv3AyVHPbnZGeM7sYzUhuRylXUl/IdAg3xVMA2ESWNcOGsv5YlsCNXXP8CajOdE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728495716; c=relaxed/simple; bh=3v6e6FTzORMmiObSB3M440Kxb0phw9hOhS8Gm7oEa4Y=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uJroBtM9fRoKGg4qPy0qC/BPbTGm4keFHCRcJ89y05Gdhqe7XCWthZgiC0a3YeVeLLk4CihOuJujf1w7wmOwf215incmd6bO8yXZMYE8v/vUn9sAyrNvkDJAbneBQnRXREePV+0XANBRYauyYw5VlK7WMKg+yg48lZ9af5gAB24= 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=5rotEBds; arc=fail smtp.client-ip=40.107.244.85 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="5rotEBds" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XUXnw5PjkAbkGEp90TjXe9KT3wvEFAeLhGJdKuUcY2AfOB/0neFkLnmV7GPr8zD0wCumf2Efp/TqLf+eQC1qL3Lp2VrRRkPvFEaMZAXSJnhp2H2k1zQv4fTq4db/bq25DPi39jQn/aw6Vlm1aQPYCX2dwybjpvvx7u2ux8T3SHfAmq0F8VIT98HgGQE5nOZhaAKBV2N/f5ovXxDnOge4naVWQo2oPEIOuGDK/uR0b5GStKXVTwFwjTL3JCv9XGYlNSFJ38vdrUNz6Ei6sJY7OQd9nXxC7Gd8UDQrrDKUthIc0A8YDwcegnx3H2W0dh0ilG53QXVqKZWgysZWlhyjwg== 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=FontY8M27P3KEF5HatrQLgY/cY8MrR0WU1Tg7SNrTrY=; b=EUOtcrYSbpcdObOp2kdypZW8D1kHT8O3emNkJoEugleQCTlz6Hs3mPpEsSGLrLnX4FBWVw9IqyKbh5ILRTo1HlCDGGeBC+Gwf0QgkPO5s4tLGxDf92ruHQiBhpmLNygQVyV8WOyzVI4dyMDHKiLx3flFGFvLTR9ma8QmRL/WYLjsLVahKRVPnbi/ZCC7Hq0/4XGhF5GHe/DuY7Y+F8i1JZs8OGf9GgS9QbNQy23iVuQVAWD8EeLPFAb8qJDIiS2/Gf/sZkHh8rk15/QD49rG0WgwZzj6SCcLVMa7TtgS5vhfdYGO5Qe26sh1Duh2OFxzqZj28EWl8drR011yw2ClbQ== 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=FontY8M27P3KEF5HatrQLgY/cY8MrR0WU1Tg7SNrTrY=; b=5rotEBdsWTA2e/cVrxeXxuXsTRvFm5LEvhfQ3yVZuTo8rmwEgcl+tsQw2I16XEN4vlmTlYJ44Ugyo00EYbA4QLSzU4IX5RdTZZgp8dg8RO4R/vGzVSHTkHjrSVf74SWusygkYGadRGvhv+cSBvBB7mGLwmgRcSIdjE1EpjkMqYo= Received: from MW4PR04CA0118.namprd04.prod.outlook.com (2603:10b6:303:83::33) by DS7PR12MB5814.namprd12.prod.outlook.com (2603:10b6:8:76::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.16; Wed, 9 Oct 2024 17:41:48 +0000 Received: from SJ1PEPF00001CDF.namprd05.prod.outlook.com (2603:10b6:303:83:cafe::37) by MW4PR04CA0118.outlook.office365.com (2603:10b6:303:83::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.17 via Frontend Transport; Wed, 9 Oct 2024 17:41:48 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ1PEPF00001CDF.mail.protection.outlook.com (10.167.242.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8048.13 via Frontend Transport; Wed, 9 Oct 2024 17:41:48 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 9 Oct 2024 12:41:46 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v8 13/25] x86/resctrl: Introduce mbm_cntr_map to track assignable counters at domain Date: Wed, 9 Oct 2024 12:39:38 -0500 Message-ID: <2362cc9dc2e2e30c560423add198b621ad3d3307.1728495588.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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00001CDF:EE_|DS7PR12MB5814:EE_ X-MS-Office365-Filtering-Correlation-Id: b714a2f1-c71b-4627-952d-08dce889a6ab 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?+AgMjxvWIUSbvyoi7YIgK6HsDLPPPYmHUqujqazAuRGkQBQpKb96zi3MJMby?= =?us-ascii?Q?oGCY5TZSl72cRrKUij9r+fsf1iVRu7WUW16yyCfiIWsrKgiVNMjO2qBXTGzd?= =?us-ascii?Q?90O685eaxxmBOKUWj7gtQdOXWc8cOjA9t0MPcnIoQONdCBHlFHYZW4oNZY3J?= =?us-ascii?Q?NN33H4QrgaoOapKvof6+Sl27vQ+1bJVHGNjv85zIahMGUJIekNs1+VZqxPUo?= =?us-ascii?Q?tcN/IuXsKhc0UDpRJqZgefuLkOoISgIloBkJg/eM8uCNCiPH8216u1Bt5wO0?= =?us-ascii?Q?cX9kO2likU0RMNfaQR4pI9RHEWFkelLoy3U17ID/tE1utOTaW3GzNg9pj2nI?= =?us-ascii?Q?G10kq+wuXSTS8gC9etiJVOry1onSH2QFHMYzLo4NKJkAIbSaDH5JmuEZbJXu?= =?us-ascii?Q?5PS6jq1cANiDXrvcqE15fl8WP3GBvK7VfBLPh0dvFhnTjcQzOZ1s26Q6QUs1?= =?us-ascii?Q?3RON7qbbczsFJ5RLPkAjrEUquVoEQsqXnszCz1trvGMeQ3enLdysJZpyuulu?= =?us-ascii?Q?Ccb+3UKMmBJayw6HGEo6Yl5wYYr/hPCpXs+XMTDxxVQqf4nvY6gV+TiBAv5Z?= =?us-ascii?Q?VWynv7k9lhE0V8DU+4wRsyTSFtgbyHWK7BhfQ+9XOoqzx3rjdKZC87wo7ESG?= =?us-ascii?Q?4EIy9jgzyjndpRQc1GMqFrIOxKvKkk4tXg5JpownXDyd90cyhfdg/rHzV9/B?= =?us-ascii?Q?yzt+od+kolT60tmuxQVvIScWdY836hXFQc9ElnqxTIoh60zV22diKjaPIae+?= =?us-ascii?Q?eLW26WLmkL2nhjkSIMiDXWRrg24hN78tX7YFCbqRYB2fR4LlaamVhGCVoPbT?= =?us-ascii?Q?5D36i/rAiV2+owQ8RgAB6vZyStd0Pgxy8Eub67ZYf++idKVsI7zK3xpPEtNZ?= =?us-ascii?Q?bYoGulnhQUc54+krzBI6GMHGkTuUnixkenTjajgg8NKPXgt2viOkSvMyw5sa?= =?us-ascii?Q?mAhAv3at1mn6h68e1Ie74Gm9Ri0EQiXiTHbgaoLL1pDPXARsJMrALgjioedM?= =?us-ascii?Q?9jDAxxc8hm7GFHPwNV2Ep1U2b+Kw5pwwsx0Qt3GWgBp0MpG3HwFVVgXvojj5?= =?us-ascii?Q?PsLQDWyo5+rXFnJryFSUfEoEOgDOycjszgChtVL5DtV+FBPsUCQKXtzNOHBx?= =?us-ascii?Q?fXxkHQwZVuE1D+mByl0W5IqReO8pUN2rL2RmgfiL3f7glDAM5cxR4jfO/sG4?= =?us-ascii?Q?BLbyA5ikle9YQTWpsUmKWPiXzrQiiW2AajKneCuUWpP70/bHJcwqeBpzWCuj?= =?us-ascii?Q?iRlC0YwQ+aYOTqG42I+NN+OKWIIvVBgpps9NFEjbf0hPXliX6aJH8Br/oaVT?= =?us-ascii?Q?oJNRFurJc/gGxydzYR3EPvtwVLRH3ESbtffwoOhbQ2Y6j5Iv+BMoMrCiOPXL?= =?us-ascii?Q?XC8/tQwgwi/Q0ibOdHRvgaN6O4nT?= 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: 09 Oct 2024 17:41:48.2787 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b714a2f1-c71b-4627-952d-08dce889a6ab 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: SJ1PEPF00001CDF.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB5814 Content-Type: text/plain; charset="utf-8" The MBM counters are allocated globally and assigned to an RMID, event pair in a resctrl group. It is tracked by mbm_cntr_free_map. Counters are assigned to the domain based on the user input. It needs to be tracked at domain level also. Add the mbm_cntr_map bitmap in struct rdt_mon_domain to keep track of assignment at domain level. The global counter at mbm_cntr_free_map can be released when assignment at all the domains are cleared. Signed-off-by: Babu Moger Reviewed-by: Reinette Chatre --- v8: Minor commit message changes. v7: Added check mbm_cntr_assignable for allocating bitmap mbm_cntr_map v6: New patch to add domain level assignment. --- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 10 ++++++++++ include/linux/resctrl.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index ba90e520150f..610eae64b13a 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -4093,6 +4093,7 @@ static void __init rdtgroup_setup_default(void) =20 static void domain_destroy_mon_state(struct rdt_mon_domain *d) { + bitmap_free(d->mbm_cntr_map); bitmap_free(d->rmid_busy_llc); kfree(d->mbm_total); kfree(d->mbm_local); @@ -4166,6 +4167,15 @@ static int domain_setup_mon_state(struct rdt_resourc= e *r, struct rdt_mon_domain return -ENOMEM; } } + if (is_mbm_enabled() && r->mon.mbm_cntr_assignable) { + d->mbm_cntr_map =3D bitmap_zalloc(r->mon.num_mbm_cntrs, GFP_KERNEL); + if (!d->mbm_cntr_map) { + bitmap_free(d->rmid_busy_llc); + kfree(d->mbm_total); + kfree(d->mbm_local); + return -ENOMEM; + } + } =20 return 0; } diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 54eacc8a9d49..329fe23474ff 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -105,6 +105,7 @@ struct rdt_ctrl_domain { * @cqm_limbo: worker to periodically read CQM h/w counters * @mbm_work_cpu: worker CPU for MBM h/w counters * @cqm_work_cpu: worker CPU for CQM h/w counters + * @mbm_cntr_map: bitmap to track domain counter assignment */ struct rdt_mon_domain { struct rdt_domain_hdr hdr; @@ -116,6 +117,7 @@ struct rdt_mon_domain { struct delayed_work cqm_limbo; int mbm_work_cpu; int cqm_work_cpu; + unsigned long *mbm_cntr_map; }; =20 /** --=20 2.34.1 From nobody Wed Nov 27 12:26:58 2024 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2068.outbound.protection.outlook.com [40.107.96.68]) (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 E62E31E0E0E; Wed, 9 Oct 2024 17:42:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.96.68 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728495725; cv=fail; b=Gi+nMlggZpS2GnEoXPLVDUh5Ujbbd9OgkDfGufSJuLR7KikMWiImvDIAaMsgmVeHVz9vsdII3Oe2/Ozo1jeXUr7tafVlMd86Unv3WkB1Pt0n71PNqJ6n4xZQx5Fp8zvic6vHkUhHusuZuL6BpFyVTtBTxL7ftQyazVuiy5JNttU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728495725; c=relaxed/simple; bh=y3MLz0yY9re2k6mna8Qs5qcZtKxwa2dWNVejpMPWoHw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=CSq3d9qP8tJR+0Ux3v60pOtC3uEoGRoGysO7g4EdULROE5BkUHqDgLZ/srWkyF6y5YhW+EGNRz91kZ8qBThh/4GGuQJbIv/JgbMFXVpXOq4HNbf8hrn8raQfhRWsBU9eyLVgooDgf0dF+/VeAYpN9fnCSHIXLEL5D6LywrFHnyE= 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=Z+LTW6Sk; arc=fail smtp.client-ip=40.107.96.68 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="Z+LTW6Sk" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xSMsnc0xVLPBDBBuBdIL7qns+b7pDCQqCd5qXbPZSThP6FSP9IClZ+L7UCCGeAxg9vY8lptptv7ffCLV3I/L/CPNDzYPc0uxTfBfqM+88oJh1Q2UI/Eu49tfDQukDfycGeV09Gvsuqu2Px5hSOygQId6vlFepUl8kH447hrakqZY58NTqhbli7d7iqNZ9YAFIQrhO33ofT7kuiOzLtloNqS1NAoySFZ16jYkSH5JS8mewp8oSVLiwkGzTc4WdbJG0IKTi5QGNDb34iwMaK9ZVkgGhuQT9gyi+GB787fnLSkMNfZT3CDS1P/hZR/yAQqVapm2nXc4NiNngOUUnldZWg== 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=eeguYBnlP4mO4oUjNQ1zFexrmO7vdBwh7ol9YfGu7Ow=; b=CFQwfOsn12oY3PS+tDnpjtoH01JxVYF8bQRrkryinAnImv4zb+odDviAvmNiscxkcE9I8IgEiy52skw/P/Pqtnu1aYcZ9e9L17WtOwmX2ubPlD7aKIThNv13nBQzAMEvdWauYW5KqmjEvapSLeH/Ky5YjfRZHJ0Cbv+UMb1Oj9LLLUvhki/xwac3nUJBp49dVhmKmeviE/xTOPcqQNrJgFTjP7pz0nDEAfAqCW26nuEJAvGhHGM+/zdSb9NAG8a/BLiNminZfPkLHyoS014+6fh6w/6GakyKYWBDl8tSrzhrt8vszckl9vi+Kzhf53c/7sK5PFtZ4OlN4QgrBV1tug== 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=eeguYBnlP4mO4oUjNQ1zFexrmO7vdBwh7ol9YfGu7Ow=; b=Z+LTW6SkVymelwcZX0xob5Sx5TOj0BvNEvKsdsxSwj+3WQryIPGsuvAMf4czvPkKpNnFkpvx9wGwL1/amYBbTVDIsPGBt4eLHn/UrFQC+oQPwwz8EPbohojzMWoNVscjFwgoHDDmdVV6LDl4KNnBtlZw77f8UQxUHvReLiWIm9Y= Received: from SJ0PR13CA0157.namprd13.prod.outlook.com (2603:10b6:a03:2c7::12) by LV2PR12MB5848.namprd12.prod.outlook.com (2603:10b6:408:173::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.16; Wed, 9 Oct 2024 17:41:56 +0000 Received: from SJ1PEPF00001CDC.namprd05.prod.outlook.com (2603:10b6:a03:2c7:cafe::35) by SJ0PR13CA0157.outlook.office365.com (2603:10b6:a03:2c7::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.16 via Frontend Transport; Wed, 9 Oct 2024 17:41:56 +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 SJ1PEPF00001CDC.mail.protection.outlook.com (10.167.242.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8048.13 via Frontend Transport; Wed, 9 Oct 2024 17:41:56 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 9 Oct 2024 12:41:54 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v8 14/25] x86/resctrl: Add data structures and definitions for ABMC assignment Date: Wed, 9 Oct 2024 12:39:39 -0500 Message-ID: <94cfd19bf9b16570b07649e1058b4ee55ac8c102.1728495588.git.babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00001CDC:EE_|LV2PR12MB5848:EE_ X-MS-Office365-Filtering-Correlation-Id: 44993453-8bdb-4c04-b35a-08dce889ab5d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|7416014|36860700013|376014|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?B?LzF3amhhYVRGU3R6ZHNtOXlSTU1KRVFTMUV2THZYVzJlbGh5Qk53SFVSMUds?= =?utf-8?B?TFk3Zm1WWmFtYThtaUt4Yk82Z2tGV25qRitmeG1XdjN6NVMraExoM3VvbGMx?= =?utf-8?B?UlZSTmtQYkVWZGtyNHV4YTBnWFF1aDBHMDVHcmlVWlJzenQzT05QemdkQmtt?= =?utf-8?B?U0hYeThGRWZYbTY4ZVZTa1psNjVSSGl4VmtNcXBCSWpMVjJWOFc4dkMzanNK?= =?utf-8?B?cnQremJ5K3lHb3FTZjNQaDVXWGc1amwxS2ZHVGdsWmJRQU5pakJZVXBCOG1r?= =?utf-8?B?RjRSckhjWnd3SURlbGlvTy9aSXAxZSs1NXVxeW5PZGlLS2dYcnl6WEZ3b0RC?= =?utf-8?B?RjZjMFU1Y2pSbm8wQWR4Q05jNW5JSFdXZUNEdTM2LzZ1OHhPZTJJQlBFRGpF?= =?utf-8?B?U2xGRnVjRzlncUxZZHBYK1ZtcjZiVWxjRzNYejUvYm96VGN0czFSVUpTcVo1?= =?utf-8?B?b1o5ZWVLa1VMU1JkNzMvR05Zay9NeW5CVUJXTUMyUW1qVkxFZlRyNnFrVlNx?= =?utf-8?B?M2liZnQ5NTBtU2ttS05jVUZ3eEwycW04K0NvdERVODRtVXd6b0lVb25vZExX?= =?utf-8?B?OHp3NlhwYVNMWG03amF5R0hYeTRSY2dnKzViWUdaTEkrUFZVdzZUTDBhMmNr?= =?utf-8?B?MmM4ck0wTVFmRUdrMFNvd0JnTUF6R0lseHYzR1dNVllMNFRWNDI1Rk5lSU9N?= =?utf-8?B?RVF6M0pzVys3M3dzV0lSNVdONnVESnRTdmF5SWZyMlZhTHhqRm80MXNJMmFW?= =?utf-8?B?YUdlQ052VGp6YnZsNS82ODc3Y1hOenhqdnE5ak9TejRmZ2d0TnZzMGk1YTNo?= =?utf-8?B?Z25hUzVoTUZJY1AyMW5ZN0hTL2dHaCtTSUsvQUFpeDhMbDRMSktsVkt4MjdV?= =?utf-8?B?ZmVRL0IvdGdJckhJUWYwaGJxY09tS3BTblM2N3BmWjZzeTBFT3RHYnJiZlZ0?= =?utf-8?B?ZjU4NWNYTjF6WTJacWo4OXROa0lXNlBtUjZreWlhK2NGNldKUGZCOTZaODFM?= =?utf-8?B?aGp5dmRucUZoV3RYZldHODFDWFZ4SHdJd0dFR2tpYU0vV0FKQ0g1Z2ZpTWk0?= =?utf-8?B?VmwzRWRSMjMvdWlTU3VrNTRBSEtBU2dVRkR0UWVmak1RVkhOMTdjazR2V05K?= =?utf-8?B?YVMyMld0blFzeTJTUmlUVmNrdlhwR1VMUHRwaG9PL1ZEallNRHl0b1FxcGZy?= =?utf-8?B?M0xPTk0wZkVvQTRvMzJKM1Vhelk5TlEwWHJGU2pKS2tiODYyWlpkTGZzbWNm?= =?utf-8?B?RGhIYjRHTkszZlFFNjQ1UU1JUWtieTdaSmhIWS9NMllUaU9XLzVzY2YwZmZ4?= =?utf-8?B?NzF0WDQvSjYreWgxTW5BcTRRVkVieDlaUGlNQzVMR0cwUjZaLy9zckFqVTFD?= =?utf-8?B?R2wzQ21OQ0RWSFN4bDFDWm1PVDRCTVJ4N0oxRmxCZXRsS2F1SUlCSEhSYU1y?= =?utf-8?B?NzVJKzErZ2FDVEdVNUFlYzB2YlNFWTVZeDNoUnhiUVJNRXllclN2UEpNRHhR?= =?utf-8?B?TS9HbnJGcDBOTkF1YU5vUHRQUEhNekxlRlBNdXcxMTZzMlljdUFkVTRqcEhB?= =?utf-8?B?dGNtTGw3aFpNZHppa2xMYjFJaEhEbTJOS25vbmI1bXNFUTFhS1NtL1FjcktD?= =?utf-8?B?ZCtldXlUNEdjU0VhUXFzVVo5M1BNb2kxeEQ5aG1hU1czbXA0bzg0dkkyTURz?= =?utf-8?B?UVUzbjc2azRieFNJWXVrRVVhTHF5RXEzUUxHblhQakxWTzZLYlZWYlVhS0ZS?= =?utf-8?B?OFlRNjZiUDBqYU02QjZ3MnRuSkJVQmwwR2NBQ3RuRU50SGxBQ0JVRXBFdklm?= =?utf-8?B?emdwTTNNT3o0ZSs2bXo3QWNiZG9YQ1VSL3BXYVBXVXdVbDYvY3c0aFRuOGpX?= =?utf-8?Q?8xJ07Uig5GAuu?= 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)(36860700013)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2024 17:41:56.1569 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 44993453-8bdb-4c04-b35a-08dce889ab5d 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: SJ1PEPF00001CDC.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5848 The ABMC feature provides an option to the user to assign a hardware counter to an RMID, event pair and monitor the bandwidth as long as the counter is assigned. The bandwidth events will be tracked by the hardware until the user changes the configuration. Each resctrl group can configure maximum two counters, one for total event and one for local event. The ABMC feature implements an MSR L3_QOS_ABMC_CFG (C000_03FDh). Configuration is done by setting the counter id, bandwidth source (RMID) and bandwidth configuration supported by BMEC (Bandwidth Monitoring Event Configuration). Attempts to read or write the MSR when ABMC is not enabled will result in a #GP(0) exception. Introduce the data structures and definitions for MSR L3_QOS_ABMC_CFG (0xC000_03FDh): =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Bits Mnemonic Description Access Reset Type Value =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 63 CfgEn Configuration Enable R/W 0 62 CtrEn Enable/disable counting R/W 0 61:53 =E2=80=93 Reserved MBZ 0 52:48 CtrID Counter Identifier R/W 0 47 IsCOS BwSrc field is a CLOSID R/W 0 (not an RMID) 46:44 =E2=80=93 Reserved MBZ 0 43:32 BwSrc Bandwidth Source R/W 0 (RMID or CLOSID) 31:0 BwType Bandwidth configuration R/W 0 to track for this counter =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D The feature details are documented in the APM listed below [1]. [1] AMD64 Architecture Programmer's Manual Volume 2: System Programming Publication # 24593 Revision 3.41 section 19.3.3.3 Assignable Bandwidth Monitoring (ABMC). Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D206537 Signed-off-by: Babu Moger --- v8: Update the configuration notes in kernel_doc. Few commit message update. v7: Removed the reference of L3_QOS_ABMC_DSC as it is not used anymore. Moved the configuration notes to kernel_doc. Adjusted the tabs for l3_qos_abmc_cfg and checkpatch seems happy. v6: Removed all the fs related changes. Added note on CfgEn,CtrEn. Removed the definitions which are not used. Removed cntr_id initialization. v5: Moved assignment flags here (path 10/19 of v4). Added MON_CNTR_UNSET definition to initialize cntr_id's. More details in commit log. Renamed few fields in l3_qos_abmc_cfg for readability. v4: Added more descriptions. Changed the name abmc_ctr_id to ctr_id. Added L3_QOS_ABMC_DSC. Used for reading the configuration. v3: No changes. v2: No changes. --- arch/x86/include/asm/msr-index.h | 1 + arch/x86/kernel/cpu/resctrl/internal.h | 33 ++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-in= dex.h index 43c9dc473aba..2c281c977342 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -1196,6 +1196,7 @@ #define MSR_IA32_SMBA_BW_BASE 0xc0000280 #define MSR_IA32_EVT_CFG_BASE 0xc0000400 #define MSR_IA32_L3_QOS_EXT_CFG 0xc00003ff +#define MSR_IA32_L3_QOS_ABMC_CFG 0xc00003fd =20 /* AMD-V MSRs */ #define MSR_VM_CR 0xc0010114 diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 86e3e188c119..de397468b945 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -602,6 +602,39 @@ union cpuid_0x10_x_edx { unsigned int full; }; =20 +/* + * ABMC counters can be configured by writing to L3_QOS_ABMC_CFG. + * Reading L3_QOS_ABMC_DSC returns the configuration of the counter id + * specified in L3_QOS_ABMC_CFG.cntr_id. + * @bw_type : Bandwidth configuration(supported by BMEC) + * tracked by the @cntr_id. + * @bw_src : Bandwidth source (RMID or CLOSID). + * @reserved1 : Reserved. + * @is_clos : @bw_src field is a CLOSID (not an RMID). + * @cntr_id : Counter identifier. + * @reserved : Reserved. + * @cntr_en : Counting enable bit. + * @cfg_en : Configuration enable bit. + * + * Configuration and counting: + * cfg_en=3D0, : No configuration changes applied. + * cfg_en=3D1, cntr_en=3D0 : Configure cntr_id and but no counting the ev= ents. + * cfg_en=3D1, cntr_en=3D1 : Configure cntr_id and start counting the eve= nts. + */ +union l3_qos_abmc_cfg { + struct { + unsigned long bw_type :32, + bw_src :12, + reserved1: 3, + is_clos : 1, + cntr_id : 5, + reserved : 9, + cntr_en : 1, + cfg_en : 1; + } split; + unsigned long full; +}; + void rdt_last_cmd_clear(void); void rdt_last_cmd_puts(const char *s); __printf(1, 2) --=20 2.34.1 From nobody Wed Nov 27 12:26:58 2024 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2082.outbound.protection.outlook.com [40.107.220.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2DF511E32D1; Wed, 9 Oct 2024 17:42:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.82 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728495731; cv=fail; b=BVv4Cgpa7ZCRMTKYpIYyf4qnf49DWj5QmzRLGxZ7neehCwtk59HbeNfIjVIBotT0pnhMpCJJqdLw2DGgIeEBDeZ4nqi8rkdUzBVF5ckR91td9KoCXf41/E3GOxW+qVVdUg1/RFjVtNgwnZp45Xe07r3jSmzQZQ4xTN2Z+Anv+pc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728495731; c=relaxed/simple; bh=M32fLlMWXhXq10kLBTMnEAmGBWXflttE78CJACq5wSw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JV27UURCQ2HqafHmfc8YLCF8P6B7S2vzFF6o/JOu0Xlg8yTSijUVaJzMyJnq1WXAzymr0cXNPOwAbVxMYk+TRpU+EhEFtQB1pi/o92Q6HJVnPmauHK4OY4TJDY2cANfURs4V5XY3OQNXY4eqaXX7FFyDrZD69y1bnuJmjd4sU5w= 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=eMe+GQ5l; arc=fail smtp.client-ip=40.107.220.82 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="eMe+GQ5l" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DQDW1odIMhrgf0NvzM5yE8rJWsfB0zirVRaxaewRXPETgLVAwa1G9sXDLrlO9yPe7cdTLdp48s1zy8DTzPkHfOk4aRkMMGWum5/IWZrbVgA/4MzxulTF5BAyUr06PHWbqQzBFgMqHjZhtk/HXlWXA3lceN00cbwl1g5h2opQMT9FxdThZhdr1FBJ1nRGiuWOTs6TMLGqPqAiSYlRenR0VCKRcppNET/0vkHLx0UFeQwLtRr2TH9iMIZvYj54+9dC7Vf/UvWnSvm/UUWfMGx5qn4cL17kKe/yP+NtPzg4J93qFmY3EKMALf0rfnpeo55MTEkO3MHzu5m8Ez2ylbp+fA== 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=v4hDXsETz4uVGQ5eV7unGv0DAOlVnE8k9yIgIab80CQ=; b=d8aGsmjFTgtY6RRVwDdQt6VhCjnvF8/s0qb1ahFqBOx47bGKriByL/Mq/N6taxr7Lv6nr75Mh23zxKQykMstZJLM0fD+UGufOelDDat8+Z2qFrJz1hZF5g+YnTaILOKvQVZQJI2xt42oQ3K9qDKRXS4kdJz5TtSzxSzdkxzXGXC0bVTqIIOLTVUXlf4W0WQZw67juOiaXQiOnIBa9IhXqLmfHmOQL85/bqC4CxOmCfSsrFO3tcKk2JBhGhD4mGn0/NYgKxkegqQRXJk5QBFqMBoF3cBuYpNyhhifMTs1gUW82KpHQEyFyzIKJTTFBsBAtatz6A4pWf/sjzy0thxpOw== 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=v4hDXsETz4uVGQ5eV7unGv0DAOlVnE8k9yIgIab80CQ=; b=eMe+GQ5lKqtve2SeSIEBrp0qskoSaoJBbddIbaLT407cy4Q/TeCqrm73WFBDKX6TX2re3rUh+rk2uC7rBNEdmtn386vySfUEHVLz4NR9qPBGO14n8oqtLGzbPHPdIuiZpMcEHYEEdL8V5umdcamCdGPfafBnMaCemlaqKiDP0QI= Received: from MW3PR05CA0005.namprd05.prod.outlook.com (2603:10b6:303:2b::10) by LV8PR12MB9333.namprd12.prod.outlook.com (2603:10b6:408:1fa::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.18; Wed, 9 Oct 2024 17:42:05 +0000 Received: from SJ1PEPF00001CE1.namprd05.prod.outlook.com (2603:10b6:303:2b:cafe::e5) by MW3PR05CA0005.outlook.office365.com (2603:10b6:303:2b::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.16 via Frontend Transport; Wed, 9 Oct 2024 17:42:04 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ1PEPF00001CE1.mail.protection.outlook.com (10.167.242.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8048.13 via Frontend Transport; Wed, 9 Oct 2024 17:42:04 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 9 Oct 2024 12:42:02 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v8 15/25] x86/resctrl: Introduce cntr_id in mongroup for assignments Date: Wed, 9 Oct 2024 12:39:40 -0500 Message-ID: <0af9b74cc32cbdd26fb0d9adda40c359e8bf1bb9.1728495588.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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00001CE1:EE_|LV8PR12MB9333:EE_ X-MS-Office365-Filtering-Correlation-Id: 9aa61f55-5daa-4695-0f95-08dce889b03e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|36860700013|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?QQ/lBC99fGNht45QCfPrviwvPV8AysC9NAQTW5ganuNKM6xZlPeGD0oQNwfx?= =?us-ascii?Q?StOU4RFbLr4402bjwAFivG1io9A1qjcnR9D+jFhUwVop3sUnrEdnnIq2MGUi?= =?us-ascii?Q?z0yLMzbUmoNlWRGkQRX+X1iFmSe1bWj5TXQ3riBLmW+Bp40Lgef6sVCCQ0Y+?= =?us-ascii?Q?d5rwhpFAFyZtrJOA8iabU8Zl+2ktTLr1i7xcXskRMbHs3eCsLly7obu7X2R+?= =?us-ascii?Q?DKOuSKWbXOzDmpjAQxePzUN2DvkbMitKlZiEQH3d8QsAoXzjgWP3PNfKesIu?= =?us-ascii?Q?K60Tl01bxNiUJAC8VMoQviXkB5mIBfsQMRBOtuNH1tBWFxw6wR/Xzog4n04M?= =?us-ascii?Q?lbhFKjR1+zLhZXak1uab7FlIPBfK/Ao5pt6iGXzKYS2mG93T04zZFt0LNa+l?= =?us-ascii?Q?gfK9ft4qdoTxa4vHurZTaMfzQlyk/ASDO3Vm2pGKXEweYdP/FpGHuw/BpasT?= =?us-ascii?Q?DJ+XjzLvC8ODrPPZ3e3ap6Cq+xkpo1BB3yxEN8B1JwHYrE8gtLtxYeZVLFgc?= =?us-ascii?Q?93VZFYnBu5AcRw/WhS0u2h9NGfjcOQXSjUZZfI77s5yb6+sf4C+YfFwSh45Y?= =?us-ascii?Q?kLMqSNi+fqOV6SF3KLE8O6SQ2R9AAMkG6YMYvpw6H2hCsUuHZlEf03zuCdzc?= =?us-ascii?Q?Z5GYAdOlmwf36hH/12u6fqq2BD3vckMR3U35Kr9K4zi4mFZjijAiu8+fuDQO?= =?us-ascii?Q?UHadTCttCG/ixdyUxh61B/yHYl3slSz9NBBno4VSKBtjOJwCfWPDhbdbllXw?= =?us-ascii?Q?sWtGGiEIdLU/ookqHC/FOPg9S4CBUKtmWXfRSTzQu0gLerkLGfiL97pdjUZK?= =?us-ascii?Q?AB/8g8lMnJFtgym+rKYAoEgaLmZfPLCEyraeySs+EWP0dUjUHfW7NJgYUBHg?= =?us-ascii?Q?gIm1JSmu65HnKBkdi2HKGuA/i325bdyOXlf80uWKeOhbyx222nHzBCzNKUeb?= =?us-ascii?Q?IgNcqsC7PLWAEu8f4+XLcw+p4vL/AlH/fD9K6e31aT3S5tq63KjfizlE9yEE?= =?us-ascii?Q?JXsCketTCO4+35ZX7zmobwxV4mhszsmyA2EOI0a9bH08X8qvY0rZ4r1kxNT5?= =?us-ascii?Q?ZRzWRVQJ8MKK5hhj1PRpFFij0oNHDdZwTAgKAniblh53OteXCTSO/oAemJ4x?= =?us-ascii?Q?asmbF/OUh7EZm5DTbmZs21k3Va8XYCbMT6qDBc4qKxpK57pzJ4dUkIgmMzq9?= =?us-ascii?Q?xNZWDPezTOkXiOiwHVmOLrijJdFjkBNw/2ThtAUVFVDXDb9xxNNVwGA+3jAd?= =?us-ascii?Q?r1s7jvCbidme6AGr5lcMfZmsGGCC9N0Unt8OeZpT6bS3v/DeecOXe0zFqrno?= =?us-ascii?Q?/fS6r+Pg9OOuBn8xOImVVpNV3Hr8o5Ej1plYA4tPFKsf/NTqmk6aJY66JYmN?= =?us-ascii?Q?42ULqMMZA9GTd4QcGJuFWTNu7OgR?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(36860700013)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2024 17:42:04.0101 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9aa61f55-5daa-4695-0f95-08dce889b03e 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: SJ1PEPF00001CE1.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV8PR12MB9333 Content-Type: text/plain; charset="utf-8" mbm_cntr_assign feature provides an option to the user to assign a counter to an RMID, event pair and monitor the bandwidth as long as the counter is assigned. There can be two counters per monitor group, one for MBM total event and another for MBM local event. Introduce cntr_id to manage the assignments. Signed-off-by: Babu Moger --- v8: Minor commit message update. v7: Minor comment update for cntr_id. v6: New patch. Separated FS and arch bits. --- arch/x86/kernel/cpu/resctrl/internal.h | 7 +++++++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index de397468b945..58298db9034f 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -62,6 +62,11 @@ /* Setting bit 0 in L3_QOS_EXT_CFG enables the ABMC feature. */ #define ABMC_ENABLE_BIT 0 =20 +/* Maximum assignable counters per resctrl group */ +#define MAX_CNTRS 2 + +#define MON_CNTR_UNSET U32_MAX + /** * cpumask_any_housekeeping() - Choose any CPU in @mask, preferring those = that * aren't marked nohz_full @@ -231,12 +236,14 @@ enum rdtgrp_mode { * @parent: parent rdtgrp * @crdtgrp_list: child rdtgroup node list * @rmid: rmid for this rdtgroup + * @cntr_id: IDs of hardware counters assigned to monitor group */ struct mongroup { struct kernfs_node *mon_data_kn; struct rdtgroup *parent; struct list_head crdtgrp_list; u32 rmid; + u32 cntr_id[MAX_CNTRS]; }; =20 /** diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 610eae64b13a..03b670b95c49 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -3530,6 +3530,9 @@ static int mkdir_rdt_prepare_rmid_alloc(struct rdtgro= up *rdtgrp) } rdtgrp->mon.rmid =3D ret; =20 + rdtgrp->mon.cntr_id[0] =3D MON_CNTR_UNSET; + rdtgrp->mon.cntr_id[1] =3D MON_CNTR_UNSET; + ret =3D mkdir_mondata_all(rdtgrp->kn, rdtgrp, &rdtgrp->mon.mon_data_kn); if (ret) { rdt_last_cmd_puts("kernfs subdir error\n"); @@ -4084,6 +4087,9 @@ static void __init rdtgroup_setup_default(void) rdtgroup_default.closid =3D RESCTRL_RESERVED_CLOSID; rdtgroup_default.mon.rmid =3D RESCTRL_RESERVED_RMID; rdtgroup_default.type =3D RDTCTRL_GROUP; + rdtgroup_default.mon.cntr_id[0] =3D MON_CNTR_UNSET; + rdtgroup_default.mon.cntr_id[1] =3D MON_CNTR_UNSET; + INIT_LIST_HEAD(&rdtgroup_default.mon.crdtgrp_list); =20 list_add(&rdtgroup_default.rdtgroup_list, &rdt_all_groups); --=20 2.34.1 From nobody Wed Nov 27 12:26:58 2024 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2057.outbound.protection.outlook.com [40.107.92.57]) (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 7EAE91E1A33; Wed, 9 Oct 2024 17:42:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.57 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728495742; cv=fail; b=t8kXAg+NVGQ8JSR87Z/Ipc27xTY0k/eXWJmznh1J5duhICtljss0Ke/k/bdn/mMgiboggA0+g8WGNhYb3Rg0/YbVbwBmzt+wCPYF9EU6ik+Rl9lEmhZcW04WY5DKYzDjzTmNmb7480C7HGALbamqBcGdNed8GAQp0zsZhQyLlho= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728495742; c=relaxed/simple; bh=5AA33wEW4RmHQYqyrAuSIu/ZcGAMmWiTMteJD9EBTNY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=OPhYGshvhaY3N+gObYKAUNiv5nPKKR6thOp7eeXQuXVQfXvKue6hxR+BOtZTHu8sxyclocExSIt1ePprOWAJlgb3wvjDtsBrd7OLZr+S/y/fRTY2cnCM0IMEWBj4uWyAjKk2/Qo79L6oWHqs4EVQh3/SJfsEet8MiuQe85VQpPQ= 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=vMkCPtqG; arc=fail smtp.client-ip=40.107.92.57 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="vMkCPtqG" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tSarYAgnghTTtb1EFpUZyDLxJyXJLggPOKB2Bbok0Ngg1S4lZu39S1qPdQ9tEpTRCzeH3pMos9ZciIUKMlyZOXgSInuhaoJGH0g/7aJBzOnU0NWgpmbGyysvwnJay6vuLP70pbHDA+7clLGpjpi9KAxEDnQVEAx7g6ApOwUBf63RQc3COrg+hzJVsem3z2qEXUCvTJgS2XtHMRJcycgIU1PlYbS78mhwPxxPkb/6AL+SBBe2vKurfBbsezSmHZpS86/otuglkCyYxBB1HYBbZIcLSCvfn4zyUy9YBBvD6KK842irT1P7xsT33bV+0VpH1OBrgfCepSDslfw21/3L4g== 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=eQ2qWLhEqL0q+1ZgpyNrBBt//SU5rEtyko75c8TlI8s=; b=vZCEUaRjD+n1oA4Um/5YQZw6Bh/oixoilTFyZqPjiTdT3An3BS33WaMKL7nLrqXFRf23hDGst6trpptcADAivE+S4vl3pvaW6zBqxvXk0m7yHHTGLckbs18s60gHRlLHaTHY0yvRPRe7iOiUyEscwApXORS48gj7uvkw2K6qY+8exOoJS7pCJYlmw1e+iVIod8+uIUT3AJudOEvGmWvgdupvq3YiiIC2rGKzzs3/Sk2gct66TTYeEr+HjJi6CfsI59f7lVLegL4rIhCdY4C8lnq/nr+recocLde/gDxx0TZ8zCQkSt5PRzT17aBRf0TYBL5imXMsQBqAQdVdeqYvdA== 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=eQ2qWLhEqL0q+1ZgpyNrBBt//SU5rEtyko75c8TlI8s=; b=vMkCPtqGmeXq/G9evP6N/lFW0SFYLalOWMNx7hH1NTso2Q7rTDVyu3tGuV4TMc3RID0X+OcLmljyr6b6eTrVAWxxjyjRaASHZuwauK1BIBxaz5OTGEHyvNRUeyzOnXqtuq2BxFRYgNoMsEftsOJkuvdXwmOpx7g3KUYFgQn3n84= Received: from SJ0PR05CA0062.namprd05.prod.outlook.com (2603:10b6:a03:332::7) by CY5PR12MB6528.namprd12.prod.outlook.com (2603:10b6:930:43::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.23; Wed, 9 Oct 2024 17:42:12 +0000 Received: from SJ1PEPF00001CE3.namprd05.prod.outlook.com (2603:10b6:a03:332:cafe::f1) by SJ0PR05CA0062.outlook.office365.com (2603:10b6:a03:332::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.7 via Frontend Transport; Wed, 9 Oct 2024 17:42:12 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ1PEPF00001CE3.mail.protection.outlook.com (10.167.242.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8048.13 via Frontend Transport; Wed, 9 Oct 2024 17:42: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; Wed, 9 Oct 2024 12:42:09 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v8 16/25] x86/resctrl: Implement resctrl_arch_config_cntr() to assign a counter with ABMC Date: Wed, 9 Oct 2024 12:39:41 -0500 Message-ID: <16d88cc4091cef1999b7ec329364e12dd0dc748d.1728495588.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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00001CE3:EE_|CY5PR12MB6528:EE_ X-MS-Office365-Filtering-Correlation-Id: 3af46a2b-b956-4af6-17dc-08dce889b4c5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|36860700013|7416014|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?rKTKnmXHbO3guJwtLYgc+qJNe/UVkge/dSDTBQceFG5O9whfbvEI52nmvE1C?= =?us-ascii?Q?1voyLSBBO7P/eg2YzfZceXgIGh1KF+/e0D6MzSexqI9NtJz+G1vdMQDI2Gr7?= =?us-ascii?Q?UQxbASiFsrtoxN62A73KbaGKRP47CPZZB7IzCktpdrHJiS6wxeAd2TKFGRry?= =?us-ascii?Q?+IsN1uyUhm+dHCIQnpwnh7EUK3VyQZhDJP9jQK5Q8eQ2TtlsNKwKc5/3dwNe?= =?us-ascii?Q?uahkbxGQL5swxauDAwMw/Su2DO4wW5p4cY6n87qd29vBpCG8FK2lPTiDX6XB?= =?us-ascii?Q?wQGOE81kyRIcnkkfoiSQXzH/moLCVZ1on9kKkCfgfax3wlpfWZ0TYlXcmClF?= =?us-ascii?Q?t1eDQTfG7cFcPChc5Xs0b10L1svzSC3KWOwQr6G1SN0XjWWMS2FE0eAZHWuM?= =?us-ascii?Q?7FTLuPmBMRjAJ6L54MhMvvzbHW4YHMB77wqovAtTfZYdRTZlDMucoamkutP7?= =?us-ascii?Q?jfQhk37SbWMlt7ot70LvjA7zEn3s7gZmfAY1QaOVBbwwERyBabt9Gl6t2bsb?= =?us-ascii?Q?CjBGs+EYEGaMB4JT+2nuCL7/L/uodMHnfiHHQN9I1ZU3A9X30L7ELfmfqsrH?= =?us-ascii?Q?Btesao6RrNBD/ljgp0P+SyeGhUai+yBMM4A4F0BSXRc4h9AX1Qm/EF9acLZQ?= =?us-ascii?Q?Mjoh+lY7FEBO9y4RUH/cJ+0Gp0gYgclb59yRCKnJNtnuZT3CxASNPXZjpjdD?= =?us-ascii?Q?2DyQvViSAb16WHQsyvEp3J922uekfvZenCHqBS39whHttiPEez30VSFENEi8?= =?us-ascii?Q?tp+00hJkHAcTb/LKifCAkaMNWItwWr9xZlMnaNH068KAQAPmx8mfBEhNpElv?= =?us-ascii?Q?K8upeTHMDWPJn1LW5w41+zVpNqMmiDkBetlUSxCjuVDDsD77jYD/RfxeQfS2?= =?us-ascii?Q?XSmNf4FhHGCJQzuTgiKt/FQuMTXTcJRu2D0dXLEIy+vMTIsEzhIrPrxhlZUF?= =?us-ascii?Q?/FyNN2SHOfrjXBCuPpVZTT929iRut6nPHlkLWMosp1y/Mqor+LBiDotTEpFs?= =?us-ascii?Q?e1RyOYIXCQt3aSMPMkiL9CNvZiYRkxLHCT0taztMmIF/7WNpoksCcP3BmaYy?= =?us-ascii?Q?rUrAsMKRxNmyFKZkVOQ8qeApOgw3XQTZSLTVI7lG9HlElxoDujSxmYHFWqYm?= =?us-ascii?Q?8YPoJAWjag2pG4GNpmjGA4bftohvtOpelHUjC2zEGdUN9mBa7+suMAe0Zfgh?= =?us-ascii?Q?lCtYbrnTR+MjhsmerjcqAzD/0MLUrTd6QqOrYebzKWemBvey+yx5dpCvlCYf?= =?us-ascii?Q?h2SZRZRDeEvZcn59gGTLJ8+QEhXQg7kKbBxZfkH/YDzqzR9cksNhQMIVTbHR?= =?us-ascii?Q?OzXFeqcMkG3Pw9DqF07vpdq/JFDS3ehoZV4GHXdtpnWyzZWYS5yuSyFPRClT?= =?us-ascii?Q?Wsad5S2OPdFbpYfKxE6qQacIZV1b?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(1800799024)(36860700013)(7416014)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2024 17:42:11.9340 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3af46a2b-b956-4af6-17dc-08dce889b4c5 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: SJ1PEPF00001CE3.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6528 Content-Type: text/plain; charset="utf-8" The ABMC feature provides an option to the user to assign a hardware counter to an RMID, event pair and monitor the bandwidth as long as it is assigned. The assigned RMID will be tracked by the hardware until the user unassigns it manually. Counters are configured by writing to L3_QOS_ABMC_CFG MSR and specifying the counter id, bandwidth source, and bandwidth types. Provide the interface to assign the counter ids to RMID. The feature details are documented in the APM listed below [1]. [1] AMD64 Architecture Programmer's Manual Volume 2: System Programming Publication # 24593 Revision 3.41 section 19.3.3.3 Assignable Bandwidth Monitoring (ABMC). Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D206537 Signed-off-by: Babu Moger --- v8: Rename resctrl_arch_assign_cntr to resctrl_arch_config_cntr. v7: Separated arch and fs functions. This patch only has arch implementatio= n. Added struct rdt_resource to the interface resctrl_arch_assign_cntr. Rename rdtgroup_abmc_cfg() to resctrl_abmc_config_one_amd(). v6: Removed mbm_cntr_alloc() from this patch to keep fs and arch code separate. Added code to update the counter assignment at domain level. v5: Few name changes to match cntr_id. Changed the function names to rdtgroup_assign_cntr resctr_arch_assign_cntr More comments on commit log. Added function summary. v4: Commit message update. User bitmap APIs where applicable. Changed the interfaces considering MPAM(arm). Added domain specific assignment. v3: Removed the static from the prototype of rdtgroup_assign_abmc. The function is not called directly from user anymore. These changes are related to global assignment interface. v2: Minor text changes in commit message. --- arch/x86/kernel/cpu/resctrl/internal.h | 3 ++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 45 ++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 58298db9034f..6d4df0490186 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -705,6 +705,9 @@ int mbm_cntr_alloc(struct rdt_resource *r); void mbm_cntr_free(struct rdt_resource *r, u32 cntr_id); void arch_mbm_evt_config_init(struct rdt_hw_mon_domain *hw_dom); unsigned int mon_event_config_index_get(u32 evtid); +int resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_mon_domain= *d, + enum resctrl_event_id evtid, u32 rmid, u32 closid, + u32 cntr_id, bool assign); void rdt_staged_configs_clear(void); bool closid_allocated(unsigned int closid); int resctrl_find_cleanest_closid(void); diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 03b670b95c49..4ab1a18010c9 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -1853,6 +1853,51 @@ static ssize_t mbm_local_bytes_config_write(struct k= ernfs_open_file *of, return ret ?: nbytes; } =20 +static void resctrl_abmc_config_one_amd(void *info) +{ + u64 *msrval =3D info; + + wrmsrl(MSR_IA32_L3_QOS_ABMC_CFG, *msrval); +} + +/* + * Send an IPI to the domain to assign the counter to RMID, event pair. + */ +int resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_mon_domain= *d, + enum resctrl_event_id evtid, u32 rmid, u32 closid, + u32 cntr_id, bool assign) +{ + struct rdt_hw_mon_domain *hw_dom =3D resctrl_to_arch_mon_dom(d); + union l3_qos_abmc_cfg abmc_cfg =3D { 0 }; + struct arch_mbm_state *arch_mbm; + + abmc_cfg.split.cfg_en =3D 1; + abmc_cfg.split.cntr_en =3D assign ? 1 : 0; + abmc_cfg.split.cntr_id =3D cntr_id; + abmc_cfg.split.bw_src =3D rmid; + + /* Update the event configuration from the domain */ + if (evtid =3D=3D QOS_L3_MBM_TOTAL_EVENT_ID) { + abmc_cfg.split.bw_type =3D hw_dom->mbm_total_cfg; + arch_mbm =3D &hw_dom->arch_mbm_total[rmid]; + } else { + abmc_cfg.split.bw_type =3D hw_dom->mbm_local_cfg; + arch_mbm =3D &hw_dom->arch_mbm_local[rmid]; + } + + smp_call_function_any(&d->hdr.cpu_mask, resctrl_abmc_config_one_amd, + &abmc_cfg, 1); + + /* + * Reset the architectural state so that reading of hardware + * counter is not considered as an overflow in next update. + */ + if (arch_mbm) + memset(arch_mbm, 0, sizeof(struct arch_mbm_state)); + + return 0; +} + /* rdtgroup information files for one cache resource. */ static struct rftype res_common_files[] =3D { { --=20 2.34.1 From nobody Wed Nov 27 12:26:58 2024 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2057.outbound.protection.outlook.com [40.107.94.57]) (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 4CE141E1C12; Wed, 9 Oct 2024 17:42:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.57 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728495748; cv=fail; b=f3AEgrzLTMq2l4xG9w44E1wGnYPEazbnYI5zUOVTif0heZMctgxBzQb5/v3h9aGOwBi+5lCCAHDgwVBO0603d6OPjnFr0nTpZxIGcVRW2kjEs1Tinc8dudGSIzrGATqhUZfaRecAu1ic58Z2h1r/6eijoJ90u8FEf+7Pif2Xlpc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728495748; c=relaxed/simple; bh=t+tVSSHAitiBMpltgu5NQPbv9hMc8CuiRy0k6uXOu5w=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qNPqagmqHxeozYBCi4OWId8TY7foV7ffqCVJaIdPL/LX5TOH403lGAfQQSOCbgMOztbEdl8C1HBJzaI9w1cXcIWoVhdy/bSyrqLyPg2T0AkZQWgcxVVfk9lhfxhUdbk6toLEB+YrfFbEQHybQbhuoyPgIMlHxi0lP4Buf4CSmWs= 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=IOKcQZra; arc=fail smtp.client-ip=40.107.94.57 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="IOKcQZra" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qgMD6c3632nkolidqKte+Lo16B0hKGkO+c985NZZg5zieMqu7+jkR24t23K2I1KhpC/trbXdiHXF2fizrnrZ5gQsO+I6fojoXepnu/ULnmmPRskpXVL5m2q4e1PcVE0VwFdL5M/beX8UpnabAQL9W5fG/hE4yLeWr7SOIoG6Wf3JWPk5aFBALbGYLgR2xY0xbu+MK/3U9mFBb5JVTR92Eu4iWjylfh9bdiG7l3q8PBiu0ZbO3j76DKLBzoT1PQlzBEk85Y+7557panQc82TPMmvFa0TxE86C6LMqpgiMXFJy3mITwFbpdKCDvBOIgCs+vBmFKMqeD2Xpj1J6QHgALA== 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=mJpQL0XC0YaApHy1ipBeqsFdLvjd54LAip84w/ETV1Q=; b=f2XArmH7V4p/F35eiPyufASXU6did3/rNTEtuQmCnj1wE5S/HjXybQueruEOd0sGxEYNS0QP3VdLRa1vSxljmiKdq/bRitr7DVtgoLhtaCfslYfaucOIVY3U6xaRgCEvEtCf5a6Nf6sy5UBYDIrcpzg0U5qeamwEob1E6yNqJqQoaDdX+Gixw83N+1bygKxo4J0DH0W1iTfHNt+kw7ZY8zuPksuxCHpu6o3bsMmO4+V2B/N4iCiGjGZFBM9NtldomchM7kwXv5HRw0R9/LH6Yhk8/RrkXobs7CwmJ5bgr4hXzIb/X5HHPiZZV7gOwGHBV9bQjdWtejJuG4xf1Apbfw== 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=mJpQL0XC0YaApHy1ipBeqsFdLvjd54LAip84w/ETV1Q=; b=IOKcQZra3ivf2+twW7iMS8x1kK6HH/AEW1cbj9hyToECYXJ2z8BYthEjdfYqywuVIsLNHK0Tu0XkT5xsy79aozi7lNCSP/CE/qvvhMv6G9ux3cjii4JfUlSdf3e65/roOtOmjWhMUsPVauX+0TkvfUR290kbf8bY5rw+5Ripo/Y= Received: from SJ0PR05CA0067.namprd05.prod.outlook.com (2603:10b6:a03:332::12) by SJ0PR12MB6902.namprd12.prod.outlook.com (2603:10b6:a03:484::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.16; Wed, 9 Oct 2024 17:42:20 +0000 Received: from SJ1PEPF00001CE3.namprd05.prod.outlook.com (2603:10b6:a03:332:cafe::b) by SJ0PR05CA0067.outlook.office365.com (2603:10b6:a03:332::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.7 via Frontend Transport; Wed, 9 Oct 2024 17:42:20 +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 SJ1PEPF00001CE3.mail.protection.outlook.com (10.167.242.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8048.13 via Frontend Transport; Wed, 9 Oct 2024 17:42:19 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 9 Oct 2024 12:42:17 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v8 17/25] x86/resctrl: Add the interface to assign/update counter assignment Date: Wed, 9 Oct 2024 12:39:42 -0500 Message-ID: <86c8fd4db89f264b1382cd22d7cf53c4510bf07a.1728495588.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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00001CE3:EE_|SJ0PR12MB6902:EE_ X-MS-Office365-Filtering-Correlation-Id: 812ed83a-db3a-4106-9348-08dce889b98e 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?kw7cT/uD3zzsTBINwcygdZ2Et3Ml1a1IYcU7QbvoO/EI64lIvCnPELVwYwd3?= =?us-ascii?Q?QqSEvXSAZrsyN38D2QJ5I7N3tpHJH7/dISIRsvrKaYX+o/Do+iCkE0m7nDCt?= =?us-ascii?Q?MpBTKtDWULEd6R4R64tXGN0urGwTMtUgdTwBpoAF75HVHvpBkR1Jor6eHb8C?= =?us-ascii?Q?GQYD21Y5pKUGTuUZkobWcaIhkwfHrAea1FFGSz70t5Ez459HyYLoMqlCNMDt?= =?us-ascii?Q?DJecKmA2UtLPeTcvk6dBSxFWjK3pecERCqjYcPnMD2b75LgPN70nx5woZgFg?= =?us-ascii?Q?jMFgPy497SJ5URz5rP2QmzI5PdkPm+f0qSA//8n6uIOsWPwx5XlEieooK+2X?= =?us-ascii?Q?gZX77U889+oHMf0x9KhPmGEMlZ2vOHk1RgCp1lGFMcjejPis405wyM70ykCg?= =?us-ascii?Q?OQERkavtui7a3cChR21GlZbz07l6cHqgKK0Sq8Kdelw0RaBxh9Jh0nyG2Ck/?= =?us-ascii?Q?mFAhNE61v1vb8T3QT0MzgnuzpXWFL56RugI9t1pPqrEVSvS/SdZnO+4nNxLq?= =?us-ascii?Q?KZ1mc857sjWbTjy9odSNXYeIYJaOC9cr6+S1uAqBJ0XYnvD4NUc908ECknar?= =?us-ascii?Q?laxRBqKWIEgC+LoHJaZ2INAKDIeYxWyJn/BtMKM+V30WwXR6516pQlF66N5i?= =?us-ascii?Q?h0S4kQqHH3kBiIR0IDqVkXRG2QKqmv9U8j7C10qO7nhboc5i+IUGSlJI4CdH?= =?us-ascii?Q?KxlZ9AHeihgY7pPxeYzGzz8fuEIMyLG0HsVi1v1qzY7nWiL+WF1IJJZKtXyx?= =?us-ascii?Q?R7z0nHWFflLK/RdYEqbHhkx+tntDsiNfx2ujb7n1Avt3QS9bCaj5TD0Y2LOI?= =?us-ascii?Q?YP2DMDOnU8VVkXJO/FFyOnPe0JtQ4smyJz8/LKZqHLYYfFyAKAUIZLlHawgF?= =?us-ascii?Q?PhhUv09utcaXudiAotH9H2IMqX2Zv7mXUe619iqvZ8Y5d3sY3BT+o8hnLlZV?= =?us-ascii?Q?ijleQrWLVwgiOHZ/C6chkPnQkXVV5LTrOOYdpwHkWP1rlywho7YryIm6WAXT?= =?us-ascii?Q?dwT2qN1aBUXTNRXgGH/w+MKv9cvbC3CLtU7Qqtmj0fdSwoySZRn1Gf9YVO7w?= =?us-ascii?Q?80RjulN/8umpIWkdcW6wMGzNrAtt+CP+cvPErTC7bvWLNEjDtoD1KHyWVnMA?= =?us-ascii?Q?PsFr5sCvPzt4wZZ3vl3PxFc+WcNgdVvXLqioXh84y4CZCpJs4QskHVmKBCmc?= =?us-ascii?Q?y+BgsQaahcIGk1C4wtGXs/ujOaOsrHdxd4LnyQXTCgZQJ2eDZKuY7xQKXskd?= =?us-ascii?Q?E7jkG50QSjyyf1by8UP6evMw6cg/s2dMV0YLnL/VRho8G9YXlBwTGKwTnFVc?= =?us-ascii?Q?4ZITEV7kdWcH4uQ94Pf6CmE+ES+Flg89puSyffobYWPD5X/F/Tb10/lBzvoB?= =?us-ascii?Q?2c15c9cqaVxfIW8+EjRLpqZudPZU?= 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: 09 Oct 2024 17:42:19.9653 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 812ed83a-db3a-4106-9348-08dce889b98e 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: SJ1PEPF00001CE3.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6902 Content-Type: text/plain; charset="utf-8" The mbm_cntr_assign mode offers several hardware counters that can be assigned to an RMID-event pair and monitor the bandwidth as long as it is assigned. Counters are managed at two levels. The global assignment is tracked using the mbm_cntr_free_map field in the struct resctrl_mon, while domain-specific assignments are tracked using the mbm_cntr_map field in the struct rdt_mon_domain. Allocation begins at the global level and is then applied individually to each domain. Introduce an interface to allocate these counters and update the corresponding domains accordingly. Signed-off-by: Babu Moger --- v8: Renamed rdtgroup_assign_cntr() to rdtgroup_assign_cntr_event(). Added the code to return the error if rdtgroup_assign_cntr_event fails. Moved definition of MBM_EVENT_ARRAY_INDEX to resctrl/internal.h. Updated typo in the comments. v7: New patch. Moved all the FS code here. Merged rdtgroup_assign_cntr and rdtgroup_alloc_cntr. Adde new #define MBM_EVENT_ARRAY_INDEX. --- arch/x86/kernel/cpu/resctrl/internal.h | 9 +++++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 47 ++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 6d4df0490186..900e18aea2c4 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -67,6 +67,13 @@ =20 #define MON_CNTR_UNSET U32_MAX =20 +/* + * Get the counter index for the assignable counter + * 0 for evtid =3D=3D QOS_L3_MBM_TOTAL_EVENT_ID + * 1 for evtid =3D=3D QOS_L3_MBM_LOCAL_EVENT_ID + */ +#define MBM_EVENT_ARRAY_INDEX(_event) ((_event) - 2) + /** * cpumask_any_housekeeping() - Choose any CPU in @mask, preferring those = that * aren't marked nohz_full @@ -708,6 +715,8 @@ unsigned int mon_event_config_index_get(u32 evtid); int resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_mon_domain= *d, enum resctrl_event_id evtid, u32 rmid, u32 closid, u32 cntr_id, bool assign); +int rdtgroup_assign_cntr_event(struct rdt_resource *r, struct rdtgroup *rd= tgrp, + struct rdt_mon_domain *d, enum resctrl_event_id evtid); void rdt_staged_configs_clear(void); bool closid_allocated(unsigned int closid); int resctrl_find_cleanest_closid(void); diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 4ab1a18010c9..e4f628e6fe65 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -1898,6 +1898,53 @@ int resctrl_arch_config_cntr(struct rdt_resource *r,= struct rdt_mon_domain *d, return 0; } =20 +/* + * Assign a hardware counter to the group. + * Counter will be assigned to all the domains if rdt_mon_domain is NULL + * else the counter will be allocated to specific domain. + */ +int rdtgroup_assign_cntr_event(struct rdt_resource *r, struct rdtgroup *rd= tgrp, + struct rdt_mon_domain *d, enum resctrl_event_id evtid) +{ + int index =3D MBM_EVENT_ARRAY_INDEX(evtid); + int cntr_id =3D rdtgrp->mon.cntr_id[index]; + int ret; + + /* + * Allocate a new counter id to the event if the counter is not + * assigned already. + */ + if (cntr_id =3D=3D MON_CNTR_UNSET) { + cntr_id =3D mbm_cntr_alloc(r); + if (cntr_id < 0) { + rdt_last_cmd_puts("Out of MBM assignable counters\n"); + return -ENOSPC; + } + rdtgrp->mon.cntr_id[index] =3D cntr_id; + } + + if (!d) { + list_for_each_entry(d, &r->mon_domains, hdr.list) { + ret =3D resctrl_arch_config_cntr(r, d, evtid, rdtgrp->mon.rmid, + rdtgrp->closid, cntr_id, true); + if (ret) + goto out_done_assign; + + set_bit(cntr_id, d->mbm_cntr_map); + } + } else { + ret =3D resctrl_arch_config_cntr(r, d, evtid, rdtgrp->mon.rmid, + rdtgrp->closid, cntr_id, true); + if (ret) + goto out_done_assign; + + set_bit(cntr_id, d->mbm_cntr_map); + } + +out_done_assign: + return ret; +} + /* rdtgroup information files for one cache resource. */ static struct rftype res_common_files[] =3D { { --=20 2.34.1 From nobody Wed Nov 27 12:26:58 2024 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 F130E1DE4CE; Wed, 9 Oct 2024 17:42:37 +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=1728495759; cv=fail; b=cKUfWKH67D8LlXsvD2EGQvWKfqQmFSqCR5+SSEOw99Qu0xFy2r6/O6hF/p1x/0Uft2a8cFPw3K5cnfAD+DoGn4GpYgxytn9L3v4xdbVC/qMQaAP/yfCD1PQB0V5gT9rYRSF4gkz/gJWhy1i3fRcTSfFzSQDikmZ57z0deF/cg0w= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728495759; c=relaxed/simple; bh=FCyD88I/IEkfxwVdahvsv9OoqjzLZ4t0VxiQAmkzsFA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lWGvzATphARXdr5eb5bN4m5mwNsyFl5OCtk7I8nqfi7ADSXoxh8ZtmC2tI7BfDgEAKmXia8D4q1eXwbPDjEkWx/jENjUg9deEVB5n0o8yg+RefqfxJMyHJ84WXkiGD8J20tCidqo2ceFrHCTlodZIFnDLmIbQ1IZgue5RH9dV5U= 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=dzXI9hq5; 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="dzXI9hq5" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=mrb4jH9zBh0uFyNOVp449aqMDh1mmElpu1+QbxdNxaPyztFO/8Bf69BUYTMdL2AgOnIqo47s6KNMa4mfc2CpyUfqgzogHPT1AR5V5Z8cy+kB9gcVzaqIluKPMKrIjcJI44OsYs7V7XREAMLRiAp1+yUM09QVg9QffGuzFWiszQUV1sfeE7O7927DSqpLc6w05Q5TUIu9424pdUtqpJ6MQKY0Z6gteNR1PiLotlAJbLugVI14RVC4RsCgknAmZYcu4ErzhY3KM+he2Zf+zh8jLro39Y0m/mZNw3FD9chQx5UMsUPycwPIXxQFFlu+RJZOPCEA5aXTiQQDN/ThLen/9w== 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=IMMeuRMpmwsEA1CkpjlARXsTE3OzNy1B7XrwrI3lVos=; b=KAk0jEc5ZLXqF2SyBuchwZ7okXmkh8/p3Xe5/Co9w/4V0OJX509KT3vItMHoto/9w+TinSnmIJWOpTWdP8mROJGkNhFQNebF8iAhEt7RHIFfNkQ+Hl94D3ZzwVJiP8sieTkrrMDnPLD0dWGczoYzkX6s4CEMdgjLGkXhuDn8eccaDsOa2/jwZOmlzsDykPqa1zE7NgQMy22flbeEIFvOKMETDoWRZ0OMFPxRnDtpPWBRKwC41yXFshO1tdi7fgldwkbDpQAe2vtuU9mTbZDI9/AdEmpB6O6mJYv3373ssbrD1GU252ezqie4/I2DoPW8fq+DBpfAiOQhaVLKaofs4g== 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=IMMeuRMpmwsEA1CkpjlARXsTE3OzNy1B7XrwrI3lVos=; b=dzXI9hq5dHhTjlbk1cKyp4F505uaBKQXbYLB4AvH8NscdxZmPZfdRxD4AwnSTOdcreNaeG6oApXy8HbUvtCCZktU84gXxKqG++/8EyuVTfEyv4NrXD2ijclitPWHCgZvl0Ja6I+qsqsWZDLlTQtKhuoWHWWn2YBoJfWE5NHLcS8= Received: from MW4PR04CA0102.namprd04.prod.outlook.com (2603:10b6:303:83::17) by IA0PR12MB8279.namprd12.prod.outlook.com (2603:10b6:208:40c::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.16; Wed, 9 Oct 2024 17:42:28 +0000 Received: from SJ1PEPF00001CDF.namprd05.prod.outlook.com (2603:10b6:303:83:cafe::2f) by MW4PR04CA0102.outlook.office365.com (2603:10b6:303:83::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.17 via Frontend Transport; Wed, 9 Oct 2024 17:42:27 +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 SJ1PEPF00001CDF.mail.protection.outlook.com (10.167.242.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8048.13 via Frontend Transport; Wed, 9 Oct 2024 17:42:27 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 9 Oct 2024 12:42:25 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v8 18/25] x86/resctrl: Add the interface to unassign a MBM counter Date: Wed, 9 Oct 2024 12:39:43 -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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00001CDF:EE_|IA0PR12MB8279:EE_ X-MS-Office365-Filtering-Correlation-Id: 05b1f789-e715-41e9-84ab-08dce889be28 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?7fr4Aw/LXiyFr1rN8yNORwfIa77/TEraAab/a2aK7Z0K0kJ5eF1sW+iFfa/l?= =?us-ascii?Q?pY+4Cem+3rz5Mvq5wqTfr9oq2/Ow7NeTU1hAAhcun0MhieaYfZipR8oXl6Nj?= =?us-ascii?Q?a7Ojxirp5wWS3IMBDSHuItRaGZ0YQPb29CKwQU6PASGX+vnSXpLHAMgIX6r0?= =?us-ascii?Q?txPoIz4aKHbaXV1LkNZPduQDJol6nE41WAOfS6rihrhif3qWnQrR0z+6rfoo?= =?us-ascii?Q?MXuYtpqEUCe5PmroR+iYvxQhzcGOc6rtoUPpNP3aWUkeZncL7VkvoZ5hFSY9?= =?us-ascii?Q?eklKAMoRH2SqwVGsROyCO1C12kvda2da7QW/sZHlNV/pkt3wD4d3uL0cY9E9?= =?us-ascii?Q?IKxOa7/i+Fyi4yA4S/Le8umFQpn6rbAVbc7D5u6qb8Cj8a9c4MCCs6HZg/eE?= =?us-ascii?Q?VwK3VTTf1CPoNegukKRgLjT/q17VV4sDgKOu+cHhJ1YjyUtkAZMCCa8em4+z?= =?us-ascii?Q?2y4tHhox9XIORrzJnHluN8Ib+6bvLvijBL1UCLq4DC56baIyYKYhs7t5OZgZ?= =?us-ascii?Q?dP1VHjJI6Ydg2NS+bcb5ZSg0XzDdZshFZoTkSU6CyFJ9iJ5GBrBoxJvcpxl4?= =?us-ascii?Q?/tSXKogbYK9AVlJV4niEmxS1M3CrCbq7mCGr6ZvZLGC5aUPBDvwKSWKF+D6E?= =?us-ascii?Q?Gox0fKlKbfsPKckgJjjWCav4IPofcUTuA28A8dPZwcacohsBZc9OGErMX2mI?= =?us-ascii?Q?9/LrB6UkFgvZd3q8h7EUgwQANdwrOuGKif1CIeHf8KYwsBHF8H9YOfJagJ3p?= =?us-ascii?Q?e/YPQyglie3vu7nsRPZFsrh3PPRca8bEHsBZ61pepTxIavsDi75NJdyWu18F?= =?us-ascii?Q?O6AWvWORfKq8hr33GzSDpvfd5lMHvedUW6xMNVVztASUYQalI1A/kAPpOZP5?= =?us-ascii?Q?jTaDrBq/mrl11ntJEU55zIKIH1gUheUwECZ5rlF7yTod9oHOY+Ug9OyQ8mOe?= =?us-ascii?Q?dBepjx0tOrFSbtTG9ZJND8z75gdxiOp4An2dU6diCtr9E+msgxYGIyl+7QjL?= =?us-ascii?Q?wNZQvyNzS5v5RRw6qvhlyruWekq9ZB0b0xCMxgoKsQyNkPxM97OldmF6uanJ?= =?us-ascii?Q?KrnP6NJMVTr/DPRe0LIUurI1RQ55a/nwov7rI4IdeePc6F9nwENwLUlV3W7b?= =?us-ascii?Q?jGVnfPwwgbqUd0b/cqtuO2bcdLP7MnBB3v+XdY9uBJcZNoO5SpS8jYqKSnBK?= =?us-ascii?Q?VSAwi4Bj4FgUY/I8iHTTxIV5VF8ZLlwvield6Lb/rHcfEATm56kJmtfZehVB?= =?us-ascii?Q?UkQjw1DcbKD455kbwO50EaJiBbNW5MBHxx5enIHL3q3bMKOgtlzXpO4gtVP/?= =?us-ascii?Q?JDRpHUriirdZWjpF2zgBecTMbLZ9oT0WSWiQBZPNzMig/4sFhvfREXQKWI3E?= =?us-ascii?Q?hatoSBCMDizHmiduMwq/w1s5Qs9q?= 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: 09 Oct 2024 17:42:27.6851 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 05b1f789-e715-41e9-84ab-08dce889be28 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: SJ1PEPF00001CDF.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8279 Content-Type: text/plain; charset="utf-8" The mbm_cntr_assign mode provides a limited number of hardware counters that can be assigned to an RMID-event pair to monitor bandwidth while assigned. If all counters are in use, the kernel will show an error message: "Out of MBM assignable counters" when a new assignment is requested. To make space for a new assignment, users must unassign an already assigned counter. Introduce an interface that allows for the unassignment of counter IDs from both the group and the domain. Additionally, ensure that the global counter is released if it is no longer assigned to any domains. Signed-off-by: Babu Moger --- v8: Renamed rdtgroup_mbm_cntr_is_assigned to mbm_cntr_assigned_to_domain Added return error handling in resctrl_arch_config_cntr(). v7: Merged rdtgroup_unassign_cntr and rdtgroup_free_cntr functions. Renamed rdtgroup_mbm_cntr_test() to rdtgroup_mbm_cntr_is_assigned(). Reworded the commit log little bit. v6: Removed mbm_cntr_free from this patch. Added counter test in all the domains and free if it is not assigned to any domains. v5: Few name changes to match cntr_id. Changed the function names to rdtgroup_unassign_cntr More comments on commit log. v4: Added domain specific unassign feature. Few name changes. v3: Removed the static from the prototype of rdtgroup_unassign_abmc. The function is not called directly from user anymore. These changes are related to global assignment interface. v2: No changes. --- arch/x86/kernel/cpu/resctrl/internal.h | 2 + arch/x86/kernel/cpu/resctrl/rdtgroup.c | 56 ++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 900e18aea2c4..6f388d20fb22 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -717,6 +717,8 @@ int resctrl_arch_config_cntr(struct rdt_resource *r, st= ruct rdt_mon_domain *d, u32 cntr_id, bool assign); int rdtgroup_assign_cntr_event(struct rdt_resource *r, struct rdtgroup *rd= tgrp, struct rdt_mon_domain *d, enum resctrl_event_id evtid); +int rdtgroup_unassign_cntr_event(struct rdt_resource *r, struct rdtgroup *= rdtgrp, + struct rdt_mon_domain *d, enum resctrl_event_id evtid); void rdt_staged_configs_clear(void); bool closid_allocated(unsigned int closid); int resctrl_find_cleanest_closid(void); diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index e4f628e6fe65..791258adcbda 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -1945,6 +1945,62 @@ int rdtgroup_assign_cntr_event(struct rdt_resource *= r, struct rdtgroup *rdtgrp, return ret; } =20 +static bool mbm_cntr_assigned_to_domain(struct rdt_resource *r, u32 cntr_i= d) +{ + struct rdt_mon_domain *d; + + list_for_each_entry(d, &r->mon_domains, hdr.list) + if (test_bit(cntr_id, d->mbm_cntr_map)) + return 1; + + return 0; +} + +/* + * Unassign a hardware counter from the domain and the group. + * Counter will be unassigned in all the domains if rdt_mon_domain is NULL + * else the counter will be assigned to specific domain. + * Global counter will be freed once it is unassigned from all the domains. + */ +int rdtgroup_unassign_cntr_event(struct rdt_resource *r, struct rdtgroup *= rdtgrp, + struct rdt_mon_domain *d, enum resctrl_event_id evtid) +{ + int index =3D MBM_EVENT_ARRAY_INDEX(evtid); + int cntr_id =3D rdtgrp->mon.cntr_id[index]; + int ret; + + /* Return early if the counter is unassigned already */ + if (cntr_id =3D=3D MON_CNTR_UNSET) + return 0; + + if (!d) { + list_for_each_entry(d, &r->mon_domains, hdr.list) { + ret =3D resctrl_arch_config_cntr(r, d, evtid, rdtgrp->mon.rmid, + rdtgrp->closid, cntr_id, false); + if (ret) + goto out_done_unassign; + + clear_bit(cntr_id, d->mbm_cntr_map); + } + } else { + ret =3D resctrl_arch_config_cntr(r, d, evtid, rdtgrp->mon.rmid, + rdtgrp->closid, cntr_id, false); + if (ret) + goto out_done_unassign; + + clear_bit(cntr_id, d->mbm_cntr_map); + } + + /* Update the counter bitmap */ + if (!mbm_cntr_assigned_to_domain(r, cntr_id)) { + mbm_cntr_free(r, cntr_id); + rdtgrp->mon.cntr_id[index] =3D MON_CNTR_UNSET; + } + +out_done_unassign: + return ret; +} + /* rdtgroup information files for one cache resource. */ static struct rftype res_common_files[] =3D { { --=20 2.34.1 From nobody Wed Nov 27 12:26:58 2024 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2078.outbound.protection.outlook.com [40.107.244.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 E46A81E5707; Wed, 9 Oct 2024 17:42:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.78 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728495766; cv=fail; b=gVawc6EpuHFbSnv+iY6vrFvoRNhnuuYx9OleqVkMoyB14d+DpYzwFYWkbMa5fOsd/3tZewD/GuOwJUwyV0YsOhz91lU39ZkbwDTXncLQhN4Gz9yH+UTQLLIyffa0V2JDxf+tFGgEV9fy17BZUukpSSzG/YvokXeKz+c3nlWN3cw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728495766; c=relaxed/simple; bh=xsuQf+Xi1K7w10llE8EEZC0QAvDtxRBPe/pw/ipoUFk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=b7A86kSzZSgr7IUwxa4Uz7s3fDjzZlSR5HGZjbjp2LlR8BtMaKQLMq2NccwRMzA7MZ/MyDkgnFgJqBjYsEQcetG3RCIOIFKsbB5Y0GxgAmLC6Hxqh5FZHUfoOszOwPK4UW1l7X4jGfu+tj9hn8t+cvur7NjeOjLFVgP1T0UBRcE= 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=EerjHQTO; arc=fail smtp.client-ip=40.107.244.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="EerjHQTO" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UPnQ1Y3OJsByQtOsPc9Eje1g/KOiEmlUxJlr8Qsd9hIYA2gEkTpuUCk5cCbTMR98OksOgBmULZ3bXHAWGus6cVTDNO7KJ1BrElgKxKboC6/FosnZDYxcD9EBveVdZgIxmjy/rOYVxC5z6PTnUb5zCRuxaM9w5Xu2jTiCbqG4eZdar2q93NUla6TrxiwvKnTKxrYZ3XpYBTJ9H/sU7/kEGQUpa4+fPEFwAMSfK3QvK+HutJCwElCU8iKJKgvwDgULlhrG757tAKwXpGAXqE8X+R3E3jnV+Y5zM+UIngmpivj+CPIhS2aJHrL6eMABFRed/crKRjtWB1ElWKNbxhUpQA== 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=Hc+0AADQMoosJ61LZmhV+p940KckAOkrBzNETg+Iwqs=; b=X8NbfbXXMHle/sDE+tL96ucPPbmorNNYVU9GJU3IQb8APw3Mqd04KLg2TRhSeOkLxU9dbmYpesrqeU+/ucXq3yluS03WTFRtuqpLUlAfv8sFL0MNmSW23o5WW75A40eP7cBBcnfZtgbfFpmzD66HmzqBlq0rEIhSAVz29yxr//z0QvYZUsZBBCoNAV7X4a+MB8HigwkMaNHThgLcMSt2++CO+HK83+Y3IR4baCKnkF9jdN6NvQ0X/VOZik5syyJXTYNwqgbzp/ZCgrhLQnoYCuQwM26mPVsn4x5zOhBIDXo8sm2UBs1/s1hDlA6TDiWhr16az431aeG2s6+ScIvHWQ== 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=Hc+0AADQMoosJ61LZmhV+p940KckAOkrBzNETg+Iwqs=; b=EerjHQTOEebLpIrvjyO/WgKurhB/a73BzoQArOG3VPcccaYySEZyr5DVuEf7COGlRqDL49GZvqYEsEwGqec5NIJMpGQ1i328vTLnrHqvxXQq1p2fDXTJZbg0AqYO68bYVMo7SvBduX9qNlfciZxSyXVXO7rCFKWuuC2NfHweVls= Received: from SJ0PR05CA0097.namprd05.prod.outlook.com (2603:10b6:a03:334::12) by SA1PR12MB6969.namprd12.prod.outlook.com (2603:10b6:806:24c::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.23; Wed, 9 Oct 2024 17:42:35 +0000 Received: from SJ1PEPF00001CE0.namprd05.prod.outlook.com (2603:10b6:a03:334:cafe::d3) by SJ0PR05CA0097.outlook.office365.com (2603:10b6:a03:334::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.16 via Frontend Transport; Wed, 9 Oct 2024 17:42:35 +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 SJ1PEPF00001CE0.mail.protection.outlook.com (10.167.242.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8048.13 via Frontend Transport; Wed, 9 Oct 2024 17:42:35 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 9 Oct 2024 12:42:33 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v8 19/25] x86/resctrl: Auto assign/unassign counters when mbm_cntr_assign is enabled Date: Wed, 9 Oct 2024 12:39:44 -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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00001CE0:EE_|SA1PR12MB6969:EE_ X-MS-Office365-Filtering-Correlation-Id: 704a02e5-83a7-409a-c807-08dce889c2e8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?uhJdLDbrbh5U4xxzyYc1MWthl9NFUBZ+NPis8M6Yn2A7xSr6bi39C2lfgM9X?= =?us-ascii?Q?s0Ptp7i1i4pzErg8qjC723layyosvw5wG8njTbhdTWaYswfgDSILkFxAozTI?= =?us-ascii?Q?yq6UTprpVmhdsqYI4nvuBZFpVs1hhjnguwX0UIq+zX81ldjNzo0Y6pmvCObF?= =?us-ascii?Q?JaHPR8ptTJzqz7SHLOOWl+BrzRnu8wxfIO5qiaLU6YGp8pkIOXrbX851HtTD?= =?us-ascii?Q?V2voES6Wauem2vUuPVz0/tGc+Z/o/gjVV3K0mG+F/7hO/0V16q3WInrxgsdh?= =?us-ascii?Q?rI+75PsuV74/aTjG534VcpFmB2QfMCoVr5E928eoVHoVe09YxoP0/PI7duVp?= =?us-ascii?Q?MZQZu9ta/g4eVqBqSbcIoqD+w01uNoKMuyQv0ICbUMM/vagOHL57uAl8OG1t?= =?us-ascii?Q?iVdJgZKgXFOY8pjSXFwcMLbEGAqE5wB5Me5RDQbePMDo78VXAMdvD5vTtpGU?= =?us-ascii?Q?r83cmT2UfO4D3Iq8g+0KEpDBGpv0ck2LdmDPattbS6q9oBPyWmlBO8Ajt3gN?= =?us-ascii?Q?CKww8KXn5kntGdVh8sXjb9BZZl2gKajc+fVPr0gMFFnsKrZdkWJf823rZhlx?= =?us-ascii?Q?aYL1QHm30gxw9dEx1Gfe6kvbZ55WuSQDYFqqfqqGNBzDRGKW1AKHOCTELQY6?= =?us-ascii?Q?XAA30z7fgPnzyf7Iv1v/H95FSvdwvQOhUKOUjkZxLjXnfYDahrjjA3kJZA3Z?= =?us-ascii?Q?A4kRY404ZruOtjqWP2/c3Yr+kS36qDO5wYNUT5hJZwtDxAUgG6nxSeCakwir?= =?us-ascii?Q?uJm+RfCbzGpoM++QG73bNQfXZBibOw9gmHRhmklen+Q2IAJtemdoTA9OTC2h?= =?us-ascii?Q?GnpDLBU+5B7s91+t6o5LzKsXPeWw0T9WbUkkZpNndOr+xSWNxbHnSmFIwKu3?= =?us-ascii?Q?cvEs7FFERlpOEDnWLtS/BZyjRUqZwPMtZzHyQ6ZJEEuOa/FPSOecz/1FZMVI?= =?us-ascii?Q?X0oGBRrxS5g/9TvQXya1Js8csWoorTcWJ3SHeqYElG/PLw4gXfaARbi9dm74?= =?us-ascii?Q?C3f+auOtKevSz5ubo0nZdIQKPKPeJBXWw4a53StChdp1UQdz/m4sgQx5tQXa?= =?us-ascii?Q?wOYA8uZNV6oQDzBzWGEiv+CTm8HNoOnrkv2P3CLGohg2ym9+musWiVUkafdM?= =?us-ascii?Q?V9HHH7zIvQjzkGoTZgEaxGLIOqOvu9bgg/QOZ3Q8+iFvHndi+ETljMK4wuZR?= =?us-ascii?Q?0/VrThU/Af+ByhEW6pmTRVl2HVs34yy+tWkzZMYwcBW16dEC9kUxSI9T97pF?= =?us-ascii?Q?bNI+I8UytgTgN42+suu4VDOVsCvvlaSyEqLuGtfxkrh4L+CRNQLEj4pNC8Dr?= =?us-ascii?Q?hwYRRsklyVVD7LDOabiJo67EU+etV+Ls3p+S4fpDRTBq8DlJ1pCgOSiunMiw?= =?us-ascii?Q?SCCmzlmAKnRaRPZC8jaYlvLhcuau?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(82310400026)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2024 17:42:35.6404 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 704a02e5-83a7-409a-c807-08dce889c2e8 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: SJ1PEPF00001CE0.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6969 Content-Type: text/plain; charset="utf-8" Assign/unassign counters on resctrl group creation/deletion. Two counters are required per group, one for MBM total event and one for MBM local event. There are a limited number of counters available for assignment. If these counters are exhausted, the kernel will display the error message: "Out of MBM assignable counters". However, it is not necessary to fail the creation of a group due to assignment failures. Users have the flexibility to modify the assignments at a later time. Signed-off-by: Babu Moger --- v8: Renamed rdtgroup_assign_grp to rdtgroup_assign_cntrs. Renamed rdtgroup_unassign_grp to rdtgroup_unassign_cntrs. Fixed the problem with unassigning the child MON groups of CTRL_MON gro= up. v7: Reworded the commit message. Removed the reference of ABMC with mbm_cntr_assign. Renamed the function rdtgroup_assign_cntrs to rdtgroup_assign_grp. v6: Removed the redundant comments on all the calls of rdtgroup_assign_cntrs. Updated the commit message. Dropped printing error message on every call of rdtgroup_assign_cntrs. v5: Removed the code to enable/disable ABMC during the mount. That will be another patch. Added arch callers to get the arch specific data. Renamed fuctions to match the other abmc function. Added code comments for assignment failures. v4: Few name changes based on the upstream discussion. Commit message update. v3: This is a new patch. Patch addresses the upstream comment to enable ABMC feature by default if the feature is available. --- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 64 ++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 791258adcbda..cb2c60c0319e 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -2875,6 +2875,52 @@ static void schemata_list_destroy(void) } } =20 +/* + * Called when a new group is created. If `mbm_cntr_assign` mode is enable= d, + * counters are automatically assigned. Each group requires two counters: + * one for the total event and one for the local event. Due to the limited + * number of counters, assignments may fail in some cases. However, it is + * not necessary to fail the group creation. Users have the option to + * modify the assignments after the group has been created. + */ +static int rdtgroup_assign_cntrs(struct rdtgroup *rdtgrp) +{ + struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; + int ret =3D 0; + + if (!resctrl_arch_mbm_cntr_assign_enabled(r)) + return 0; + + if (is_mbm_total_enabled()) + ret =3D rdtgroup_assign_cntr_event(r, rdtgrp, NULL, QOS_L3_MBM_TOTAL_EVE= NT_ID); + + if (!ret && is_mbm_local_enabled()) + ret =3D rdtgroup_assign_cntr_event(r, rdtgrp, NULL, QOS_L3_MBM_LOCAL_EVE= NT_ID); + + return ret; +} + +/* + * Called when a group is deleted. Counters are unassigned if it was in + * assigned state. + */ +static int rdtgroup_unassign_cntrs(struct rdtgroup *rdtgrp) +{ + struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; + int ret =3D 0; + + if (!resctrl_arch_mbm_cntr_assign_enabled(r)) + return 0; + + if (is_mbm_total_enabled()) + ret =3D rdtgroup_unassign_cntr_event(r, rdtgrp, NULL, QOS_L3_MBM_TOTAL_E= VENT_ID); + + if (!ret && is_mbm_local_enabled()) + ret =3D rdtgroup_unassign_cntr_event(r, rdtgrp, NULL, QOS_L3_MBM_LOCAL_E= VENT_ID); + + return ret; +} + static int rdt_get_tree(struct fs_context *fc) { struct rdt_fs_context *ctx =3D rdt_fc2context(fc); @@ -2934,6 +2980,8 @@ static int rdt_get_tree(struct fs_context *fc) if (ret < 0) goto out_mongrp; rdtgroup_default.mon.mon_data_kn =3D kn_mondata; + + rdtgroup_assign_cntrs(&rdtgroup_default); } =20 ret =3D rdt_pseudo_lock_init(); @@ -2964,6 +3012,7 @@ static int rdt_get_tree(struct fs_context *fc) out_psl: rdt_pseudo_lock_release(); out_mondata: + rdtgroup_unassign_cntrs(&rdtgroup_default); if (resctrl_arch_mon_capable()) kernfs_remove(kn_mondata); out_mongrp: @@ -3144,6 +3193,7 @@ static void free_all_child_rdtgrp(struct rdtgroup *rd= tgrp) =20 head =3D &rdtgrp->mon.crdtgrp_list; list_for_each_entry_safe(sentry, stmp, head, mon.crdtgrp_list) { + rdtgroup_unassign_cntrs(sentry); free_rmid(sentry->closid, sentry->mon.rmid); list_del(&sentry->mon.crdtgrp_list); =20 @@ -3184,6 +3234,8 @@ static void rmdir_all_sub(void) cpumask_or(&rdtgroup_default.cpu_mask, &rdtgroup_default.cpu_mask, &rdtgrp->cpu_mask); =20 + rdtgroup_unassign_cntrs(rdtgrp); + free_rmid(rdtgrp->closid, rdtgrp->mon.rmid); =20 kernfs_remove(rdtgrp->kn); @@ -3223,6 +3275,8 @@ static void rdt_kill_sb(struct super_block *sb) resctrl_arch_disable_alloc(); if (resctrl_arch_mon_capable()) resctrl_arch_disable_mon(); + + rdtgroup_unassign_cntrs(&rdtgroup_default); resctrl_mounted =3D false; kernfs_kill_sb(sb); mutex_unlock(&rdtgroup_mutex); @@ -3814,6 +3868,8 @@ static int rdtgroup_mkdir_mon(struct kernfs_node *par= ent_kn, goto out_unlock; } =20 + rdtgroup_assign_cntrs(rdtgrp); + kernfs_activate(rdtgrp->kn); =20 /* @@ -3858,6 +3914,8 @@ static int rdtgroup_mkdir_ctrl_mon(struct kernfs_node= *parent_kn, if (ret) goto out_closid_free; =20 + rdtgroup_assign_cntrs(rdtgrp); + kernfs_activate(rdtgrp->kn); =20 ret =3D rdtgroup_init_alloc(rdtgrp); @@ -3883,6 +3941,7 @@ static int rdtgroup_mkdir_ctrl_mon(struct kernfs_node= *parent_kn, out_del_list: list_del(&rdtgrp->rdtgroup_list); out_rmid_free: + rdtgroup_unassign_cntrs(rdtgrp); mkdir_rdt_prepare_rmid_free(rdtgrp); out_closid_free: closid_free(closid); @@ -3953,6 +4012,9 @@ static int rdtgroup_rmdir_mon(struct rdtgroup *rdtgrp= , cpumask_var_t tmpmask) update_closid_rmid(tmpmask, NULL); =20 rdtgrp->flags =3D RDT_DELETED; + + rdtgroup_unassign_cntrs(rdtgrp); + free_rmid(rdtgrp->closid, rdtgrp->mon.rmid); =20 /* @@ -3999,6 +4061,8 @@ static int rdtgroup_rmdir_ctrl(struct rdtgroup *rdtgr= p, cpumask_var_t tmpmask) cpumask_or(tmpmask, tmpmask, &rdtgrp->cpu_mask); update_closid_rmid(tmpmask, NULL); =20 + rdtgroup_unassign_cntrs(rdtgrp); + free_rmid(rdtgrp->closid, rdtgrp->mon.rmid); closid_free(rdtgrp->closid); =20 --=20 2.34.1 From nobody Wed Nov 27 12:26:58 2024 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2053.outbound.protection.outlook.com [40.107.94.53]) (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 DEE5D1E8829; Wed, 9 Oct 2024 17:42:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.53 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728495769; cv=fail; b=ruG2QckcFwQTfxr4ikf8jx8zTNgbDNrcCG9qSDh2daAWqM7o7Vm4+7H9MDKfFqlaJk/t76VGA0fUVy1RMMMwNJyBpvS9KJcFTFu070fXihJ+uJmwTDhlgzGhSfNzuXlCbRt3/LEnciujm9bHXbCTnPdLwi9URjbJsIvMsXNR8aU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728495769; c=relaxed/simple; bh=cs7mul5kpEr1ioI94696AG3AJiRjsWUumrVoruql1vs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ECTSEOa7Qcp/eTiwZ+htNUgGohMBBUrXNtKxBzSm77TwLxvtMIFjdEW8lGWbbSqIcCf0TeuJ6SOaAU4+/9m8XJI+XLHcbmQETzjYJHew0Gvzyz/LTWt1yGaCzUI6wZbjVyI8z66foOspa3Oy3I63GE6KUmjVxVglMwEG8iCovvo= 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=5G3Au7Rn; arc=fail smtp.client-ip=40.107.94.53 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="5G3Au7Rn" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=mUL0qhlYpQ1kS3faFW2HakfAe32pF/hwiKwHEnltKrAG1riTuyUXBbZAMCmNAG/M5vpCTB4pKGIrnfUTfP0dWaRe7B+Bu+AqMFnJc1b1OpXxZt4GUyfJOn2IncWdhsqllmev+9ac3vE02mj/CaQSZ/MMfAu1gXSKNOBRPcJhdFaeewhF9F+2oj6bhkq/MFVqIJIoAPGS6rb0yHAFTzjRP6wunvjdZJk6SZKkeFQMdbSHmH3vpBBDLuAGJO3B1kDLfxwX2zTdKjc8HTgvQMt65S90ZVLto2JtZ6Rp7XZCrc289/ABy4uTqqwJutDkteAQlHR95sChoEbVgPXf4/Bx3A== 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=bH0V37SwRVibDd2zfkQSRVIB+ZTz2HNmALIIaFskWyQ=; b=rPVec7Nw7K+jXbjyqhtcPzf/YqujUcGv3xunBntQW+wan3oTngzcOppgADMzczo8t/dspGw9kPp5PzbArktdmWXbPx3omkeGO2S67w24w1BHGJNTv3pu6Mm9BxvDjO8ypqVl6xm7arX89tDO32008R3NDQatL7+FWtWeM0o2FDbia55FxNlkQrKYmeH0wCItfuodNHw1TNSo6nsfMzKaHdosRwOHz+ndp9EhmqLWTs0K6uCd03sxDb91ycQ+74AIt9/6BXy13e9thN31xezP2KNd3/R+SgIVmZ2OsiWeDS9XOoK7t/dgbLEnIqX2rQvu/o2Ch4avwtxXx52FQlSf9w== 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=bH0V37SwRVibDd2zfkQSRVIB+ZTz2HNmALIIaFskWyQ=; b=5G3Au7Rn4pWSsDTdcdUBwQABQsf1I8ZURgmLSTmh1FbGopVDGrL3oP3J7vJlnSHUQFHU3for9nxHW2dblAHT1vIbBFU1i2V87GScphl9n/kxVaLbmdhxiWhkHi8hpxK8pU0QIkfDB1hTujitjzIYHtkHGaIfRNNlUEWbXtuZX9Q= Received: from MW3PR05CA0022.namprd05.prod.outlook.com (2603:10b6:303:2b::27) by SJ0PR12MB6991.namprd12.prod.outlook.com (2603:10b6:a03:47c::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.23; Wed, 9 Oct 2024 17:42:44 +0000 Received: from SJ1PEPF00001CE1.namprd05.prod.outlook.com (2603:10b6:303:2b:cafe::24) by MW3PR05CA0022.outlook.office365.com (2603:10b6:303:2b::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.7 via Frontend Transport; Wed, 9 Oct 2024 17:42:43 +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 SJ1PEPF00001CE1.mail.protection.outlook.com (10.167.242.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8048.13 via Frontend Transport; Wed, 9 Oct 2024 17:42:43 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 9 Oct 2024 12:42:41 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v8 20/25] x86/resctrl: Report "Unassigned" for MBM events in mbm_cntr_assign mode Date: Wed, 9 Oct 2024 12:39:45 -0500 Message-ID: <50a4e993098422eece96d08edc337856a52cadd1.1728495588.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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00001CE1:EE_|SJ0PR12MB6991:EE_ X-MS-Office365-Filtering-Correlation-Id: 75b067dc-1551-4dcd-0699-08dce889c79c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|1800799024|36860700013|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?BilR2Eu30O6Ly5rB0MRixfrws+iIJ6q31S50FiBwbcLhzDL+9Xcz8byHno9o?= =?us-ascii?Q?VaEEMC6/J8N3VvJhpv0cfnEfnvKJixypeZVAzUQo55J5eACrRNSYswan9YTL?= =?us-ascii?Q?NFqvyXmnOxLmrfV6ND7iifhZpvPrkRqoIGBzze/V968NF9MZszTRGLF1fMPS?= =?us-ascii?Q?AKM22UJouYhr3DkYYJdpeYQ2LjApH33KpKRXYDK1TKBWVrPoLOisrb1P1k48?= =?us-ascii?Q?bK1DWdjWbab31fhoDd541rheFRIowxZQvQ53smVdc//h7huSQ4+GCDWXkzxD?= =?us-ascii?Q?5oGYHIR5Dve57ElvIXLWK8QhSYDMLL9YdH0xwdrZTGyfVJIuaVaPDoeyQ7FZ?= =?us-ascii?Q?4eyqH29OUQWccVGGJeUMk+zKqsCTOhePWCLZyBXFQwtc+hn0285NQCXKOSka?= =?us-ascii?Q?nHJCyCdaNIOdbOgBluK32vtSJGN0dfLahTUbEEBmTMxrzYtDGvyTClqKnr4b?= =?us-ascii?Q?2xNZER1Vx2KIjpZZuuH4f6c2FRepmSrLVqhqpWqbj+4/MtfB6D5q4XyOCkwu?= =?us-ascii?Q?UX9GDNhqWFpKUMudMS/jsbjubh8V6vmdYnSqwRnx4zU2WC/O8iMy0TDvkFDu?= =?us-ascii?Q?B6AcVxHkvsY++L1gy58RzRdLLLo3+qqkzvdvEaGWvjYC109/KfmF76FMO8QZ?= =?us-ascii?Q?0IVMbQgUsAbnyykCgSTZwcWXibUiDGHRDyAxWwWDErZw7LE6stvTHNA75Jrt?= =?us-ascii?Q?XmYcOwJkY2VrNejIs/b+75YPTx3V8htPJACqQc5OMrsIscwIl+MClJASiEPu?= =?us-ascii?Q?ySLncI9Dvsiu8Xe2Fw+5viXDOQ3MFxr8pVg+bGWZRuF4NrBFfmWx1i3bEb9K?= =?us-ascii?Q?3aEDT772RXEAM7qd8VP4USiFao7ddWuxQx10DnMssPjxG1nkWmWfzCu5UAXq?= =?us-ascii?Q?/gbbt4vhkLStQMkdwDfSRdwkNfJO04iG2eEK9U5bW70SbiEvSvvv+CDnzCE+?= =?us-ascii?Q?PzmeQjlbLQe+KFj2nXSkPbvIYWALB93HbKOrpRR/KDBwSQYV595KfzHZfy+Y?= =?us-ascii?Q?hUo4Pi3Zac/ratJTKGJZIBjqE7Ta/x1MKGwZJBewiPpb5TeppNAy5PEiWIm+?= =?us-ascii?Q?L+5zGRGGmutOeMrOe9YR5oC3SWNv50nNQOlVmUQMbQZIrqmTIK0oyO6JjUfY?= =?us-ascii?Q?arr6xsXyiVIVDy9IMX7zMRclF7igITqMYJATpamyldoxGKK6+4LyYB0eNQoN?= =?us-ascii?Q?w9b9+roT8LLlOJ5Df3kPW53Ux2+F5TAJ7pc6SXfBWJUF3Q5xGp7DpsiaKvqU?= =?us-ascii?Q?y/3p0U0UVca4PDTSUuwLAllNFzkB0hry50f9gszqPGoWnhs7YrwF9d62pcAW?= =?us-ascii?Q?a1/DlyndFBPWW3hKuF6I23v8GVVBO3gkaOI5nqCtruUtkHD7ak2unRTrnRpq?= =?us-ascii?Q?ZuLVaXA=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(376014)(1800799024)(36860700013)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2024 17:42:43.5416 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 75b067dc-1551-4dcd-0699-08dce889c79c 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: SJ1PEPF00001CE1.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6991 Content-Type: text/plain; charset="utf-8" In mbm_cntr_assign mode, the hardware counter should be assigned to read the MBM events. Report "Unassigned" in case the user attempts to read the events without assigning the counter. Signed-off-by: Babu Moger --- v8: Used MBM_EVENT_ARRAY_INDEX to get the index for the MBM event. Documentation update to make the text generic. v7: Moved the documentation under "mon_data". Updated the text little bit. v6: Added more explaination in the resctrl.rst Added checks to detect "Unassigned" before reading RMID. v5: New patch. --- Documentation/arch/x86/resctrl.rst | 10 ++++++++++ arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 13 ++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/re= sctrl.rst index 1b5c05a35793..99ee9c87952b 100644 --- a/Documentation/arch/x86/resctrl.rst +++ b/Documentation/arch/x86/resctrl.rst @@ -419,6 +419,16 @@ When monitoring is enabled all MON groups will also co= ntain: for the L3 cache they occupy). These are named "mon_sub_L3_YY" where "YY" is the node number. =20 + When supported the 'mbm_cntr_assign' mode allows users to assign a + counter to mon_hw_id, event pair enabling bandwidth monitoring for + as long as the counter remains assigned. The hardware will continue + tracking the assigned mon_hw_id until the user manually unassigns + it, ensuring that counters are not reset during this period. With + a limited number of counters, the system may run out of assignable + counters at some point. In that case, MBM event counters will return + "Unassigned" when the event is read. Users must manually assign a + counter to read the events. + "mon_hw_id": Available only with debug option. The identifier used by hardware for the monitor group. On x86 this is the RMID. diff --git a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c b/arch/x86/kernel/cp= u/resctrl/ctrlmondata.c index 50fa1fe9a073..5a9d15b2c319 100644 --- a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c +++ b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c @@ -562,7 +562,7 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg) struct rdtgroup *rdtgrp; struct rdt_resource *r; union mon_data_bits md; - int ret =3D 0; + int ret =3D 0, index; =20 rdtgrp =3D rdtgroup_kn_lock_live(of->kn); if (!rdtgrp) { @@ -576,6 +576,15 @@ int rdtgroup_mondata_show(struct seq_file *m, void *ar= g) evtid =3D md.u.evtid; r =3D &rdt_resources_all[resid].r_resctrl; =20 + if (resctrl_arch_mbm_cntr_assign_enabled(r) && evtid !=3D QOS_L3_OCCUP_EV= ENT_ID) { + index =3D MBM_EVENT_ARRAY_INDEX(evtid); + if (index !=3D INVALID_CONFIG_INDEX && + rdtgrp->mon.cntr_id[index] =3D=3D MON_CNTR_UNSET) { + rr.err =3D -ENOENT; + goto checkresult; + } + } + if (md.u.sum) { /* * This file requires summing across all domains that share @@ -613,6 +622,8 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg) seq_puts(m, "Error\n"); else if (rr.err =3D=3D -EINVAL) seq_puts(m, "Unavailable\n"); + else if (rr.err =3D=3D -ENOENT) + seq_puts(m, "Unassigned\n"); else seq_printf(m, "%llu\n", rr.val); =20 --=20 2.34.1 From nobody Wed Nov 27 12:26:58 2024 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2043.outbound.protection.outlook.com [40.107.244.43]) (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 A78761E1C31; Wed, 9 Oct 2024 17:43:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.43 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728495782; cv=fail; b=GLq9derXGw2uGfxFDgRfVrOG61yV5I/Zij3D/I6bAPpj6c8xKym0mXnxxptLfXbF8BnVoA4gB8OYBp4wIOD+CWBRnXSCgTglMC6lvZRSXEo5n7paPoHin2HDWTNQUAz8aX1skA3HU5ptzgTbjlwoK2luBeiQ59C6cklK9+22SAg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728495782; c=relaxed/simple; bh=xlq1FmjqHgcjMMoryVpfQnlCL8xGgr+FCAu3OLiy6qU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qh8xdZOXvV1p+gGmTVxzoNh9hfVvsd3ORpmk98m2bvRRkfu2DHzR3PUnfbdiqztRP1i0KzyqcAkoWGDc8z9yegicjqTvhYWNKeMVRxyEp3dmxyj3TWHrMbLsXN0CeIBMdO16+RfsILkqGvGzjswjSeCDc9o4TzDRQBAjDpLIidY= 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=nQxPDdAv; arc=fail smtp.client-ip=40.107.244.43 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="nQxPDdAv" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dMg2Qy5RQVuIYg72f5aVhCwqUqLRWet+s5dumcNBivHnemvTDdId9EVSeLxGyXTPuMX2G1hpXwA8+7kopjjy0Ne/sMPDoSnjjiLMIsATfrraPiwGBTtJisy9Ywi3Huw4PfbP1oH4Lzl0juKIJSAZfkiNynsS4heQ5h/ECp4uFXT+4psTXJ9cU31eb5V+TX1JbTBmyNf4hchkxdFUDlnu3WZ+2Yv9IVFDUme92Hn/Mi/uxfTxJ9bKIrmYxx3IEObdC7buaxfNCFnjC8mc+SFYzTQwn/AZvADfpg9ERakZcqLZ4KYD36+ahQCBqrHygkoJQW5Hfh/0dsgjPMgeqLyA5w== 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=67PxsLWY1X4Jyy+e6y4RSsxsqq08RHlXkJN60Okdyf0=; b=jxbrJMSxLRdWjMG9LdYI5PWjgXmuH+Lh/XM9NftnnrSvDEdk+oxvxhwGHH1I2b4lxJEnKyQe/VdmndhmVngqlX2dyTD81BHF+dDVNGPKegFy3FhXhA3ALnidUUHx98U4vCZXoslZZRsG3/BQjIdB7E8Mm3OArAAH1BCarsZ0thUPfVEqrsY3NGoohmGGUomF0AAfL9nWR4d0b5WFGxcn2KdY/AtjABax2G0fa9xFJLf4aGOWAHM8Mhsk81i5BZ4Y242GwuZ7/jR27aFmO3OyZtAQPGbO2bMRVPOvR8Ygg8lCbJmpDKafcZOOeNN9cqEoBcKW8qCnlWkWpCEkunKYLQ== 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=67PxsLWY1X4Jyy+e6y4RSsxsqq08RHlXkJN60Okdyf0=; b=nQxPDdAvP5WIVAjvM7pwcuJIsVRDOfkz+iiUhU/zudLSfN5yGAsXQ019x5K6yWbRfQzufPManWk4VsyoPf/c6+ADofRBtNrq+uemxWDEys8uZi5eF6NBBH5odWjtl25wpkhgtnZDDErIkLQxSGI6V16jaqXBYcjzSCm3hI6INN8= Received: from SJ0PR13CA0141.namprd13.prod.outlook.com (2603:10b6:a03:2c6::26) by BY5PR12MB4164.namprd12.prod.outlook.com (2603:10b6:a03:207::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.18; Wed, 9 Oct 2024 17:42:51 +0000 Received: from SJ1PEPF00001CE2.namprd05.prod.outlook.com (2603:10b6:a03:2c6:cafe::13) by SJ0PR13CA0141.outlook.office365.com (2603:10b6:a03:2c6::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.16 via Frontend Transport; Wed, 9 Oct 2024 17:42: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 SJ1PEPF00001CE2.mail.protection.outlook.com (10.167.242.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8048.13 via Frontend Transport; Wed, 9 Oct 2024 17:42:51 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 9 Oct 2024 12:42:49 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v8 21/25] x86/resctrl: Introduce the interface to switch between monitor modes Date: Wed, 9 Oct 2024 12:39:46 -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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00001CE2:EE_|BY5PR12MB4164:EE_ X-MS-Office365-Filtering-Correlation-Id: bf438eff-72f9-4e03-5b32-08dce889cc3b 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?m7wsmiiyAnCkqAI5/cqneY6+k801ype1srbxh0GZajgvLbdifTIAKxz9OWBz?= =?us-ascii?Q?QEOiXJg7eiMkd8f09ucdaHfz7d/3q1YPyTx8QZoVcwPlYfX/ai1ZLhGe4GK3?= =?us-ascii?Q?AFZhNnKg0OgWmhL9L5cyFXkhM2ZYB9/AAxpg5oIkO9F1CFLqPeMeOmrdZ+u/?= =?us-ascii?Q?iDuUKXf/m9+1SLfXWiJvUdNRNb4aqIuFi6uEtMSKxWOU7XDU1hoUufbqCUcI?= =?us-ascii?Q?HdKPufADcnkxUmrYQwCAjAR8FaWkLRXSbqqjLjspcQA7g3Kw9hKBiv327nKb?= =?us-ascii?Q?pNIB3VJx6G8vX5uVl4OgWoj+JdwvOs7pzecWaNLtDDJsMdcQzSQH3a0ZXISL?= =?us-ascii?Q?NwvmJXhzvw9oOaE3YhYjPOktKTKKRCmOtBNVyeTcvJikN4Q/NhZmg3F+9o0Z?= =?us-ascii?Q?r/bWTkLsD4yHE10rAv+ttbKvcWt8ZVQqhts2LW2XAwDuHOJS6vRXvQIKJi3B?= =?us-ascii?Q?VWksd5Qg3oGD+IFLeqbolPJRaaRr943R2oGm5qYdN/vachz5aNTT9KKcWGYO?= =?us-ascii?Q?iiCdZWVYZhFioSSFiuCISlZPDy93FA7Sh17RXWdVRmmX3flOuadyAGppPLdD?= =?us-ascii?Q?A6MRCUKDJgOj+cn6n5fosXDyQt2K4inbWr+8zQP1NpG7kqqSoTgXz52MBwUL?= =?us-ascii?Q?bTzqSbR5iOV8QsrJkg4K7pfBoY6BX+a/Ci4o92qwLfNc7ruAF8My+n6mt9Dj?= =?us-ascii?Q?LBSlYwQ/0qJxUez58h3adOb/IpU+B78fvI45bl48w2/1yQGwNd3EAjjld46U?= =?us-ascii?Q?dzLq9kZy1rUp4UY/GVlk8NDyjj3uEopNrHw2r50hN1rKRNUvRh6rM/y8okYR?= =?us-ascii?Q?htCg5jwopBRxy1rs2WQHAE9pRO9kvH6zqe6Hn/UsFUpr4wqDh/aTUMDnugxj?= =?us-ascii?Q?NGPReHOClWdMgV5iPXnNEXy+bV93HuGsTCOp3agttO99WiItPwrXSaGfyCwc?= =?us-ascii?Q?BIXhzNxq3OgesuzovGBPasO5DK9dwhhNb+HSFf7xD26viIob9ZXmV9igMLre?= =?us-ascii?Q?s9tYTYhfFZ7Fyd8PFqPt+NhpoDFBJPVvmaud7DoDx4gE//n4veMxVO4vGAnL?= =?us-ascii?Q?5n9nonUblqptvSvG7W/3Hg/GYXcg1uRfyCXLX1MUSmn86rEWqIxUddSFALcL?= =?us-ascii?Q?7Mr16Fnv1u6Vu72cWhV77hlkcmKcwCdPIbjzsEOG3927FO3b5lDxJmhJQR1W?= =?us-ascii?Q?o5S9ngDFNT7oglH5ZZ28gGUKtpa3n5Y6OHPyaaVUE6YhREPHDRovVOpd0Q+f?= =?us-ascii?Q?5+DkAZxFW9wB3Xf9+xXeJn0jXoaU3iAfcm2xKbCo13pVc4oJvOPaDcDnXBEm?= =?us-ascii?Q?dpTzN5qoqgLmrZByX02gMvpsEP06b8eOkVtRm/PKMCSpRbQcMKvDvY56x/Jb?= =?us-ascii?Q?nG/NC9I=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: 09 Oct 2024 17:42:51.2967 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bf438eff-72f9-4e03-5b32-08dce889cc3b 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: SJ1PEPF00001CE2.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4164 Content-Type: text/plain; charset="utf-8" Introduce interface to switch between mbm_cntr_assign and default modes. $ cat /sys/fs/resctrl/info/L3_MON/mbm_assign_mode [mbm_cntr_assign] default To enable the "mbm_cntr_assign" mode: $ echo "mbm_cntr_assign" > /sys/fs/resctrl/info/L3_MON/mbm_assign_mode To enable the default monitoring mode: $ echo "default" > /sys/fs/resctrl/info/L3_MON/mbm_assign_mode MBM event counters will reset when mbm_assign_mode is changed. Signed-off-by: Babu Moger --- v8: Reset the internal counters after mbm_cntr_assign mode is changed. Renamed rdtgroup_mbm_cntr_reset() to mbm_cntr_reset() Updated the documentation to make text generic. v7: Changed the interface name to mbm_assign_mode. Removed the references of ABMC. Added the changes to reset global and domain bitmaps. Added the changes to reset rmid. v6: Changed the mode name to mbm_cntr_assign. Moved all the FS related code here. Added changes to reset mbm_cntr_map and resctrl group counters. v5: Change log and mode description text correction. v4: Minor commit text changes. Keep the default to ABMC when supported. Fixed comments to reflect changed interface "mbm_mode". v3: New patch to address the review comments from upstream. --- Documentation/arch/x86/resctrl.rst | 15 ++++++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 75 +++++++++++++++++++++++++- 2 files changed, 89 insertions(+), 1 deletion(-) diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/re= sctrl.rst index 99ee9c87952b..d9574078f735 100644 --- a/Documentation/arch/x86/resctrl.rst +++ b/Documentation/arch/x86/resctrl.rst @@ -291,6 +291,21 @@ with the following files: that case reading the mbm_total_bytes and mbm_local_bytes may report 'Unavailable' if there is no counter associated with that group. =20 + * To enable "mbm_cntr_assign" mode: + :: + + # echo "mbm_cntr_assign" > /sys/fs/resctrl/info/L3_MON/mbm_assign_mo= de + + * To enable default monitoring mode: + :: + + # echo "default" > /sys/fs/resctrl/info/L3_MON/mbm_assign_mode + + The MBM events (mbm_total_bytes and/or mbm_local_bytes) associated counte= rs + may reset when the mode is changed. Moving to mbm_cntr_assign mode will + require users to assign the counters to the events. Otherwise, the MBM + event counters will return "Unassigned" when read. + "num_mbm_cntrs": The number of monitoring counters available for assignment when the architecture supports mbm_cntr_assign mode. diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index cb2c60c0319e..88eda3cf5c82 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -888,6 +888,78 @@ static int rdtgroup_mbm_assign_mode_show(struct kernfs= _open_file *of, return 0; } =20 +static void mbm_cntr_reset(struct rdt_resource *r) +{ + struct rdtgroup *prgrp, *crgrp; + struct rdt_mon_domain *dom; + + /* + * Hardware counters will reset after switching the monitor mode. + * Reset the architectural state so that reading of hardware + * counter is not considered as an overflow in the next update. + * Also reset the domain counter bitmap. + */ + list_for_each_entry(dom, &r->mon_domains, hdr.list) { + bitmap_zero(dom->mbm_cntr_map, r->mon.num_mbm_cntrs); + resctrl_arch_reset_rmid_all(r, dom); + } + + /* Reset global MBM counter map */ + bitmap_fill(r->mon.mbm_cntr_free_map, r->mon.num_mbm_cntrs); + + /* Reset the cntr_id's for all the monitor groups */ + list_for_each_entry(prgrp, &rdt_all_groups, rdtgroup_list) { + prgrp->mon.cntr_id[0] =3D MON_CNTR_UNSET; + prgrp->mon.cntr_id[1] =3D MON_CNTR_UNSET; + list_for_each_entry(crgrp, &prgrp->mon.crdtgrp_list, + mon.crdtgrp_list) { + crgrp->mon.cntr_id[0] =3D MON_CNTR_UNSET; + crgrp->mon.cntr_id[1] =3D MON_CNTR_UNSET; + } + } +} + +static ssize_t rdtgroup_mbm_assign_mode_write(struct kernfs_open_file *of, + char *buf, size_t nbytes, loff_t off) +{ + struct rdt_resource *r =3D of->kn->parent->priv; + int ret =3D 0; + bool enable; + + /* Valid input requires a trailing newline */ + if (nbytes =3D=3D 0 || buf[nbytes - 1] !=3D '\n') + return -EINVAL; + + buf[nbytes - 1] =3D '\0'; + + cpus_read_lock(); + mutex_lock(&rdtgroup_mutex); + + rdt_last_cmd_clear(); + + if (!strcmp(buf, "default")) { + enable =3D 0; + } else if (!strcmp(buf, "mbm_cntr_assign")) { + enable =3D 1; + } else { + ret =3D -EINVAL; + rdt_last_cmd_puts("Unsupported assign mode\n"); + goto write_exit; + } + + if (enable !=3D resctrl_arch_mbm_cntr_assign_enabled(r)) { + ret =3D resctrl_arch_mbm_cntr_assign_set(r, enable); + if (!ret) + mbm_cntr_reset(r); + } + +write_exit: + mutex_unlock(&rdtgroup_mutex); + cpus_read_unlock(); + + return ret ?: nbytes; +} + static int rdtgroup_num_mbm_cntrs_show(struct kernfs_open_file *of, struct seq_file *s, void *v) { @@ -2115,9 +2187,10 @@ static struct rftype res_common_files[] =3D { }, { .name =3D "mbm_assign_mode", - .mode =3D 0444, + .mode =3D 0644, .kf_ops =3D &rdtgroup_kf_single_ops, .seq_show =3D rdtgroup_mbm_assign_mode_show, + .write =3D rdtgroup_mbm_assign_mode_write, .fflags =3D RFTYPE_MON_INFO, }, { --=20 2.34.1 From nobody Wed Nov 27 12:26:58 2024 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2040.outbound.protection.outlook.com [40.107.220.40]) (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 7325A1E906A; Wed, 9 Oct 2024 17:43:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.40 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728495790; cv=fail; b=DCIkinCu8AoKFl7dCHEmwLxFrkRS4jewvao705Hmifyux9M5egYDgWxkXyQ2ueR6iITW+hQ63MhAatVd8QPQsHPUDBF8XFtl+60R6LEM9FZeJENEqrNOrQHdQABh/f+sEuKN0kIuVIYvLT7vRAfz6byflXehIPAKv1HniCBlshQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728495790; c=relaxed/simple; bh=hfYdBYcn3maJUcNMWvBwVf6FcLcZipDDaojnwc/Rybo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tleNgm1dHbuW9vA7oqnaItDt+TExmdDFQ9j+oJ6SHTtgt+eHqtKNKnWu7sc7Q9kd75RfT2IHX4MnhuYhZ0EOlC4wWceVVP4A+01Z30eJmGRFm79Hc7eF9qbxcoHb7umwulXw+POaSo61vUBf9NshU5YHMJpiUoPREDJ3yazTyt8= 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=jTwoU6Vz; arc=fail smtp.client-ip=40.107.220.40 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="jTwoU6Vz" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=VFMXQ5nxiPQ3t+rHHsYLsLvpzA5WJO0p71JhQbrWQ3ccvXr52ovo/J1ZpUf7ub+Xmcx22mpcV43hL6r+S4BZvxz/EkwT+vUSnm2CCwndch1PFuc6fDSYXGczdaYDb/hq+vDNVmRiYykmZ+j2hL1MFMMkQFQjSoy3pCOPM7i7oDkPd0lrm+VlBoLApMvQEoWmeoXxdYYHdOxWfpmfWh0IB4h4JJrkBW6DOYydirzULphpC7ssohLi1JCt6uRFT3whtId5eWWCXM4JWJnsR3uv5I1OuxxnufCKC2YX/gmopvs7NCPdoZiVMdCVScgwxBpi0RQc0AWR0ryW07KxJ6gRpw== 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=SG80/ufH+fy1EqmkR1wGC2tYi4umW0s4zU4RYKl0osc=; b=JSeNv/nnyl9M83lgrHFZOJzFFHbnR3jw0jDBqukklq3Pj/+7RrL4bAETl+EWuLiXQD3fX3X0/Fvrw1gYHhhKHKrHyeuNzNi30ABoUj0rcD1D8xp7yfxaak8eCCjRNlY2X2IelymbT5lu0eXZKyPZz9wjBXwHcLTaCh2HVhsKy8atS4rTnMiN/TayTysnVdceUHUGwXHEKyUAkabmorh5+vLIZmveW5+rRjyrJrQ18pCpijmx4adJggBFVPNsnheL0d9hIfeFt8O0ETl4i+EvbJhfd2MHV4T+gpUF8dsYJyoIY39RN9pMcAf8gfDgNcP1r55XnAi7Y+O3ViTErKs2Dw== 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=SG80/ufH+fy1EqmkR1wGC2tYi4umW0s4zU4RYKl0osc=; b=jTwoU6VzjS9LJFGJejSw9gVTZS0IdL62SLSxjEFMm1C+foip/0NNFzRRdn277HA+aUHmmNwQhvzZbAOy67SMoVQ6o1WJm4FSdP6g+vNf96eqz8hw2v/t260yxywikhYWRTk+bjFCwE9PDvbS0p80QEe8wteBjDHeLah7xlQySYU= Received: from SJ0PR05CA0189.namprd05.prod.outlook.com (2603:10b6:a03:330::14) by LV2PR12MB5752.namprd12.prod.outlook.com (2603:10b6:408:177::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.16; Wed, 9 Oct 2024 17:43:00 +0000 Received: from SJ1PEPF00001CDD.namprd05.prod.outlook.com (2603:10b6:a03:330:cafe::3) by SJ0PR05CA0189.outlook.office365.com (2603:10b6:a03:330::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.11 via Frontend Transport; Wed, 9 Oct 2024 17:42: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 SJ1PEPF00001CDD.mail.protection.outlook.com (10.167.242.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8048.13 via Frontend Transport; Wed, 9 Oct 2024 17:42: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; Wed, 9 Oct 2024 12:42:57 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v8 22/25] x86/resctrl: Configure mbm_cntr_assign mode if supported Date: Wed, 9 Oct 2024 12:39:47 -0500 Message-ID: <262fdcc3c84a26576d451649914cae9f7d431692.1728495588.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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00001CDD:EE_|LV2PR12MB5752:EE_ X-MS-Office365-Filtering-Correlation-Id: 87630c2a-324d-4807-5611-08dce889d101 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|36860700013|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?BX7/NIuXYBZhZy6SAg8+v9CtwFXM4jevY2O9RXFngd1b1So9n7BYen7Xm9c8?= =?us-ascii?Q?2FT7F6lgnqv1djyWz53sIuCljr3nw2W6zHlDT2VFV84p08FbAh+ydoC1ntTi?= =?us-ascii?Q?5N4TRV3FG9Vx+J1PjMOQOYdvNWRrOiQLThw5deYwxlo0AeB3easOeTQsScmq?= =?us-ascii?Q?saf+mBjflujUz4LWYzvVPvEfqq4AwP2ruJ41VHcNQiWcBgkh6uidDYXVYqTr?= =?us-ascii?Q?5lr8FlA9DG6t0bJMstrTnRONLmXHmfQ4wX/Jd8QM5Tgzwy5axFpcBpi8w7fI?= =?us-ascii?Q?KfXQytG+86/AqXEiO1f5ye2ArpL0B9X1H3BkHim7rfJhhmzlW+Enk3ABfTVu?= =?us-ascii?Q?lPIf5AB65f186tFP9geUpZDct9+VlJ/ZewQiZGixi2l1uPRswRsKTLcDEiN8?= =?us-ascii?Q?pDlVRdUlXkeSuldRTF7lm/76ImOgDa8ZKnzTkqThJzVvXi0lmGA2CDzwUq20?= =?us-ascii?Q?xirVOvliGDfFiIm1OGBRbzNKN+CowUqrjCqZBNgpyxllA8zEVpK7sxzPkgfZ?= =?us-ascii?Q?kyPJPBSTMp5jNw2n8upeRnL6WScHcnLwoYp3gcimygnQnqrm3YTtIUxHscCa?= =?us-ascii?Q?RD09colfIMMSzk7L9KeK4SqLDkWGXQuT+I3kwuv90CMytObCFXQBDmXDXnpf?= =?us-ascii?Q?dbZCnmxvzv5Iw48m+Bm5w5OTPyggHvljb9Sdd1YBjO31WlipBdYGluIJsVhM?= =?us-ascii?Q?2S04KfHo2gDiYjSsa+SoYWZUPRhhCMAIgVHXT/bJ6wDrMC5F3czJkJpU22tP?= =?us-ascii?Q?7efjWTHFbEaoBAST8fPKBJ3zNL+LDh/mJJzaMlEYnK0TPLFTvXkF604aoMOt?= =?us-ascii?Q?gIL50jtIfkrz5y4b5Z2vmBmM+tmEfgjXCDincOZvJ85OsxTrmb/2JVnge0Xa?= =?us-ascii?Q?+uw5ArmdbXOCdktR5armHbak9YxBX7TLY6ZSOTB710JNVZGReKCCSt/0qErE?= =?us-ascii?Q?BYXo0dWcaPEXmTFEx4r4GGnfJgPQzHDdYarVHdp9joNrFDetxHJDpNQn1jXj?= =?us-ascii?Q?0RjTyQ/4iBsvERIWLVaNdB4tirapIFfVMkFnXJVHXjsxMcPx48dEq4n2Ltu0?= =?us-ascii?Q?Fr+87+TBEaNggm3lIG5DdA1aj5s/IGd3d0yKovgdDfAYrHjGziPbZlfEHJMk?= =?us-ascii?Q?O0VnIc9QpVwaa6xZuv4oBXNNEwc9qWnNy4DVLvmwglqCEmaPajNO3S5YWxCt?= =?us-ascii?Q?qX5XQdl4cIEKEVCXcXYRda7ncddx6mtMw1iQ+GDAXYZppdZGBU4ycyOYOdhD?= =?us-ascii?Q?7lMxrybvQCjDT8lhizjj6HcWlJiBlZ4BFHqEZa4h5riIgWtO9vzUG0akU5Rc?= =?us-ascii?Q?3Cl5+0hHiS4PtYSlId3BGAIIqnQkzSjayX40em2ZkxBM8H1UpXi5g8OicEvo?= =?us-ascii?Q?B7n2Ioro1blWJFgkL8QH7arOxCiH?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(36860700013)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2024 17:42:59.3050 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 87630c2a-324d-4807-5611-08dce889d101 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: SJ1PEPF00001CDD.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5752 Content-Type: text/plain; charset="utf-8" Configure mbm_cntr_assign on AMD. 'mbm_cntr_assign' mode in AMD is ABMC (Assignable Bandwidth Monitoring Counters). It is enabled by default when supported on the system. When the ABMC is updated, it must be updated on all the logical processors in the resctrl domain. Signed-off-by: Babu Moger --- v8: Renamed resctrl_arch_mbm_cntr_assign_configure to resctrl_arch_mbm_cntr_assign_set_one. Adde r->mon_capable check. Commit message update. v7: Introduced resctrl_arch_mbm_cntr_assign_configure() to configure. Moved the default settings to rdt_get_mon_l3_config(). It should be done before the hotplug handler is called. It cannot be done at rdtgroup_init(). v6: Keeping the default enablement in arch init code for now. This may need some discussion. Renamed resctrl_arch_configure_abmc to resctrl_arch_mbm_cntr_assign_co= nfigure. v5: New patch to enable ABMC by default. --- arch/x86/kernel/cpu/resctrl/internal.h | 1 + arch/x86/kernel/cpu/resctrl/monitor.c | 1 + arch/x86/kernel/cpu/resctrl/rdtgroup.c | 11 +++++++++++ 3 files changed, 13 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 6f388d20fb22..a6f40d3115f4 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -719,6 +719,7 @@ int rdtgroup_assign_cntr_event(struct rdt_resource *r, = struct rdtgroup *rdtgrp, struct rdt_mon_domain *d, enum resctrl_event_id evtid); int rdtgroup_unassign_cntr_event(struct rdt_resource *r, struct rdtgroup *= rdtgrp, struct rdt_mon_domain *d, enum resctrl_event_id evtid); +void resctrl_arch_mbm_cntr_assign_set_one(struct rdt_resource *r); void rdt_staged_configs_clear(void); bool closid_allocated(unsigned int closid); int resctrl_find_cleanest_closid(void); diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 6b4cf4813a4b..395d99984893 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -1268,6 +1268,7 @@ int __init rdt_get_mon_l3_config(struct rdt_resource = *r) cpuid_count(0x80000020, 5, &eax, &ebx, &ecx, &edx); r->mon.num_mbm_cntrs =3D (ebx & GENMASK(15, 0)) + 1; resctrl_file_fflags_init("num_mbm_cntrs", RFTYPE_MON_INFO); + hw_res->mbm_cntr_assign_enabled =3D true; } } =20 diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 88eda3cf5c82..f890d294e002 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -2736,6 +2736,13 @@ int resctrl_arch_mbm_cntr_assign_set(struct rdt_reso= urce *r, bool enable) return 0; } =20 +void resctrl_arch_mbm_cntr_assign_set_one(struct rdt_resource *r) +{ + struct rdt_hw_resource *hw_res =3D resctrl_to_arch_res(r); + + resctrl_abmc_set_one_amd(&hw_res->mbm_cntr_assign_enabled); +} + /* * We don't allow rdtgroup directories to be created anywhere * except the root directory. Thus when looking for the rdtgroup @@ -4523,9 +4530,13 @@ int resctrl_online_mon_domain(struct rdt_resource *r= , struct rdt_mon_domain *d) =20 void resctrl_online_cpu(unsigned int cpu) { + struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; + mutex_lock(&rdtgroup_mutex); /* The CPU is set in default rdtgroup after online. */ cpumask_set_cpu(cpu, &rdtgroup_default.cpu_mask); + if (r->mon_capable && r->mon.mbm_cntr_assignable) + resctrl_arch_mbm_cntr_assign_set_one(r); mutex_unlock(&rdtgroup_mutex); } =20 --=20 2.34.1 From nobody Wed Nov 27 12:26:58 2024 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2068.outbound.protection.outlook.com [40.107.236.68]) (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 F0E111D3631; Wed, 9 Oct 2024 17:43:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.68 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728495801; cv=fail; b=JOSjVKBEDZoW+vPhVOdTSXwZEGPHgBx/Ju5hXS8hXha8fDMon9pmcy42s815cijTqyiaDo1VqjrbuMk+xn9O2w1mudkeZQJn9tsZK9o7Q7L9CGUCw+2+ISqqIiSXsaqqxvLHc5xGO+JKwuB9AJm56y0NtCbzhhYxAiCMU9oPh8o= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728495801; c=relaxed/simple; bh=dqrYKJVpZyDIA9xmcbhN6MVLuKNXJCvsmc6AHY9WfmI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HVpocf63pV3kmP5v6Oa7YjZ5Y9G12YvkHJPliyZ6lK/vRf2eSwCadZVWzofo+gGlmgoRp7e0qfBFmPDuEenuLxStM676oaEPkN+gfs75vfLI4ufTk1hHhnyo6lJjzjpy78gT1xLa6RAmTXxGRVjm1133CAjyr35DxLc2X3G/HQI= 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=SoGqh+Pq; arc=fail smtp.client-ip=40.107.236.68 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="SoGqh+Pq" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GmJ1oWLGlM9y94kevsF1Y9jDbrt64U1rmx6LdgFj2KaLLmsaw0m7gkIdc5ScVBfDYCPJCH32BTVk4FMB33n0rk1jqJ30695DalI5WRt0k7N2yYicQ5f8C5VnBYwjwPMlO8it9yD0Pjd/HdgjNFse6wPJgQLcTZjPuzp3Y7uF8ROUQZajcTdHIZ0UYMCQTSCoV/2uMMQLJEVXgfVT9KjsDXaVtppstFa4pLTFflMDnxgwDwg04IIkqWu4fpqN0YTTvSPCS2OhofX9npq4FDTEi+5qr38/Gev/4239Tret1p14KkjMN4Ohak3vaMXxQxhtzTFkdtpJjnPfp2ow0kN9NA== 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=RI0vKJLGLntUZmP06OaTtEewm2vElUTYjUMt3Ujyzcc=; b=M/EaIzlXYvQEJqyjh0b/RvPDHsOMl2hoondw6qCJlzj8JKfsmSTGTz3DnXzS/BY3FA8vdGT6yo+xhvft3tRid91Wo3RpgyHdZy4WnLH4R/FHk+YWMD4GtJJp7Ea/lQMwzXYG7SC7QMqpYd02BEg/GG/oD+Hj8sGFHPa/ctgHGxQdazlBIZtRy/9GehpULs8YMVT6RyDLQkjnfh1uUieLSoLB5lk/Q13zrJLzOo254STqVRpNsP4L7zJdItCQD3B6YFbgNqYGHUEWqyy+MCk5oJDusC8IVhBG6LEy5ITXfqSaDcPErv90GBN0XVKP/3aPyM9rMcX9TUzT3TUtCD7HkQ== 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=RI0vKJLGLntUZmP06OaTtEewm2vElUTYjUMt3Ujyzcc=; b=SoGqh+PqVTNneFiteL5zlot6A4z4y4xLG/QVuH3Gg9Q9Plu8npF2Kz/jArPULHJZe2qgZN7CnM0vNdy7+T86fzhvNBZL8UsBdQZO0HKzSWafAjCytlllGBVbnPf+TdClToi5YzONN5yUIckiPoHolLyGqnToqsexNPYQcmt/0e4= Received: from PH7P222CA0006.NAMP222.PROD.OUTLOOK.COM (2603:10b6:510:33a::26) by LV3PR12MB9267.namprd12.prod.outlook.com (2603:10b6:408:211::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.16; Wed, 9 Oct 2024 17:43:09 +0000 Received: from MWH0EPF000A6735.namprd04.prod.outlook.com (2603:10b6:510:33a:cafe::fa) by PH7P222CA0006.outlook.office365.com (2603:10b6:510:33a::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.24 via Frontend Transport; Wed, 9 Oct 2024 17:43:09 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000A6735.mail.protection.outlook.com (10.167.249.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8048.13 via Frontend Transport; Wed, 9 Oct 2024 17:43:08 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 9 Oct 2024 12:43:05 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v8 23/25] x86/resctrl: Update assignments on event configuration changes Date: Wed, 9 Oct 2024 12:39:48 -0500 Message-ID: <715b84c29f4ec849a79698ad43218d4a486422d3.1728495588.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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000A6735:EE_|LV3PR12MB9267:EE_ X-MS-Office365-Filtering-Correlation-Id: 60c20372-2d00-4cc2-73b5-08dce889d6bd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?nnWt8mLh57qXcu/0mkYVRpoCmHPVZKZgmOP2YSs32FgzphAwpk8kTnKIoUeo?= =?us-ascii?Q?+WHkQKe4rFkafmCMJm1hR7eTn6Ut4M2XA9fTygGo9zRsSM7462rvoTssHFLn?= =?us-ascii?Q?JmXzAPa058BVCbtCxpNC73Ii7eNykw7tsgiGopSbp6C5YYc8eThwmd6KJNx2?= =?us-ascii?Q?zJTtHDZ8c4CeNMPWCRBzbbSmYdqdFNKHtWmzDHgth6SnWld3fFxNkYw7B8nf?= =?us-ascii?Q?focLxxBToVkch43WLl/m1Gopi55stnUUfdAB/HreBU9P3O5d9ax8jOQptugc?= =?us-ascii?Q?Wi/wTZ339QfsK9anIuvOrKrzoCqB+RcGOQiYTs+ZKgOUHniCCvBleu+3/dX0?= =?us-ascii?Q?WbhVi84fhkxKi5K/3yqFqIMNF6/SpRuiGrhnu5e08ePfOgyvHBLtroEW277x?= =?us-ascii?Q?ctLHlWZJr3ly3xGOKkRmWWzfhmJm+E9kNtKIMqa6rfpsM4AuhYrSgtkIP9Yd?= =?us-ascii?Q?Qea2ix+YRk4/9n1jY5Z08+z3veVgsC+8U/U9tV9YVwqo4isCibw5BGJe8ppr?= =?us-ascii?Q?7xHSVZPxQKrIqtf6rbfGOZhwdy/PF2sR1uwd+zPBh0PoVpb4NNwsYvg3LmCy?= =?us-ascii?Q?UFmbAx1llC8gnykvvn1AjcURHYPcz5b3Bc+eVH3elyA3bTlVbzieDYFQS6cS?= =?us-ascii?Q?zqQ+wwZHOBFXrJfhpTJvOoDDfmqa6jkBA0M1JK6RS1p4S0VJmqbnk63i0mSB?= =?us-ascii?Q?QqgBiwJJwTD4Wno1xLwkPlQybUA7bphRy5WFAEgE4RU+Ophcr0o3xDJ6kB1F?= =?us-ascii?Q?eC4me5Akgi+ZSVY7o6PVCI1BujHtDUJW+fj5hPp6KTJuH3pj8TsoafhzsBVk?= =?us-ascii?Q?KRUFVagoc6UC3JCgQI+l5qvBu2qN3VEYrpr86WJy/KoerL+Gc4dDNmSck+Oh?= =?us-ascii?Q?YpnoYPNSQ/Uq8ukU+3moXMM2+uXi9bdpyPgJUCQ6d5pkQo+EwpTBUSKnQ922?= =?us-ascii?Q?mKLTMOuiuskTC9mpJf8TjOXV3ZUpH0b4NcBvvnqiTmONLy6Zh2kIXM+plu0G?= =?us-ascii?Q?fT51Q5rC1saRbAfVbC3d4OAR/he+bECqaERFZLf7hpZ84ieiSd5aNcIWNohS?= =?us-ascii?Q?f2kWoI72s9ZkWtE3SjhJQpUmBdyUFtONreip2CbtaboMAjZsWZ5bdv0yMSeK?= =?us-ascii?Q?lYy9UiHejeXQwmPa7vdZHnIiLkwUJvu6baP8tuW9W6Zllh6ccEfmx8fthn9u?= =?us-ascii?Q?gHGtyYUO4nIxT8nPC2ogDXA2udce43D5ogMtkmtoUOax6dA5VKg4oiNl1Igo?= =?us-ascii?Q?oEnahAPVklIVdvCHUsVdBrCcyVyH5A7Vn0t0Z/KDj7tD2X92M7AeXxqEo16c?= =?us-ascii?Q?LmzXTUnk4ftIquIarUJkpxfFoIHV6PZXVb8kLGxk4qnc6xjwDBJZk5Gmv8P2?= =?us-ascii?Q?QO382FiqXEbgyHXOV+nrNalJBrm5?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(376014)(7416014)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2024 17:43:08.8796 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 60c20372-2d00-4cc2-73b5-08dce889d6bd 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: MWH0EPF000A6735.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR12MB9267 Content-Type: text/plain; charset="utf-8" Users can modify the configuration of assignable events. Whenever the event configuration is updated, MBM assignments must be revised across all monitor groups within the impacted domains. Signed-off-by: Babu Moger --- v8: Patch changed completely. Updated the assignment on same IPI as the event is updated. Could not do the way we discussed in the thread. https://lore.kernel.org/lkml/f77737ac-d3f6-3e4b-3565-564f79c86ca8@amd.c= om/ Needed to figure out event type to update the configuration. v7: New patch to update the assignments. Missed it earlier. --- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 49 ++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index f890d294e002..cf2e0ad0e4f4 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -1669,6 +1669,7 @@ static int rdtgroup_size_show(struct kernfs_open_file= *of, } =20 struct mon_config_info { + struct rdt_resource *r; struct rdt_mon_domain *d; u32 evtid; u32 mon_config; @@ -1694,11 +1695,46 @@ u32 resctrl_arch_mon_event_config_get(struct rdt_mo= n_domain *d, return INVALID_CONFIG_VALUE; } =20 +static void mbm_cntr_event_update(int cntr_id, unsigned int index, u32 val) +{ + union l3_qos_abmc_cfg abmc_cfg =3D { 0 }; + struct rdtgroup *prgrp, *crgrp; + int update =3D 0; + + /* Check if the cntr_id is associated to the event type updated */ + list_for_each_entry(prgrp, &rdt_all_groups, rdtgroup_list) { + if (prgrp->mon.cntr_id[index] =3D=3D cntr_id) { + abmc_cfg.split.bw_src =3D prgrp->mon.rmid; + update =3D 1; + goto out_update; + } + list_for_each_entry(crgrp, &prgrp->mon.crdtgrp_list, mon.crdtgrp_list) { + if (crgrp->mon.cntr_id[index] =3D=3D cntr_id) { + abmc_cfg.split.bw_src =3D crgrp->mon.rmid; + update =3D 1; + goto out_update; + } + } + } + +out_update: + if (update) { + abmc_cfg.split.cfg_en =3D 1; + abmc_cfg.split.cntr_en =3D 1; + abmc_cfg.split.cntr_id =3D cntr_id; + abmc_cfg.split.bw_type =3D val; + wrmsrl(MSR_IA32_L3_QOS_ABMC_CFG, abmc_cfg.full); + } +} + void resctrl_arch_mon_event_config_set(void *info) { struct mon_config_info *mon_info =3D info; + struct rdt_mon_domain *d =3D mon_info->d; + struct rdt_resource *r =3D mon_info->r; struct rdt_hw_mon_domain *hw_dom; unsigned int index; + int cntr_id; =20 index =3D mon_event_config_index_get(mon_info->evtid); if (index =3D=3D INVALID_CONFIG_INDEX) @@ -1718,6 +1754,18 @@ void resctrl_arch_mon_event_config_set(void *info) hw_dom->mbm_local_cfg =3D mon_info->mon_config; break; } + + /* + * Update the assignment if the domain has the cntr_id's assigned + * to event type updated. + */ + if (resctrl_arch_mbm_cntr_assign_enabled(r)) { + for (cntr_id =3D 0; cntr_id < r->mon.num_mbm_cntrs; cntr_id++) { + if (test_bit(cntr_id, d->mbm_cntr_map)) + mbm_cntr_event_update(cntr_id, index, + mon_info->mon_config); + } + } } =20 /** @@ -1805,6 +1853,7 @@ static void mbm_config_write_domain(struct rdt_resour= ce *r, mon_info.d =3D d; mon_info.evtid =3D evtid; mon_info.mon_config =3D val; + mon_info.r =3D r; =20 /* * Update MSR_IA32_EVT_CFG_BASE MSR on one of the CPUs in the --=20 2.34.1 From nobody Wed Nov 27 12:26:58 2024 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2063.outbound.protection.outlook.com [40.107.220.63]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6441F1E1C16; Wed, 9 Oct 2024 17:43:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.63 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728495803; cv=fail; b=dWzESnJB6m5PC+ncROjxXIz9KOiUiuXiL31VlPyXXpgNSa7QzR1CiAF3Y9Kp4DgHoVGfHeD8OvmYcyZHAkWFFs482YO8Pzrfz1jNPRvkJR68b/GgqtBDbErswtaCT/FcxDVuDd4+RN+uAIeUL+lf0N13aBH+15iYdMG3934ujR8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728495803; c=relaxed/simple; bh=rYE4pqPKTxNWOiKpzB6HIH+2jMXh+jp2wukpmRbkobg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Xg0yWQKO2AsS4f6tK6eeXKX4ISI0SWWTkjt3MU/YTVnToa7OHEmMJPAUgtbXoRS6jtr2Smv2wpx5qIPdG95m+UAckc0e2h43bE1A+slZAzl/VgVG0tAykzjPPAa0WbPXNgPMI3ftnMjMQv8U4ZzIIWj34k434p7Ra/+Q7Vigzy0= 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=CRwQl8VY; arc=fail smtp.client-ip=40.107.220.63 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="CRwQl8VY" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=G+lJ3/QaBmTpsdtIAZpAw5wp5hpfNnkUJexhp5YPT6KBu6xTioWdIHJyoHJ8KceOKhhNQva1yRjAGRLJr+fz6tgh9qrTfbVuFU1smZVXLE6wjI+6sZQgIaE0RgiBj6tOiNQrtiW7gMebgTs7sdWy78kuRl6R86XfZX/l308yBZhA9LHo+KXOjnB+0sFUwU20WiBEoSR2cYkmHVVombo6KZjk7+8Cx36VNSO1hIdbGzeDxVHoEHfP5ywufrxxx1z8rqvVPi2+J9Ic3l9nEgKjl9idlHVnC8Aqi4Yl5G6/LK4D8BRIuiAjYqyw8VFKJM5H3TiC5ULuUgX1AFkTnwqfDg== 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=d8dDnVu9ddF9jZWljiKZs//miZaaUmUR3ORebllxJbY=; b=aeR5HT3QVnYTatpgpNZfjyTCsW5AtNlflGDPueGr3txtFytgjiDlzaZMhBwfO4KMYGg4Q0beQL8RXf46bH2WJGpjIEeSazPxCrd/j3CyjBc8QUOx0WaVWoN+IbB3hxCUVCWXPJNV+bgsuwR8ZcFSj0IiqffF327Hwh4Vd0WZrlqF/kCuNxuuCasdVxEdoqLaATRePB1rLNHIGWtwGfCKUHybetfQd0NDZhpzbBG9jQhfq0lQkh5kjdomKJYsEwR2mGgc85wBVUSks3QnHVOCE95MRXbXQHqFOWAcyrr0GxeIAvrURZ5L6PbKSs9hKjPlmd7KnnAz5iANbwFuJnK+ag== 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=d8dDnVu9ddF9jZWljiKZs//miZaaUmUR3ORebllxJbY=; b=CRwQl8VYtnNtnpU3goCXTfvGk3S0vDiR1o6CpVgsmyMDOdWfUxoPVqcLuCHsXNc7RLRW8T+VAXbPKgaTvb7JOiL8KyzimdQwZhoqPWQ3nlNkWAw21Z2URdtPrzSJY88ewY1c0Xarsj/fRAtqjf21lHPQ9CxjPxPL2V0TYXBu2XA= Received: from PH7P221CA0005.NAMP221.PROD.OUTLOOK.COM (2603:10b6:510:32a::22) by DM3PR12MB9288.namprd12.prod.outlook.com (2603:10b6:0:4a::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.18; Wed, 9 Oct 2024 17:43:16 +0000 Received: from MWH0EPF000A6730.namprd04.prod.outlook.com (2603:10b6:510:32a:cafe::58) by PH7P221CA0005.outlook.office365.com (2603:10b6:510:32a::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.18 via Frontend Transport; Wed, 9 Oct 2024 17:43:16 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000A6730.mail.protection.outlook.com (10.167.249.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8048.13 via Frontend Transport; Wed, 9 Oct 2024 17:43:15 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 9 Oct 2024 12:43:13 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v8 24/25] x86/resctrl: Introduce interface to list assignment states of all the groups Date: Wed, 9 Oct 2024 12:39:49 -0500 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000A6730:EE_|DM3PR12MB9288:EE_ X-MS-Office365-Filtering-Correlation-Id: 312dcf3d-8abf-47e7-9f7f-08dce889da72 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|7416014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?EnmR4uYHaLDSwWPyFhQe2DtxkHU69GXejebZrN6wyFq/b59Wr4JCb0SfV8iX?= =?us-ascii?Q?TDYvzs2vBd22DoLJsiZ1lkdJtr75EiDvzUul7Ia+GfK3J9gECdDGoPsaIMWz?= =?us-ascii?Q?f4s4ojZMAIIyabWHNy5xjAAeTnpSqTqEO9Gq85MtwsaPJ8Vb9ZwuaZbyURGS?= =?us-ascii?Q?bShsV0peTabTATTvvDReXPb56t0Qg+uH06YfVuwkHq+AgbPVeyEGLMYXSmC4?= =?us-ascii?Q?f7L3WP5m0bB3hCiIfiS7rhEa02FL3TO1cuQ1FbmbsRudJ2qcy9CcjIL3hoM7?= =?us-ascii?Q?lATrk82MEgEzwSw9ue/B3+SXEPdn7MsppQr6bbRgRm0VKi0cJ1Ujjch5wwbC?= =?us-ascii?Q?VGKiDyon+QtOGc73UkSfktL/yUeid3v+atSnZi9BKT37JARjvMPFpdBHmVwJ?= =?us-ascii?Q?cQfFYKXmLeoTYQT/XE/Mhl+I9COvGtfVfNKocoQTOXj5EBiNNnxtTyTFrcH4?= =?us-ascii?Q?k1WSamPD6p/cvg6Lw4mEAJs/VSFraFlTF/cuzp32sGdyCsnFZdu1+0ZOcePh?= =?us-ascii?Q?cFsDfHVGlPkOTnQYbDLfLwOs9Tocs1/168oeAVrQ5voXmGlIJYG5zoJJVbbZ?= =?us-ascii?Q?o390gj3hkmIYEHDW9X5vd8cWQWlh4jJWCIcOB5Xho+SA18Rk0Pfb03CQMM00?= =?us-ascii?Q?Wk4uWjiXyH9pJMbRPGTukNlyJr9gUSlnX8kt/Ic6bQiOF9mbVZJaFPhEGsev?= =?us-ascii?Q?Ep18Is+lHutSl0z1XNmg4asDnQl1uZGfKX0irJK/mb9mY3X06M9bO1LuWPYY?= =?us-ascii?Q?b+FClKzgHKQVWsUHpfP7rbpU9F8xpjvS7uZsiooASta3bCiPpsiO5f3lKmGb?= =?us-ascii?Q?JLFPVrmSu/9HBmd5iKzoL5zOTDq+PFHdOCpR5TLupX1YC6pJ6hk1U3DGoSJI?= =?us-ascii?Q?ILOkW9XU2Iq/vqE5HdtjUYOg/9qp2ld+tsf8z8+N/vy7ZIq2DRIfUYlqHRUm?= =?us-ascii?Q?PmzPJ9MW543Cr4mMOgeOYbjPTe+dSztCdAcIShaQ1GbAqzej8bXTtNV62xg/?= =?us-ascii?Q?IAt8DknH2AhBMaCGwwOGm9eCc4eUvss7liQj6zdialuoyBteurNFMxmM8FJW?= =?us-ascii?Q?y6MVrnKQCWnR0+WZU+gD3Qbn01UUo4TC2Hx3YRBwLWhnXAxpl5Rog2m9C9Dw?= =?us-ascii?Q?/ZO69jeFNC2ECu0Yp2GJXyDwR+KCzQwgbeR0zDGRXuGr//t/WpC5o7jTYu9+?= =?us-ascii?Q?NqshfjgDfVo/GauJjGET6NNgf4tO0AZsx+SfkCZmDSV6qObSM+z8HSl680a1?= =?us-ascii?Q?LCy+Nvh8SLtVuFgoDqBJN41+scKfgMa9dn7kWtQt7np0/Yj2KVJTad6qkHCd?= =?us-ascii?Q?6KV4GZOvWWNiwd51t7euPnI72WDgvsTd+HOKEhFkKcyFN3+E1KKBjTmwnghE?= =?us-ascii?Q?nSSIejDFmzwYnyhcXYfMtVXhhDsP?= 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)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2024 17:43:15.1001 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 312dcf3d-8abf-47e7-9f7f-08dce889da72 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: MWH0EPF000A6730.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3PR12MB9288 Content-Type: text/plain; charset="utf-8" Provide the interface to list the assignment states of all the resctrl groups in mbm_cntr_assign mode. Example: $mount -t resctrl resctrl /sys/fs/resctrl/ $cat /sys/fs/resctrl/info/L3_MON/mbm_assign_control //0=3Dtl;1=3Dtl; List follows the following format: "//=3D" Format for specific type of groups: - Default CTRL_MON group: "//=3D" - Non-default CTRL_MON group: "//=3D" - Child MON group of default CTRL_MON group: "//=3D" - Child MON group of non-default CTRL_MON group: "//=3D" Flags can be one of the following: t MBM total event is enabled l MBM local event is enabled tl Both total and local MBM events are enabled _ None of the MBM events are enabled Signed-off-by: Babu Moger --- v8: Moved resctrl_mbm_event_assigned() in here as it is first used here. Moved rdt_last_cmd_clear() before making any call. Updated the commit log. Corrected the doc format. v7: Renamed the interface name from 'mbm_control' to 'mbm_assign_control' to match 'mbm_assign_mode'. Removed Arch references from FS code. Added rdt_last_cmd_clear() before the command processing. Added rdtgroup_mutex before all the calls. Removed references of ABMC from FS code. v6: The domain specific assignment can be determined looking at mbm_cntr_ma= p. Removed rdtgroup_abmc_dom_cfg() and rdtgroup_abmc_dom_state(). Removed the switch statement for the domain_state detection. Determined the flags incremently. Removed special handling of default group while printing.. v5: Replaced "assignment flags" with "flags". Changes related to mon structure. Changes related renaming the interface from mbm_assign_control to mbm_control. v4: Added functionality to query domain specific assigment in. rdtgroup_abmc_dom_state(). v3: New patch. Addresses the feedback to provide the global assignment interface. https://lore.kernel.org/lkml/c73f444b-83a1-4e9a-95d3-54c5165ee782@intel= .com/ --- Documentation/arch/x86/resctrl.rst | 44 +++++++++++++++ arch/x86/kernel/cpu/resctrl/monitor.c | 1 + arch/x86/kernel/cpu/resctrl/rdtgroup.c | 76 ++++++++++++++++++++++++++ 3 files changed, 121 insertions(+) diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/re= sctrl.rst index d9574078f735..b85d3bc3e301 100644 --- a/Documentation/arch/x86/resctrl.rst +++ b/Documentation/arch/x86/resctrl.rst @@ -310,6 +310,50 @@ with the following files: The number of monitoring counters available for assignment when the architecture supports mbm_cntr_assign mode. =20 +"mbm_assign_control": + Reports the resctrl group and monitor status of each group. + + List follows the following format: + "//=3D" + + Format for specific type of groups: + + * Default CTRL_MON group: + "//=3D" + + * Non-default CTRL_MON group: + "//=3D" + + * Child MON group of default CTRL_MON group: + "//=3D" + + * Child MON group of non-default CTRL_MON group: + "//=3D" + + Flags can be one of the following: + :: + + t MBM total event is assigned. + l MBM local event is assigned. + tl Both total and local MBM events are assigned. + _ None of the MBM events are assigned. + + Examples: + :: + + # mkdir /sys/fs/resctrl/mon_groups/child_default_mon_grp + # mkdir /sys/fs/resctrl/non_default_ctrl_mon_grp + # mkdir /sys/fs/resctrl/non_default_ctrl_mon_grp/mon_groups/child_non_de= fault_mon_grp + + # cat /sys/fs/resctrl/info/L3_MON/mbm_assign_control + non_default_ctrl_mon_grp//0=3Dtl;1=3Dtl; + non_default_ctrl_mon_grp/child_non_default_mon_grp/0=3Dtl;1=3Dtl; + //0=3Dtl;1=3Dtl; + /child_default_mon_grp/0=3Dtl;1=3Dtl; + + There are four resctrl groups. All the groups have total and local MBM ev= ents + assigned on domain 0 and 1. + "max_threshold_occupancy": Read/write file provides the largest value (in bytes) at which a previously used LLC_occupancy diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 395d99984893..fa7c77935080 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -1269,6 +1269,7 @@ int __init rdt_get_mon_l3_config(struct rdt_resource = *r) r->mon.num_mbm_cntrs =3D (ebx & GENMASK(15, 0)) + 1; resctrl_file_fflags_init("num_mbm_cntrs", RFTYPE_MON_INFO); hw_res->mbm_cntr_assign_enabled =3D true; + resctrl_file_fflags_init("mbm_assign_control", RFTYPE_MON_INFO); } } =20 diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index cf2e0ad0e4f4..cf92ceb0f05e 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -970,6 +970,76 @@ static int rdtgroup_num_mbm_cntrs_show(struct kernfs_o= pen_file *of, return 0; } =20 +static bool resctrl_mbm_event_assigned(struct rdtgroup *rdtg, + struct rdt_mon_domain *d, u32 evtid) +{ + int index =3D MBM_EVENT_ARRAY_INDEX(evtid); + int cntr_id =3D rdtg->mon.cntr_id[index]; + + return cntr_id !=3D MON_CNTR_UNSET && test_bit(cntr_id, d->mbm_cntr_map); +} + +static char *rdtgroup_mon_state_to_str(struct rdtgroup *rdtgrp, + struct rdt_mon_domain *d, char *str) +{ + char *tmp =3D str; + + /* Query the total and local event flags for the domain */ + if (resctrl_mbm_event_assigned(rdtgrp, d, QOS_L3_MBM_TOTAL_EVENT_ID)) + *tmp++ =3D 't'; + + if (resctrl_mbm_event_assigned(rdtgrp, d, QOS_L3_MBM_LOCAL_EVENT_ID)) + *tmp++ =3D 'l'; + + if (tmp =3D=3D str) + *tmp++ =3D '_'; + + *tmp =3D '\0'; + return str; +} + +static int rdtgroup_mbm_assign_control_show(struct kernfs_open_file *of, + struct seq_file *s, void *v) +{ + struct rdt_resource *r =3D of->kn->parent->priv; + struct rdt_mon_domain *dom; + struct rdtgroup *rdtg; + char str[10]; + + mutex_lock(&rdtgroup_mutex); + rdt_last_cmd_clear(); + + if (!resctrl_arch_mbm_cntr_assign_enabled(r)) { + rdt_last_cmd_puts("mbm_cntr_assign mode is not enabled\n"); + mutex_unlock(&rdtgroup_mutex); + return -EINVAL; + } + + list_for_each_entry(rdtg, &rdt_all_groups, rdtgroup_list) { + struct rdtgroup *crg; + + seq_printf(s, "%s//", rdtg->kn->name); + + list_for_each_entry(dom, &r->mon_domains, hdr.list) + seq_printf(s, "%d=3D%s;", dom->hdr.id, + rdtgroup_mon_state_to_str(rdtg, dom, str)); + seq_putc(s, '\n'); + + list_for_each_entry(crg, &rdtg->mon.crdtgrp_list, + mon.crdtgrp_list) { + seq_printf(s, "%s/%s/", rdtg->kn->name, crg->kn->name); + + list_for_each_entry(dom, &r->mon_domains, hdr.list) + seq_printf(s, "%d=3D%s;", dom->hdr.id, + rdtgroup_mon_state_to_str(crg, dom, str)); + seq_putc(s, '\n'); + } + } + + mutex_unlock(&rdtgroup_mutex); + return 0; +} + #ifdef CONFIG_PROC_CPU_RESCTRL =20 /* @@ -2256,6 +2326,12 @@ static struct rftype res_common_files[] =3D { .kf_ops =3D &rdtgroup_kf_single_ops, .seq_show =3D rdtgroup_num_mbm_cntrs_show, }, + { + .name =3D "mbm_assign_control", + .mode =3D 0444, + .kf_ops =3D &rdtgroup_kf_single_ops, + .seq_show =3D rdtgroup_mbm_assign_control_show, + }, { .name =3D "cpus_list", .mode =3D 0644, --=20 2.34.1 From nobody Wed Nov 27 12:26:58 2024 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2073.outbound.protection.outlook.com [40.107.95.73]) (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 9546B1DFE0E; Wed, 9 Oct 2024 17:43:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.95.73 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728495812; cv=fail; b=uBybiiqNvQU6yUzv4pmM+U77Jrh9nUau1OC0y0DcsN6/sU1SAoF008TRXY6+izUpiEZc2tHddKEJihLE0JwVtjNQARZyI/vxMiVn9OvLqRbSHqlYVV78QFHt1Ke11zoB/iRWhp3uy+yuX1oVzrLmFS2Vg3hCKuljL8GEBK4+bJ0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728495812; c=relaxed/simple; bh=bK/ojl/wBbcH/26aXwlmp1CbiBI8qkRQiZjcLS0V+3E=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fjkxbAfAC76xWDirhddM2mtd7Qf8UiTndlkKu45h9XDquLN3cqQyUwlBydgKHKi1DnmIVajuBfBGAS3eMXQUJTJEDTHPJbyok32kcx8L0nX1YipE+yzhgoImD05oOAvZu7ln+Qcnx0+sdgNdOAKEpw2P4CtQpO3X/VM3lRjgnGA= 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=LmPZ4u8U; arc=fail smtp.client-ip=40.107.95.73 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="LmPZ4u8U" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=pp/0V4/LRGjsNQSq2IgZtZlRvaFZfhXha5oATXGt5Qm+uPRJ9QvkQMkjj78g6knn8kvT16U64AHotmY2clXnEaEAR8Uyl0clMPQ7xS1dn9jQ7iKp0HoZZy5tEBk5puOsJ2G75b4sK75h3t86m9ML2fBANhCJ+3ImBjq6SweeNXYBQjTIsewwzSmWVYvklpV4Prk2tAd5lC6vRiL3bbkXL6Bmo4dURnXOjUE6kU7xsMQTt2sdIHILzjsWEhUGU8eyuOe1w/Xkvmfz0qPOJ6hmiA8lCe9lot7eQ9mbxR6teOi4Apjt+J8kqB/+R5F39HJ4yC3GUJ2s0C1GpDWmRGViAg== 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=OdJ7A6iYNpGAyUVxO7RNZz7dBVSTFvxNxLDFKM0Whsw=; b=iWKBt1ELB22HwTwxlGFXEFo6LrryrbikyJVcFzf6gwBCUzkW5ouokgWOWdYoSH05FX8DbDA68d6/zcxfaogpViUgPTQwGs7Nwa/FR3p2qgyyhybuVYCftmCu6vxK3AT+dU8H5kswtdtY8zh5NWV0p7PfjcKAvU1Fp/qUkHO9ZXt5+4kZcXalavhkGfnAK/OVCe58BKmJdzTEsw+/ZH7TVx1F1VfsqY9aAK7e+SDw+Y8R7zMy/IQFdRwxTbYmzy15/xAQk7hiV7JmyU0z9/kSttC9AuM3ZoLDSe7sa2dNnrTVsA7Y+QZe+8atZIChYDxZZqJhdtH1e6C06wA+dSB3zQ== 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=OdJ7A6iYNpGAyUVxO7RNZz7dBVSTFvxNxLDFKM0Whsw=; b=LmPZ4u8Uq581QUUOCggW8eEl1wbxqut65i1uvAifOhe25AHuda8fg1FK/359Mve9IHADWofeSPEP+hQLQRvicDn+8dGLGfk0owLe5a2UMzKMZL4feADSvTHIXLMtIsCFdvEqIAdOU6fSGrjX3jyCFf9MR3ReSEYHvMTstf9WoW8= Received: from PH7P221CA0028.NAMP221.PROD.OUTLOOK.COM (2603:10b6:510:32a::16) by IA0PR12MB8647.namprd12.prod.outlook.com (2603:10b6:208:480::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.22; Wed, 9 Oct 2024 17:43:24 +0000 Received: from MWH0EPF000A6730.namprd04.prod.outlook.com (2603:10b6:510:32a:cafe::dc) by PH7P221CA0028.outlook.office365.com (2603:10b6:510:32a::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.18 via Frontend Transport; Wed, 9 Oct 2024 17:43:24 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000A6730.mail.protection.outlook.com (10.167.249.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8048.13 via Frontend Transport; Wed, 9 Oct 2024 17:43:22 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 9 Oct 2024 12:43:20 -0500 From: Babu Moger To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v8 25/25] x86/resctrl: Introduce interface to modify assignment states of the groups Date: Wed, 9 Oct 2024 12:39:50 -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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000A6730:EE_|IA0PR12MB8647:EE_ X-MS-Office365-Filtering-Correlation-Id: 5b3f8933-bc75-4abf-cceb-08dce889df0e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?B?UytFSGR4V2ZHOVhLQ3drRUhjdUM0SzJGYzdwQ0FiTityV20yY0FnNUNDRXRv?= =?utf-8?B?VWlaK2pjSEQxOU1QUTBxNStuaHpTTk54eklMd0J6bjRCWjRmTkJmWVFjOG9y?= =?utf-8?B?ME1takZ4djNaY2dzakduV0hiazk1cmFVKzMvSnRyY2lrWG13RkJzcEJWWFYw?= =?utf-8?B?OUpYckRYOVNseWE0QmJsUXBPYU0welZ3UHdRanV3WGtNZjZGVVljWllXSVRM?= =?utf-8?B?K21EcVpVcUFpYWZiOWRLNkVidC9WR1llWUVPNk9iL3lPUklQU1E5aERqbzd2?= =?utf-8?B?MzNUTkw1ZFArUnI5eWduYy8vZTlkM21Da1dhMXJHRW0vdURadkNJTUpIWUJV?= =?utf-8?B?eWMxSE5BWW9jYUVJLy9KVkdaYWNaalRRaVlQaUxHSmd3RSt0YmlVOXNkU0p5?= =?utf-8?B?bkQ3bloyQ3J1QWc2VDEweWNpUnJRVm8rTGF2SGJTT0VpMHoyY1hkczFYVFAv?= =?utf-8?B?L2ZKb1pBS3g5RFZKU2tZU0xGOEcwNUNYRlU2U0M2N0FvNWtKRFNQQkp0YUR3?= =?utf-8?B?WnAweDZFblJEUGI3ZndMeFc2dW1lV3RPdWt1UTdsMDRDODV6TlN5eXlVS3d5?= =?utf-8?B?S2JvNzNWR1BVYVYyWmZLbG9jZVBSdDUxTnNvc1piR0ZGMUI0dGVoaHJHRmpq?= =?utf-8?B?SmhTakRrOUwxTnF0NGV1ZU4rakpiTDJadTRtNDVSTkNQeVJCRlc1V2RWOHZF?= =?utf-8?B?amlDdjFYdUZJV0l4cW9QRDhndmtNY3JHTU1SckxKR25PVXpaaUdSOERrS3BR?= =?utf-8?B?UXpXcndWZE9QZTZCUVQwajB2R05qTmF3b05IT2p2bzhETkN5UXhqaDlmM3RR?= =?utf-8?B?cDV5YjJyc2tHb2tlaTJaRms0S1JzQ1M4a2hoR0RIRkJTUkZpYklObjVHcFRw?= =?utf-8?B?R0pFOGo3RWRtekxROGkxcGhSSlhDSmM5UzMxUUpzZWtpWWFWYW81bHdlTDdO?= =?utf-8?B?OGF4NzM5YUJJTnBCUjd4aVZrVkZBcmFCTHQzanNOVlRLQU14OGxqYmR1ZEFt?= =?utf-8?B?Si9SSm5kWno4cmJaRUIvTFphMHpZOXBKLzB0a0EzanpCYjltVm5RSzNveXEx?= =?utf-8?B?SmhLYkN4dUt5ZEVDaDdIZXI4N0JqbEtBZVNNQlF0NE42WnVRMkVYT2JLeFdE?= =?utf-8?B?RDVObzIrWGJ5VXBNTFV2cFdiM0xHVUdUczhOZnlhenNjMTJySjVPK2FCRHNl?= =?utf-8?B?UEw5MTdWTFZOOHR0c0ZSRDErSHFkTmJNMkdLYTdmNlBucExpcnFHdTBtUENE?= =?utf-8?B?Sy9hNDhtVFdCREFqYmxlR20vKzBhZTFUaVZVbmhJRVNCdnhhcE9mcTRtSkI3?= =?utf-8?B?SnBmTlFEaXpoOEhwQm1ZZis3NFN5aGt1b1NWYVBHV0hjaUNCeW5oM05nQWRz?= =?utf-8?B?bGZjb1FIc2RWaDc5Z25RdE5qbUMyWEhxZ0RqQnY5Y0pTdXhNSFJMZ2hFMjFH?= =?utf-8?B?bkoyR29yR2ZnU1ZaWWFmQ3ZJMlVDV0VoMXl4RE1TSzB6TXoxRUcvWjNtWUhu?= =?utf-8?B?MkxNVVZyUXNhQzZFcTZSNUJoTUFRdXZ1UU1WWGlkYVZPdmlvaTF5b1F1VnhY?= =?utf-8?B?SzArUGp3ZWd0VVFGL1d2UHFCd3llTEJLTmNaQTVoQ3R5eWJyd0pWYTMrZEM4?= =?utf-8?B?SmtZeTFlaDZGbUxKNGVxUFlldUFEbmRkeDFrVmYwWTNCczd1MFJZUmhTcWNT?= =?utf-8?B?RVR0bFlSb211NkxxNlhCSDBjeWdnVFVRSGdYK0t0NzRxOFA4TmVGTXR0WGxH?= =?utf-8?B?cEhnZUVXMkt3K1dlSlI2NFBjRGIzSjdPVjNVa3FIZW1ESzJ1Zk9QWG85a21Y?= =?utf-8?B?MUx5ekp1WkR2RWRBNTQ1Qm9YMk1semg4YjFtcmI2c2Y3SjMrcjBPYm9FdXZw?= =?utf-8?Q?gM7VhbThIHx6l?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(376014)(1800799024)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2024 17:43:22.8501 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5b3f8933-bc75-4abf-cceb-08dce889df0e 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: MWH0EPF000A6730.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8647 Introduce the interface to assign MBM events in mbm_cntr_assign mode. Events can be enabled or disabled by writing to file /sys/fs/resctrl/info/L3_MON/mbm_assign_control Format is similar to the list format with addition of opcode for the assignment operation. "//" Format for specific type of groups: * Default CTRL_MON group: "//" * Non-default CTRL_MON group: "//" * Child MON group of default CTRL_MON group: "//" * Child MON group of non-default CTRL_MON group: "//" Domain_id '*' will apply the flags on all the domains. Opcode can be one of the following: =3D Update the assignment to match the flags + Assign a new MBM event without impacting existing assignments. - Unassign a MBM event from currently assigned events. Assignment flags can be one of the following: t MBM total event l MBM local event tl Both total and local MBM events _ None of the MBM events. Valid only with '=3D' opcode. This flag cannot be combined with other flags. Signed-off-by: Babu Moger --- v8: Moved unassign as the first action during the assign modification. Assign none "_" takes priority. Cannot be mixed with other flags. Updated the documentation and .rst file format. htmldoc looks ok. v7: Simplified the parsing (strsep(&token, "//") in rdtgroup_mbm_assign_con= trol_write(). Added mutex lock in rdtgroup_mbm_assign_control_write() while processin= g. Renamed rdtgroup_find_grp to rdtgroup_find_grp_by_name. Fixed rdtgroup_str_to_mon_state to return error for invalid flags. Simplified the calls rdtgroup_assign_cntr by merging few functions earl= ier. Removed ABMC reference in FS code. Reinette commented about handling the combination of flags like 'lt_' a= nd '_lt'. Not sure if we need to change the behaviour here. Processed them sequen= cially right now. Users have the liberty to pass the flags. Restricting it might be a pro= blem later. v6: Added support assign all if domain id is '*' Fixed the allocation of counter id if it not assigned already. v5: Interface name changed from mbm_assign_control to mbm_control. Fixed opcode and flags combination. '=3D_" is valid. "-_" amd "+_" is not valid. Minor message update. Renamed the function with prefix - rdtgroup_. Corrected few documentation mistakes. Rebase related changes after SNC support. v4: Added domain specific assignments. Fixed the opcode parsing. v3: New patch. Addresses the feedback to provide the global assignment interface. https://lore.kernel.org/lkml/c73f444b-83a1-4e9a-95d3-54c5165ee782@intel= .com/ --- Documentation/arch/x86/resctrl.rst | 115 +++++++++++- arch/x86/kernel/cpu/resctrl/internal.h | 10 ++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 233 ++++++++++++++++++++++++- 3 files changed, 356 insertions(+), 2 deletions(-) diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/re= sctrl.rst index b85d3bc3e301..77bb0b095127 100644 --- a/Documentation/arch/x86/resctrl.rst +++ b/Documentation/arch/x86/resctrl.rst @@ -336,7 +336,8 @@ with the following files: t MBM total event is assigned. l MBM local event is assigned. tl Both total and local MBM events are assigned. - _ None of the MBM events are assigned. + _ None of the MBM events are assigned. Only works with opcode '=3D' for= write + and cannot be combined with other flags. =20 Examples: :: @@ -354,6 +355,118 @@ with the following files: There are four resctrl groups. All the groups have total and local MBM ev= ents assigned on domain 0 and 1. =20 + Assignment state can be updated by writing to the interface. + + Format is similar to the list format with addition of opcode for the + assignment operation. + + "//" + + Format for each type of groups: + + * Default CTRL_MON group: + "//" + + * Non-default CTRL_MON group: + "//" + + * Child MON group of default CTRL_MON group: + "//" + + * Child MON group of non-default CTRL_MON group: + "//" + + Domain_id '*' will apply the flags on all the domains. + + Opcode can be one of the following: + :: + + =3D Update the assignment to match the MBM event. + + Assign a new MBM event without impacting existing assignments. + - Unassign a MBM event from currently assigned events. + + Examples: + Initial group status: + :: + + # cat /sys/fs/resctrl/info/L3_MON/mbm_assign_control + non_default_ctrl_mon_grp//0=3Dtl;1=3Dtl; + non_default_ctrl_mon_grp/child_non_default_mon_grp/0=3Dtl;1=3Dtl; + //0=3Dtl;1=3Dtl; + /child_default_mon_grp/0=3Dtl;1=3Dtl; + + To update the default group to assign only total MBM event on domain 0: + :: + + # echo "//0=3Dt" > /sys/fs/resctrl/info/L3_MON/mbm_assign_control + + Assignment status after the update: + :: + + # cat /sys/fs/resctrl/info/L3_MON/mbm_assign_control + non_default_ctrl_mon_grp//0=3Dtl;1=3Dtl; + non_default_ctrl_mon_grp/child_non_default_mon_grp/0=3Dtl;1=3Dtl; + //0=3Dt;1=3Dtl; + /child_default_mon_grp/0=3Dtl;1=3Dtl; + + To update the MON group child_default_mon_grp to remove total MBM event o= n domain 1: + :: + + # echo "/child_default_mon_grp/1-t" > /sys/fs/resctrl/info/L3_MON/mbm_a= ssign_control + + Assignment status after the update: + :: + + $ cat /sys/fs/resctrl/info/L3_MON/mbm_assign_control + non_default_ctrl_mon_grp//0=3Dtl;1=3Dtl; + non_default_ctrl_mon_grp/child_non_default_mon_grp/0=3Dtl;1=3Dtl; + //0=3Dt;1=3Dtl; + /child_default_mon_grp/0=3Dtl;1=3Dl; + + To update the MON group non_default_ctrl_mon_grp/child_non_default_mon_gr= p to unassign + both local and total MBM events on domain 1: + :: + + # echo "non_default_ctrl_mon_grp/child_non_default_mon_grp/1=3D_" > + /sys/fs/resctrl/info/L3_MON/mbm_assign_control + + Assignment status after the update: + :: + + non_default_ctrl_mon_grp//0=3Dtl;1=3Dtl; + non_default_ctrl_mon_grp/child_non_default_mon_grp/0=3Dtl;1=3D_; + //0=3Dt;1=3Dtl; + /child_default_mon_grp/0=3Dtl;1=3Dl; + + To update the default group to add a local MBM event domain 0. + :: + + # echo "//0+l" > /sys/fs/resctrl/info/L3_MON/mbm_assign_control + + Assignment status after the update: + :: + + # cat /sys/fs/resctrl/info/L3_MON/mbm_assign_control + non_default_ctrl_mon_grp//0=3Dtl;1=3Dtl; + non_default_ctrl_mon_grp/child_non_default_mon_grp/0=3Dtl;1=3D_; + //0=3Dtl;1=3Dtl; + /child_default_mon_grp/0=3Dtl;1=3Dl; + + To update the non default CTRL_MON group non_default_ctrl_mon_grp to unas= sign all the + MBM events on all the domains. + :: + + # echo "non_default_ctrl_mon_grp//*=3D_" > /sys/fs/resctrl/info/L3_MON/= mbm_assign_control + + Assignment status after the update: + :: + + #cat /sys/fs/resctrl/info/L3_MON/mbm_assign_control + non_default_ctrl_mon_grp//0=3D_;1=3D_; + non_default_ctrl_mon_grp/child_non_default_mon_grp/0=3Dtl;1=3D_; + //0=3Dtl;1=3Dtl; + /child_default_mon_grp/0=3Dtl;1=3Dl; + "max_threshold_occupancy": Read/write file provides the largest value (in bytes) at which a previously used LLC_occupancy diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index a6f40d3115f4..e8d6a430dc4a 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -74,6 +74,16 @@ */ #define MBM_EVENT_ARRAY_INDEX(_event) ((_event) - 2) =20 +/* + * Assignment flags for mbm_cntr_assign feature + */ +enum { + ASSIGN_NONE =3D 0, + ASSIGN_TOTAL =3D BIT(QOS_L3_MBM_TOTAL_EVENT_ID), + ASSIGN_LOCAL =3D BIT(QOS_L3_MBM_LOCAL_EVENT_ID), + ASSIGN_INVALID, +}; + /** * cpumask_any_housekeeping() - Choose any CPU in @mask, preferring those = that * aren't marked nohz_full diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index cf92ceb0f05e..6095146e3ba4 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -1040,6 +1040,236 @@ static int rdtgroup_mbm_assign_control_show(struct = kernfs_open_file *of, return 0; } =20 +static int rdtgroup_str_to_mon_state(char *flag) +{ + int i, mon_state =3D ASSIGN_NONE; + + for (i =3D 0; i < strlen(flag); i++) { + switch (*(flag + i)) { + case 't': + mon_state |=3D ASSIGN_TOTAL; + break; + case 'l': + mon_state |=3D ASSIGN_LOCAL; + break; + case '_': + return ASSIGN_NONE; + default: + return ASSIGN_INVALID; + } + } + + return mon_state; +} + +static struct rdtgroup *rdtgroup_find_grp_by_name(enum rdt_group_type rtyp= e, + char *p_grp, char *c_grp) +{ + struct rdtgroup *rdtg, *crg; + + if (rtype =3D=3D RDTCTRL_GROUP && *p_grp =3D=3D '\0') { + return &rdtgroup_default; + } else if (rtype =3D=3D RDTCTRL_GROUP) { + list_for_each_entry(rdtg, &rdt_all_groups, rdtgroup_list) + if (!strcmp(p_grp, rdtg->kn->name)) + return rdtg; + } else if (rtype =3D=3D RDTMON_GROUP) { + list_for_each_entry(rdtg, &rdt_all_groups, rdtgroup_list) { + if (!strcmp(p_grp, rdtg->kn->name)) { + list_for_each_entry(crg, &rdtg->mon.crdtgrp_list, + mon.crdtgrp_list) { + if (!strcmp(c_grp, crg->kn->name)) + return crg; + } + } + } + } + + return NULL; +} + +static int rdtgroup_process_flags(struct rdt_resource *r, + enum rdt_group_type rtype, + char *p_grp, char *c_grp, char *tok) +{ + int op, mon_state, assign_state, unassign_state; + char *dom_str, *id_str, *op_str; + struct rdt_mon_domain *d; + struct rdtgroup *rdtgrp; + unsigned long dom_id; + int ret, found =3D 0; + + rdtgrp =3D rdtgroup_find_grp_by_name(rtype, p_grp, c_grp); + + if (!rdtgrp) { + rdt_last_cmd_puts("Not a valid resctrl group\n"); + return -EINVAL; + } + +next: + if (!tok || tok[0] =3D=3D '\0') + return 0; + + /* Start processing the strings for each domain */ + dom_str =3D strim(strsep(&tok, ";")); + + op_str =3D strpbrk(dom_str, "=3D+-"); + + if (op_str) { + op =3D *op_str; + } else { + rdt_last_cmd_puts("Missing operation =3D, +, - character\n"); + return -EINVAL; + } + + id_str =3D strsep(&dom_str, "=3D+-"); + + /* Check for domain id '*' which means all domains */ + if (id_str && *id_str =3D=3D '*') { + d =3D NULL; + goto check_state; + } else if (!id_str || kstrtoul(id_str, 10, &dom_id)) { + rdt_last_cmd_puts("Missing domain id\n"); + return -EINVAL; + } + + /* Verify if the dom_id is valid */ + list_for_each_entry(d, &r->mon_domains, hdr.list) { + if (d->hdr.id =3D=3D dom_id) { + found =3D 1; + break; + } + } + + if (!found) { + rdt_last_cmd_printf("Invalid domain id %ld\n", dom_id); + return -EINVAL; + } + +check_state: + mon_state =3D rdtgroup_str_to_mon_state(dom_str); + + if (mon_state =3D=3D ASSIGN_INVALID) { + rdt_last_cmd_puts("Invalid assign flag\n"); + goto out_fail; + } + + assign_state =3D 0; + unassign_state =3D 0; + + switch (op) { + case '+': + if (mon_state =3D=3D ASSIGN_NONE) { + rdt_last_cmd_puts("Invalid assign opcode\n"); + goto out_fail; + } + assign_state =3D mon_state; + break; + case '-': + if (mon_state =3D=3D ASSIGN_NONE) { + rdt_last_cmd_puts("Invalid assign opcode\n"); + goto out_fail; + } + unassign_state =3D mon_state; + break; + case '=3D': + assign_state =3D mon_state; + unassign_state =3D (ASSIGN_TOTAL | ASSIGN_LOCAL) & ~assign_state; + break; + default: + break; + } + + if (unassign_state & ASSIGN_TOTAL) { + ret =3D rdtgroup_unassign_cntr_event(r, rdtgrp, d, QOS_L3_MBM_TOTAL_EVEN= T_ID); + if (ret) + goto out_fail; + } + + if (unassign_state & ASSIGN_LOCAL) { + ret =3D rdtgroup_unassign_cntr_event(r, rdtgrp, d, QOS_L3_MBM_LOCAL_EVEN= T_ID); + if (ret) + goto out_fail; + } + + if (assign_state & ASSIGN_TOTAL) { + ret =3D rdtgroup_assign_cntr_event(r, rdtgrp, d, QOS_L3_MBM_TOTAL_EVENT_= ID); + if (ret) + goto out_fail; + } + + if (assign_state & ASSIGN_LOCAL) { + ret =3D rdtgroup_assign_cntr_event(r, rdtgrp, d, QOS_L3_MBM_LOCAL_EVENT_= ID); + if (ret) + goto out_fail; + } + + goto next; + +out_fail: + + return -EINVAL; +} + +static ssize_t rdtgroup_mbm_assign_control_write(struct kernfs_open_file *= of, + char *buf, size_t nbytes, loff_t off) +{ + struct rdt_resource *r =3D of->kn->parent->priv; + char *token, *cmon_grp, *mon_grp; + enum rdt_group_type rtype; + int ret; + + /* Valid input requires a trailing newline */ + if (nbytes =3D=3D 0 || buf[nbytes - 1] !=3D '\n') + return -EINVAL; + + buf[nbytes - 1] =3D '\0'; + + cpus_read_lock(); + mutex_lock(&rdtgroup_mutex); + + if (!resctrl_arch_mbm_cntr_assign_enabled(r)) { + rdt_last_cmd_puts("mbm_cntr_assign mode is not enabled\n"); + mutex_unlock(&rdtgroup_mutex); + cpus_read_unlock(); + return -EINVAL; + } + + rdt_last_cmd_clear(); + + while ((token =3D strsep(&buf, "\n")) !=3D NULL) { + if (strstr(token, "/")) { + /* + * The write command follows the following format: + * =E2=80=9C//=E2= =80=9D + * Extract the CTRL_MON group. + */ + cmon_grp =3D strsep(&token, "/"); + + /* + * Extract the MON_GROUP. + * strsep returns empty string for contiguous delimiters. + * Empty mon_grp here means it is a RDTCTRL_GROUP. + */ + mon_grp =3D strsep(&token, "/"); + + if (*mon_grp =3D=3D '\0') + rtype =3D RDTCTRL_GROUP; + else + rtype =3D RDTMON_GROUP; + + ret =3D rdtgroup_process_flags(r, rtype, cmon_grp, mon_grp, token); + if (ret) + break; + } + } + + mutex_unlock(&rdtgroup_mutex); + cpus_read_unlock(); + + return ret ?: nbytes; +} + #ifdef CONFIG_PROC_CPU_RESCTRL =20 /* @@ -2328,9 +2558,10 @@ static struct rftype res_common_files[] =3D { }, { .name =3D "mbm_assign_control", - .mode =3D 0444, + .mode =3D 0644, .kf_ops =3D &rdtgroup_kf_single_ops, .seq_show =3D rdtgroup_mbm_assign_control_show, + .write =3D rdtgroup_mbm_assign_control_write, }, { .name =3D "cpus_list", --=20 2.34.1