]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
x86/resctrl: Move resctrl types to a separate header
authorJames Morse <james.morse@arm.com>
Tue, 11 Mar 2025 18:36:58 +0000 (18:36 +0000)
committerBorislav Petkov (AMD) <bp@alien8.de>
Wed, 12 Mar 2025 11:23:00 +0000 (12:23 +0100)
When resctrl is fully factored into core and per-arch code, each arch will
need to use some resctrl common definitions in order to define its own
specializations and helpers.  Following conventional practice, it would be
desirable to put the dependent arch definitions in an <asm/resctrl.h> header
that is included by the common <linux/resctrl.h> header.  However, this can
make it awkward to avoid a circular dependency between <linux/resctrl.h> and
the arch header.

To avoid such dependencies, move the affected common types and constants into
a new header that does not need to depend on <linux/resctrl.h> or on the arch
headers.

The same logic applies to the monitor-configuration defines, move these too.

Some kind of enumeration for events is needed between the filesystem and
architecture code. Take the x86 definition as its convenient for x86.

The definition of enum resctrl_event_id is needed to allow the architecture
code to define resctrl_arch_mon_ctx_alloc() and resctrl_arch_mon_ctx_free().

The definition of enum resctrl_res_level is needed to allow the architecture
code to define resctrl_arch_set_cdp_enabled() and
resctrl_arch_get_cdp_enabled().

The bits for mbm_local_bytes_config et al are ABI, and must be the same on all
architectures. These are documented in Documentation/arch/x86/resctrl.rst

The maintainers entry for these headers was missed when resctrl.h was created.
Add a wildcard entry to match both resctrl.h and resctrl_types.h.

Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
Reviewed-by: Tony Luck <tony.luck@intel.com>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Reviewed-by: Fenghua Yu <fenghuay@nvidia.com>
Reviewed-by: Babu Moger <babu.moger@amd.com>
Tested-by: Carl Worth <carl@os.amperecomputing.com> # arm64
Tested-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
Tested-by: Peter Newman <peternewman@google.com>
Tested-by: Amit Singh Tomar <amitsinght@marvell.com> # arm64
Tested-by: Shanker Donthineni <sdonthineni@nvidia.com> # arm64
Tested-by: Babu Moger <babu.moger@amd.com>
Link: https://lore.kernel.org/r/20250311183715.16445-14-james.morse@arm.com
MAINTAINERS
arch/x86/include/asm/resctrl.h
arch/x86/kernel/cpu/resctrl/internal.h
include/linux/resctrl.h
include/linux/resctrl_types.h [new file with mode: 0644]

index ed7aa6867674ea65e6a92a792d013a946c7de953..2d0b669e7431967a78fcebe4721c55af9a6a86d3 100644 (file)
@@ -19894,6 +19894,7 @@ S:      Supported
 F:     Documentation/arch/x86/resctrl*
 F:     arch/x86/include/asm/resctrl.h
 F:     arch/x86/kernel/cpu/resctrl/
+F:     include/linux/resctrl*.h
 F:     tools/testing/selftests/resctrl/
 
 READ-COPY UPDATE (RCU)
index 6908cd0e6e40157c324a5cbdd0e07d932096cf59..52f2326e2b1e6e20dc7eb13d510f1c8e9ca64844 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <linux/jump_label.h>
 #include <linux/percpu.h>
+#include <linux/resctrl_types.h>
 #include <linux/sched.h>
 
 /*
index da73404183da257fedef6a27a0faeb140ae65712..5f3713fb2eaf13a607209902d68187d5ab952622 100644 (file)
  */
 #define MBM_CNTR_WIDTH_OFFSET_MAX (62 - MBM_CNTR_WIDTH_BASE)
 
