From: Ben Horgan <ben.horgan@arm.com>
To: Jinjie Ruan <ruanjinjie@huawei.com>,
tony.luck@intel.com, reinette.chatre@intel.com,
Dave.Martin@arm.com, james.morse@arm.com, babu.moger@amd.com,
tglx@kernel.org, mingo@redhat.com, bp@alien8.de,
dave.hansen@linux.intel.com, hpa@zytor.com, fenghuay@nvidia.com,
x86@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v9 2/9] fs/resctrl: Add resctrl_arch_rmid_idx_match() helper
Date: Mon, 26 Oct 2026 12:12:28 +0000 [thread overview]
Message-ID: <4a20a2c8-579f-4234-a03a-079a0225e2b9@arm.com> (raw)
In-Reply-To: <20261012082337.822258-3-ruanjinjie@huawei.com>
Hi Jinjie,
On 12/10/2026 09:23, Jinjie Ruan wrote:
> The current RMID allocator assumes that RMID and CLOSID are entirely
> independent or follow a rigid 2D encoding. This prevents architectures
> where an RMID is bound to a specific CLOSID from properly filtering
> free RMIDs.
Is this patch required for the PARTID narrowing usage in this series? The static mapping is still a
2D encoding.
Thanks,
Ben
>
> Introduce resctrl_arch_rmid_idx_match() to allow architectures to define
> their own compatibility rules between a target CLOSID and an allocated
> RMID's CLOSID.
>
> No functional change.
>
> Cc: Reinette Chatre <reinette.chatre@intel.com>
> Cc: Dave Martin <Dave.Martin@arm.com>
> Cc: James Morse <james.morse@arm.com>
> Cc: Babu Moger <babu.moger@amd.com>
> Cc: Thomas Gleixner <tglx@kernel.org>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Borislav Petkov <bp@alien8.de>
> Cc: Dave Hansen <dave.hansen@linux.intel.com>
> Cc: "H. Peter Anvin" <hpa@zytor.com>
> Cc: Ben Horgan <ben.horgan@arm.com>
> Cc: Fenghua Yu <fenghuay@nvidia.com>
> Suggested-by: James Morse <james.morse@arm.com>
> Signed-off-by: Zeng Heng <zengheng4@huawei.com>
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
> ---
> arch/x86/include/asm/resctrl.h | 6 ++++++
> drivers/resctrl/mpam_resctrl.c | 6 ++++++
> fs/resctrl/monitor.c | 13 +++----------
> include/linux/arm_mpam.h | 1 +
> 4 files changed, 16 insertions(+), 10 deletions(-)
>
> diff --git a/arch/x86/include/asm/resctrl.h b/arch/x86/include/asm/resctrl.h
> index 8f6edcdcfd87..7bb297a0ab6e 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;
> }
>
> +/* x86 RMIDs are independent; any RMID can be used with any CLOSID. */
> +static inline bool resctrl_arch_rmid_idx_match(u32 closid, u32 rmid_closid)
> +{
> + return true;
> +}
> +
> /* 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 9d223057953a..385c745787f2 100644
> --- a/drivers/resctrl/mpam_resctrl.c
> +++ b/drivers/resctrl/mpam_resctrl.c
> @@ -279,6 +279,12 @@ u32 resctrl_arch_rmid_idx_encode(u32 closid, u32 rmid)
> return closid * (mpam_pmg_max + 1) + rmid;
> }
>
> +/* Check if the RMID's associated closid matches the target CLOSID. */
> +bool resctrl_arch_rmid_idx_match(u32 closid, u32 rmid_closid)
> +{
> + return closid == rmid_closid;
> +}
> +
> void resctrl_arch_rmid_idx_decode(u32 idx, u32 *closid, u32 *rmid)
> {
> *closid = idx / (mpam_pmg_max + 1);
> diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c
> index 73413cb128ea..39908f67dea4 100644
> --- a/fs/resctrl/monitor.c
> +++ b/fs/resctrl/monitor.c
> @@ -205,23 +205,16 @@ bool has_busy_rmid(struct rdt_l3_mon_domain *d)
> 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
> - * to be if it were used with this CLOSID.
> - * If the CLOSID is irrelevant on this architecture, the two
> - * index values are always the same on every entry and thus the
> - * very first entry will be returned.
> + * Check if the free RMID matches the target CLOSID.
> + * Architecture-specific rules apply.
> */
> - itr_idx = resctrl_arch_rmid_idx_encode(itr->closid, itr->rmid);
> - cmp_idx = resctrl_arch_rmid_idx_encode(closid, itr->rmid);
> -
> - if (itr_idx == cmp_idx)
> + if (resctrl_arch_rmid_idx_match(closid, itr->closid))
> return itr;
> }
>
> diff --git a/include/linux/arm_mpam.h b/include/linux/arm_mpam.h
> index f92a36187a52..0bc8049a3733 100644
> --- a/include/linux/arm_mpam.h
> +++ b/include/linux/arm_mpam.h
> @@ -60,6 +60,7 @@ void resctrl_arch_sched_in(struct task_struct *tsk);
> bool resctrl_arch_match_closid(struct task_struct *tsk, u32 closid);
> bool resctrl_arch_match_rmid(struct task_struct *tsk, u32 closid, u32 rmid);
> u32 resctrl_arch_rmid_idx_encode(u32 closid, u32 rmid);
> +bool resctrl_arch_rmid_idx_match(u32 closid, u32 rmid_closid);
> void resctrl_arch_rmid_idx_decode(u32 idx, u32 *closid, u32 *rmid);
> u32 resctrl_arch_system_num_rmid_idx(void);
>
next prev parent reply other threads:[~2026-10-26 12:12 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-12 8:23 [PATCH v9 0/9] arm_mpam: Introduce Narrow-PARTID feature Jinjie Ruan
2026-10-12 8:23 ` [PATCH v9 1/9] fs/resctrl: Unmount resctrl with the CDP state it was mounted with Jinjie Ruan
2026-10-12 8:23 ` [PATCH v9 2/9] fs/resctrl: Add resctrl_arch_rmid_idx_match() helper Jinjie Ruan
2026-10-26 12:12 ` Ben Horgan [this message]
2026-10-27 3:56 ` Jinjie Ruan
2026-10-12 8:23 ` [PATCH v9 3/9] arm_mpam: resctrl: Add resctrl_closid_rmid_to_partid_pmg() helper Jinjie Ruan
2026-10-12 8:23 ` [PATCH v9 4/9] arm_mpam: Add a helper to check a PARTID is in a CLOSID Jinjie Ruan
2026-10-12 8:23 ` [PATCH v9 5/9] arm_mpam: Track the PARTID and internal PARTID limits per class Jinjie Ruan
2026-10-12 8:23 ` [PATCH v9 6/9] arm_mpam: Divide the PARTIDs between the control groups Jinjie Ruan
2026-10-12 8:23 ` [PATCH v9 7/9] arm_mpam: Map resctrl RMIDs onto the request PARTIDs Jinjie Ruan
2026-10-12 8:23 ` [PATCH v9 8/9] arm_mpam: Identify the non-aliasing controls Jinjie Ruan
2026-10-12 8:23 ` [PATCH v9 9/9] arm_mpam: Use the request PARTIDs beyond the internal range Jinjie Ruan
2026-10-22 0:02 ` [PATCH v9 0/9] arm_mpam: Introduce Narrow-PARTID feature Shaopeng Tan (Fujitsu)
2026-10-22 1:51 ` Jinjie Ruan
2026-10-22 13:20 ` Zeng Heng
2026-10-23 2:53 ` Shaopeng Tan (Fujitsu)
2026-10-23 3:24 ` 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=4a20a2c8-579f-4234-a03a-079a0225e2b9@arm.com \
--to=ben.horgan@arm.com \
--cc=Dave.Martin@arm.com \
--cc=babu.moger@amd.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=fenghuay@nvidia.com \
--cc=hpa@zytor.com \
--cc=james.morse@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=reinette.chatre@intel.com \
--cc=ruanjinjie@huawei.com \
--cc=tglx@kernel.org \
--cc=tony.luck@intel.com \
--cc=x86@kernel.org \
/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®