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>,
Dave Martin <Dave.Martin@arm.com>,
Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
Subject: [PATCH v5 21/40] x86/resctrl: Change mon_event_config_{read,write}() to be arch helpers
Date: Fri, 4 Oct 2024 18:03:28 +0000 [thread overview]
Message-ID: <20241004180347.19985-22-james.morse@arm.com> (raw)
In-Reply-To: <20241004180347.19985-1-james.morse@arm.com>
mon_event_config_{read,write}() are called via IPI and access model
specific registers to do their work.
To support another architecture, this needs abstracting.
Rename mon_event_config_{read,write}() to have a "resctrl_arch_"
prefix, and move their struct mon_config_info parameter into
<linux/resctrl.h>. This allows another architecture to supply an
implementation of these.
As struct mon_config_info is now exposed globally, give it a 'resctrl_'
prefix. MPAM systems need access to the domain to do this work, add
the resource and domain to struct resctrl_mon_config_info.
Co-developed-by: Dave Martin <Dave.Martin@arm.com>
Signed-off-by: Dave Martin <Dave.Martin@arm.com>
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>
---
Changes since v3:
* Added comments over the read/write helper to explain the type of the void
pointer.
Changes since v1:
* [Whitespace only] Re-tabbed struct resctrl_mon_config_info in
<linux/resctrl.h> to fit the prevailing style.
Non-functional change.
* [Commit message only] Reword to align with the actual naming of the
definitions and destination header file.
---
arch/x86/kernel/cpu/resctrl/rdtgroup.c | 34 +++++++++++++-------------
include/linux/resctrl.h | 25 +++++++++++++++++++
2 files changed, 42 insertions(+), 17 deletions(-)
diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
index 9294bf74f3a8..304fdf199de7 100644
--- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
+++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
@@ -1571,11 +1571,6 @@ static int rdtgroup_size_show(struct kernfs_open_file *of,
return ret;
}
-struct mon_config_info {
- u32 evtid;
- u32 mon_config;
-};
-
#define INVALID_CONFIG_INDEX UINT_MAX
/**
@@ -1600,9 +1595,9 @@ static inline unsigned int mon_event_config_index_get(u32 evtid)
}
}
-static void mon_event_config_read(void *info)
+void resctrl_arch_mon_event_config_read(void *info)
{
- struct mon_config_info *mon_info = info;
+ struct resctrl_mon_config_info *mon_info = info;
unsigned int index;
u64 msrval;
@@ -1617,14 +1612,15 @@ static void mon_event_config_read(void *info)
mon_info->mon_config = msrval & MAX_EVT_CONFIG_BITS;
}
-static void mondata_config_read(struct rdt_mon_domain *d, struct mon_config_info *mon_info)
+static void mondata_config_read(struct resctrl_mon_config_info *mon_info)
{
- smp_call_function_any(&d->hdr.cpu_mask, mon_event_config_read, mon_info, 1);
+ smp_call_function_any(&mon_info->d->hdr.cpu_mask,
+ resctrl_arch_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;
+ struct resctrl_mon_config_info mon_info;
struct rdt_mon_domain *dom;
bool sep = false;
@@ -1635,9 +1631,11 @@ static int mbm_config_show(struct seq_file *s, struct rdt_resource *r, u32 evtid
if (sep)
seq_puts(s, ";");
- memset(&mon_info, 0, sizeof(struct mon_config_info));
+ memset(&mon_info, 0, sizeof(struct resctrl_mon_config_info));
+ mon_info.r = r;
+ mon_info.d = dom;
mon_info.evtid = evtid;
- mondata_config_read(dom, &mon_info);
+ mondata_config_read(&mon_info);
seq_printf(s, "%d=0x%02x", dom->hdr.id, mon_info.mon_config);
sep = true;
@@ -1670,9 +1668,9 @@ static int mbm_local_bytes_config_show(struct kernfs_open_file *of,
return 0;
}
-static void mon_event_config_write(void *info)
+void resctrl_arch_mon_event_config_write(void *info)
{
- struct mon_config_info *mon_info = info;
+ struct resctrl_mon_config_info *mon_info = info;
unsigned int index;
index = mon_event_config_index_get(mon_info->evtid);
@@ -1686,14 +1684,16 @@ static void mon_event_config_write(void *info)
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 = {0};
+ struct resctrl_mon_config_info mon_info = {0};
/*
* Read the current config value first. If both are the same then
* no need to write it again.
*/
+ mon_info.r = r;
+ mon_info.d = d;
mon_info.evtid = evtid;
- mondata_config_read(d, &mon_info);
+ mondata_config_read(&mon_info);
if (mon_info.mon_config == val)
return;
@@ -1705,7 +1705,7 @@ static void mbm_config_write_domain(struct rdt_resource *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_write,
&mon_info, 1);
/*
diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h
index 224a14d9aa7a..0072c2e5947f 100644
--- a/include/linux/resctrl.h
+++ b/include/linux/resctrl.h
@@ -271,6 +271,13 @@ struct resctrl_cpu_defaults {
u32 rmid;
};
+struct resctrl_mon_config_info {
+ struct rdt_resource *r;
+ struct rdt_mon_domain *d;
+ u32 evtid;
+ u32 mon_config;
+};
+
/**
* resctrl_arch_sync_cpu_closid_rmid() - Refresh this CPU's CLOSID and RMID.
* Call via IPI.
@@ -315,6 +322,24 @@ int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid);
bool __init resctrl_arch_is_evt_configurable(enum resctrl_event_id evt);
+/**
+ * resctrl_arch_mon_event_config_write() - Write the config for a counter.
+ * @info: struct resctrl_mon_config_info describing the resource, domain
+ * and event.
+ *
+ * Must be called on a CPU that is a member of the specified domain.
+ */
+void resctrl_arch_mon_event_config_write(void *info);
+
+/**
+ * resctrl_arch_mon_event_config_read() - Read the config for a counter.
+ * @info: struct resctrl_mon_config_info describing the resource, domain
+ * and event.
+ *
+ * Must be called on a CPU that is a member of the specified domain.
+ */
+void resctrl_arch_mon_event_config_read(void *info);
+
/*
* Update the ctrl_val and apply this config right now.
* Must be called on one of the domain's CPUs.
--
2.39.2
next prev 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 ` James Morse [this message]
2024-10-23 22:19 ` [PATCH v5 21/40] x86/resctrl: Change mon_event_config_{read,write}() to be arch helpers Reinette Chatre
2025-02-07 15:45 ` James Morse
2024-10-04 18:03 ` [PATCH v5 22/40] x86/resctrl: Move mbm_cfg_mask to struct rdt_resource James Morse
2024-10-23 22:42 ` 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-22-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).