mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Reinette Chatre <reinette.chatre@intel.com>
To: Jinjie Ruan <ruanjinjie@huawei.com>, <tony.luck@intel.com>,
	<Dave.Martin@arm.com>, <james.morse@arm.com>,
	<babu.moger@amd.com>, <corbet@lwn.net>,
	<skhan@linuxfoundation.org>, <rdunlap@infradead.org>,
	<tglx@kernel.org>, <mingo@redhat.com>, <bp@alien8.de>,
	<dave.hansen@linux.intel.com>, <hpa@zytor.com>,
	<ben.horgan@arm.com>, <fenghuay@nvidia.com>,
	<tan.shaopeng@fujitsu.com>, <will@kernel.org>, <gshan@redhat.com>,
	<zengheng4@huawei.com>, <jic23@kernel.org>, <x86@kernel.org>,
	<linux-kernel@vger.kernel.org>, <linux-doc@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH v5 RESEND 5/7] fs/resctrl: Release the limbo RMIDs when the CDP state changes
Date: Wed, 11 Nov 2026 10:33:15 -0800	[thread overview]
Message-ID: <3c48dac2-78af-44c9-b546-e5fcf7bbd8d6@intel.com> (raw)
In-Reply-To: <20261110133938.3768632-6-ruanjinjie@huawei.com>

Hi Jinjie,

On 11/10/26 5:39 AM, 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.
> 
> When a mount changes the CDP state, release the RMIDs in limbo without
> reading them instead of restarting the limbo handler. Cache lines that

This is a resctrl filesystem patch. Please take care to make it clear when
the description refers to architecture specific behavior and when it describes
filesystem behavior that impacts all architectures. First two paragraphs
describe MPAM behavior. Above then jumps to resctrl filesystem behavior
but it describes the filesystem behavior specific to MPAM systems as the
new filesystem behavior for all architectures.

Specifically, above needs a caveat that this new resctrl filesystem behavior
is restricted to systems where RMID depends on CLOSID.

> 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.

nack. The helper name and value returned on x86 is the first hint that this
is not right. For x86 the value is not a statement about x86: CDP exists on
x86 and can be enabled, so a function called resctrl_arch_mon_cdp_enabled()
returning false reads as wrong until the comment above it explains that what
is really being reported is whether CDP changes the IDs the monitors use.

Every architecture now needs to match this. This looks more like forcing
every architecture to indicate whether it has the same quirk as MPAM.

If there is no way to handle this in MPAM driver then handling this should at
least be contained between resctrl filesystem and MPAM driver. This should not
be forced on all architectures.

I trust the MPAM folks to say whether it can or cannot be done in MPAM driver.
If this is not possible in MPAM driver then it looks like this needs to go back
to include the L2 CDP check as was done in previous version. With this check 
gated by IS_ENABLED(CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID) it does hint "MPAM"
but would also need a comment to explain why that is done.

> 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+

Is the "7.1+" constraint needed?


> 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

"hardware IDs" should be invisible to resctrl filesystem. The filesystem and
architecture separation should ideally hide these details from resctrl filesystem.

How about something like below that also makes clear what "true" means:
	"True if the RMIDs in limbo were placed there while CDP was enabled."

> + *			used for a CLOSID when the RMIDs in limbo were freed.
> + *			Only set when CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID

"set" -> "used"? (to highlight that all reads and writes are gated by
CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID)

> + *			is enabled.

"enabled" -> "defined" (to match surrounding language)


Please match the spacing of surrounding code by using spaces, not tabs.

> + */
> +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

What does "hardware IDs" refer to here? On the resctrl filesystem side I
think "RMID index" will be the accurate term that makes it clear what this
refers to.

> + * 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);
>  	}
>  }
>  

Reinette

  reply	other threads:[~2026-11-11 18:33 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-10 13:39 [PATCH v5 RESEND 0/7] fs/resctrl: Fix some resctl bugs related to mpam Jinjie Ruan
2026-11-10 13:39 ` [PATCH v5 RESEND 1/7] fs/resctrl: Report a temporary RMID shortage per CLOSID Jinjie Ruan
2026-11-10 13:39 ` [PATCH v5 RESEND 2/7] fs/resctrl: Do not allocate a monitor context when releasing limbo RMIDs Jinjie Ruan
2026-11-10 13:39 ` [PATCH v5 RESEND 3/7] fs/resctrl: Clear the CDP state after the cleanup Jinjie Ruan
2026-11-11 18:27   ` Reinette Chatre
2026-11-10 13:39 ` [PATCH v5 RESEND 4/7] fs/resctrl: Stop the limbo handler while resctrl is unmounted Jinjie Ruan
2026-11-11 18:26   ` Reinette Chatre
2026-11-10 13:39 ` [PATCH v5 RESEND 5/7] fs/resctrl: Release the limbo RMIDs when the CDP state changes Jinjie Ruan
2026-11-11 18:33   ` Reinette Chatre [this message]
2026-11-10 13:39 ` [PATCH v5 RESEND 6/7] fs/resctrl: Disallow monitor group move when the RMID index changes Jinjie Ruan
2026-11-11 18:33   ` Reinette Chatre
2026-11-10 13:39 ` [PATCH v5 RESEND 7/7] fs/resctrl: Add info/moveable_mon_group Jinjie Ruan
2026-11-11 18:34   ` Reinette Chatre

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=3c48dac2-78af-44c9-b546-e5fcf7bbd8d6@intel.com \
    --to=reinette.chatre@intel.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=ruanjinjie@huawei.com \
    --cc=skhan@linuxfoundation.org \
    --cc=tan.shaopeng@fujitsu.com \
    --cc=tglx@kernel.org \
    --cc=tony.luck@intel.com \
    --cc=will@kernel.org \
    --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®