Linux Documentation
 help / color / mirror / Atom feed
* [PATCH v6 0/6] fs/resctrl: Fix some resctl bugs related to mpam
@ 2026-11-19  9:48 Jinjie Ruan
  2026-11-19  9:48 ` [PATCH v6 1/6] fs/resctrl: Report a temporary RMID shortage per CLOSID Jinjie Ruan
                   ` (5 more replies)
  0 siblings, 6 replies; 12+ messages in thread
From: Jinjie Ruan @ 2026-11-19  9:48 UTC (permalink / raw)
  To: tony.luck, reinette.chatre, Dave.Martin, james.morse, babu.moger,
	corbet, skhan, rdunlap, bp, tan.shaopeng, gshan, ben.horgan,
	jic23, fenghuay, zengheng4, x86, linux-kernel, linux-doc
  Cc: ruanjinjie

Fix resctrl RMID allocation to report a retryable -EBUSY only when
the target CLOSID actually has RMIDs in limbo.

Split the domain-offline path out so it releases busy RMIDs without
allocating a monitor context it never uses.

Also unmount resctrl with the CDP state it was mounted with to fix
another bug with mpam cdp.

And do not allow monitor group move when the RMID index changes.

These fixes are split out of the v10 Narrow-PARTID series below.
	https://lore.kernel.org/all/20261020134239.3921377-1-ruanjinjie@huawei.com/

v5 RESEND -> v6:
- Drop the moveable_mon_group interface to be discussed widely.
- Updated variable and function name, commit message, comments (Reinette).
- Remove cdp hook and instead check whether all resource CDPs are
  enabled and add a comment (Reinette, Ben).
- Add reviewed-by.
- v5 RESEND: https://lore.kernel.org/all/20261110133938.3768632-1-ruanjinjie@huawei.com/

v5 -> v5 RESEND:
- resend because of email problem.

Changes in v5:
- Update and split the patch as Reinette and Ben suggested.
- Adjust the commit message.
- Add Reviewed-by.
- Link to v4:
  - https://lore.kernel.org/all/20261105070934.2258613-1-ruanjinjie@huawei.com/
  - https://lore.kernel.org/all/20261105123524.2282090-1-ruanjinjie@huawei.com/

Changes in v4:
- Fix the unmount resctrl bug as Reinette suggested.
- Adjust the commit message.
- Add Reviewed-bys.
- Link to v3:
  - https://lore.kernel.org/all/20261031063634.1678345-1-ruanjinjie@huawei.com/
  - https://lore.kernel.org/all/20261031094616.1691026-1-ruanjinjie@huawei.com/

Jinjie Ruan (5):
  fs/resctrl: Report a temporary RMID shortage per CLOSID
  fs/resctrl: Do not allocate a monitor context when releasing limbo
    RMIDs
  fs/resctrl: Clear the CDP state after the cleanup
  fs/resctrl: Stop the limbo handler while resctrl is unmounted
  fs/resctrl: Release the limbo RMIDs when the CDP state changes

Peter Newman (1):
  fs/resctrl: Disallow monitor group move when the RMID index changes

 Documentation/filesystems/resctrl.rst |   8 +-
 fs/resctrl/internal.h                 |   4 +-
 fs/resctrl/monitor.c                  | 160 +++++++++++++++++++++-----
 fs/resctrl/rdtgroup.c                 |  27 ++++-
 4 files changed, 160 insertions(+), 39 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v6 1/6] fs/resctrl: Report a temporary RMID shortage per CLOSID
  2026-11-19  9:48 [PATCH v6 0/6] fs/resctrl: Fix some resctl bugs related to mpam Jinjie Ruan
@ 2026-11-19  9:48 ` Jinjie Ruan
  2026-11-19  9:48 ` [PATCH v6 2/6] fs/resctrl: Do not allocate a monitor context when releasing limbo RMIDs Jinjie Ruan
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 12+ messages in thread
From: Jinjie Ruan @ 2026-11-19  9:48 UTC (permalink / raw)
  To: tony.luck, reinette.chatre, Dave.Martin, james.morse, babu.moger,
	corbet, skhan, rdunlap, bp, tan.shaopeng, gshan, ben.horgan,
	jic23, fenghuay, zengheng4, x86, linux-kernel, linux-doc
  Cc: ruanjinjie

An RMID that is freed is held in limbo until its cache occupancy drops
below the threshold, after which it returns to the free list. A request
that fails because of limbo is thus temporary and worth retrying, which
resctrl reports to userspace as -EBUSY. A request that fails because
every RMID is in use is permanent and reported as -ENOSPC.

Where an RMID is only meaningful together with a CLOSID, a request can
only be satisfied by an RMID belonging to the requested CLOSID, so the
distinction has to be drawn per CLOSID. Instead it is drawn system wide.
-ENOSPC is reported when the free list holds no RMID for the requested
CLOSID, even when that CLOSID has RMIDs in limbo. -EBUSY is reported
when the free list is empty and another CLOSID has an RMID in limbo,
even when the requested CLOSID has none. Userspace is thus told to give
up on a shortage that may clear on its own, and to retry one that cannot
clear until it removes a group itself.

Architectures where the RMID is independent of the CLOSID always match
the first entry on the free list, so neither case arises there and only
MPAM systems are affected.

Draw the distinction from the number of RMIDs the requested CLOSID has
in limbo where the RMID depends on the CLOSID, and from the system wide
count otherwise. Drop the separate test for an empty free list, which
the search handles on its own.

Fixes: c4c0376eefe1 ("x86/resctrl: Allow RMID allocation to be scoped by CLOSID")
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Reviewed-by: Ben Horgan <ben.horgan@arm.com>
Cc: James Morse <james.morse@arm.com>
Cc: Reinette Chatre <reinette.chatre@intel.com>
Cc: Babu Moger <babu.moger@amd.com>
Cc: <stable@vger.kernel.org> # 7.1.x
---
 fs/resctrl/monitor.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c
index 04e4ea612b7c..b8f4e1ff4083 100644
--- a/fs/resctrl/monitor.c
+++ b/fs/resctrl/monitor.c
@@ -207,9 +207,6 @@ static struct rmid_entry *resctrl_find_free_rmid(u32 closid)
 	struct rmid_entry *itr;
 	u32 itr_idx, cmp_idx;
 
-	if (list_empty(&rmid_free_lru))
-		return rmid_limbo_count ? ERR_PTR(-EBUSY) : ERR_PTR(-ENOSPC);
-
 	list_for_each_entry(itr, &rmid_free_lru, list) {
 		/*
 		 * Get the index of this free RMID, and the index it would need
@@ -225,7 +222,17 @@ static struct rmid_entry *resctrl_find_free_rmid(u32 closid)
 			return itr;
 	}
 
-	return ERR_PTR(-ENOSPC);
+	/*
+	 * No free RMID matched. If this CLOSID has RMIDs in limbo, return
+	 * -EBUSY so userspace can retry. Otherwise, the CLOSID is genuinely
+	 * out of RMIDs. When RMIDs are not per-CLOSID, any RMID in limbo
+	 * delays the allocation.
+	 */
+	if (IS_ENABLED(CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID))
+		return closid_num_dirty_rmid[closid] ? ERR_PTR(-EBUSY) :
+						       ERR_PTR(-ENOSPC);
+
+	return rmid_limbo_count ? ERR_PTR(-EBUSY) : ERR_PTR(-ENOSPC);
 }
 
 /**
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v6 2/6] fs/resctrl: Do not allocate a monitor context when releasing limbo RMIDs
  2026-11-19  9:48 [PATCH v6 0/6] fs/resctrl: Fix some resctl bugs related to mpam Jinjie Ruan
  2026-11-19  9:48 ` [PATCH v6 1/6] fs/resctrl: Report a temporary RMID shortage per CLOSID Jinjie Ruan
@ 2026-11-19  9:48 ` Jinjie Ruan
  2026-11-19  9:48 ` [PATCH v6 3/6] fs/resctrl: Clear the CDP state after the cleanup Jinjie Ruan
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 12+ messages in thread
From: Jinjie Ruan @ 2026-11-19  9:48 UTC (permalink / raw)
  To: tony.luck, reinette.chatre, Dave.Martin, james.morse, babu.moger,
	corbet, skhan, rdunlap, bp, tan.shaopeng, gshan, ben.horgan,
	jic23, fenghuay, zengheng4, x86, linux-kernel, linux-doc
  Cc: ruanjinjie

Busy RMIDs of a monitor domain are normally released by the limbo
handler once their cache occupancy drops below the threshold. When a
domain goes offline, its busy RMIDs are released without checking
occupancy, since the domain is going away and the RMIDs would otherwise
never return to the free list.

On the monitor domain offline path, __check_limbo() allocates the
monitor context that an occupancy check needs before it scans the busy
RMIDs, but without using it, and returns early when that allocation
fails. Then the caller destroys the domain's monitoring state, including
the bitmap that records which RMIDs are busy, so nothing can clear those
bits afterwards and the busy counts never reach zero. Those RMIDs never
return to the free list and, where the RMID depends on the CLOSID, the
dirty count of their CLOSID never decreases. The allocation can also
wait for a monitor to become free, which stalls the CPU offline path on
a context that is not going to be used.

Only MPAM systems are affected. An architecture that can always read an
RMID allocates nothing for the monitor context, so the allocation can
neither fail nor wait there.

Move the release of busy RMIDs into a separate function that does not
take a monitor context and leave the occupancy check to __check_limbo().

Fixes: e557999f80a5 ("x86/resctrl: Allow arch to allocate memory needed in resctrl_arch_rmid_read()")
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Reviewed-by: Ben Horgan <ben.horgan@arm.com>
Cc: James Morse <james.morse@arm.com>
Cc: Reinette Chatre <reinette.chatre@intel.com>
Cc: <stable@vger.kernel.org> # 7.1.x
---
 fs/resctrl/internal.h |  2 +-
 fs/resctrl/monitor.c  | 72 ++++++++++++++++++++++++++++---------------
 fs/resctrl/rdtgroup.c |  2 +-
 3 files changed, 49 insertions(+), 27 deletions(-)

diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h
index e62a277dee85..1c85e06f09bf 100644
--- a/fs/resctrl/internal.h
+++ b/fs/resctrl/internal.h
@@ -405,7 +405,7 @@ void cqm_handle_limbo(struct work_struct *work);
 
 bool has_busy_rmid(struct rdt_l3_mon_domain *d);
 
-void __check_limbo(struct rdt_l3_mon_domain *d, bool force_free);
+void release_limbo_rmids(struct rdt_l3_mon_domain *d);
 
 void resctrl_file_fflags_init(const char *config, unsigned long fflags);
 
diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c
index b8f4e1ff4083..ae9ddd380515 100644
--- a/fs/resctrl/monitor.c
+++ b/fs/resctrl/monitor.c
@@ -124,21 +124,45 @@ static void limbo_release_entry(struct rmid_entry *entry)
 		closid_num_dirty_rmid[entry->closid]--;
 }
 
+/*
+ * Release the RMIDs that are marked as busy for this domain without
+ * checking their LLC occupancy. Cache lines may still be tagged with
+ * these RMIDs and will be accounted to the next user of each RMID.
+ */
+void release_limbo_rmids(struct rdt_l3_mon_domain *d)
+{
+	u32 idx_limit = resctrl_arch_system_num_rmid_idx();
+	struct rmid_entry *entry;
+	u32 idx, cur_idx = 1;
+
+	for (;;) {
+		idx = find_next_bit(d->rmid_busy_llc, idx_limit, cur_idx);
+		if (idx >= idx_limit)
+			break;
+
+		entry = __rmid_entry(idx);
+		clear_bit(idx, d->rmid_busy_llc);
+		if (!--entry->busy)
+			limbo_release_entry(entry);
+		cur_idx = idx + 1;
+	}
+}
+
 /*
  * Check the RMIDs that are marked as busy for this domain. If the
  * reported LLC occupancy is below the threshold clear the busy bit and
  * decrement the count. If the busy count gets to zero on an RMID, we
  * free the RMID
  */
