From: Jinjie Ruan <ruanjinjie01@gmail.com>
To: babu.moger@amd.com, ben.horgan@arm.com, bp@alien8.de,
corbet@lwn.net, dave.hansen@linux.intel.com, Dave.Martin@arm.com,
fenghuay@nvidia.com, gshan@redhat.com, hpa@zytor.com,
james.morse@arm.com, jic23@kernel.org, mingo@redhat.com,
rdunlap@infradead.org, reinette.chatre@intel.com,
skhan@linuxfoundation.org, tan.shaopeng@fujitsu.com,
tglx@kernel.org, tony.luck@intel.com, zengheng4@huawei.com,
x86@kernel.org, linux-kernel@vger.kernel.org,
linux-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Cc: ruanjinjie@huawei.com
Subject: [PATCH v5 5/7] fs/resctrl: Release the limbo RMIDs when the CDP state changes
Date: Tue, 10 Nov 2026 21:20:52 +0800 [thread overview]
Message-ID: <20261110132054.3702-6-ruanjinjie01@gmail.com> (raw)
In-Reply-To: <20261110132054.3702-1-ruanjinjie01@gmail.com>
From: Jinjie Ruan <ruanjinjie@huawei.com>
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.
When a mount changes the CDP state, release the RMIDs in limbo without
reading them instead of restarting the limbo handler. Cache lines that
still carry those RMIDs are accounted to the next user of each RMID.
The CDP state that matters is the one that changes the PARTIDs used by
the monitors, which is not necessarily the CDP state of the L3
resource. MPAM gives every CLOSID two PARTIDs in all MSCs while CDP is
enabled on any resource, so enabling CDP on L2 alone also changes the
PARTIDs the L3 monitors use. Add resctrl_arch_mon_cdp_enabled() to let
the architecture report this. Only MPAM can be affected, so the RMIDs
are only released where the RMID depends on the CLOSID. On x86 the
RMID does not depend on the CLOSID, and resctrl_arch_mon_cdp_enabled()
returns false.
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> # 7.1+
---
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/
---
arch/x86/include/asm/resctrl.h | 6 ++++++
drivers/resctrl/mpam_resctrl.c | 9 +++++++++
fs/resctrl/monitor.c | 25 +++++++++++++++++++++++--
include/linux/arm_mpam.h | 1 +
4 files changed, 39 insertions(+), 2 deletions(-)
diff --git a/arch/x86/include/asm/resctrl.h b/arch/x86/include/asm/resctrl.h
index 8f6edcdcfd87..d88a09a45d7b 100644
--- a/arch/x86/include/asm/resctrl.h
+++ b/arch/x86/include/asm/resctrl.h
@@ -181,6 +181,12 @@ static inline u32 resctrl_arch_rmid_idx_encode(u32 ignored, u32 rmid)
return rmid;
}
+/* The RMID does not depend on the CLOSID, so neither does CDP change it */
+static inline bool resctrl_arch_mon_cdp_enabled(void)
+{
+ return false;
+}
+
/* x86 can always read an rmid, nothing needs allocating */
struct rdt_resource;
static inline void *resctrl_arch_mon_ctx_alloc(struct rdt_resource *r,
diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
index 5468367776e2..563ca99a581d 100644
--- a/drivers/resctrl/mpam_resctrl.c
+++ b/drivers/resctrl/mpam_resctrl.c
@@ -148,6 +148,15 @@ bool resctrl_arch_get_cdp_enabled(enum resctrl_res_level rid)
return mpam_resctrl_controls[rid].cdp_enabled;
}
+/*
+ * CDP emulation gives every CLOSID two PARTIDs in all MSCs, so CDP enabled
+ * on any resource changes the PARTIDs the monitors use for a CLOSID.
+ */
+bool resctrl_arch_mon_cdp_enabled(void)
+{
+ return cdp_enabled;
+}
+
u32 resctrl_arch_preconvert_bw(const struct rdt_resource *r, u32 val)
{
return val;
diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c
index f56d0e32fd06..87d744a168fb 100644
--- a/fs/resctrl/monitor.c
+++ b/fs/resctrl/monitor.c
@@ -70,6 +70,14 @@ static u32 *closid_num_dirty_rmid;
*/
static unsigned int rmid_limbo_count;
+/*
+ * @limbo_cdp_enabled - Whether CDP changed the hardware IDs the monitors
+ * used for a CLOSID when the RMIDs in limbo were freed.
+ * Only set when CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID
+ * is enabled.
+ */
+static bool limbo_cdp_enabled;
+
/*
* @rmid_entry - The entry in the limbo and free lists.
*/
@@ -1044,12 +1052,15 @@ int setup_rmid_lru_list(void)
* resctrl_limbo_resume() - 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 hardware IDs a CLOSID is monitored
+ * with, the RMIDs in limbo can no longer be read: release them instead.
*/
void resctrl_limbo_resume(void)
{
struct rdt_l3_mon_domain *d;
struct rdt_resource *r;
+ bool release = false;
lockdep_assert_cpus_held();
lockdep_assert_held(&rdtgroup_mutex);
@@ -1057,6 +1068,13 @@ void resctrl_limbo_resume(void)
if (!resctrl_is_mon_event_enabled(QOS_L3_OCCUP_EVENT_ID))
return;
+ if (IS_ENABLED(CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID)) {
+ bool cdp_enabled = resctrl_arch_mon_cdp_enabled();
+
+ release = cdp_enabled != limbo_cdp_enabled;
+ limbo_cdp_enabled = cdp_enabled;
+ }
+
r = resctrl_arch_get_resource(RDT_RESOURCE_L3);
list_for_each_entry_rcu(d, &r->mon_domains, hdr.list,
lockdep_is_cpus_held()) {
@@ -1068,7 +1086,10 @@ void resctrl_limbo_resume(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);
}
}
diff --git a/include/linux/arm_mpam.h b/include/linux/arm_mpam.h
index 002f56e15362..ff1e1d6420fa 100644
--- a/include/linux/arm_mpam.h
+++ b/include/linux/arm_mpam.h
@@ -62,6 +62,7 @@ bool resctrl_arch_match_rmid(struct task_struct *tsk, u32 closid, u32 rmid);
u32 resctrl_arch_rmid_idx_encode(u32 closid, u32 rmid);
void resctrl_arch_rmid_idx_decode(u32 idx, u32 *closid, u32 *rmid);
u32 resctrl_arch_system_num_rmid_idx(void);
+bool resctrl_arch_mon_cdp_enabled(void);
struct rdt_resource;
void *resctrl_arch_mon_ctx_alloc(struct rdt_resource *r, enum resctrl_event_id evtid);
--
2.43.0
next prev parent reply other threads:[~2026-11-10 14:51 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 13:20 [PATCH v5 0/7] fs/resctrl: Fix some resctl bugs related to mpam Jinjie Ruan
2026-11-10 13:20 ` [PATCH v5 1/7] fs/resctrl: Report a temporary RMID shortage per CLOSID Jinjie Ruan
2026-11-10 13:33 ` Jinjie Ruan
2026-11-10 13:20 ` [PATCH v5 2/7] fs/resctrl: Do not allocate a monitor context when releasing limbo RMIDs Jinjie Ruan
2026-11-10 13:20 ` [PATCH v5 3/7] fs/resctrl: Clear the CDP state after the cleanup Jinjie Ruan
2026-11-10 13:20 ` [PATCH v5 4/7] fs/resctrl: Stop the limbo handler while resctrl is unmounted Jinjie Ruan
2026-11-10 13:20 ` Jinjie Ruan [this message]
2026-11-10 13:20 ` [PATCH v5 6/7] fs/resctrl: Disallow monitor group move when the RMID index changes Jinjie Ruan
2026-11-10 13:20 ` [PATCH v5 7/7] fs/resctrl: Add info/moveable_mon_group Jinjie Ruan
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=20261110132054.3702-6-ruanjinjie01@gmail.com \
--to=ruanjinjie01@gmail.com \
--cc=Dave.Martin@arm.com \
--cc=babu.moger@amd.com \
--cc=ben.horgan@arm.com \
--cc=bp@alien8.de \
--cc=corbet@lwn.net \
--cc=dave.hansen@linux.intel.com \
--cc=fenghuay@nvidia.com \
--cc=gshan@redhat.com \
--cc=hpa@zytor.com \
--cc=james.morse@arm.com \
--cc=jic23@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=rdunlap@infradead.org \
--cc=reinette.chatre@intel.com \
--cc=ruanjinjie@huawei.com \
--cc=skhan@linuxfoundation.org \
--cc=tan.shaopeng@fujitsu.com \
--cc=tglx@kernel.org \
--cc=tony.luck@intel.com \
--cc=x86@kernel.org \
--cc=zengheng4@huawei.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®