mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jinjie Ruan <ruanjinjie@huawei.com>
To: Ben Horgan <ben.horgan@arm.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>,
	<tan.shaopeng@fujitsu.com>, <zengheng4@huawei.com>,
	<jic23@kernel.org>, <gshan@redhat.com>, <catalin.marinas@arm.com>,
	<x86@kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v10 RESEND 06/15] fs/resctrl: Unmount resctrl with the CDP state it was mounted with
Date: Sat, 31 Oct 2026 10:00:03 +0800	[thread overview]
Message-ID: <bec33507-f683-4d52-990c-be520a99f6f1@huawei.com> (raw)
In-Reply-To: <8f6fdcad-912d-49f6-babe-e428290f0cce@arm.com>



在 2026/10/26 23:08, Ben Horgan 写道:
> Hi Jinjie,
> 
> On 20/10/2026 14:42, Jinjie Ruan wrote:
>> From: Zeng Heng <zengheng4@huawei.com>
>>
>> resctrl disables CDP before the control and monitor groups are torn down
>> on unmount. The architecture translates between CLOSID and PARTID using
>> the CDP state, so the RMIDs freed by rmdir_all_sub() and
>> resctrl_fs_teardown() are parsed with the wrong mapping. On arm64 the
>> RMID limbo handler can still be running, and a CLOSID left in the limbo
>> list is re-interpreted with the CDP state of the next mount. Enabling
>> CDP doubles the CLOSID on arm64, which can push the stale value out of
>> range and take an MPAM error interrupt.
>>
>> Disable CDP after the groups have been torn down, so every CLOSID freed
>> on unmount is parsed with the CDP state it was allocated under. Return
>> the RMIDs still in limbo to the free list and stop the worker, so
>> nothing carries over to the next mount.
>>
>> Cc: Tony Luck <tony.luck@intel.com>
>> 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>
>> Signed-off-by: Zeng Heng <zengheng4@huawei.com>
>> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
>> ---
>>  fs/resctrl/rdtgroup.c | 46 +++++++++++++++++++++++++++++++++++++++++--
>>  1 file changed, 44 insertions(+), 2 deletions(-)
>>
>> diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
>> index 5dcbb0a964e8..40821cf07649 100644
>> --- a/fs/resctrl/rdtgroup.c
>> +++ b/fs/resctrl/rdtgroup.c
>> @@ -3145,6 +3145,41 @@ static void resctrl_fs_teardown(void)
>>  	rdtgroup_destroy_root();
>>  }
>>  
>> +/*
>> + * The RMID limbo handler keeps running after unmount. Any CLOSID still in
>> + * limbo would be re-interpreted with the CDP state of the next mount. MPAM
>> + * doubles CLOSID when CDP is enabled, which can push the stale value out of
>> + * range. Force the limbo list back to the free list before the CLOSID state
>> + * is torn down.
> 
> If the limbo list is being emptied then the limbo handler is effectively not being run. This is a
> reduction of functionality of resctrl. We either need a way to keep it running or rebuild the list
> at mount. There was some discussion at
> https://lore.kernel.org/all/20260413085405.1166412-2-zengheng4@huawei.com/

Hi Ben,

Thank you for the reminder, will update the patch based on the
discussion and your new suggestion.

> 
> This is a fs/resctrl patch that doesn't directly relate with the subject of the series and so
> unlikely to get much attention from the resctrl maintainers. If you respin I'd suggest posting this
> separately. I note that Tony Luck has a patch in the same area, [1].

Thank you! I will notice Tony's patch and post next version separately.

> 
> [1] https://lore.kernel.org/lkml/20260928221509.68002-14-tony.luck@intel.com/
> 
> Thanks,
> 
> Ben
> 
>> + */
>> +static void rdt_flush_limbo(void)
>> +{
>> +	struct rdt_resource *r = resctrl_arch_get_resource(RDT_RESOURCE_L3);
>> +	struct rdt_l3_mon_domain *d;
>> +
>> +	if (!IS_ENABLED(CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID))
>> +		return;
>> +
>> +	if (!resctrl_is_mon_event_enabled(QOS_L3_OCCUP_EVENT_ID))
>> +		return;
>> +
>> +	list_for_each_entry(d, &r->mon_domains, hdr.list) {
>> +		if (!has_busy_rmid(d))
>> +			continue;
>> +
>> +		/*
>> +		 * The limbo handler acquires rdtgroup_mutex. Release it
>> +		 * here to allow the handler to complete, then reacquire
>> +		 * to maintain lock ordering for __check_limbo().
>> +		 * This matches the pattern used in resctrl_offline_cpu().
>> +		 */
>> +		mutex_unlock(&rdtgroup_mutex);
>> +		cancel_delayed_work_sync(&d->cqm_limbo);
>> +		mutex_lock(&rdtgroup_mutex);
>> +		__check_limbo(d, true);
>> +	}
>> +}
>> +
>>  static void resctrl_unmount(void)
>>  {
>>  	struct rdt_resource *r;
>> @@ -3152,13 +3187,20 @@ 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();
>> +	rdt_flush_limbo();
>> +
>> +	/*
>> +	 * Clear the CDP state last. free_rmid() translates between CLOSID and
>> +	 * PARTID using the CDP state; clearing it first would make the
>> +	 * translation inconsistent for the RMIDs being torn down.
>> +	 */
>> +	rdt_disable_ctx();
>> +
>>  	if (resctrl_arch_alloc_capable())
>>  		resctrl_arch_disable_alloc();
>>  	if (resctrl_arch_mon_capable())
> 

-- 
Best regards,
Jinjie


  reply	other threads:[~2026-10-31  2:00 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-20 13:42 [PATCH v10 RESEND 00/15] arm_mpam: Introduce Narrow-PARTID feature Jinjie Ruan
2026-10-20 13:42 ` [PATCH v10 RESEND 01/15] fs/resctrl: Return -EBUSY when per-CLOSID RMIDs are in limbo Jinjie Ruan
2026-10-26 14:05   ` Ben Horgan
2026-10-28 21:28   ` Reinette Chatre
2026-10-29  3:51     ` Jinjie Ruan
2026-10-20 13:42 ` [PATCH v10 RESEND 02/15] fs/resctrl: Skip monitor context allocation when force-freeing RMIDs Jinjie Ruan
2026-10-26 14:08   ` Ben Horgan
2026-10-26 14:11     ` Ben Horgan
2026-10-27  1:33       ` Jinjie Ruan
2026-10-28 21:29         ` Reinette Chatre
2026-10-29  4:05           ` Jinjie Ruan
2026-10-20 13:42 ` [PATCH v10 RESEND 03/15] arm_mpam: Fix error return in resctrl_arch_mon_ctx_alloc() Jinjie Ruan
2026-10-26 14:40   ` Ben Horgan
2026-10-27  1:25     ` Jinjie Ruan
2026-10-20 13:42 ` [PATCH v10 RESEND 04/15] arm_mpam: Fix infinite PARTID reset loop when 65536 PARTIDs are supported Jinjie Ruan
2026-10-20 13:42 ` [PATCH v10 RESEND 05/15] arm_mpam: Don't stall MPAM enable when an MSC fails to probe Jinjie Ruan
2026-10-26 14:49   ` Ben Horgan
2026-10-27  1:47     ` Jinjie Ruan
2026-10-30 15:29       ` Ben Horgan
2026-10-31  1:23         ` Jinjie Ruan
2026-10-20 13:42 ` [PATCH v10 RESEND 06/15] fs/resctrl: Unmount resctrl with the CDP state it was mounted with Jinjie Ruan
2026-10-26 15:08   ` Ben Horgan
2026-10-31  2:00     ` Jinjie Ruan [this message]
2026-10-20 13:42 ` [PATCH v10 RESEND 07/15] fs/resctrl: Add resctrl_arch_rmid_idx_match() helper Jinjie Ruan
2026-10-20 13:42 ` [PATCH v10 RESEND 08/15] arm_mpam: resctrl: Add resctrl_closid_rmid_to_partid_pmg() helper Jinjie Ruan
2026-10-20 13:42 ` [PATCH v10 RESEND 09/15] arm_mpam: Add a helper to check a PARTID is in a CLOSID Jinjie Ruan
2026-10-20 13:42 ` [PATCH v10 RESEND 10/15] arm_mpam: Track the PARTID and internal PARTID limits per class Jinjie Ruan
2026-10-20 13:42 ` [PATCH v10 RESEND 11/15] arm_mpam: Divide the PARTIDs between the control groups Jinjie Ruan
2026-10-20 13:42 ` [PATCH v10 RESEND 12/15] arm_mpam: Map resctrl RMIDs onto the request PARTIDs Jinjie Ruan
2026-10-20 13:42 ` [PATCH v10 RESEND 13/15] arm_mpam: Identify the non-aliasing controls Jinjie Ruan
2026-10-20 13:42 ` [PATCH v10 RESEND 14/15] arm_mpam: Use the request PARTIDs beyond the internal range Jinjie Ruan
2026-10-20 13:42 ` [PATCH v10 RESEND 15/15] arm_mpam: resctrl: Add kunit tests for narrow PARTID helpers 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=bec33507-f683-4d52-990c-be520a99f6f1@huawei.com \
    --to=ruanjinjie@huawei.com \
    --cc=Dave.Martin@arm.com \
    --cc=babu.moger@amd.com \
    --cc=ben.horgan@arm.com \
    --cc=bp@alien8.de \
    --cc=catalin.marinas@arm.com \
    --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-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=reinette.chatre@intel.com \
    --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®