mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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>, Will Deacon <will@kernel.org>,
	Dave Martin <Dave.Martin@arm.com>,
	Catalin Marinas <catalin.marinas@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>,
	Richard Cheng <icheng@nvidia.com>
Cc: linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	Fenghua Yu <fenghuay@nvidia.com>
Subject: [PATCH RFC v1 5/6] arm_mpam: Add MB_MAXHLM_NODE and Node scope
Date: Mon,  9 Nov 2026 13:29:36 -0800	[thread overview]
Message-ID: <20261109212937.1409570-6-fenghuay@nvidia.com> (raw)
In-Reply-To: <20261109212937.1409570-1-fenghuay@nvidia.com>

Memory-level MSCs expose their domains as NUMA nodes, so their
hard-limit control must be named MB_MAXHLM_NODE rather than MB_MAXHLM.
Add RESCTRL_CTRL_NAME_MAXHLM_NODE and create it for memory classes.
Set the MBA resource ctrl_scope to RESCTRL_NODE for those classes.

Add resctrl_ctrl_maxhlm() so the schemata parser, group setup, default
value, and resctrl_arch_get_config()/resctrl_arch_update_one() accept
both hard-limit names.

The hard-limit control is a 0/1 HARDLIM toggle. Set its scalar range
to 0..1 with a reset value of 0 instead of inheriting the bandwidth
percentage range.

Signed-off-by: Fenghua Yu <fenghuay@nvidia.com>
---
 drivers/resctrl/mpam_resctrl.c | 47 ++++++++++++++++++++++++++++++----
 fs/resctrl/ctrlmondata.c       |  3 ++-
 fs/resctrl/rdtgroup.c          |  2 +-
 include/linux/resctrl.h        | 12 +++++++--
 4 files changed, 55 insertions(+), 9 deletions(-)

diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
index ea1fb7fc7e01..f1325ffb6343 100644
--- a/drivers/resctrl/mpam_resctrl.c
+++ b/drivers/resctrl/mpam_resctrl.c
@@ -1266,10 +1266,14 @@ 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);
 }
 
