[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e0fe5863ad1801183047196d212ff3b1b79898fe.1747349530.git.babu.moger@amd.com>
Date: Thu, 15 May 2025 17:52:08 -0500
From: Babu Moger <babu.moger@....com>
To: <corbet@....net>, <tony.luck@...el.com>, <reinette.chatre@...el.com>,
<tglx@...utronix.de>, <mingo@...hat.com>, <bp@...en8.de>,
<dave.hansen@...ux.intel.com>
CC: <james.morse@....com>, <dave.martin@....com>, <fenghuay@...dia.com>,
<x86@...nel.org>, <hpa@...or.com>, <paulmck@...nel.org>,
<akpm@...ux-foundation.org>, <thuth@...hat.com>, <rostedt@...dmis.org>,
<ardb@...nel.org>, <gregkh@...uxfoundation.org>,
<daniel.sneddon@...ux.intel.com>, <jpoimboe@...nel.org>,
<alexandre.chartre@...cle.com>, <pawan.kumar.gupta@...ux.intel.com>,
<thomas.lendacky@....com>, <perry.yuan@....com>, <seanjc@...gle.com>,
<kai.huang@...el.com>, <xiaoyao.li@...el.com>, <babu.moger@....com>,
<kan.liang@...ux.intel.com>, <xin3.li@...el.com>, <ebiggers@...gle.com>,
<xin@...or.com>, <sohil.mehta@...el.com>, <andrew.cooper3@...rix.com>,
<mario.limonciello@....com>, <linux-doc@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, <peternewman@...gle.com>,
<maciej.wieczor-retman@...el.com>, <eranian@...gle.com>,
<Xiaojian.Du@....com>, <gautham.shenoy@....com>
Subject: [PATCH v13 23/27] x86/resctrl: Introduce mbm_L3_assignments to list assignments in a group
Introduce the interface to display the assignment states for each group
when mbm_cntr_assign mode is enabled.
The list is displayed in the following format:
<Event configuration>:<Domain id>=<Assignment type>
Event configuration: A valid event configuration listed in the
/sys/fs/resctrl/info/L3_MON/counter_configs directory.
Domain ID: A valid domain ID number.
The assignment type can be one of the following:
_ : No event configuration assigned
e : Event configuration assigned in exclusive mode
Example:
$cd /sys/fs/resctrl
$cat mbm_L3_assignments
mbm_total_bytes:0=e;1=e
mbm_local_bytes:0=e;1=e
Signed-off-by: Babu Moger <babu.moger@....com>
---
v13: Changelog update.
Few changes in mbm_L3_assignments_show() after moving the event config to evt_list.
Resolved conflicts caused by the recent FS/ARCH code restructure.
The rdtgroup.c/monitor.c files have been split between the FS and ARCH directories.
v12: New patch:
Assignment interface moved inside the group based the discussion
https://lore.kernel.org/lkml/CALPaoCiii0vXOF06mfV=kVLBzhfNo0SFqt4kQGwGSGVUqvr2Dg@mail.gmail.com/#t
---
Documentation/filesystems/resctrl.rst | 28 +++++++++++++++
fs/resctrl/monitor.c | 1 +
fs/resctrl/rdtgroup.c | 52 +++++++++++++++++++++++++++
3 files changed, 81 insertions(+)
diff --git a/Documentation/filesystems/resctrl.rst b/Documentation/filesystems/resctrl.rst
index 356f1f918a86..2350c1f21f4e 100644
--- a/Documentation/filesystems/resctrl.rst
+++ b/Documentation/filesystems/resctrl.rst
@@ -504,6 +504,34 @@ When the "mba_MBps" mount option is used all CTRL_MON groups will also contain:
/sys/fs/resctrl/info/L3_MON/mon_features changes the input
event.
+"mbm_L3_assignments":
+ This interface file is created when the mbm_cntr_assign mode is supported
+ and shows the assignment status for each group.
+
+ The assignment list is displayed in the following format:
+
+ <Event configuration>:<Domain id>=<Assignment type>
+
+ Event configuration: A valid event configuration listed in the
+ /sys/fs/resctrl/info/L3_MON/counter_configs directory.
+
+ Domain ID: A valid domain ID number.
+
+ Assignment types:
+
+ _ : No event configuration assigned
+
+ e : Event configuration assigned in exclusive mode
+
+ Example:
+ To list the assignment states for the default group.
+ ::
+
+ # cd /sys/fs/resctrl
+ # cat mbm_L3_assignments
+ mbm_total_bytes:0=e;1=e
+ mbm_local_bytes:0=e;1=e
+
Resource allocation rules
-------------------------
diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c
index 5f6c4b662f3b..b982540ce4e3 100644
--- a/fs/resctrl/monitor.c
+++ b/fs/resctrl/monitor.c
@@ -935,6 +935,7 @@ int resctrl_mon_resource_init(void)
resctrl_file_fflags_init("event_filter", RFTYPE_ASSIGN_CONFIG);
resctrl_file_fflags_init("mbm_assign_on_mkdir", RFTYPE_MON_INFO |
RFTYPE_RES_CACHE);
+ resctrl_file_fflags_init("mbm_L3_assignments", RFTYPE_MON_BASE);
}
return 0;
diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
index 931ea355f159..8d970b99bbbd 100644
--- a/fs/resctrl/rdtgroup.c
+++ b/fs/resctrl/rdtgroup.c
@@ -2080,6 +2080,52 @@ static ssize_t resctrl_mbm_assign_on_mkdir_write(struct kernfs_open_file *of,
return ret ?: nbytes;
}
+static int mbm_L3_assignments_show(struct kernfs_open_file *of, struct seq_file *s, void *v)
+{
+ struct rdt_resource *r = resctrl_arch_get_resource(RDT_RESOURCE_L3);
+ struct rdt_mon_domain *d;
+ struct rdtgroup *rdtgrp;
+ struct mon_evt *mevt;
+ int ret = 0;
+ bool sep;
+
+ rdtgrp = rdtgroup_kn_lock_live(of->kn);
+ if (!rdtgrp)
+ return -ENOENT;
+
+ rdt_last_cmd_clear();
+ if (!resctrl_arch_mbm_cntr_assign_enabled(r)) {
+ rdt_last_cmd_puts("mbm_cntr_assign mode not enabled\n");
+ ret = -ENOENT;
+ goto assign_out;
+ }
+
+ list_for_each_entry(mevt, &r->mon.evt_list, list) {
+ if (mevt->mbm_mode != MBM_MODE_ASSIGN)
+ continue;
+
+ sep = false;
+ seq_printf(s, "%s:", mevt->name);
+ list_for_each_entry(d, &r->mon_domains, hdr.list) {
+ if (sep)
+ seq_putc(s, ';');
+
+ if (mbm_cntr_get(r, d, rdtgrp, mevt->evtid) >= 0)
+ seq_printf(s, "%d=e", d->hdr.id);
+ else
+ seq_printf(s, "%d=_", d->hdr.id);
+
+ sep = true;
+ }
+ seq_putc(s, '\n');
+ }
+
+assign_out:
+ rdtgroup_kn_unlock(of->kn);
+
+ return ret;
+}
+
/* rdtgroup information files for one cache resource. */
static struct rftype res_common_files[] = {
{
@@ -2218,6 +2264,12 @@ static struct rftype res_common_files[] = {
.seq_show = event_filter_show,
.write = event_filter_write,
},
+ {
+ .name = "mbm_L3_assignments",
+ .mode = 0444,
+ .kf_ops = &rdtgroup_kf_single_ops,
+ .seq_show = mbm_L3_assignments_show,
+ },
{
.name = "mbm_assign_mode",
.mode = 0444,
--
2.34.1
Powered by blists - more mailing lists