-void __check_limbo(struct rdt_l3_mon_domain *d, bool force_free)
+static void __check_limbo(struct rdt_l3_mon_domain *d)
 {
 	struct rdt_resource *r = resctrl_arch_get_resource(RDT_RESOURCE_L3);
 	u32 idx_limit = resctrl_arch_system_num_rmid_idx();
 	struct rmid_entry *entry;
-	bool rmid_dirty = true;
 	u32 idx, cur_idx = 1;
 	void *arch_mon_ctx;
 	void *arch_priv;
+	bool rmid_dirty;
 	u64 val = 0;
 
 	arch_priv = mon_event_all[QOS_L3_OCCUP_EVENT_ID].arch_priv;
@@ -161,30 +185,28 @@ void __check_limbo(struct rdt_l3_mon_domain *d, bool force_free)
 			break;
 
 		entry = __rmid_entry(idx);
-		if (!force_free) {
-			if (resctrl_arch_rmid_read(r, &d->hdr, entry->closid,
-						   entry->rmid, QOS_L3_OCCUP_EVENT_ID,
-						   arch_priv, &val, arch_mon_ctx)) {
-				rmid_dirty = true;
-			} else {
-				rmid_dirty = (val >= resctrl_rmid_realloc_threshold);
-
-				/*
-				 * x86's CLOSID and RMID are independent numbers,
-				 * so the entry's CLOSID is an empty CLOSID
-				 * (X86_RESCTRL_EMPTY_CLOSID). On Arm the RMID
-				 * (PMG) extends the CLOSID (PARTID) space with
-				 * bits that aren't used to select the configuration.
-				 * It is thus necessary to track both CLOSID and
-				 * RMID because there may be dependencies between
-				 * them on some architectures.
-				 */
-				trace_mon_llc_occupancy_limbo(entry->closid, entry->rmid,
-							      d->hdr.id, val);
-			}
+		if (resctrl_arch_rmid_read(r, &d->hdr, entry->closid,
+					   entry->rmid, QOS_L3_OCCUP_EVENT_ID,
+					   arch_priv, &val, arch_mon_ctx)) {
+			rmid_dirty = true;
+		} else {
+			rmid_dirty = (val >= resctrl_rmid_realloc_threshold);
+
+			/*
+			 * x86's CLOSID and RMID are independent numbers,
+			 * so the entry's CLOSID is an empty CLOSID
+			 * (X86_RESCTRL_EMPTY_CLOSID). On Arm the RMID
+			 * (PMG) extends the CLOSID (PARTID) space with
+			 * bits that aren't used to select the configuration.
+			 * It is thus necessary to track both CLOSID and
+			 * RMID because there may be dependencies between
+			 * them on some architectures.
+			 */
+			trace_mon_llc_occupancy_limbo(entry->closid, entry->rmid,
+						      d->hdr.id, val);
 		}
 
-		if (force_free || !rmid_dirty) {
+		if (!rmid_dirty) {
 			clear_bit(idx, d->rmid_busy_llc);
 			if (!--entry->busy)
 				limbo_release_entry(entry);
@@ -843,7 +865,7 @@ void cqm_handle_limbo(struct work_struct *work)
 	if (cpumask_empty(&d->hdr.cpu_mask))
 		goto out_unlock;
 
-	__check_limbo(d, false);
+	__check_limbo(d);
 
 	if (has_busy_rmid(d)) {
 		d->cqm_work_cpu = cpumask_any_housekeeping(&d->hdr.cpu_mask,
diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
index 57ab090072c2..5d0351453c2f 100644
--- a/fs/resctrl/rdtgroup.c
+++ b/fs/resctrl/rdtgroup.c
@@ -4590,7 +4590,7 @@ void resctrl_offline_mon_domain(struct rdt_resource *r, struct rdt_domain_hdr *h
 		 * the RMID as busy creates RMID leaks if the
 		 * package never comes back.
 		 */
-		__check_limbo(d, true);
+		release_limbo_rmids(d);
 	}
 
 	domain_destroy_l3_mon_state(d);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v6 3/6] fs/resctrl: Clear the CDP state after the cleanup
  2026-11-19  9:48 [PATCH v6 0/6] fs/resctrl: Fix some resctl bugs related to mpam Jinjie Ruan
  2026-11-19  9:48 ` [PATCH v6 1/6] fs/resctrl: Report a temporary RMID shortage per CLOSID Jinjie Ruan
  2026-11-19  9:48 ` [PATCH v6 2/6] fs/resctrl: Do not allocate a monitor context when releasing limbo RMIDs Jinjie Ruan
@ 2026-11-19  9:48 ` Jinjie Ruan
  2026-11-19 11:21   ` Ben Horgan
  2026-11-19  9:48 ` [PATCH v6 4/6] fs/resctrl: Stop the limbo handler while resctrl is unmounted Jinjie Ruan
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 12+ messages in thread
From: Jinjie Ruan @ 2026-11-19  9:48 UTC (permalink / raw)
  To: tony.luck, reinette.chatre, Dave.Martin, james.morse, babu.moger,
	corbet, skhan, rdunlap, bp, tan.shaopeng, gshan, ben.horgan,
	jic23, fenghuay, zengheng4, x86, linux-kernel, linux-doc
  Cc: ruanjinjie

To support CDP, resctrl halves the number of CLOSIDs available to
resource groups and gives each remaining CLOSID two hardware
configurations instead of one, distinguished by index: 2 * CLOSID for
data and 2 * CLOSID + 1 for code. Without CDP a CLOSID has a single
configuration, at index CLOSID. Every architecture computes these
indices the same way.

Unmounting clears the CDP state before it undoes what the groups were
given, so the cleanup computes index CLOSID where the group was set up
with 2 * CLOSID and 2 * CLOSID + 1. The group's two configurations are
left in place and index CLOSID is cleared instead, which with CDP
enabled is a configuration of a different CLOSID. The architecture may
keep this state for as long as the resource exists.

Only MPAM can reach this today. Of everything the cleanup has to undo,
MPAM addresses only the MBM counter assignment by the translated CLOSID,
and it only began doing so when it implemented assignable counters. x86
addresses its counters by RMID alone.

Clear the CDP state after the cleanup, so that the cleanup runs with the
CDP state the groups were set up under.

Fixes: 6e0e538a75ce ("arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use")
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Cc: <stable@vger.kernel.org>
---
v6:
- Describe the CDP indices as resctrl filesystem behavior that applies
  to every architecture, and the flow instead of the code (Reinette).
- Drop the stable version range, the Fixes tag already gives it.
---
 fs/resctrl/rdtgroup.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
index 5d0351453c2f..3312637fb514 100644
--- a/fs/resctrl/rdtgroup.c
+++ b/fs/resctrl/rdtgroup.c
@@ -3150,13 +3150,19 @@ static void resctrl_unmount(void)
 	cpus_read_lock();
 	mutex_lock(&rdtgroup_mutex);
 
-	rdt_disable_ctx();
-
 	/* Put everything back to default values. */
 	for_each_alloc_capable_rdt_resource(r)
 		resctrl_arch_reset_all_ctrls(r);
 
 	resctrl_fs_teardown();
+
+	/*
+	 * Clear the CDP state after the cleanup. The CDP state decides
+	 * which hardware configuration a CLOSID refers to, so the teardown
+	 * must run with the state the configuration was created under.
+	 */
+	rdt_disable_ctx();
+
 	if (resctrl_arch_alloc_capable())
 		resctrl_arch_disable_alloc();
 	if (resctrl_arch_mon_capable())
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v6 4/6] fs/resctrl: Stop the limbo handler while resctrl is unmounted
  2026-11-19  9:48 [PATCH v6 0/6] fs/resctrl: Fix some resctl bugs related to mpam Jinjie Ruan
                   ` (2 preceding siblings ...)
  2026-11-19  9:48 ` [PATCH v6 3/6] fs/resctrl: Clear the CDP state after the cleanup Jinjie Ruan
@ 2026-11-19  9:48 ` Jinjie Ruan
  2026-11-19 12:34   ` Ben Horgan
  2026-11-19  9:48 ` [PATCH v6 5/6] fs/resctrl: Release the limbo RMIDs when the CDP state changes Jinjie Ruan
  2026-11-19  9:48 ` [PATCH v6 6/6] fs/resctrl: Disallow monitor group move when the RMID index changes Jinjie Ruan
  5 siblings, 1 reply; 12+ messages in thread
From: Jinjie Ruan @ 2026-11-19  9:48 UTC (permalink / raw)
  To: tony.luck, reinette.chatre, Dave.Martin, james.morse, babu.moger,
	corbet, skhan, rdunlap, bp, tan.shaopeng, gshan, ben.horgan,
	jic23, fenghuay, zengheng4, x86, linux-kernel, linux-doc
  Cc: ruanjinjie

A monitoring group's RMID is not returned to the free list when the
group is removed. It stays in limbo until the cache occupancy still
counted against it has dropped low enough for the RMID to be reused,
which the limbo handler checks once a second.

The limbo handler keeps running after resctrl is unmounted, where there
is nothing for it to achieve. An RMID is only allocated when a group is
created, which needs resctrl to be mounted, so no RMID the limbo handler
returns to the free list can be used before the next mount, and that
mount can check them itself. The MBM overflow handler already stops for
this reason once resctrl_mounted is cleared.

Reading the RMIDs in limbo while resctrl is unmounted is not safe on
every architecture. On MPAM the counter of an RMID is selected by the
CLOSID that owns it, and the CLOSID depends on the CDP state. Unmount
clears the CDP state, so the limbo handler that keeps running reads the
RMIDs freed under CDP through the CLOSIDs of the cleared state.

Stop the limbo handler while resctrl is unmounted, as the overflow
handler does, and restart it after a mount on every domain that still
has RMIDs in limbo. The worker can stay queued across the unmount, so
cancel it before queuing it again.

Fixes: 6789fb99282c ("arm_mpam: resctrl: Add CDP emulation")
Suggested-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Cc: <stable@vger.kernel.org>
---
v6:
- Explain first why stopping the limbo handler is fine on every
  architecture, and describe MPAM by CLOSID only (Reinette).
- Rename resctrl_limbo_resume() to cqm_resume_limbo_handler() and declare
  it with the other limbo handler helpers (Reinette).
- Return early when the L3 resource is not mon_capable (Reinette).
- Drop the stable version range, the Fixes tag already gives it.
---
 fs/resctrl/internal.h |  2 ++
 fs/resctrl/monitor.c  | 42 ++++++++++++++++++++++++++++++++++++++++--
 fs/resctrl/rdtgroup.c |  2 ++
 3 files changed, 44 insertions(+), 2 deletions(-)

diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h
index 1c85e06f09bf..f52e0937702a 100644
--- a/fs/resctrl/internal.h
+++ b/fs/resctrl/internal.h
@@ -401,6 +401,8 @@ bool is_mba_sc(struct rdt_resource *r);
 void cqm_setup_limbo_handler(struct rdt_l3_mon_domain *dom, unsigned long delay_ms,
 			     int exclude_cpu);
 
+void cqm_resume_limbo_handler(void);
+
 void cqm_handle_limbo(struct work_struct *work);
 
 bool has_busy_rmid(struct rdt_l3_mon_domain *d);
diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c
index ae9ddd380515..ede1708b920e 100644
--- a/fs/resctrl/monitor.c
+++ b/fs/resctrl/monitor.c
@@ -852,6 +852,13 @@ void cqm_handle_limbo(struct work_struct *work)
 	 */
 	mutex_lock(&rdtgroup_mutex);
 
+	/*
+	 * If the filesystem has been unmounted this work no longer needs to
+	 * run. cqm_resume_limbo_handler() restarts it on the next mount.
+	 */
+	if (!resctrl_mounted)
+		goto out_unlock;
+
 	/*
 	 * Ensure the worker is dedicated to a CPU as intended and not
 	 * relocated by workqueue subsystem as part of CPU going offline.
@@ -1001,8 +1008,8 @@ int setup_rmid_lru_list(void)
 	/*
 	 * Called on every mount, but the number of RMIDs cannot change
 	 * after the first mount, so keep using the same set of rmid_ptrs[]
-	 * until resctrl_exit(). Note that the limbo handler continues to
-	 * access rmid_ptrs[] after resctrl is unmounted.
+	 * until resctrl_exit(). Note that the RMIDs in limbo stay in limbo
+	 * across an unmount and are checked again after the next mount.
 	 */
 	if (rmid_ptrs)
 		return 0;
@@ -1033,6 +1040,37 @@ int setup_rmid_lru_list(void)
 	return 0;
 }
 
+/**
+ * cqm_resume_limbo_handler() - Restart the limbo handler after a mount.
+ *
+ * The limbo handler stops while resctrl is unmounted. Restart it on every
+ * domain that still has RMIDs in limbo.
+ */
+void cqm_resume_limbo_handler(void)
+{
+	struct rdt_resource *r = resctrl_arch_get_resource(RDT_RESOURCE_L3);
+	struct rdt_l3_mon_domain *d;
+
+	lockdep_assert_cpus_held();
+	lockdep_assert_held(&rdtgroup_mutex);
+
+	if (!r->mon_capable || !resctrl_is_mon_event_enabled(QOS_L3_OCCUP_EVENT_ID))
+		return;
+
+	list_for_each_entry_rcu(d, &r->mon_domains, hdr.list,
+				lockdep_is_cpus_held()) {
+		if (!has_busy_rmid(d))
+			continue;
+
+		/*
+		 * The unmount may have left the worker queued. Cancel it so
+		 * it is queued again on a CPU picked now.
+		 */
+		cancel_delayed_work(&d->cqm_limbo);
+		cqm_setup_limbo_handler(d, 0, RESCTRL_PICK_ANY_CPU);
+	}
+}
+
 void free_rmid_lru_list(void)
 {
 	if (!resctrl_arch_mon_capable())
diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
index 3312637fb514..c7c4f618208d 100644
--- a/fs/resctrl/rdtgroup.c
+++ b/fs/resctrl/rdtgroup.c
@@ -3267,6 +3267,8 @@ static int rdt_get_tree(struct fs_context *fc)
 						   RESCTRL_PICK_ANY_CPU);
 	}
 
+	cqm_resume_limbo_handler();
+
 	/*
 	 * Ensure root remains accessible after mutex is unlocked so that
 	 * kernfs_kill_sb() can run safely if called by kernfs_get_tree()'s
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v6 5/6] fs/resctrl: Release the limbo RMIDs when the CDP state changes
  2026-11-19  9:48 [PATCH v6 0/6] fs/resctrl: Fix some resctl bugs related to mpam Jinjie Ruan
                   ` (3 preceding siblings ...)
  2026-11-19  9:48 ` [PATCH v6 4/6] fs/resctrl: Stop the limbo handler while resctrl is unmounted Jinjie Ruan
@ 2026-11-19  9:48 ` Jinjie Ruan
  2026-11-19 16:49   ` Ben Horgan
  2026-11-19  9:48 ` [PATCH v6 6/6] fs/resctrl: Disallow monitor group move when the RMID index changes Jinjie Ruan
  5 siblings, 1 reply; 12+ messages in thread
From: Jinjie Ruan @ 2026-11-19  9:48 UTC (permalink / raw)
  To: tony.luck, reinette.chatre, Dave.Martin, james.morse, babu.moger,
	corbet, skhan, rdunlap, bp, tan.shaopeng, gshan, ben.horgan,
	jic23, fenghuay, zengheng4, x86, linux-kernel, linux-doc
  Cc: ruanjinjie

On MPAM the counter of an RMID is selected by the PARTIDs of the CLOSID
that owned it. Without CDP, CLOSID c is PARTID c; with CDP it is
PARTIDs 2c and 2c+1. An RMID that stays in limbo across an unmount and
a mount that changes the CDP state is read through the PARTIDs of the
new state, which are not the PARTIDs its cache lines are tagged with.

With 5 PARTIDs:

  mount                  CDP off, CLOSID c -> PARTID c
  mkdir g1..g4           CLOSIDs 1..4
  umount                 RMIDs enter limbo with CLOSIDs 1..4
  mount -o cdp           CDP on, CLOSID c -> PARTIDs 2c, 2c+1
  limbo handler          reads CLOSID 2 as PARTID 5 > PARTID_MAX 4
                         MSC error interrupt, mpam_disable()

The other direction is worse because nothing reports it. If resctrl is
mounted with CDP and mounted again without it, CLOSID c is read as
PARTID c, which is in range, so the limbo handler silently tests the
occupancy of the PARTID of a different CLOSID and frees or keeps the
RMIDs based on it.

Where the RMID depends on the CLOSID, as on MPAM, release the RMIDs in
limbo without reading them when a mount changes the CDP state, instead
of restarting the limbo handler. Cache lines that still carry those
RMIDs are accounted to the next user of each RMID. Where the RMID does
not depend on the CLOSID, as on x86, the CDP state does not change how
an RMID is read and the limbo handler is restarted as before.

Compare the CDP state of every resource, not just the L3: on MPAM, CDP
enabled on any resource gives every CLOSID two PARTIDs in all MSCs, so
mounting with -o cdpl2 alone also changes how the L3 monitors read a
CLOSID, and cache levels beyond the L3 would too.

Reproduced on QEMU with the sequence above:

  mpam:__mpam_irq_handler: error irq from msc:1 'MSMONCFG_ID_RANGE', partid:5, pmg: 0, ris: 0
  mpam:mpam_disable: MPAM disabled due to hardware error interrupt

With the change the sequence completes without an error.

Fixes: 6789fb99282c ("arm_mpam: resctrl: Add CDP emulation")
Suggested-by: Ben Horgan <ben.horgan@arm.com>
Suggested-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Cc: <stable@vger.kernel.org>
---
v6:
- Drop resctrl_arch_mon_cdp_enabled() and compare the CDP state of
  every resouce's cdp state, with a comment on why they are
  checked (Reinette, Ben).
- Restrict the release to the systems where the RMID depends on the
  CLOSID, in the changelog and the comments, and keep the hardware IDs
  out of the file system comments (Reinette).
- Reword the limbo_cdp_enabled comment (Reinette).
- Drop the stable version range, the Fixes tag already gives it.
v5:
- Split the change of the limbo handler lifetime into the previous
  patch. The limbo handler now stops while resctrl is unmounted on every
  architecture, and only the release of the RMIDs depends on
  CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID.
- Drop the cqm_work_cpu changes. resctrl_limbo_resume() cancels the
  worker before it queues it again or releases the RMIDs.
- Move the rdt_disable_ctx() reordering to a separate patch.
- Add resctrl_arch_mon_cdp_enabled() instead of comparing the CDP state
  of L2 in the file system.
- Rename limbo_cdp to limbo_cdp_enabled and document that it is only set
  with CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID.
- Check QOS_L3_OCCUP_EVENT_ID first and drop the rmid_busy_llc check.
- Use lockdep_assert_cpus_held() at the start of resctrl_limbo_resume().
- Describe the reverse sequence, from CDP on to CDP off.
- Link to v4: https://lore.kernel.org/all/20261105070934.2258613-4-ruanjinjie@huawei.com/
v4:
- Use resctrl_mounted instead of a separate limbo_paused flag.
- Record the CDP state once when resctrl is mounted.
- Add resctrl_limbo_resume(), called once resctrl_mounted is set.
- Previous Link: https://lore.kernel.org/all/20261031094616.1691026-1-ruanjinjie@huawei.com/
---
 fs/resctrl/monitor.c | 35 +++++++++++++++++++++++++++++++++--
 1 file changed, 33 insertions(+), 2 deletions(-)

diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c
index ede1708b920e..2c8c60138768 100644
--- a/fs/resctrl/monitor.c
+++ b/fs/resctrl/monitor.c
@@ -70,6 +70,13 @@ static u32 *closid_num_dirty_rmid;
  */
 static unsigned int rmid_limbo_count;
 
+/*
+ * @limbo_cdp_enabled - True if the RMIDs in limbo were placed there while CDP
+ *     was enabled. Only used when CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID is
+ *     defined.
+ */
+static bool limbo_cdp_enabled;
+
 /*
  * @rmid_entry - The entry in the limbo and free lists.
  */
@@ -1044,12 +1051,15 @@ int setup_rmid_lru_list(void)
  * cqm_resume_limbo_handler() - Restart the limbo handler after a mount.
  *
  * The limbo handler stops while resctrl is unmounted. Restart it on every
- * domain that still has RMIDs in limbo.
+ * domain that still has RMIDs in limbo. Where the RMID depends on the CLOSID
+ * and the mount changed the RMID index a CLOSID is monitored with, the RMIDs
+ * in limbo can no longer be read: release them instead.
  */
 void cqm_resume_limbo_handler(void)
 {
 	struct rdt_resource *r = resctrl_arch_get_resource(RDT_RESOURCE_L3);
 	struct rdt_l3_mon_domain *d;
+	bool release = false;
 
 	lockdep_assert_cpus_held();
 	lockdep_assert_held(&rdtgroup_mutex);
@@ -1057,6 +1067,24 @@ void cqm_resume_limbo_handler(void)
 	if (!r->mon_capable || !resctrl_is_mon_event_enabled(QOS_L3_OCCUP_EVENT_ID))
 		return;
 
+	/*
+	 * Where the RMID depends on the CLOSID, the RMIDs in limbo can only
+	 * be read with the CDP state they were freed under. Check every
+	 * resource because CDP enabled on any resource changes how every
+	 * CLOSID is monitored, so CDP on another resource alone also changes
+	 * how the L3 monitors are read.
+	 */
+	if (IS_ENABLED(CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID)) {
+		struct rdt_resource *res;
+		bool cdp_enabled = false;
+
+		for_each_rdt_resource(res)
+			cdp_enabled |= resctrl_arch_get_cdp_enabled(res->rid);
+
+		release = cdp_enabled != limbo_cdp_enabled;
+		limbo_cdp_enabled = cdp_enabled;
+	}
+
 	list_for_each_entry_rcu(d, &r->mon_domains, hdr.list,
 				lockdep_is_cpus_held()) {
 		if (!has_busy_rmid(d))
@@ -1067,7 +1095,10 @@ void cqm_resume_limbo_handler(void)
 		 * it is queued again on a CPU picked now.
 		 */
 		cancel_delayed_work(&d->cqm_limbo);
-		cqm_setup_limbo_handler(d, 0, RESCTRL_PICK_ANY_CPU);
+		if (release)
+			release_limbo_rmids(d);
+		else
+			cqm_setup_limbo_handler(d, 0, RESCTRL_PICK_ANY_CPU);
 	}
 }
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v6 6/6] fs/resctrl: Disallow monitor group move when the RMID index changes
  2026-11-19  9:48 [PATCH v6 0/6] fs/resctrl: Fix some resctl bugs related to mpam Jinjie Ruan
                   ` (4 preceding siblings ...)
  2026-11-19  9:48 ` [PATCH v6 5/6] fs/resctrl: Release the limbo RMIDs when the CDP state changes Jinjie Ruan
@ 2026-11-19  9:48 ` Jinjie Ruan
  2026-11-19 16:57   ` Ben Horgan
  5 siblings, 1 reply; 12+ messages in thread
From: Jinjie Ruan @ 2026-11-19  9:48 UTC (permalink / raw)
  To: tony.luck, reinette.chatre, Dave.Martin, james.morse, babu.moger,
	corbet, skhan, rdunlap, bp, tan.shaopeng, gshan, ben.horgan,
	jic23, fenghuay, zengheng4, x86, linux-kernel, linux-doc
  Cc: ruanjinjie

From: Peter Newman <peternewman@google.com>

A MON group can be moved into the mon_groups directory of another
CTRL_MON group to move its tasks to that group's allocation while
keeping their monitoring data. Where the RMID is only meaningful
together with the CLOSID, as on arm64 MPAM where the RMID is a PMG that
extends the PARTID, the move changes the RMID index of the group. The
move succeeds, but:

- The group's monitoring data is reset. Its counters are identified by
  the CLOSID and RMID together, so after the move the group reads the
  counters of the new CLOSID instead of the ones its tasks used.

- The group uses an RMID index that was never allocated to it. When
  the group is removed, free_rmid() puts an RMID index of the new CLOSID
  into limbo without checking that the group owns it. If another group
  of that CLOSID holds the index, the limbo handler tests and frees an
  RMID that is still in use, while the RMID index allocated to the
  moved group is never freed. If no other group holds it, the index is
  in use while it is considered free for allocation.

- The tasks are not moved. mongrp_reparent() sets the new parent and
  CLOSID of the group before rdt_move_group_tasks() looks for the tasks
  to update, and the search then matches on the new CLOSID, which none
  of the tasks carries yet. The tasks keep the old CLOSID and the old
  CTRL_MON group's allocation, and the group does not count them.

Fixing the task move does not make the move work. The RMID index is the
hardware ID the counters count for, so a group whose CLOSID changes
cannot keep its monitoring data, and it would need a new RMID index
allocated for the new CLOSID, which fails when every RMID index of that
CLOSID is in use. The documentation promises that a move keeps the
monitoring data, so the move cannot be supported, as decided in the
thread at the Link tag.

Reject the move with -EOPNOTSUPP when it changes the RMID index of the
group, and document that a move is not allowed when the monitoring data
or assigned tasks would be impacted. Leave the move allowed where the
RMID does not depend on the CLOSID, such as on x86, and leave renaming
within the same CTRL_MON group allowed everywhere; neither changes the
RMID index.

Fixes: 3e9b35823aab ("arm_mpam: resctrl: Add rmid index helpers")
Signed-off-by: Peter Newman <peternewman@google.com>
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/lkml/3a637631-c8ec-4e26-a03c-5ac80d16fab3@arm.com/
---
v6:
- Describe the RMID index that is used while it is considered free, and
  keep the last paragraph imperative (Reinette).
v5:
- Retitle as the RMID index changes, not the RMID, and a rename within
  the same CTRL_MON group is still allowed.
- Describe the RMID index that is freed without having been allocated,
  and why the move cannot be fixed instead of being rejected.
- Drop the parent and resctrl_arch_mon_capable() checks, which the RMID
  index comparison and the MON group check already cover.
- Use the resctrl.rst terms in the last_cmd_status message.
- Drop the stable version range and the Link tags the changelog did not
  refer to, and link the decision to reject the move instead.
- Link to v2: https://lore.kernel.org/all/20261105123524.2282090-1-ruanjinjie@huawei.com/
v2:
- Drop the Suggested-by tag.
- Describe the systems by whether the RMID depends on the CLOSID rather
  than by MPAM, in both the changelog and resctrl.rst.
- Explain that moving a monitor group is already broken on these systems
  because the tasks are not moved, so no existing user relies on it.
- v1: https://lore.kernel.org/all/20261104101913.586595-1-ruanjinjie@huawei.com/
---
 Documentation/filesystems/resctrl.rst |  8 ++++----
 fs/resctrl/rdtgroup.c                 | 13 +++++++++++++
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/Documentation/filesystems/resctrl.rst b/Documentation/filesystems/resctrl.rst
index b52795e03303..fecb2cd2b343 100644
--- a/Documentation/filesystems/resctrl.rst
+++ b/Documentation/filesystems/resctrl.rst
@@ -551,10 +551,10 @@ will automatically remove all MON groups below it.
 
 Moving MON group directories to a new parent CTRL_MON group is supported
 for the purpose of changing the resource allocations of a MON group
-without impacting its monitoring data or assigned tasks. This operation
-is not allowed for MON groups which monitor CPUs. No other move
-operation is currently allowed other than simply renaming a CTRL_MON or
-MON group.
+without impacting its monitoring data or assigned tasks. This operation is
+not allowed for MON groups which monitor CPUs, or when the monitoring data
+or assigned tasks would be impacted. No other move operation is currently
+allowed other than simply renaming a CTRL_MON or MON group.
 
 All groups contain the following files:
 
diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
index c7c4f618208d..e16ae5799e0b 100644
--- a/fs/resctrl/rdtgroup.c
+++ b/fs/resctrl/rdtgroup.c
@@ -4403,6 +4403,19 @@ static int rdtgroup_rename(struct kernfs_node *kn,
 		goto out;
 	}
 
+	/*
+	 * Moving the group to another CTRL_MON group changes its CLOSID.
+	 * Where the RMID is only meaningful together with the CLOSID, this
+	 * changes the RMID index and the monitor state cannot follow the
+	 * move. A rename within the same CTRL_MON group keeps the index.
+	 */
+	if (resctrl_arch_rmid_idx_encode(rdtgrp->closid, rdtgrp->mon.rmid) !=
+	    resctrl_arch_rmid_idx_encode(new_prdtgrp->closid, rdtgrp->mon.rmid)) {
+		rdt_last_cmd_puts("Moving a MON group to a new CTRL_MON group is not supported\n");
+		ret = -EOPNOTSUPP;
+		goto out;
+	}
+
 	/*
 	 * If the MON group is monitoring CPUs, the CPUs must be assigned to the
 	 * current parent CTRL_MON group and therefore cannot be assigned to
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH v6 3/6] fs/resctrl: Clear the CDP state after the cleanup
  2026-11-19  9:48 ` [PATCH v6 3/6] fs/resctrl: Clear the CDP state after the cleanup Jinjie Ruan
@ 2026-11-19 11:21   ` Ben Horgan
  2026-11-19 12:15     ` Jinjie Ruan
  0 siblings, 1 reply; 12+ messages in thread
From: Ben Horgan @ 2026-11-19 11:21 UTC (permalink / raw)
  To: Jinjie Ruan, tony.luck, reinette.chatre, Dave.Martin, james.morse,
	babu.moger, corbet, skhan, rdunlap, bp, tan.shaopeng, gshan,
	jic23, fenghuay, zengheng4, x86, linux-kernel, linux-doc

Hi Jinjie,

On 19/11/2026 09:48, Jinjie Ruan wrote:
> To support CDP, resctrl halves the number of CLOSIDs available to
> resource groups and gives each remaining CLOSID two hardware
> configurations instead of one, distinguished by index: 2 * CLOSID for
> data and 2 * CLOSID + 1 for code. Without CDP a CLOSID has a single
> configuration, at index CLOSID. Every architecture computes these
> indices the same way.
> 
> Unmounting clears the CDP state before it undoes what the groups were
> given, so the cleanup computes index CLOSID where the group was set up
> with 2 * CLOSID and 2 * CLOSID + 1. The group's two configurations are
> left in place and index CLOSID is cleared instead, which with CDP
> enabled is a configuration of a different CLOSID. The architecture may
> keep this state for as long as the resource exists.
> 
> Only MPAM can reach this today. Of everything the cleanup has to undo,
> MPAM addresses only the MBM counter assignment by the translated CLOSID,
> and it only began doing so when it implemented assignable counters. 

This is clearly not ideal but even in MPAM we get away without any usable visible effect. Or am I
missing something? We are left with some assigned counters from the MPAM driver point of view but
the resctrl is in charge of the assignments and MPAM doesn't check if a counter is already assigned
when resctrl asks for a new assignment. The change looks good to me.

Thanks,

Ben


x86
> addresses its counters by RMID alone.
> 
> Clear the CDP state after the cleanup, so that the cleanup runs with the
> CDP state the groups were set up under.
> 
> Fixes: 6e0e538a75ce ("arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use")
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
> Cc: <stable@vger.kernel.org>
> ---
> v6:
> - Describe the CDP indices as resctrl filesystem behavior that applies
>   to every architecture, and the flow instead of the code (Reinette).
> - Drop the stable version range, the Fixes tag already gives it.
> ---
>  fs/resctrl/rdtgroup.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
> index 5d0351453c2f..3312637fb514 100644
> --- a/fs/resctrl/rdtgroup.c
> +++ b/fs/resctrl/rdtgroup.c
> @@ -3150,13 +3150,19 @@ static void resctrl_unmount(void)
>  	cpus_read_lock();
>  	mutex_lock(&rdtgroup_mutex);
>  
> -	rdt_disable_ctx();
> -
>  	/* Put everything back to default values. */
>  	for_each_alloc_capable_rdt_resource(r)
>  		resctrl_arch_reset_all_ctrls(r);
>  
>  	resctrl_fs_teardown();
> +
> +	/*
> +	 * Clear the CDP state after the cleanup. The CDP state decides
> +	 * which hardware configuration a CLOSID refers to, so the teardown
> +	 * must run with the state the configuration was created under.
> +	 */
> +	rdt_disable_ctx();
> +
>  	if (resctrl_arch_alloc_capable())
>  		resctrl_arch_disable_alloc();
>  	if (resctrl_arch_mon_capable())


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v6 3/6] fs/resctrl: Clear the CDP state after the cleanup
  2026-11-19 11:21   ` Ben Horgan
@ 2026-11-19 12:15     ` Jinjie Ruan
  0 siblings, 0 replies; 12+ messages in thread
From: Jinjie Ruan @ 2026-11-19 12:15 UTC (permalink / raw)
  To: Ben Horgan, tony.luck, reinette.chatre, Dave.Martin, james.morse,
	babu.moger, corbet, skhan, rdunlap, bp, tan.shaopeng, gshan,
	jic23, fenghuay, zengheng4, x86, linux-kernel, linux-doc



在 2026/11/19 19:21, Ben Horgan 写道:
> Hi Jinjie,
> 
> On 19/11/2026 09:48, Jinjie Ruan wrote:
>> To support CDP, resctrl halves the number of CLOSIDs available to
>> resource groups and gives each remaining CLOSID two hardware
>> configurations instead of one, distinguished by index: 2 * CLOSID for
>> data and 2 * CLOSID + 1 for code. Without CDP a CLOSID has a single
>> configuration, at index CLOSID. Every architecture computes these
>> indices the same way.
>>
>> Unmounting clears the CDP state before it undoes what the groups were
>> given, so the cleanup computes index CLOSID where the group was set up
>> with 2 * CLOSID and 2 * CLOSID + 1. The group's two configurations are
>> left in place and index CLOSID is cleared instead, which with CDP
>> enabled is a configuration of a different CLOSID. The architecture may
>> keep this state for as long as the resource exists.
>>
>> Only MPAM can reach this today. Of everything the cleanup has to undo,
>> MPAM addresses only the MBM counter assignment by the translated CLOSID,
>> and it only began doing so when it implemented assignable counters. 
> 
> This is clearly not ideal but even in MPAM we get away without any usable visible effect. Or am I
> missing something? We are left with some assigned counters from the MPAM driver point of view but
> the resctrl is in charge of the assignments and MPAM doesn't check if a counter is already assigned
> when resctrl asks for a new assignment. The change looks good to me.

I agree with your analysis, and I have also confirmed it:

- __config_cntr() only performs an overwrite write and does not modify
the allocation of assigned_counters[].

 if (assign)
     mon->mbwu_idx_to_mon[mbwu_idx] = mon->assigned_counters[mon_idx];
 else
     mon->mbwu_idx_to_mon[mbwu_idx] = -1;

- When umount, the resctrl cntr_cfg[] is destroyed along with the
domain, and cross-mounting does not exist.

- When the mbm_cntr_get() is used to read, cntr_cfg[] of the resctrl is
checked first. If no record is found, the value is directly set to
Unassigned, so the stale mbwu_idx_to_mon will not be read between
unmounted and the next time it is mounted.

- Each time a new allocation is performed, the same
mbwu_idx_to_mon[mbwu_idx] is overwritten.

so there is no observable error. It is a silent error.

Best regards,
Jinjie

> 
> Thanks,
> 
> Ben
> 
> 
> x86
>> addresses its counters by RMID alone.
>>
>> Clear the CDP state after the cleanup, so that the cleanup runs with the
>> CDP state the groups were set up under.
>>
>> Fixes: 6e0e538a75ce ("arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use")
>> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
>> Cc: <stable@vger.kernel.org>
>> ---
>> v6:
>> - Describe the CDP indices as resctrl filesystem behavior that applies
>>   to every architecture, and the flow instead of the code (Reinette).
>> - Drop the stable version range, the Fixes tag already gives it.
>> ---
>>  fs/resctrl/rdtgroup.c | 10 ++++++++--
>>  1 file changed, 8 insertions(+), 2 deletions(-)
>>
>> diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
>> index 5d0351453c2f..3312637fb514 100644
>> --- a/fs/resctrl/rdtgroup.c
>> +++ b/fs/resctrl/rdtgroup.c
>> @@ -3150,13 +3150,19 @@ static void resctrl_unmount(void)
>>  	cpus_read_lock();
>>  	mutex_lock(&rdtgroup_mutex);
>>  
>> -	rdt_disable_ctx();
>> -
>>  	/* Put everything back to default values. */
>>  	for_each_alloc_capable_rdt_resource(r)
>>  		resctrl_arch_reset_all_ctrls(r);
>>  
>>  	resctrl_fs_teardown();
>> +
>> +	/*
>> +	 * Clear the CDP state after the cleanup. The CDP state decides
>> +	 * which hardware configuration a CLOSID refers to, so the teardown
>> +	 * must run with the state the configuration was created under.
>> +	 */
>> +	rdt_disable_ctx();
>> +
>>  	if (resctrl_arch_alloc_capable())
>>  		resctrl_arch_disable_alloc();
>>  	if (resctrl_arch_mon_capable())
> 


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v6 4/6] fs/resctrl: Stop the limbo handler while resctrl is unmounted
  2026-11-19  9:48 ` [PATCH v6 4/6] fs/resctrl: Stop the limbo handler while resctrl is unmounted Jinjie Ruan
@ 2026-11-19 12:34   ` Ben Horgan
  0 siblings, 0 replies; 12+ messages in thread
From: Ben Horgan @ 2026-11-19 12:34 UTC (permalink / raw)
  To: Jinjie Ruan, tony.luck, reinette.chatre, Dave.Martin, james.morse,
	babu.moger, corbet, skhan, rdunlap, bp, tan.shaopeng, gshan,
	jic23, fenghuay, zengheng4, x86, linux-kernel, linux-doc

Hi Jinjie,

On 19/11/2026 09:48, Jinjie Ruan wrote:
> A monitoring group's RMID is not returned to the free list when the
> group is removed. It stays in limbo until the cache occupancy still
> counted against it has dropped low enough for the RMID to be reused,
> which the limbo handler checks once a second.
> 
> The limbo handler keeps running after resctrl is unmounted, where there
> is nothing for it to achieve. An RMID is only allocated when a group is
> created, which needs resctrl to be mounted, so no RMID the limbo handler
> returns to the free list can be used before the next mount, and that
> mount can check them itself. The MBM overflow handler already stops for
> this reason once resctrl_mounted is cleared.
> 
> Reading the RMIDs in limbo while resctrl is unmounted is not safe on
> every architecture. On MPAM the counter of an RMID is selected by the
> CLOSID that owns it, and the CLOSID depends on the CDP state. Unmount
> clears the CDP state, so the limbo handler that keeps running reads the
> RMIDs freed under CDP through the CLOSIDs of the cleared state.
> 
> Stop the limbo handler while resctrl is unmounted, as the overflow
> handler does, and restart it after a mount on every domain that still
> has RMIDs in limbo. The worker can stay queued across the unmount, so
> cancel it before queuing it again.
> 
> Fixes: 6789fb99282c ("arm_mpam: resctrl: Add CDP emulation")
> Suggested-by: Reinette Chatre <reinette.chatre@intel.com>
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
> Cc: <stable@vger.kernel.org>
> ---
> v6:
> - Explain first why stopping the limbo handler is fine on every
>   architecture, and describe MPAM by CLOSID only (Reinette).
> - Rename resctrl_limbo_resume() to cqm_resume_limbo_handler() and declare
>   it with the other limbo handler helpers (Reinette).
> - Return early when the L3 resource is not mon_capable (Reinette).
> - Drop the stable version range, the Fixes tag already gives it.
> ---
>  fs/resctrl/internal.h |  2 ++
>  fs/resctrl/monitor.c  | 42 ++++++++++++++++++++++++++++++++++++++++--
>  fs/resctrl/rdtgroup.c |  2 ++
>  3 files changed, 44 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h
> index 1c85e06f09bf..f52e0937702a 100644
> --- a/fs/resctrl/internal.h
> +++ b/fs/resctrl/internal.h
> @@ -401,6 +401,8 @@ bool is_mba_sc(struct rdt_resource *r);
>  void cqm_setup_limbo_handler(struct rdt_l3_mon_domain *dom, unsigned long delay_ms,
>  			     int exclude_cpu);
>  
> +void cqm_resume_limbo_handler(void);
> +
>  void cqm_handle_limbo(struct work_struct *work);
>  
>  bool has_busy_rmid(struct rdt_l3_mon_domain *d);
> diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c
> index ae9ddd380515..ede1708b920e 100644
> --- a/fs/resctrl/monitor.c
> +++ b/fs/resctrl/monitor.c
> @@ -852,6 +852,13 @@ void cqm_handle_limbo(struct work_struct *work)
>  	 */
>  	mutex_lock(&rdtgroup_mutex);
>  
> +	/*
> +	 * If the filesystem has been unmounted this work no longer needs to
> +	 * run. cqm_resume_limbo_handler() restarts it on the next mount.
> +	 */
> +	if (!resctrl_mounted)
> +		goto out_unlock;
> +
>  	/*
>  	 * Ensure the worker is dedicated to a CPU as intended and not
>  	 * relocated by workqueue subsystem as part of CPU going offline.
> @@ -1001,8 +1008,8 @@ int setup_rmid_lru_list(void)
>  	/*
>  	 * Called on every mount, but the number of RMIDs cannot change
>  	 * after the first mount, so keep using the same set of rmid_ptrs[]
> -	 * until resctrl_exit(). Note that the limbo handler continues to
> -	 * access rmid_ptrs[] after resctrl is unmounted.
> +	 * until resctrl_exit(). Note that the RMIDs in limbo stay in limbo
> +	 * across an unmount and are checked again after the next mount.
>  	 */
>  	if (rmid_ptrs)
>  		return 0;
> @@ -1033,6 +1040,37 @@ int setup_rmid_lru_list(void)
>  	return 0;
>  }
>  
> +/**
> + * cqm_resume_limbo_handler() - Restart the limbo handler after a mount.
> + *
> + * The limbo handler stops while resctrl is unmounted. Restart it on every
> + * domain that still has RMIDs in limbo.
> + */
> +void cqm_resume_limbo_handler(void)
> +{
> +	struct rdt_resource *r = resctrl_arch_get_resource(RDT_RESOURCE_L3);
> +	struct rdt_l3_mon_domain *d;
> +
> +	lockdep_assert_cpus_held();
> +	lockdep_assert_held(&rdtgroup_mutex);
> +
> +	if (!r->mon_capable || !resctrl_is_mon_event_enabled(QOS_L3_OCCUP_EVENT_ID))
> +		return;
> +
> +	list_for_each_entry_rcu(d, &r->mon_domains, hdr.list,
> +				lockdep_is_cpus_held()) {

nit: Unnecessary line break.

Reviewed-by: Ben Horgan <ben.horgan@arm.com>

Thanks,

Ben

> +		if (!has_busy_rmid(d))
> +			continue;
> +
> +		/*
> +		 * The unmount may have left the worker queued. Cancel it so
> +		 * it is queued again on a CPU picked now.
> +		 */
> +		cancel_delayed_work(&d->cqm_limbo);
> +		cqm_setup_limbo_handler(d, 0, RESCTRL_PICK_ANY_CPU);
> +	}
> +}
> +
>  void free_rmid_lru_list(void)
>  {
>  	if (!resctrl_arch_mon_capable())
> diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
> index 3312637fb514..c7c4f618208d 100644
> --- a/fs/resctrl/rdtgroup.c
> +++ b/fs/resctrl/rdtgroup.c
> @@ -3267,6 +3267,8 @@ static int rdt_get_tree(struct fs_context *fc)
>  						   RESCTRL_PICK_ANY_CPU);
>  	}
>  
> +	cqm_resume_limbo_handler();
> +
>  	/*
>  	 * Ensure root remains accessible after mutex is unlocked so that
>  	 * kernfs_kill_sb() can run safely if called by kernfs_get_tree()'s


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v6 5/6] fs/resctrl: Release the limbo RMIDs when the CDP state changes
  2026-11-19  9:48 ` [PATCH v6 5/6] fs/resctrl: Release the limbo RMIDs when the CDP state changes Jinjie Ruan
@ 2026-11-19 16:49   ` Ben Horgan
  0 siblings, 0 replies; 12+ messages in thread
From: Ben Horgan @ 2026-11-19 16:49 UTC (permalink / raw)
  To: Jinjie Ruan, tony.luck, reinette.chatre, Dave.Martin, james.morse,
	babu.moger, corbet, skhan, rdunlap, bp, tan.shaopeng, gshan,
	jic23, fenghuay, zengheng4, x86, linux-kernel, linux-doc

Hi Jinjie,

On 19/11/2026 09:48, Jinjie Ruan wrote:
> On MPAM the counter of an RMID is selected by the PARTIDs of the CLOSID
> that owned it. Without CDP, CLOSID c is PARTID c; with CDP it is
> PARTIDs 2c and 2c+1. An RMID that stays in limbo across an unmount and
> a mount that changes the CDP state is read through the PARTIDs of the
> new state, which are not the PARTIDs its cache lines are tagged with.
> 
> With 5 PARTIDs:
> 
>   mount                  CDP off, CLOSID c -> PARTID c
>   mkdir g1..g4           CLOSIDs 1..4
>   umount                 RMIDs enter limbo with CLOSIDs 1..4
>   mount -o cdp           CDP on, CLOSID c -> PARTIDs 2c, 2c+1
>   limbo handler          reads CLOSID 2 as PARTID 5 > PARTID_MAX 4
>                          MSC error interrupt, mpam_disable()
> 
> The other direction is worse because nothing reports it. If resctrl is
> mounted with CDP and mounted again without it, CLOSID c is read as
> PARTID c, which is in range, so the limbo handler silently tests the
> occupancy of the PARTID of a different CLOSID and frees or keeps the
> RMIDs based on it.
> 
> Where the RMID depends on the CLOSID, as on MPAM, release the RMIDs in
> limbo without reading them when a mount changes the CDP state, instead
> of restarting the limbo handler. Cache lines that still carry those
> RMIDs are accounted to the next user of each RMID. Where the RMID does
> not depend on the CLOSID, as on x86, the CDP state does not change how
> an RMID is read and the limbo handler is restarted as before.
> 
> Compare the CDP state of every resource, not just the L3: on MPAM, CDP
> enabled on any resource gives every CLOSID two PARTIDs in all MSCs, so
> mounting with -o cdpl2 alone also changes how the L3 monitors read a
> CLOSID, and cache levels beyond the L3 would too.
> 
> Reproduced on QEMU with the sequence above:
> 
>   mpam:__mpam_irq_handler: error irq from msc:1 'MSMONCFG_ID_RANGE', partid:5, pmg: 0, ris: 0
>   mpam:mpam_disable: MPAM disabled due to hardware error interrupt
> 
> With the change the sequence completes without an error.
> 
> Fixes: 6789fb99282c ("arm_mpam: resctrl: Add CDP emulation")
> Suggested-by: Ben Horgan <ben.horgan@arm.com>
> Suggested-by: Reinette Chatre <reinette.chatre@intel.com>
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
> Cc: <stable@vger.kernel.org>
> ---
> v6:
> - Drop resctrl_arch_mon_cdp_enabled() and compare the CDP state of
>   every resouce's cdp state, with a comment on why they are
>   checked (Reinette, Ben).
> - Restrict the release to the systems where the RMID depends on the
>   CLOSID, in the changelog and the comments, and keep the hardware IDs
>   out of the file system comments (Reinette).
> - Reword the limbo_cdp_enabled comment (Reinette).
> - Drop the stable version range, the Fixes tag already gives it.
> v5:
> - Split the change of the limbo handler lifetime into the previous
>   patch. The limbo handler now stops while resctrl is unmounted on every
>   architecture, and only the release of the RMIDs depends on
>   CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID.
> - Drop the cqm_work_cpu changes. resctrl_limbo_resume() cancels the
>   worker before it queues it again or releases the RMIDs.
> - Move the rdt_disable_ctx() reordering to a separate patch.
> - Add resctrl_arch_mon_cdp_enabled() instead of comparing the CDP state
>   of L2 in the file system.
> - Rename limbo_cdp to limbo_cdp_enabled and document that it is only set
>   with CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID.
> - Check QOS_L3_OCCUP_EVENT_ID first and drop the rmid_busy_llc check.
> - Use lockdep_assert_cpus_held() at the start of resctrl_limbo_resume().
> - Describe the reverse sequence, from CDP on to CDP off.
> - Link to v4: https://lore.kernel.org/all/20261105070934.2258613-4-ruanjinjie@huawei.com/
> v4:
> - Use resctrl_mounted instead of a separate limbo_paused flag.
> - Record the CDP state once when resctrl is mounted.
> - Add resctrl_limbo_resume(), called once resctrl_mounted is set.
> - Previous Link: https://lore.kernel.org/all/20261031094616.1691026-1-ruanjinjie@huawei.com/
> ---
>  fs/resctrl/monitor.c | 35 +++++++++++++++++++++++++++++++++--
>  1 file changed, 33 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c
> index ede1708b920e..2c8c60138768 100644
> --- a/fs/resctrl/monitor.c
> +++ b/fs/resctrl/monitor.c
> @@ -70,6 +70,13 @@ static u32 *closid_num_dirty_rmid;
>   */
>  static unsigned int rmid_limbo_count;
>  
> +/*
> + * @limbo_cdp_enabled - True if the RMIDs in limbo were placed there while CDP
> + *     was enabled. Only used when CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID is
> + *     defined.
> + */
> +static bool limbo_cdp_enabled;
> +
>  /*
>   * @rmid_entry - The entry in the limbo and free lists.
>   */
> @@ -1044,12 +1051,15 @@ int setup_rmid_lru_list(void)
>   * cqm_resume_limbo_handler() - Restart the limbo handler after a mount.
>   *
>   * The limbo handler stops while resctrl is unmounted. Restart it on every
> - * domain that still has RMIDs in limbo.
> + * domain that still has RMIDs in limbo. Where the RMID depends on the CLOSID
> + * and the mount changed the RMID index a CLOSID is monitored with, the RMIDs
> + * in limbo can no longer be read: release them instead.
>   */
>  void cqm_resume_limbo_handler(void)
>  {
>  	struct rdt_resource *r = resctrl_arch_get_resource(RDT_RESOURCE_L3);
>  	struct rdt_l3_mon_domain *d;
> +	bool release = false;
>  
>  	lockdep_assert_cpus_held();
>  	lockdep_assert_held(&rdtgroup_mutex);
> @@ -1057,6 +1067,24 @@ void cqm_resume_limbo_handler(void)
>  	if (!r->mon_capable || !resctrl_is_mon_event_enabled(QOS_L3_OCCUP_EVENT_ID))
>  		return;
>  
> +	/*
> +	 * Where the RMID depends on the CLOSID, the RMIDs in limbo can only
> +	 * be read with the CDP state they were freed under. Check every
> +	 * resource because CDP enabled on any resource changes how every
> +	 * CLOSID is monitored, so CDP on another resource alone also changes
> +	 * how the L3 monitors are read.
> +	 */
> +	if (IS_ENABLED(CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID)) {
> +		struct rdt_resource *res;
> +		bool cdp_enabled = false;
> +
> +		for_each_rdt_resource(res)
> +			cdp_enabled |= resctrl_arch_get_cdp_enabled(res->rid);
> +
> +		release = cdp_enabled != limbo_cdp_enabled;
> +		limbo_cdp_enabled = cdp_enabled;
> +	}
> +
>  	list_for_each_entry_rcu(d, &r->mon_domains, hdr.list,
>  				lockdep_is_cpus_held()) {
>  		if (!has_busy_rmid(d))
> @@ -1067,7 +1095,10 @@ void cqm_resume_limbo_handler(void)
>  		 * it is queued again on a CPU picked now.
>  		 */
>  		cancel_delayed_work(&d->cqm_limbo);
> -		cqm_setup_limbo_handler(d, 0, RESCTRL_PICK_ANY_CPU);
> +		if (release)
> +			release_limbo_rmids(d);

Rather than release all the rmids don't we want to check them all to see which are busy?

Thanks,

Ben

> +		else
> +			cqm_setup_limbo_handler(d, 0, RESCTRL_PICK_ANY_CPU);
>  	}
>  }
>  


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v6 6/6] fs/resctrl: Disallow monitor group move when the RMID index changes
  2026-11-19  9:48 ` [PATCH v6 6/6] fs/resctrl: Disallow monitor group move when the RMID index changes Jinjie Ruan
@ 2026-11-19 16:57   ` Ben Horgan
  0 siblings, 0 replies; 12+ messages in thread