-/* Reads to Local DRAM Memory */
-#define READS_TO_LOCAL_MEM             BIT(0)
-
-/* Reads to Remote DRAM Memory */
-#define READS_TO_REMOTE_MEM            BIT(1)
-
-/* Non-Temporal Writes to Local Memory */
-#define NON_TEMP_WRITE_TO_LOCAL_MEM    BIT(2)
-
-/* Non-Temporal Writes to Remote Memory */
-#define NON_TEMP_WRITE_TO_REMOTE_MEM   BIT(3)
-
-/* Reads to Local Memory the system identifies as "Slow Memory" */
-#define READS_TO_LOCAL_S_MEM           BIT(4)
-
-/* Reads to Remote Memory the system identifies as "Slow Memory" */
-#define READS_TO_REMOTE_S_MEM          BIT(5)
-
-/* Dirty Victims to All Types of Memory */
-#define DIRTY_VICTIMS_TO_ALL_MEM       BIT(6)
-
-/* Max event bits supported */
-#define MAX_EVT_CONFIG_BITS            GENMASK(6, 0)
-
 /**
  * cpumask_any_housekeeping() - Choose any CPU in @mask, preferring those that
  *                             aren't marked nohz_full
index 93d9a435f035f67d173abef9f56cdbf38a9b43f3..326f7ba220e79c2c68104c32ed0835a0093b0612 100644 (file)
@@ -6,6 +6,7 @@
 #include <linux/kernel.h>
 #include <linux/list.h>
 #include <linux/pid.h>
+#include <linux/resctrl_types.h>
 
 /* CLOSID, RMID value used by the default control group */
 #define RESCTRL_RESERVED_CLOSID                0
@@ -37,28 +38,8 @@ enum resctrl_conf_type {
        CDP_DATA,
 };
 
-enum resctrl_res_level {
-       RDT_RESOURCE_L3,
-       RDT_RESOURCE_L2,
-       RDT_RESOURCE_MBA,
-       RDT_RESOURCE_SMBA,
-
-       /* Must be the last */
-       RDT_NUM_RESOURCES,
-};
-
 #define CDP_NUM_TYPES  (CDP_DATA + 1)
 
-/*
- * Event IDs, the values match those used to program IA32_QM_EVTSEL before
- * reading IA32_QM_CTR on RDT systems.
- */
-enum resctrl_event_id {
-       QOS_L3_OCCUP_EVENT_ID           = 0x01,
-       QOS_L3_MBM_TOTAL_EVENT_ID       = 0x02,
-       QOS_L3_MBM_LOCAL_EVENT_ID       = 0x03,
-};
-
 /**
  * struct resctrl_staged_config - parsed configuration to be applied
  * @new_ctrl:          new ctrl value to be loaded
diff --git a/include/linux/resctrl_types.h b/include/linux/resctrl_types.h
new file mode 100644 (file)
index 0000000..f26450b
--- /dev/null
@@ -0,0 +1,54 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2025 Arm Ltd.
+ * Based on arch/x86/kernel/cpu/resctrl/internal.h
+ */
+
+#ifndef __LINUX_RESCTRL_TYPES_H
+#define __LINUX_RESCTRL_TYPES_H
+
+/* Reads to Local DRAM Memory */
+#define READS_TO_LOCAL_MEM             BIT(0)
+
+/* Reads to Remote DRAM Memory */
+#define READS_TO_REMOTE_MEM            BIT(1)
+
+/* Non-Temporal Writes to Local Memory */
+#define NON_TEMP_WRITE_TO_LOCAL_MEM    BIT(2)
+
+/* Non-Temporal Writes to Remote Memory */
+#define NON_TEMP_WRITE_TO_REMOTE_MEM   BIT(3)
+
+/* Reads to Local Memory the system identifies as "Slow Memory" */
+#define READS_TO_LOCAL_S_MEM           BIT(4)
+
+/* Reads to Remote Memory the system identifies as "Slow Memory" */
+#define READS_TO_REMOTE_S_MEM          BIT(5)
+
+/* Dirty Victims to All Types of Memory */
+#define DIRTY_VICTIMS_TO_ALL_MEM       BIT(6)
+
+/* Max event bits supported */
+#define MAX_EVT_CONFIG_BITS            GENMASK(6, 0)
+
+enum resctrl_res_level {
+       RDT_RESOURCE_L3,
+       RDT_RESOURCE_L2,
+       RDT_RESOURCE_MBA,
+       RDT_RESOURCE_SMBA,
+
+       /* Must be the last */
+       RDT_NUM_RESOURCES,
+};
+
+/*
+ * Event IDs, the values match those used to program IA32_QM_EVTSEL before
+ * reading IA32_QM_CTR on RDT systems.
+ */
+enum resctrl_event_id {
+       QOS_L3_OCCUP_EVENT_ID           = 0x01,
+       QOS_L3_MBM_TOTAL_EVENT_ID       = 0x02,
+       QOS_L3_MBM_LOCAL_EVENT_ID       = 0x03,
+};
+
+#endif /* __LINUX_RESCTRL_TYPES_H */