linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: James Morse <james.morse@arm.com>
To: x86@kernel.org, linux-kernel@vger.kernel.org
Cc: Fenghua Yu <fenghua.yu@intel.com>,
	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>,
	Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
Subject: [PATCH v5 22/40] x86/resctrl: Move mbm_cfg_mask to struct rdt_resource
Date: Fri,  4 Oct 2024 18:03:29 +0000	[thread overview]
Message-ID: <20241004180347.19985-23-james.morse@arm.com> (raw)
In-Reply-To: <20241004180347.19985-1-james.morse@arm.com>

The mbm_cfg_mask field lists the bits that user-space can set when
configuring an event. This value is output via the last_cmd_status
file.

Once the filesystem parts of resctrl are moved to live in /fs/, the
struct rdt_hw_resource is inaccessible to the filesystem code. Because
this value is output to user-space, it has to be accessible to the
filesystem code.

Move it to struct rdt_resource.

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>
Reviewed-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
---
Change since v1:
 * Reword comments to avoid being overly arch-specific.
---
 arch/x86/kernel/cpu/resctrl/internal.h | 3 ---
 arch/x86/kernel/cpu/resctrl/monitor.c  | 2 +-
 arch/x86/kernel/cpu/resctrl/rdtgroup.c | 5 ++---
 include/linux/resctrl.h                | 3 +++
 4 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h
index 6b076216911c..92a94939cf93 100644
--- a/arch/x86/kernel/cpu/resctrl/internal.h
+++ b/arch/x86/kernel/cpu/resctrl/internal.h
@@ -415,8 +415,6 @@ struct msr_param {
  * @msr_update:		Function pointer to update QOS MSRs
  * @mon_scale:		cqm counter * mon_scale = occupancy in bytes
  * @mbm_width:		Monitor width, to detect and correct for overflow.
- * @mbm_cfg_mask:	Bandwidth sources that can be tracked when Bandwidth
- *			Monitoring Event Configuration (BMEC) is supported.
  * @cdp_enabled:	CDP state of this resource
  *
  * Members of this structure are either private to the architecture
@@ -430,7 +428,6 @@ struct rdt_hw_resource {
 	void			(*msr_update)(struct msr_param *m);
 	unsigned int		mon_scale;
 	unsigned int		mbm_width;
-	unsigned int		mbm_cfg_mask;
 	bool			cdp_enabled;
 };
 
diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c
index ae8552ef98e6..175fd7dbf34f 100644
--- a/arch/x86/kernel/cpu/resctrl/monitor.c
+++ b/arch/x86/kernel/cpu/resctrl/monitor.c
@@ -1256,7 +1256,7 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r)
 
 		/* Detect list of bandwidth sources that can be tracked */
 		cpuid_count(0x80000020, 3, &eax, &ebx, &ecx, &edx);
-		hw_res->mbm_cfg_mask = ecx & MAX_EVT_CONFIG_BITS;
+		r->mbm_cfg_mask = ecx & MAX_EVT_CONFIG_BITS;
 	}
 
 	r->mon_capable = true;
diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
index 304fdf199de7..0f839b5c59da 100644
--- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
+++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
@@ -1722,7 +1722,6 @@ static void mbm_config_write_domain(struct rdt_resource *r,
 
 static int mon_config_write(struct rdt_resource *r, char *tok, u32 evtid)
 {
-	struct rdt_hw_resource *hw_res = resctrl_to_arch_res(r);
 	char *dom_str = NULL, *id_str;
 	unsigned long dom_id, val;
 	struct rdt_mon_domain *d;
@@ -1749,9 +1748,9 @@ static int mon_config_write(struct rdt_resource *r, char *tok, u32 evtid)
 	}
 
 	/* Value from user cannot be more than the supported set of events */
-	if ((val & hw_res->mbm_cfg_mask) != val) {
+	if ((val & r->mbm_cfg_mask) != val) {
 		rdt_last_cmd_printf("Invalid event configuration: max valid mask is 0x%02x\n",
-				    hw_res->mbm_cfg_mask);
+				    r->mbm_cfg_mask);
 		return -EINVAL;
 	}
 
diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h
index 0072c2e5947f..84588ab1994d 100644
--- a/include/linux/resctrl.h
+++ b/include/linux/resctrl.h
@@ -218,6 +218,8 @@ enum resctrl_schema_fmt {
  * @name:		Name to use in "schemata" file.
  * @schema_fmt:	Which format string and parser is used for this schema.
  * @evt_list:		List of monitoring events
+ * @mbm_cfg_mask:	Bandwidth sources that can be tracked when Bandwidth
+ *			Monitoring Event Configuration (BMEC) is supported.
  * @cdp_capable:	Is the CDP feature available on this resource
  */
 struct rdt_resource {
@@ -234,6 +236,7 @@ struct rdt_resource {
 	char			*name;
 	enum resctrl_schema_fmt	schema_fmt;
 	struct list_head	evt_list;
+	unsigned int		mbm_cfg_mask;
 	bool			cdp_capable;
 };
 
-- 
2.39.2


  parent reply	other threads:[~2024-10-04 18:06 UTC|newest]

Thread overview: 102+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-04 18:03 [PATCH v5 00/40] x86/resctrl: Move the resctrl filesystem code to /fs/resctrl James Morse
2024-10-04 18:03 ` [PATCH v5 01/40] x86/resctrl: Fix allocation of cleanest CLOSID on platforms with no monitors James Morse
2024-10-04 18:03 ` [PATCH v5 02/40] x86/resctrl: Add a helper to avoid reaching into the arch code resource list James Morse
2024-10-15 22:57   ` Tony Luck
2024-10-18 17:07     ` James Morse
2024-10-18 17:14       ` Luck, Tony
2024-10-23 21:03   ` Reinette Chatre
2024-10-04 18:03 ` [PATCH v5 03/40] x86/resctrl: Remove fflags from struct rdt_resource James Morse
2024-10-23 21:03   ` Reinette Chatre
2024-12-20 18:10     ` James Morse
2024-10-04 18:03 ` [PATCH v5 04/40] x86/resctrl: Use schema type to determine how to parse schema values James Morse
2024-10-15 23:15   ` Tony Luck
2024-10-18 17:07     ` James Morse
2024-10-23 21:14   ` Reinette Chatre
2024-12-20 18:10     ` James Morse
2024-10-04 18:03 ` [PATCH v5 05/40] x86/resctrl: Use schema type to determine the schema format string James Morse
2024-10-21 17:39   ` Reinette Chatre
2024-10-04 18:03 ` [PATCH v5 06/40] x86/resctrl: Remove data_width and the tabular format James Morse
2024-10-15 23:29   ` Tony Luck
2024-10-18 17:07     ` James Morse
2024-10-04 18:03 ` [PATCH v5 07/40] x86/resctrl: Add max_bw to struct resctrl_membw James Morse
2024-10-09 18:02   ` Tony Luck
2024-10-23 21:14   ` Reinette Chatre
2024-12-20 18:10     ` James Morse
2024-10-04 18:03 ` [PATCH v5 08/40] x86/resctrl: Generate default_ctrl instead of sharing it James Morse
2024-10-23 21:15   ` Reinette Chatre
2025-02-07 15:42     ` James Morse
2024-10-04 18:03 ` [PATCH v5 09/40] x86/resctrl: Add helper for setting CPU default properties James Morse
2024-10-04 18:03 ` [PATCH v5 10/40] x86/resctrl: Remove rdtgroup from update_cpu_closid_rmid() James Morse
2024-10-04 18:03 ` [PATCH v5 11/40] x86/resctrl: Export resctrl fs's init function James Morse
2024-10-16 16:20   ` Tony Luck
2024-10-04 18:03 ` [PATCH v5 12/40] x86/resctrl: Wrap resctrl_arch_find_domain() around rdt_find_domain() James Morse
2024-10-23 21:16   ` Reinette Chatre
2025-02-07 15:42     ` James Morse
2024-10-04 18:03 ` [PATCH v5 13/40] x86/resctrl: Move resctrl types to a separate header James Morse
2024-10-04 18:03 ` [PATCH v5 14/40] x86/resctrl: Add a resctrl helper to reset all the resources James Morse
2024-10-23 21:32   ` Reinette Chatre
2025-02-07 15:43     ` James Morse
2025-02-13 23:52       ` Reinette Chatre
2024-10-04 18:03 ` [PATCH v5 15/40] x86/resctrl: Move monitor exit work to a resctrl exit call James Morse
2024-10-04 18:03 ` [PATCH v5 16/40] x86/resctrl: Move monitor init work to a resctrl init call James Morse
2024-10-04 18:03 ` [PATCH v5 17/40] x86/resctrl: Rewrite and move the for_each_*_rdt_resource() walkers James Morse
2024-10-08  0:00   ` Tony Luck
2024-10-08 16:40     ` Reinette Chatre
2024-10-18 17:07       ` James Morse
2024-10-23 21:51   ` Reinette Chatre
2025-02-07 15:44     ` James Morse
2024-10-04 18:03 ` [PATCH v5 18/40] x86/resctrl: Export the is_mbm_*_enabled() helpers to asm/resctrl.h James Morse
2024-10-23 22:00   ` Reinette Chatre
2025-02-07 15:44     ` James Morse
2024-10-04 18:03 ` [PATCH v5 19/40] x86/resctrl: Add resctrl_arch_is_evt_configurable() to abstract BMEC James Morse
2024-10-23 22:04   ` Reinette Chatre
2025-02-07 15:44     ` James Morse
2024-10-04 18:03 ` [PATCH v5 20/40] x86/resctrl: Slightly clean-up mbm_config_show() James Morse
2024-10-16 16:50   ` Tony Luck
2024-10-04 18:03 ` [PATCH v5 21/40] x86/resctrl: Change mon_event_config_{read,write}() to be arch helpers James Morse
2024-10-23 22:19   ` Reinette Chatre
2025-02-07 15:45     ` James Morse
2024-10-04 18:03 ` James Morse [this message]
2024-10-23 22:42   ` [PATCH v5 22/40] x86/resctrl: Move mbm_cfg_mask to struct rdt_resource Reinette Chatre
2024-10-04 18:03 ` [PATCH v5 23/40] x86/resctrl: Add resctrl_arch_ prefix to pseudo lock functions James Morse
2024-10-23 22:44   ` Reinette Chatre
2025-02-07 15:45     ` James Morse
2024-10-04 18:03 ` [PATCH v5 24/40] x86/resctrl: Allow an architecture to disable pseudo lock James Morse
2024-10-04 18:03 ` [PATCH v5 25/40] x86/resctrl: Make prefetch_disable_bits belong to the arch code James Morse
2024-10-23 22:53   ` Reinette Chatre
2025-02-07 15:46     ` James Morse
2024-10-04 18:03 ` [PATCH v5 26/40] x86/resctrl: Make resctrl_arch_pseudo_lock_fn() take a plr James Morse
2024-10-04 18:03 ` [PATCH v5 27/40] x86/resctrl: Move thread_throttle_mode_init() to be managed by resctrl James Morse
2024-10-23 22:59   ` Reinette Chatre
2025-02-10 13:22     ` James Morse
2024-10-04 18:03 ` [PATCH v5 28/40] x86/resctrl: Move get_config_index() to a header James Morse
2024-10-04 18:03 ` [PATCH v5 29/40] x86/resctrl: Claim get_{mon,ctrl}_domain_from_cpu() helpers for resctrl James Morse
2024-10-23 23:02   ` Reinette Chatre
2024-10-04 18:03 ` [PATCH v5 30/40] x86/resctrl: Describe resctrl's bitmap size assumptions James Morse
2024-10-08 18:50   ` Tony Luck
2025-02-07 15:46     ` James Morse
2024-10-04 18:03 ` [PATCH v5 31/40] x86/resctrl: Rename resctrl_sched_in() to begin with "resctrl_arch_" James Morse
2024-10-04 18:03 ` [PATCH v5 32/40] x86/resctrl: resctrl_exit() teardown resctrl but leave the mount point James Morse
2024-10-23 23:50   ` Reinette Chatre
2025-02-07 15:54     ` James Morse
2024-10-04 18:03 ` [PATCH v5 33/40] x86/resctrl: Drop __init/__exit on assorted symbols James Morse
2024-10-23 23:56   ` Reinette Chatre
2025-02-07 15:54     ` James Morse
2024-10-04 18:03 ` [PATCH v5 34/40] x86/resctrl: Move is_mba_sc() out of core.c James Morse
2024-10-04 18:03 ` [PATCH v5 35/40] x86/resctrl: Add end-marker to the resctrl_event_id enum James Morse
2024-10-04 18:03 ` [PATCH v5 36/40] x86/resctrl: Remove a newline to avoid confusing the code move script James Morse
2024-10-04 18:03 ` [PATCH v5 37/40] x86/resctrl: Split trace.h James Morse
2024-10-04 18:03 ` [PATCH v5 38/40] fs/resctrl: Add boiler plate for external resctrl code James Morse
2024-10-08 23:03   ` Tony Luck
2024-10-24  0:08   ` Reinette Chatre
2025-02-07 15:54     ` James Morse
2024-10-04 18:03 ` [PATCH v5 39/40] x86/resctrl: Move the filesystem bits to headers visible to fs/resctrl James Morse
2024-10-04 18:03 ` [PATCH v5 40/40] x86/resctrl: Add python script to move resctrl code to /fs/resctrl James Morse
2024-10-08 23:08   ` Tony Luck
2024-10-24  0:17     ` Reinette Chatre
2025-02-07 15:55       ` James Morse
2024-10-04 21:18 ` [PATCH v5 00/40] x86/resctrl: Move the resctrl filesystem " Reinette Chatre
2024-10-07 17:29   ` James Morse
2024-10-08 23:24 ` Tony Luck
2024-10-17 17:43 ` Tony Luck
2024-12-06  7:17 ` 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=20241004180347.19985-23-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=fenghua.yu@intel.com \
    --cc=hpa@zytor.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=shameerali.kolothum.thodi@huawei.com \
    --cc=tan.shaopeng@fujitsu.com \
    --cc=tan.shaopeng@jp.fujitsu.com \
    --cc=tglx@linutronix.de \
    --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;
as well as URLs for NNTP newsgroup(s).