-static void _mpam_resctrl_ctrl_init_mba(struct mpam_resctrl_ctrl *mpam_ctrl,
+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)
 {
+	struct mpam_resctrl_res *res;
+	struct mpam_class *class;
+
 	mpam_ctrl->r_ctrl.type = RESCTRL_CTRL_SCALAR;
 	mpam_ctrl->r_ctrl.name = name;
 	INIT_LIST_HEAD_RCU(&mpam_ctrl->r_ctrl.domains);
@@ -1287,6 +1291,35 @@ static void _mpam_resctrl_ctrl_init_mba(struct mpam_resctrl_ctrl *mpam_ctrl,
 	mpam_ctrl->r_ctrl.scalar.gran = get_mba_granularity(cprops);
 
 	__set_bit(RESCTRL_SCALAR_FLAG_LINEAR, mpam_ctrl->r_ctrl.scalar.flags);
+
+	/*
+	 * The hard-limit control is a 0/1 HARDLIM toggle. It must not
+	 * inherit the bandwidth percentage range.
+	 */
+	if (resctrl_ctrl_maxhlm(&mpam_ctrl->r_ctrl)) {
+		mpam_ctrl->r_ctrl.scalar.min = 0;
+		mpam_ctrl->r_ctrl.scalar.max = 1;
+		mpam_ctrl->r_ctrl.scalar.reset_val = 0;
+		mpam_ctrl->r_ctrl.scalar.gran = 1;
+	}
+
+	res = container_of(r, struct mpam_resctrl_res, resctrl_res);
+	class = res->class;
+	if (mpam_class_memory(class))
+		r->ctrl_scope = RESCTRL_NODE;
+}
+
+static enum resctrl_ctrl_name get_ctrl_name_maxhlm(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;
+	if (mpam_class_memory(class))
+		return RESCTRL_CTRL_NAME_MAXHLM_NODE;
+
+	return RESCTRL_CTRL_NAME_MAXHLM;
 }
 
 static int mpam_resctrl_ctrl_init_mba(struct rdt_resource *r,
@@ -1305,10 +1338,10 @@ static int mpam_resctrl_ctrl_init_mba(struct rdt_resource *r,
 	res = container_of(r, struct mpam_resctrl_res, resctrl_res);
 	class = res->class;
 	if (mpam_class_memory(class)) {
-		_mpam_resctrl_ctrl_init_mba(mpam_ctrl, cprops,
+		_mpam_resctrl_ctrl_init_mba(r, mpam_ctrl, cprops,
 					    RESCTRL_CTRL_NAME_NODE);
 	} else {
-		_mpam_resctrl_ctrl_init_mba(mpam_ctrl, cprops,
+		_mpam_resctrl_ctrl_init_mba(r, mpam_ctrl, cprops,
 					    RESCTRL_CTRL_NAME_DEF);
 	}
 
@@ -1318,14 +1351,16 @@ static int mpam_resctrl_ctrl_init_mba(struct rdt_resource *r,
 	 * this fails.
 	 */
 	if (mpam_has_feature(mpam_feat_mbw_max_hardlim_rw, cprops)) {
+		enum resctrl_ctrl_name name;
+
 		ctrl_maxhlm = kzalloc_obj(*ctrl_maxhlm);
 		if (!ctrl_maxhlm) {
 			kfree(mpam_ctrl);
 			return -ENOMEM;
 		}
 
-		_mpam_resctrl_ctrl_init_mba(ctrl_maxhlm, cprops,
-					    RESCTRL_CTRL_NAME_MAXHLM);
+		name = get_ctrl_name_maxhlm(r);
+		_mpam_resctrl_ctrl_init_mba(r, ctrl_maxhlm, cprops, name);
 	}
 
 	/*
@@ -1588,6 +1623,7 @@ u32 resctrl_arch_get_config(struct rdt_resource *r, struct resctrl_ctrl *ctrl,
 				configured_by = mpam_feat_mbw_max;
 			break;
 		case RESCTRL_CTRL_NAME_MAXHLM:
+		case RESCTRL_CTRL_NAME_MAXHLM_NODE:
 			configured_by = mpam_feat_mbw_max_hardlim_rw;
 			break;
 		default:
@@ -1671,6 +1707,7 @@ int resctrl_arch_update_one(struct rdt_resource *r, struct resctrl_ctrl *ctrl,
 			}
 			return -EINVAL;
 		case RESCTRL_CTRL_NAME_MAXHLM:
+		case RESCTRL_CTRL_NAME_MAXHLM_NODE:
 			if (mpam_has_feature(mpam_feat_mbw_max_hardlim_rw, cprops) &&
 			    mpam_has_feature(mpam_feat_mbw_max, cprops)) {
 				/*
diff --git a/fs/resctrl/ctrlmondata.c b/fs/resctrl/ctrlmondata.c
index 9111b0130783..352a3f847b4b 100644
--- a/fs/resctrl/ctrlmondata.c
+++ b/fs/resctrl/ctrlmondata.c
@@ -189,7 +189,7 @@ static int parse_bw(struct rdt_parse_data *data, struct rdt_resource_final *f,
 	}
 
 	/* Parse mb_maxhlm line */
-	if (ctrl->name == RESCTRL_CTRL_NAME_MAXHLM) {
+	if (resctrl_ctrl_maxhlm(ctrl)) {
 		if (!mb_maxhlm_validate(data->buf, &bw_val, r, ctrl))
 			return -EINVAL;
 
@@ -397,6 +397,7 @@ static const char * const resctrl_ctrl_name[] = {
 	[RESCTRL_CTRL_NAME_REGION0_MIN]		= "REGION0_MIN",
 	[RESCTRL_CTRL_NAME_REGION0_MAX]		= "REGION0_MAX",
 	[RESCTRL_CTRL_NAME_MAXHLM]	= "MAXHLM",
+	[RESCTRL_CTRL_NAME_MAXHLM_NODE]	= "MAXHLM_NODE",
 };
 
 const char *resctrl_ctrl_name_str(enum resctrl_ctrl_name name)
diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
index 01e69d0d9e96..1a6dbad15fd5 100644
--- a/fs/resctrl/rdtgroup.c
+++ b/fs/resctrl/rdtgroup.c
@@ -4429,7 +4429,7 @@ static int rdtgroup_init_alloc(struct rdtgroup *rdtgrp)
 		for_each_enabled_ctrl(ctrl, r) {
 			if (r->rid == RDT_RESOURCE_MBA ||
 			    r->rid == RDT_RESOURCE_SMBA) {
-				if (ctrl->name == RESCTRL_CTRL_NAME_MAXHLM) {
+				if (resctrl_ctrl_maxhlm(ctrl)) {
 					rdtgroup_init_mb_hlim(ctrl);
 					continue;
 				}
diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h
index 5711154145f8..1c75ac68d68f 100644
--- a/include/linux/resctrl.h
+++ b/include/linux/resctrl.h
@@ -403,6 +403,7 @@ struct resctrl_mon {
  * @RESCTRL_CTRL_NAME_REGION0_MIN:	"REGION0_MIN"
  * @RESCTRL_CTRL_NAME_REGION0_MAX:	"REGION0_MAX"
  * @RESCTRL_CTRL_NAME_MAXHLM:	"MAXHLM"
+ * @RESCTRL_CTRL_NAME_MAXHLM_NODE:"MAXHLM_NODE"
  */
 enum resctrl_ctrl_name {
 	RESCTRL_CTRL_NAME_DEF,
@@ -412,7 +413,8 @@ enum resctrl_ctrl_name {
 	RESCTRL_CTRL_NAME_REGION0_MIN,
 	RESCTRL_CTRL_NAME_REGION0_MAX,
 	RESCTRL_CTRL_NAME_MAXHLM,
-	RESCTRL_CTRL_NAME_LAST = RESCTRL_CTRL_NAME_MAXHLM
+	RESCTRL_CTRL_NAME_MAXHLM_NODE,
+	RESCTRL_CTRL_NAME_LAST = RESCTRL_CTRL_NAME_MAXHLM_NODE
 };
 
 /**
@@ -603,6 +605,12 @@ int resctrl_arch_control_mode_set(struct rdt_resource *r,
  */
 void resctrl_arch_sync_cpu_closid_rmid(void *info);
 
+static inline bool resctrl_ctrl_maxhlm(struct resctrl_ctrl *ctrl)
+{
+	return ctrl->name == RESCTRL_CTRL_NAME_MAXHLM ||
+	       ctrl->name == RESCTRL_CTRL_NAME_MAXHLM_NODE;
+}
+
 /**
  * resctrl_get_default_ctrlval() - Return the default control value for this
  *                                 control.
@@ -619,7 +627,7 @@ static inline u32 resctrl_get_default_ctrlval(struct resctrl_ctrl *ctrl)
 		return BIT_MASK(ctrl->bitmap.cbm_len) - 1;
 	case RESCTRL_CTRL_SCALAR:
 		/* The hard-limit toggle defaults to off. */
-		if (ctrl->name == RESCTRL_CTRL_NAME_MAXHLM)
+		if (resctrl_ctrl_maxhlm(ctrl))
 			return 0;
 
 		return ctrl->scalar.reset_val;
-- 
2.53.0


  parent reply	other threads:[~2026-11-09 21:29 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-09 21:29 [PATCH RFC v1 0/6] arm_mpam,resctrl: expose MPAM MBW_MAX hard limit Fenghua Yu
2026-11-09 21:29 ` [PATCH RFC v1 1/6] resctrl: wire MB_MAXHLM schemata parsing and group setup Fenghua Yu
2026-11-09 21:29 ` [PATCH RFC v1 2/6] arm_mpam: resctrl: probe MPAMF_MBW_IDR MAX_LIM and hardlim_rw Fenghua Yu
2026-11-09 21:29 ` [PATCH RFC v1 3/6] arm_mpam: resctrl: track MBW max hard-limit in config Fenghua Yu
2026-11-09 21:29 ` [PATCH RFC v1 4/6] arm_mpam: resctrl: add MAXHLM control on the MBA resource Fenghua Yu
2026-11-09 21:29 ` Fenghua Yu [this message]
2026-11-09 21:29 ` [PATCH RFC v1 6/6] Documentation: resctrl: document MB_MAXHLM for MPAM MBA 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=20261109212937.1409570-6-fenghuay@nvidia.com \
    --to=fenghuay@nvidia.com \
    --cc=Dave.Martin@arm.com \
    --cc=babu.moger@amd.com \
    --cc=ben.horgan@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=fustini@kernel.org \
    --cc=icheng@nvidia.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=will@kernel.org \
    --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

all inboxes | Powered by JetHome®