From: Ben Horgan @ 2026-11-19 16:57 UTC (permalink / raw)
  To: Jinjie Ruan, tony.luck, reinette.chatre, Dave.Martin, james.morse,
	babu.moger, corbet, skhan, rdunlap, bp, tan.shaopeng, gshan,
	jic23, fenghuay, zengheng4, x86, linux-kernel, linux-doc

Hi Jinjie,

On 19/11/2026 09:48, Jinjie Ruan wrote:
> From: Peter Newman <peternewman@google.com>
> 
> A MON group can be moved into the mon_groups directory of another
> CTRL_MON group to move its tasks to that group's allocation while
> keeping their monitoring data. Where the RMID is only meaningful
> together with the CLOSID, as on arm64 MPAM where the RMID is a PMG that
> extends the PARTID, the move changes the RMID index of the group. The
> move succeeds, but:
> 
> - The group's monitoring data is reset. Its counters are identified by
>   the CLOSID and RMID together, so after the move the group reads the
>   counters of the new CLOSID instead of the ones its tasks used.
> 
> - The group uses an RMID index that was never allocated to it. When
>   the group is removed, free_rmid() puts an RMID index of the new CLOSID
>   into limbo without checking that the group owns it. If another group
>   of that CLOSID holds the index, the limbo handler tests and frees an
>   RMID that is still in use, while the RMID index allocated to the
>   moved group is never freed. If no other group holds it, the index is
>   in use while it is considered free for allocation.
> 
> - The tasks are not moved. mongrp_reparent() sets the new parent and
>   CLOSID of the group before rdt_move_group_tasks() looks for the tasks
>   to update, and the search then matches on the new CLOSID, which none
>   of the tasks carries yet. The tasks keep the old CLOSID and the old
>   CTRL_MON group's allocation, and the group does not count them.
> 
> Fixing the task move does not make the move work. The RMID index is the
> hardware ID the counters count for, so a group whose CLOSID changes
> cannot keep its monitoring data, and it would need a new RMID index
> allocated for the new CLOSID, which fails when every RMID index of that
> CLOSID is in use. The documentation promises that a move keeps the
> monitoring data, so the move cannot be supported, as decided in the
> thread at the Link tag.
> 
> Reject the move with -EOPNOTSUPP when it changes the RMID index of the
> group, and document that a move is not allowed when the monitoring data
> or assigned tasks would be impacted. Leave the move allowed where the
> RMID does not depend on the CLOSID, such as on x86, and leave renaming
> within the same CTRL_MON group allowed everywhere; neither changes the
> RMID index.
> 
> Fixes: 3e9b35823aab ("arm_mpam: resctrl: Add rmid index helpers")
> Signed-off-by: Peter Newman <peternewman@google.com>
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
> Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
> Cc: <stable@vger.kernel.org>
> Link: https://lore.kernel.org/lkml/3a637631-c8ec-4e26-a03c-5ac80d16fab3@arm.com/

