mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jinjie Ruan <ruanjinjie@huawei.com>
To: <tony.luck@intel.com>, <reinette.chatre@intel.com>,
	<Dave.Martin@arm.com>, <james.morse@arm.com>,
	<babu.moger@amd.com>, <corbet@lwn.net>,
	<skhan@linuxfoundation.org>, <rdunlap@infradead.org>,
	<bp@alien8.de>, <tan.shaopeng@fujitsu.com>, <fenghuay@nvidia.com>,
	<will@kernel.org>, <gshan@redhat.com>, <jic23@kernel.org>,
	<ben.horgan@arm.com>, <zengheng4@huawei.com>, <x86@kernel.org>,
	<linux-kernel@vger.kernel.org>, <linux-doc@vger.kernel.org>
Cc: <ruanjinjie@huawei.com>
Subject: [PATCH v7 3/6] fs/resctrl: Clear the CDP state after the cleanup
Date: Thu, 26 Nov 2026 17:50:35 +0800	[thread overview]
Message-ID: <20261126095038.2276975-4-ruanjinjie@huawei.com> (raw)
In-Reply-To: <20261126095038.2276975-1-ruanjinjie@huawei.com>

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.

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.

Nothing visible goes wrong. resctrl keeps its own record of the counter
assignments, discards it on unmount and only reads a counter it has
assigned, and each new assignment overwrites the architecture's mapping.
The architecture is still left holding assignments that resctrl no
longer knows about.

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>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
---
v7:
- State that the stale assignments have no visible effect (Ben).
- Drop the stable tag, as nothing visible goes wrong.
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


  parent reply	other threads:[~2026-11-26  9:50 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26  9:50 [PATCH v7 0/6] fs/resctrl: Fix some resctl bugs related to mpam Jinjie Ruan
2026-11-26  9:50 ` [PATCH v7 1/6] fs/resctrl: Report a temporary RMID shortage per CLOSID Jinjie Ruan
2026-11-26  9:50 ` [PATCH v7 2/6] fs/resctrl: Do not allocate a monitor context when releasing limbo RMIDs Jinjie Ruan
2026-11-26  9:50 ` Jinjie Ruan [this message]
2026-11-26  9:50 ` [PATCH v7 4/6] fs/resctrl: Stop the limbo handler while resctrl is unmounted Jinjie Ruan
2026-11-26  9:50 ` [PATCH v7 5/6] fs/resctrl: Recreate the dirty RMIDs when the CDP state changes Jinjie Ruan
2026-12-03 20:15   ` Reinette Chatre
2026-11-26  9:50 ` [PATCH v7 6/6] fs/resctrl: Disallow monitor group move when the RMID index changes Jinjie Ruan
2026-12-03 20:05 ` [PATCH v7 0/6] fs/resctrl: Fix some resctl bugs related to mpam 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=20261126095038.2276975-4-ruanjinjie@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=corbet@lwn.net \
    --cc=fenghuay@nvidia.com \
    --cc=gshan@redhat.com \
    --cc=james.morse@arm.com \
    --cc=jic23@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rdunlap@infradead.org \
    --cc=reinette.chatre@intel.com \
    --cc=skhan@linuxfoundation.org \
    --cc=tan.shaopeng@fujitsu.com \
    --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®