From: Fenghua Yu <fenghuay@nvidia.com>
To: Reinette Chatre <reinette.chatre@intel.com>,
Tony Luck <tony.luck@intel.com>, Ben Horgan <ben.horgan@arm.com>,
James Morse <james.morse@arm.com>,
Dave Martin <Dave.Martin@arm.com>,
Shaopeng Tan <tan.shaopeng@fujitsu.com>,
Chen Yu <yu.c.chen@intel.com>, Babu Moger <babu.moger@amd.com>,
Drew Fustini <fustini@kernel.org>,
Vikram Sethi <vsethi@nvidia.com>,
Shanker Donthineni <sdonthineni@nvidia.com>,
Newton Liu <newtonl@nvidia.com>, Gavin Shan <gshan@redhat.com>
Cc: linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
Fenghua Yu <fenghuay@nvidia.com>
Subject: [PATCH 18/23] arm_mpam: Emulate MB control with node-scoped MB_NODE control
Date: Thu, 16 Jul 2026 14:03:08 -0700 [thread overview]
Message-ID: <20260716210329.2914625-18-fenghuay@nvidia.com> (raw)
In-Reply-To: <cover.1784217438.git.fenghuay@nvidia.com>
On memory-class MSCs the MB bandwidth control is node-scoped. Add a
node-scoped MB_NODE control that emulates the default MB control by
pointing its resctrl_ctrl::emulated at the default control, so it is
exposed nested under MB in resource_schemata.
Introduce mpam_resctrl_ctrl_node() to identify memory-class resources
and use it when selecting the control scope and the hard-limit control
name, replacing the open-coded mpam_class_memory() lookups. Expose the
NODE control scope in the per-control "scope" sysfs file so node-scoped
controls report "NODE" instead of "Unsupported control scope".
Signed-off-by: Fenghua Yu <fenghuay@nvidia.com>
---
drivers/resctrl/mpam_resctrl.c | 166 ++++++++++++++++++++++++++++-----
fs/resctrl/rdtgroup.c | 3 +
2 files changed, 146 insertions(+), 23 deletions(-)
diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
index f67647d95bbe..890b17c218a2 100644
--- a/drivers/resctrl/mpam_resctrl.c
+++ b/drivers/resctrl/mpam_resctrl.c
@@ -1253,20 +1253,133 @@ void resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_l3_mon_domain *
resctrl_arch_reset_cntr(r, d, closid, rmid, cntr_id, evtid);
}
+/* Fixme: Is this a right helper? How to get MB and MB_NODE together */
+static bool mpam_resctrl_ctrl_node(struct rdt_resource *r)
+{
+ struct mpam_resctrl_res *res;
+ struct mpam_class *class;
+
+ res = container_of(r, struct mpam_resctrl_res, resctrl_res);
+ class = res->class;
+
+ return mpam_class_memory(class);
+}
+
+static bool mpam_resctrl_cache_has_mba(void)
+{
+ struct mpam_resctrl_res *l3_res = &mpam_resctrl_controls[RDT_RESOURCE_L3];
+ struct mpam_class *class = l3_res->class;
+
+ if (!class)
+ return false;
+
+ return class_has_usable_mba(&class->props);
+}
+
+static void _mpam_resctrl_ctrl_init_mba(struct rdt_resource *r,
+ struct mpam_resctrl_ctrl *mpam_ctrl,
+ struct mpam_props *cprops,
+ enum resctrl_ctrl_name name)
+{
+ mpam_ctrl->r_ctrl.type = RESCTRL_CTRL_SCALAR;
+ mpam_ctrl->r_ctrl.name = name;
+ INIT_LIST_HEAD_RCU(&mpam_ctrl->r_ctrl.domains);
+
+ mpam_ctrl->r_ctrl.membw.min_bw = get_mba_min(cprops);
+ mpam_ctrl->r_ctrl.membw.max_bw = MAX_MBA_BW;
+ mpam_ctrl->r_ctrl.membw.bw_gran = get_mba_granularity(cprops);
+
+ if (mpam_resctrl_ctrl_node(r)) {
+ /*
+ * Default to legacy mode so a disabled MB control is emulated
+ * by the node-scoped control, keeping the "MB:" schemata line
+ * for backward compatibility. User space can switch to native
+ * mode to disable emulation.
+ */
+ r->mode = RESCTRL_CTRL_LEGACY;
+ /*
+ * On a memory-class resource the legacy MB control is backed by
+ * the L3 cache MBW hardware when the cache has usable MBA, so it
+ * keeps cache scope. Otherwise it is node-scoped and emulated by
+ * the MB_NODE control.
+ */
+ if (name == RESCTRL_CTRL_NAME_DEF && mpam_resctrl_cache_has_mba())
+ mpam_ctrl->r_ctrl.scope = RESCTRL_L3_CACHE;
+ else
+ mpam_ctrl->r_ctrl.scope = RESCTRL_NODE;
+ } else {
+ mpam_ctrl->r_ctrl.scope = RESCTRL_L3_CACHE;
+ r->mode = RESCTRL_CTRL_LEGACY;
+ }
+}
+
+static void mpam_resctrl_ctrl_set_mbw_status(struct resctrl_ctrl *ctrl,
+ struct rdt_resource *r,
+ struct mpam_props *cprops)
+{
+ switch (ctrl->name) {
+ case RESCTRL_CTRL_NAME_DEF:
+ if (mpam_resctrl_ctrl_node(r))
+ ctrl->membw.no_mbw_hw = !mpam_resctrl_cache_has_mba();
+ else
+ ctrl->membw.no_mbw_hw = !class_has_usable_mba(cprops);
+ break;
+ case RESCTRL_CTRL_NAME_NODE:
+ ctrl->membw.no_mbw_hw = !class_has_usable_mba(cprops);
+ break;
+ default:
+ ctrl->membw.no_mbw_hw = true;
+ break;
+ }
+}
+
+static int mpam_resctrl_ctrl_init_mba(struct rdt_resource *r,
+ struct mpam_props *cprops)
+{
+ struct mpam_resctrl_ctrl *ctrl_def;
+
+ ctrl_def = kzalloc_obj(*ctrl_def);
+ if (!ctrl_def)
+ return -ENOMEM;
+
+ _mpam_resctrl_ctrl_init_mba(r, ctrl_def, cprops, RESCTRL_CTRL_NAME_DEF);
+ mpam_resctrl_ctrl_set_mbw_status(&ctrl_def->r_ctrl, r, cprops);
+ list_add(&ctrl_def->r_ctrl.entry, &r->controls);
+
+ if (mpam_resctrl_ctrl_node(r)) {
+ struct mpam_resctrl_ctrl *ctrl_node;
+
+ ctrl_node = kzalloc_obj(*ctrl_node);
+ if (ctrl_node) {
+ _mpam_resctrl_ctrl_init_mba(r, ctrl_node, cprops,
+ RESCTRL_CTRL_NAME_NODE);
+ mpam_resctrl_ctrl_set_mbw_status(&ctrl_node->r_ctrl, r,
+ cprops);
+ if (ctrl_def->r_ctrl.membw.no_mbw_hw)
+ ctrl_def->r_ctrl.emulated_by = &ctrl_node->r_ctrl;
+
+ list_add(&ctrl_node->r_ctrl.entry, &r->controls);
+ }
+ }
+
+ return 0;
+}
+
static int mpam_resctrl_control_init(struct mpam_resctrl_res *res)
{
struct mpam_class *class = res->class;
struct mpam_props *cprops = &class->props;
struct rdt_resource *r = &res->resctrl_res;
struct mpam_resctrl_ctrl *mpam_ctrl;
-
- mpam_ctrl = kzalloc_obj(*mpam_ctrl);
- if (!mpam_ctrl)
- return -ENOMEM;
+ int ret = 0;
switch (r->rid) {
case RDT_RESOURCE_L2:
case RDT_RESOURCE_L3:
+ mpam_ctrl = kzalloc_obj(*mpam_ctrl);
+ if (!mpam_ctrl)
+ return -ENOMEM;
+
mpam_ctrl->r_ctrl.type = RESCTRL_CTRL_BITMAP;
mpam_ctrl->r_ctrl.name = RESCTRL_CTRL_NAME_DEF;
INIT_LIST_HEAD_RCU(&mpam_ctrl->r_ctrl.domains);
@@ -1298,18 +1411,12 @@ static int mpam_resctrl_control_init(struct mpam_resctrl_res *res)
r->alloc_capable = true;
break;
case RDT_RESOURCE_MBA:
- mpam_ctrl->r_ctrl.type = RESCTRL_CTRL_SCALAR;
- mpam_ctrl->r_ctrl.scope = RESCTRL_L3_CACHE;
- mpam_ctrl->r_ctrl.name = RESCTRL_CTRL_NAME_DEF;
- INIT_LIST_HEAD_RCU(&mpam_ctrl->r_ctrl.domains);
+ ret = mpam_resctrl_ctrl_init_mba(r, cprops);
+ if (ret)
+ return ret;
r->bw_delay_linear = true;
r->bw_throttle_mode = THREAD_THROTTLE_UNDEFINED;
- mpam_ctrl->r_ctrl.membw.min_bw = get_mba_min(cprops);
- mpam_ctrl->r_ctrl.membw.max_bw = MAX_MBA_BW;
- mpam_ctrl->r_ctrl.membw.bw_gran = get_mba_granularity(cprops);
- list_add(&mpam_ctrl->r_ctrl.entry, &r->controls);
-
r->name = "MB";
r->alloc_capable = true;
break;
@@ -1472,7 +1579,7 @@ u32 resctrl_arch_get_config(struct rdt_resource *r, struct resctrl_ctrl *ctrl,
struct mpam_props *cprops;
struct mpam_resctrl_res *res;
struct mpam_resctrl_dom *dom;
- enum mpam_device_features configured_by;
+ enum mpam_device_features configured_by = MPAM_FEATURE_LAST;
lockdep_assert_cpus_held();
@@ -1500,16 +1607,22 @@ u32 resctrl_arch_get_config(struct rdt_resource *r, struct resctrl_ctrl *ctrl,
configured_by = mpam_feat_cpor_part;
break;
case RDT_RESOURCE_MBA:
- if (mpam_has_feature(mpam_feat_mbw_max, cprops)) {
- configured_by = mpam_feat_mbw_max;
+ switch (ctrl->name) {
+ case RESCTRL_CTRL_NAME_DEF:
+ case RESCTRL_CTRL_NAME_NODE:
+ if (mpam_has_feature(mpam_feat_mbw_max, cprops))
+ configured_by = mpam_feat_mbw_max;
+ break;
+ default:
break;
}
- fallthrough;
+ break;
default:
return resctrl_get_default_ctrlval(ctrl);
}
- if (!r->alloc_capable || partid >= resctrl_arch_get_num_closid(r) ||
+ if (configured_by == MPAM_FEATURE_LAST || !r->alloc_capable ||
+ partid >= resctrl_arch_get_num_closid(r) ||
!mpam_has_feature(configured_by, cfg))
return resctrl_get_default_ctrlval(ctrl);
@@ -1570,12 +1683,19 @@ int resctrl_arch_update_one(struct rdt_resource *r, struct resctrl_ctrl *ctrl,
mpam_set_feature(mpam_feat_cpor_part, &cfg);
break;
case RDT_RESOURCE_MBA:
- if (mpam_has_feature(mpam_feat_mbw_max, cprops)) {
- cfg.mbw_max = percent_to_mbw_max(cfg_val, cprops);
- mpam_set_feature(mpam_feat_mbw_max, &cfg);
- break;
+ switch (ctrl->name) {
+ case RESCTRL_CTRL_NAME_DEF:
+ case RESCTRL_CTRL_NAME_NODE:
+ if (mpam_has_feature(mpam_feat_mbw_max, cprops)) {
+ cfg.mbw_max = percent_to_mbw_max(cfg_val, cprops);
+ mpam_set_feature(mpam_feat_mbw_max, &cfg);
+ break;
+ }
+ return -EINVAL;
+ default:
+ return -EINVAL;
}
- fallthrough;
+ break;
default:
return -EINVAL;
}
diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
index 5be285487df7..b9e8d1183cdd 100644
--- a/fs/resctrl/rdtgroup.c
+++ b/fs/resctrl/rdtgroup.c
@@ -2239,6 +2239,9 @@ static int resctrl_ctrl_scope_show(struct kernfs_open_file *of,
case RESCTRL_L2_CACHE:
seq_puts(seq, "L2\n");
return 0;
+ case RESCTRL_NODE:
+ seq_puts(seq, "NODE\n");
+ return 0;
default:
/* resctrl does not yet support any other control scope */
seq_puts(seq, "Unsupported control scope\n");
--
2.43.0
next prev parent reply other threads:[~2026-07-16 21:05 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-16 21:02 [PATCH RFC 00/23] resctrl: MBA control emulation and ARM MPAM MB_NODE support Fenghua Yu
2026-07-16 21:02 ` [PATCH 01/23] resctrl: Fix ownership of resource_schemata control subdirectories Fenghua Yu
2026-07-16 21:02 ` [PATCH 02/23] arm_mpam: Fix NULL address access issue Fenghua Yu
2026-07-16 21:02 ` [PATCH 03/23] resctrl: Expose MBA resource_schemata mode sysfs Fenghua Yu
2026-07-16 21:02 ` [PATCH 04/23] resctrl: Expose per-control status in resource_schemata Fenghua Yu
2026-07-16 21:02 ` [PATCH 05/23] resctrl: Add nested resource_schemata support for emulated controls Fenghua Yu
2026-07-16 21:02 ` [PATCH 06/23] resctrl: Mirror schemata for controls without MBW hardware Fenghua Yu
2026-07-16 21:02 ` [PATCH 07/23] resctrl: Rebuild resource_schemata subdirs on MBA mode change Fenghua Yu
2026-07-16 21:02 ` [PATCH 08/23] Documentation: resctrl: document MBA control emulation Fenghua Yu
2026-07-16 21:02 ` [PATCH 09/23] resctrl: De-hardcode L3 monitor infrastructure Fenghua Yu
2026-07-16 21:03 ` [PATCH 10/23] resctrl: Expose MBA MBM counter assignment sysfs Fenghua Yu
2026-07-16 21:03 ` [PATCH 11/23] resctrl: name node-scoped monitor domains mon_NODE_<id> Fenghua Yu
2026-07-16 21:03 ` [PATCH 12/23] resctrl: Add node-scope MBM total event Fenghua Yu
2026-07-16 21:03 ` [PATCH 13/23] resctrl: Make MBM paths resource-aware Fenghua Yu
2026-07-16 21:03 ` [PATCH 14/23] arm_mpam: Support memory-level MSCs and ABMC per class Fenghua Yu
2026-07-16 21:03 ` [PATCH 15/23] arm_mpam: Refine L3 topology and class selection Fenghua Yu
2026-07-16 21:03 ` [PATCH 16/23] arm_mpam: Include all MSC components during domain setup Fenghua Yu
2026-07-16 21:03 ` [PATCH 17/23] arm_mpam: Handle CPU-less numa nodes Fenghua Yu
2026-07-16 21:03 ` Fenghua Yu [this message]
2026-07-16 21:03 ` [PATCH 19/23] Documentation: arm64: mpam: document memory-level MB control and NUMA nodes Fenghua Yu
2026-07-16 21:03 ` [PATCH 20/23] Documentation: resctrl: document NODE-scoped MBA domains and mon_NODE monitoring Fenghua Yu
2026-07-16 21:03 ` [PATCH 21/23] Documentation: resctrl: document MB_NODE emulation example on ARM MPAM Fenghua Yu
2026-07-16 21:03 ` [PATCH 22/23] arm_mpam: Add KUnit test for CPU-less NUMA node affinity Fenghua Yu
2026-07-16 21:03 ` [PATCH 23/23] selftests/resctrl: Add MB emulation test for ARM MPAM Fenghua Yu
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=20260716210329.2914625-18-fenghuay@nvidia.com \
--to=fenghuay@nvidia.com \
--cc=Dave.Martin@arm.com \
--cc=babu.moger@amd.com \
--cc=ben.horgan@arm.com \
--cc=fustini@kernel.org \
--cc=gshan@redhat.com \
--cc=james.morse@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=newtonl@nvidia.com \
--cc=reinette.chatre@intel.com \
--cc=sdonthineni@nvidia.com \
--cc=tan.shaopeng@fujitsu.com \
--cc=tony.luck@intel.com \
--cc=vsethi@nvidia.com \
--cc=yu.c.chen@intel.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