Looks good to me.

Reviewed-by: Ben Horgan <ben.horgan@arm.com>

> ---
> v6:
> - Describe the RMID index that is used while it is considered free, and
>   keep the last paragraph imperative (Reinette).
> v5:
> - Retitle as the RMID index changes, not the RMID, and a rename within
>   the same CTRL_MON group is still allowed.
> - Describe the RMID index that is freed without having been allocated,
>   and why the move cannot be fixed instead of being rejected.
> - Drop the parent and resctrl_arch_mon_capable() checks, which the RMID
>   index comparison and the MON group check already cover.
> - Use the resctrl.rst terms in the last_cmd_status message.
> - Drop the stable version range and the Link tags the changelog did not
>   refer to, and link the decision to reject the move instead.
> - Link to v2: https://lore.kernel.org/all/20261105123524.2282090-1-ruanjinjie@huawei.com/
> v2:
> - Drop the Suggested-by tag.
> - Describe the systems by whether the RMID depends on the CLOSID rather
>   than by MPAM, in both the changelog and resctrl.rst.
> - Explain that moving a monitor group is already broken on these systems
>   because the tasks are not moved, so no existing user relies on it.
> - v1: https://lore.kernel.org/all/20261104101913.586595-1-ruanjinjie@huawei.com/
> ---
>  Documentation/filesystems/resctrl.rst |  8 ++++----
>  fs/resctrl/rdtgroup.c                 | 13 +++++++++++++
>  2 files changed, 17 insertions(+), 4 deletions(-)
> 
> diff --git a/Documentation/filesystems/resctrl.rst b/Documentation/filesystems/resctrl.rst
> index b52795e03303..fecb2cd2b343 100644
> --- a/Documentation/filesystems/resctrl.rst
> +++ b/Documentation/filesystems/resctrl.rst
> @@ -551,10 +551,10 @@ will automatically remove all MON groups below it.
>  
>  Moving MON group directories to a new parent CTRL_MON group is supported
>  for the purpose of changing the resource allocations of a MON group
> -without impacting its monitoring data or assigned tasks. This operation
> -is not allowed for MON groups which monitor CPUs. No other move
> -operation is currently allowed other than simply renaming a CTRL_MON or
> -MON group.
> +without impacting its monitoring data or assigned tasks. This operation is
> +not allowed for MON groups which monitor CPUs, or when the monitoring data
> +or assigned tasks would be impacted. No other move operation is currently
> +allowed other than simply renaming a CTRL_MON or MON group.
>  
>  All groups contain the following files:
>  
> diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
> index c7c4f618208d..e16ae5799e0b 100644
> --- a/fs/resctrl/rdtgroup.c
> +++ b/fs/resctrl/rdtgroup.c
> @@ -4403,6 +4403,19 @@ static int rdtgroup_rename(struct kernfs_node *kn,
>  		goto out;
>  	}
>  
> +	/*
> +	 * Moving the group to another CTRL_MON group changes its CLOSID.
> +	 * Where the RMID is only meaningful together with the CLOSID, this
> +	 * changes the RMID index and the monitor state cannot follow the
> +	 * move. A rename within the same CTRL_MON group keeps the index.
> +	 */
> +	if (resctrl_arch_rmid_idx_encode(rdtgrp->closid, rdtgrp->mon.rmid) !=
> +	    resctrl_arch_rmid_idx_encode(new_prdtgrp->closid, rdtgrp->mon.rmid)) {
> +		rdt_last_cmd_puts("Moving a MON group to a new CTRL_MON group is not supported\n");
> +		ret = -EOPNOTSUPP;
> +		goto out;
> +	}
> +
>  	/*
>  	 * If the MON group is monitoring CPUs, the CPUs must be assigned to the
>  	 * current parent CTRL_MON group and therefore cannot be assigned to


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2026-11-19 16:57 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19  9:48 [PATCH v6 0/6] fs/resctrl: Fix some resctl bugs related to mpam Jinjie Ruan
2026-11-19  9:48 ` [PATCH v6 1/6] fs/resctrl: Report a temporary RMID shortage per CLOSID Jinjie Ruan
2026-11-19  9:48 ` [PATCH v6 2/6] fs/resctrl: Do not allocate a monitor context when releasing limbo RMIDs Jinjie Ruan
2026-11-19  9:48 ` [PATCH v6 3/6] fs/resctrl: Clear the CDP state after the cleanup Jinjie Ruan
2026-11-19 11:21   ` Ben Horgan
2026-11-19 12:15     ` Jinjie Ruan
2026-11-19  9:48 ` [PATCH v6 4/6] fs/resctrl: Stop the limbo handler while resctrl is unmounted Jinjie Ruan
2026-11-19 12:34   ` Ben Horgan
2026-11-19  9:48 ` [PATCH v6 5/6] fs/resctrl: Release the limbo RMIDs when the CDP state changes Jinjie Ruan
2026-11-19 16:49   ` Ben Horgan
2026-11-19  9:48 ` [PATCH v6 6/6] fs/resctrl: Disallow monitor group move when the RMID index changes Jinjie Ruan
2026-11-19 16:57   ` Ben Horgan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox