The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: James Morse <james.morse@arm.com>
To: x86@kernel.org, linux-kernel@vger.kernel.org
Cc: Reinette Chatre <reinette.chatre@intel.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	H Peter Anvin <hpa@zytor.com>, Babu Moger <Babu.Moger@amd.com>,
	James Morse <james.morse@arm.com>,
	shameerali.kolothum.thodi@huawei.com,
	D Scott Phillips OS <scott@os.amperecomputing.com>,
	carl@os.amperecomputing.com, lcherian@marvell.com,
	bobo.shaobowang@huawei.com, tan.shaopeng@fujitsu.com,
	baolin.wang@linux.alibaba.com,
	Jamie Iles <quic_jiles@quicinc.com>,
	Xin Hao <xhao@linux.alibaba.com>,
	peternewman@google.com, dfustini@baylibre.com,
	amitsinght@marvell.com, David Hildenbrand <david@redhat.com>,
	Rex Nie <rex.nie@jaguarmicro.com>,
	Dave Martin <dave.martin@arm.com>, Koba Ko <kobak@nvidia.com>,
	Shanker Donthineni <sdonthineni@nvidia.com>,
	fenghuay@nvidia.com, Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>,
	Babu Moger <babu.moger@amd.com>, Tony Luck <tony.luck@intel.com>
Subject: [PATCH v8:for-boris 13/30] x86/resctrl: Move resctrl types to a separate header
Date: Tue, 11 Mar 2025 18:36:58 +0000	[thread overview]
Message-ID: <20250311183715.16445-14-james.morse@arm.com> (raw)
In-Reply-To: <20250311183715.16445-1-james.morse@arm.com>

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>
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>
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>
---
Changes since v6:
 * Used a different year in the boiler-plate copyright notice.

Change since v3:
 * Added header include.
 * Corrected lists in the commit message.

Changes since v2:
 * Added to the commit message why each of these things is necessary.
 * Moved the enum resctrl_conf_type back to resctrl.h - this week arm's
   CDP emulation code gets away without this...

Changes since v1:
 * [Commit message only] Rewrite commit message to clarify the the
   rationale for refactoring the headers in this way.
---
 MAINTAINERS                            |  1 +
 arch/x86/include/asm/resctrl.h         |  1 +
 arch/x86/kernel/cpu/resctrl/internal.h | 24 ------------
 include/linux/resctrl.h                | 21 +---------
 include/linux/resctrl_types.h          | 54 ++++++++++++++++++++++++++
 5 files changed, 57 insertions(+), 44 deletions(-)
 create mode 100644 include/linux/resctrl_types.h

diff --git a/MAINTAINERS b/MAINTAINERS
index efee40ea589f..3487ac429a9a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -19881,6 +19881,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)
diff --git a/arch/x86/include/asm/resctrl.h b/arch/x86/include/asm/resctrl.h
index 6908cd0e6e40..52f2326e2b1e 100644
--- a/arch/x86/include/asm/resctrl.h
+++ b/arch/x86/include/asm/resctrl.h
@@ -6,6 +6,7 @@
 
 #include <linux/jump_label.h>
 #include <linux/percpu.h>
+#include <linux/resctrl_types.h>
 #include <linux/sched.h>
 
 /*
diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h
index da73404183da..5f3713fb2eaf 100644
--- a/arch/x86/kernel/cpu/resctrl/internal.h
+++ b/arch/x86/kernel/cpu/resctrl/internal.h
@@ -32,30 +32,6 @@
  */
 #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
diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h
index 93d9a435f035..326f7ba220e7 100644
--- a/include/linux/resctrl.h
+++ b/include/linux/resctrl.h
@@ -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
index 000000000000..f26450b3326b
--- /dev/null
+++ b/include/linux/resctrl_types.h
@@ -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 */
-- 
2.39.5


  parent reply	other threads:[~2025-03-11 18:40 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-11 18:36 [PATCH v8:for-boris 00/30] x86/resctrl: Move the resctrl filesystem code to /fs/resctrl James Morse
2025-03-11 18:36 ` [PATCH v8:for-boris 01/30] x86/resctrl: Fix allocation of cleanest CLOSID on platforms with no monitors James Morse
2025-03-12 17:20   ` [tip: x86/cache] " tip-bot2 for James Morse
2025-03-11 18:36 ` [PATCH v8:for-boris 02/30] x86/resctrl: Add a helper to avoid reaching into the arch code resource list James Morse
2025-03-12 17:20   ` [tip: x86/cache] " tip-bot2 for James Morse
2025-03-11 18:36 ` [PATCH v8:for-boris 03/30] x86/resctrl: Remove fflags from struct rdt_resource James Morse
2025-03-12 17:20   ` [tip: x86/cache] " tip-bot2 for James Morse
2025-03-11 18:36 ` [PATCH v8:for-boris 04/30] x86/resctrl: Use schema type to determine how to parse schema values James Morse
2025-03-12 17:20   ` [tip: x86/cache] " tip-bot2 for James Morse
2025-03-11 18:36 ` [PATCH v8:for-boris 05/30] x86/resctrl: Use schema type to determine the schema format string James Morse
2025-03-12 17:20   ` [tip: x86/cache] " tip-bot2 for James Morse
2025-03-11 18:36 ` [PATCH v8:for-boris 06/30] x86/resctrl: Remove data_width and the tabular format James Morse
2025-03-12 17:20   ` [tip: x86/cache] " tip-bot2 for James Morse
2025-03-11 18:36 ` [PATCH v8:for-boris 07/30] x86/resctrl: Add max_bw to struct resctrl_membw James Morse
2025-03-12 17:20   ` [tip: x86/cache] " tip-bot2 for James Morse
2025-03-11 18:36 ` [PATCH v8:for-boris 08/30] x86/resctrl: Generate default_ctrl instead of sharing it James Morse
2025-03-12  4:46   ` Reinette Chatre
2025-03-12 17:20   ` [tip: x86/cache] " tip-bot2 for James Morse
2025-03-11 18:36 ` [PATCH v8:for-boris 09/30] x86/resctrl: Add helper for setting CPU default properties James Morse
2025-03-12 17:20   ` [tip: x86/cache] " tip-bot2 for James Morse
2025-03-11 18:36 ` [PATCH v8:for-boris 10/30] x86/resctrl: Remove rdtgroup from update_cpu_closid_rmid() James Morse
2025-03-12 17:20   ` [tip: x86/cache] " tip-bot2 for James Morse
2025-03-11 18:36 ` [PATCH v8:for-boris 11/30] x86/resctrl: Expose resctrl fs's init function to the rest of the kernel James Morse
2025-03-12 17:20   ` [tip: x86/cache] " tip-bot2 for James Morse
2025-03-11 18:36 ` [PATCH v8:for-boris 12/30] x86/resctrl: Move rdt_find_domain() to be visible to arch and fs code James Morse
2025-03-12 17:20   ` [tip: x86/cache] " tip-bot2 for James Morse
2025-03-11 18:36 ` James Morse [this message]
2025-03-12 17:20   ` [tip: x86/cache] x86/resctrl: Move resctrl types to a separate header tip-bot2 for James Morse
2025-03-11 18:36 ` [PATCH v8:for-boris 14/30] x86/resctrl: Add an arch helper to reset one resource James Morse
2025-03-12 17:20   ` [tip: x86/cache] " tip-bot2 for James Morse
2025-03-11 18:37 ` [PATCH v8:for-boris 15/30] x86/resctrl: Move monitor exit work to a resctrl exit call James Morse
2025-03-12 17:20   ` [tip: x86/cache] " tip-bot2 for James Morse
2025-03-11 18:37 ` [PATCH v8:for-boris 16/30] x86/resctrl: Move monitor init work to a resctrl init call James Morse
2025-03-12 17:20   ` [tip: x86/cache] " tip-bot2 for James Morse
2025-03-11 18:37 ` [PATCH v8:for-boris 17/30] x86/resctrl: Rewrite and move the for_each_*_rdt_resource() walkers James Morse
2025-03-12 17:20   ` [tip: x86/cache] " tip-bot2 for James Morse
2025-03-11 18:37 ` [PATCH v8:for-boris 18/30] x86/resctrl: Move the is_mbm_*_enabled() helpers to asm/resctrl.h James Morse
2025-03-12 17:20   ` [tip: x86/cache] " tip-bot2 for James Morse
2025-03-11 18:37 ` [PATCH v8:for-boris 19/30] x86/resctrl: Add resctrl_arch_is_evt_configurable() to abstract BMEC James Morse
2025-03-12 17:20   ` [tip: x86/cache] " tip-bot2 for James Morse
2025-03-11 18:37 ` [PATCH v8:for-boris 20/30] x86/resctrl: Change mon_event_config_{read,write}() to be arch helpers James Morse
2025-03-12 17:20   ` [tip: x86/cache] " tip-bot2 for James Morse
2025-03-11 18:37 ` [PATCH v8:for-boris 21/30] x86/resctrl: Move mba_mbps_default_event init to filesystem code James Morse
2025-03-12 17:20   ` [tip: x86/cache] " tip-bot2 for James Morse
2025-03-11 18:37 ` [PATCH v8:for-boris 22/30] x86/resctrl: Move mbm_cfg_mask to struct rdt_resource James Morse
2025-03-12  4:47   ` Reinette Chatre
2025-03-12  9:13     ` Borislav Petkov
2025-03-12 17:20   ` [tip: x86/cache] " tip-bot2 for James Morse
2025-03-11 18:37 ` [PATCH v8:for-boris 23/30] x86/resctrl: Add resctrl_arch_ prefix to pseudo lock functions James Morse
2025-03-12 17:20   ` [tip: x86/cache] " tip-bot2 for James Morse
2025-03-11 18:37 ` [PATCH v8:for-boris 24/30] x86/resctrl: Allow an architecture to disable pseudo lock James Morse
2025-03-12 17:20   ` [tip: x86/cache] " tip-bot2 for James Morse
2025-03-11 18:37 ` [PATCH v8:for-boris 25/30] x86/resctrl: Make prefetch_disable_bits belong to the arch code James Morse
2025-03-12 17:20   ` [tip: x86/cache] " tip-bot2 for James Morse
2025-03-11 18:37 ` [PATCH v8:for-boris 26/30] x86/resctrl: Make resctrl_arch_pseudo_lock_fn() take a plr James Morse
2025-03-12 17:20   ` [tip: x86/cache] " tip-bot2 for James Morse
2025-03-11 18:37 ` [PATCH v8:for-boris 27/30] x86/resctrl: Move RFTYPE flags to be managed by resctrl James Morse
2025-03-12 17:20   ` [tip: x86/cache] " tip-bot2 for James Morse
2025-03-11 18:37 ` [PATCH v8:for-boris 28/30] x86/resctrl: Handle throttle_mode for SMBA resources James Morse
2025-03-12 17:20   ` [tip: x86/cache] " tip-bot2 for James Morse
2025-03-11 18:37 ` [PATCH v8:for-boris 29/30] x86/resctrl: Move get_config_index() to a header James Morse
2025-03-12 17:20   ` [tip: x86/cache] " tip-bot2 for James Morse
2025-03-11 18:37 ` [PATCH v8:for-boris 30/30] x86/resctrl: Move get_{mon,ctrl}_domain_from_cpu() to live with their callers James Morse
2025-03-12 17:20   ` [tip: x86/cache] " tip-bot2 for James Morse
2025-03-12  0:29 ` [PATCH v8:for-boris 00/30] x86/resctrl: Move the resctrl filesystem code to /fs/resctrl Moger, Babu
2025-03-12  1:53 ` Luck, Tony
2025-03-12  5:04 ` Reinette Chatre
2025-03-12 10:55 ` Shaopeng Tan (Fujitsu)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250311183715.16445-14-james.morse@arm.com \
    --to=james.morse@arm.com \
    --cc=Babu.Moger@amd.com \
    --cc=amitsinght@marvell.com \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=bobo.shaobowang@huawei.com \
    --cc=bp@alien8.de \
    --cc=carl@os.amperecomputing.com \
    --cc=dave.martin@arm.com \
    --cc=david@redhat.com \
    --cc=dfustini@baylibre.com \
    --cc=fenghuay@nvidia.com \
    --cc=hpa@zytor.com \
    --cc=kobak@nvidia.com \
    --cc=lcherian@marvell.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peternewman@google.com \
    --cc=quic_jiles@quicinc.com \
    --cc=reinette.chatre@intel.com \
    --cc=rex.nie@jaguarmicro.com \
    --cc=scott@os.amperecomputing.com \
    --cc=sdonthineni@nvidia.com \
    --cc=shameerali.kolothum.thodi@huawei.com \
    --cc=tan.shaopeng@fujitsu.com \
    --cc=tan.shaopeng@jp.fujitsu.com \
    --cc=tglx@linutronix.de \
    --cc=tony.luck@intel.com \
    --cc=x86@kernel.org \
    --cc=xhao@linux.alibaba.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox