From: Babu Moger <babu.moger@amd.com>
To: corbet@lwn.net, tony.luck@intel.com, reinette.chatre@intel.com,
Dave.Martin@arm.com, james.morse@arm.com, tglx@kernel.org,
bp@alien8.de, ben.horgan@arm.com, fenghuay@nvidia.com
Cc: skhan@linuxfoundation.org, x86@kernel.org, mingo@redhat.com,
dave.hansen@linux.intel.com, hpa@zytor.com,
akpm@linux-foundation.org, rdunlap@infradead.org,
peterz@infradead.org, feng.tang@linux.alibaba.com,
dapeng1.mi@linux.intel.com, elver@google.com,
enelsonmoore@gmail.com, kuba@kernel.org, ebiggers@kernel.org,
lirongqing@baidu.com, seanjc@google.com, nikunj@amd.com,
xin@zytor.com, pawan.kumar.gupta@linux.intel.com,
tiala@microsoft.com, chang.seok.bae@intel.com,
kprateek.nayak@amd.com, prathyushi.nangia@amd.com,
kim.phillips@amd.com, naveen@kernel.org, darwi@linutronix.de,
elena.reshetova@intel.com, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org, thomas.lendacky@amd.com,
eranian@google.com, peternewman@google.com,
qinyuntan@linux.alibaba.com
Subject: Re: [RESEND PATCH v4 11/15] fs/resctrl: Program kernel-mode binding when CPU comes online
Date: Thu, 9 Jul 2026 15:01:54 -0500 [thread overview]
Message-ID: <1c256f7c-effa-4ba5-9d1a-bcb510892458@amd.com> (raw)
In-Reply-To: <a8255414ef95dcb83b6eabbb210f45a17fec5c38.1783461016.git.babu.moger@amd.com>
On 7/7/26 16:50, Babu Moger wrote:
> Kernel-mode resctrl associations are programmed per CPU. When a
> global-assign kernel-mode policy is selected, all CPUs that are online at
> that time are configured; however, CPUs that come online later are not
> automatically updated.
>
> As a result, hot-added CPUs, or CPUs that were offline when the policy was
> selected, can run without the active kernel-mode association even though
> the resctrl policy is still in effect.
>
> Add resctrl_kmode_online_cpu() and call it from resctrl_online_cpu(). When
> a global-assign policy is active, add the newly online CPU to the bound
> group's kmode_cpu_mask and program the kernel-mode association on that CPU.
>
> Signed-off-by: Babu Moger <babu.moger@amd.com>
> ---
> v4: New patch in the series. Patch taken from:
> https://lore.kernel.org/lkml/20260611111706.1981788-5-qinyuntan@linux.alibaba.com/
> Updated the code to enable kernel-mode by default whenever a CPU comes online when
> one of global-assign mode is enabled.
> ---
> fs/resctrl/rdtgroup.c | 29 +++++++++++++++++++++++++++++
> 1 file changed, 29 insertions(+)
>
> diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
> index 21659fd75850..413d3ff14546 100644
> --- a/fs/resctrl/rdtgroup.c
> +++ b/fs/resctrl/rdtgroup.c
> @@ -4722,11 +4722,40 @@ int resctrl_online_mon_domain(struct rdt_resource *r, struct rdt_domain_hdr *hdr
> return err;
> }
>
> +/*
> + * resctrl_kmode_online_cpu() - Configure kernel-mode binding for a CPU that
> + * comes online
> + * @cpu: CPU that has just been brought online.
> + *
> + * Kernel-mode associations are maintained per CPU. When a CPU becomes
> + * online after a global-assign policy has been applied, it is updated
> + * with the current kernel-mode configuration. The CPU is then added to
> + * the bound group's kmode_cpu_mask, and the appropriate association is
> + * programmed for it.
> + */
> +static void resctrl_kmode_online_cpu(unsigned int cpu)
> +{
> + struct rdtgroup *rdtgrp = resctrl_kcfg.k_rdtgrp;
> + bool assign_mon = false;
> +
> + if (resctrl_kcfg.kmode_cur == INHERIT_CTRL_AND_MON || !rdtgrp)
> + return;
> +
> + assign_mon = (resctrl_kcfg.kmode_cur == GLOBAL_ASSIGN_CTRL_ASSIGN_MON_PER_CPU);
> +
> + cpumask_set_cpu(cpu, &rdtgrp->kmode_cpu_mask);
> +
> + resctrl_arch_configure_kmode(cpumask_of(cpu), rdtgrp->closid, rdtgrp->mon.rmid,
> + assign_mon, true);
> +}
> +
> void resctrl_online_cpu(unsigned int cpu)
> {
> mutex_lock(&rdtgroup_mutex);
> /* The CPU is set in default rdtgroup after online. */
> cpumask_set_cpu(cpu, &rdtgroup_default.cpu_mask);
> + /* Program any active kernel-mode binding on this CPU. */
> + resctrl_kmode_online_cpu(cpu);
> mutex_unlock(&rdtgroup_mutex);
> }
>
Sashiko reported:
https://sashiko.dev/#/patchset/cover.1783461016.git.babu.moger%40amd.com?part=11
--- Patch [11]: [RESEND PATCH v4 11/15] fs/resctrl: Program kernel-mode
binding when CPU comes online ---
commit ab44f1490e3dbe9a24a0baa6c7b98b7456c62c03
Author: Babu Moger <babu.moger@amd.com>
fs/resctrl: Program kernel-mode binding when CPU comes online
Kernel-mode resctrl associations are programmed per CPU. When a
global-assign
kernel-mode policy is selected, all CPUs that are online at that time are
configured; however, CPUs that come online later are not automatically
updated.
Link:
https://lore.kernel.org/lkml/20260611111706.1981788-5-qinyuntan@linux.alibaba.com/
diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
index 21659fd75850e..413d3ff14546b 100644
--- a/fs/resctrl/rdtgroup.c
+++ b/fs/resctrl/rdtgroup.c
[ ... ]
> @@ -4722,11 +4722,40 @@ int resctrl_online_mon_domain(struct
rdt_resource *r, struct rdt_domain_hdr *hdr
> return err;
> }
>
> +/*
> + * resctrl_kmode_online_cpu() - Configure kernel-mode binding for a
CPU that
> + * comes online
> + * @cpu: CPU that has just been brought online.
> + *
> + * Kernel-mode associations are maintained per CPU. When a CPU becomes
> + * online after a global-assign policy has been applied, it is updated
> + * with the current kernel-mode configuration. The CPU is then added to
> + * the bound group's kmode_cpu_mask, and the appropriate association is
> + * programmed for it.
> + */
> +static void resctrl_kmode_online_cpu(unsigned int cpu)
> +{
> + struct rdtgroup *rdtgrp = resctrl_kcfg.k_rdtgrp;
> + bool assign_mon = false;
> +
> + if (resctrl_kcfg.kmode_cur == INHERIT_CTRL_AND_MON || !rdtgrp)
> + return;
If a CPU goes offline while a kernel-mode policy is active, and the
policy is subsequently disabled (reverting to INHERIT_CTRL_AND_MON),
does returning early here leave the newly onlined CPU with a stale
kernel-mode resctrl association?
Looking at clear_closid_rmid(), it does not reset
MSR_IA32_PQR_PLZA_ASSOC during CPU online initialization. Could this
lead to the CPU executing CPL0 traffic with an invalid or malicious
cache allocation if the stale CLOSID/RMID is reallocated?
--------------------------------------------------------------------
Yes. This is an issue.
Need to clear the kmode_cpu_list if the cpu being offlined is part of
the current kmode. Also, need to disable PLZA on the CPU that is offlined.
Will take care of this in resctrl_offline_cpu().
-------------------------------------------------------------------
> +
> + assign_mon = (resctrl_kcfg.kmode_cur ==
GLOBAL_ASSIGN_CTRL_ASSIGN_MON_PER_CPU);
> +
> + cpumask_set_cpu(cpu, &rdtgrp->kmode_cpu_mask);
Since the CPU is added to kmode_cpu_mask here when it comes online,
shouldn't it be removed when it goes offline?
Looking at resctrl_offline_cpu(), it clears the CPU from rdtgrp->cpu_mask:
if (cpumask_test_and_clear_cpu(cpu, &rdtgrp->cpu_mask)) {
clear_childcpus(rdtgrp, cpu);
break;
}
But there is no corresponding logic to clear it from kmode_cpu_mask.
Does this cause stale state to be exposed to userspace via the
kmode_cpus file?
----------------------------------------------------------------------
Ditto: Will take care of this in resctrl_offline_cpu().
----------------------------------------------------------------------
Is it possible for a MON group that is actively bound to a kernel-mode
policy to be reparented?
Looking at rdtgroup_rename(), it allows reparenting if cpu_mask is empty
without checking kmode_cpu_mask:
if (!cpumask_empty(&rdtgrp->cpu_mask)) {
ret = -EINVAL;
goto out;
}
Then mongrp_reparent() updates the closid but fails to reprogram PLZA
MSRs for CPUs in kmode_cpu_mask:
rdtgrp->mon.parent = new_prdtgrp;
rdtgrp->closid = new_prdtgrp->closid;
/* Propagate updated closid to all tasks in this group. */
rdt_move_group_tasks(rdtgrp, rdtgrp, cpus);
update_closid_rmid(cpus, NULL);
Does this leave CPUs in kmode_cpu_mask running with the old parent's
CLOSID?
-----------------------------------------------------------------------
I don't see a reason to reparent the active kernel-mode group.
I'll add a check for:
if (!cpumask_empty(&rdtgrp->kmode_cpu_mask))
Thanks
Babu
next prev parent reply other threads:[~2026-07-09 20:02 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-07 21:50 [RESEND PATCH v4 00/15] x86/resctrl: Add kernel-mode (e.g., PLZA) support to the resctrl subsystem Babu Moger
2026-07-07 21:50 ` [RESEND PATCH v4 01/15] x86/resctrl: Support Privilege Level Zero Association (PLZA) Babu Moger
2026-07-07 22:01 ` Borislav Petkov
2026-07-08 14:51 ` Babu Moger
2026-07-08 17:27 ` Borislav Petkov
2026-07-08 16:55 ` Babu Moger
2026-07-08 23:28 ` Borislav Petkov
2026-07-09 0:00 ` Namhyung Kim
2026-07-09 0:12 ` Borislav Petkov
2026-07-10 0:55 ` Namhyung Kim
2026-07-10 1:46 ` Borislav Petkov
2026-07-07 21:50 ` [RESEND PATCH v4 02/15] x86/resctrl: Add PLZA support to command-line options Babu Moger
2026-07-08 17:39 ` Babu Moger
2026-07-07 21:50 ` [RESEND PATCH v4 03/15] x86/resctrl: Add data structures and definitions for PLZA configuration Babu Moger
2026-07-08 20:20 ` Babu Moger
2026-07-07 21:50 ` [RESEND PATCH v4 04/15] fs/resctrl: Introduce kernel mode (kmode) data structures Babu Moger
2026-07-08 20:56 ` Babu Moger
2026-07-07 21:50 ` [RESEND PATCH v4 05/15] x86,fs/resctrl: Introduce architecture hooks to program kernel-mode Babu Moger
2026-07-08 23:04 ` Moger, Babu
2026-07-07 21:50 ` [RESEND PATCH v4 06/15] fs/resctrl: Introduce resctrl_set_kmode_support() to initialize supported modes Babu Moger
2026-07-07 21:50 ` [RESEND PATCH v4 07/15] x86/resctrl: Expose the supported PLZA kernel-mode policies during init Babu Moger
2026-07-09 15:15 ` Babu Moger
2026-07-07 21:50 ` [RESEND PATCH v4 08/15] fs/resctrl: Add interface to display supported and active kernel-mode policy Babu Moger
2026-07-07 21:50 ` [RESEND PATCH v4 09/15] fs/resctrl: Introduce kmode_cpus/kmode_cpus_list per rdtgroup Babu Moger
2026-07-07 21:50 ` [RESEND PATCH v4 10/15] fs/resctrl: Reset the kernel-mode binding when an rdtgroup is removed Babu Moger
2026-07-09 18:15 ` Babu Moger
2026-07-07 21:50 ` [RESEND PATCH v4 11/15] fs/resctrl: Program kernel-mode binding when CPU comes online Babu Moger
2026-07-09 20:01 ` Babu Moger [this message]
2026-07-07 21:50 ` [RESEND PATCH v4 12/15] fs/resctrl: Hide kmode_cpus[_list] on groups not bound to kernel-mode Babu Moger
2026-07-07 21:50 ` [RESEND PATCH v4 13/15] fs/resctrl: Add interface to modify kernel-mode via info/kernel_mode Babu Moger
2026-07-09 22:46 ` Moger, Babu
2026-07-07 21:50 ` [RESEND PATCH v4 14/15] fs/resctrl: Allow user space to write kmode_cpus/kmode_cpus_list Babu Moger
2026-07-09 23:14 ` Moger, Babu
2026-07-07 21:50 ` [RESEND PATCH v4 15/15] fs/resctrl: Add documentation on kernel_mode with example Babu Moger
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=1c256f7c-effa-4ba5-9d1a-bcb510892458@amd.com \
--to=babu.moger@amd.com \
--cc=Dave.Martin@arm.com \
--cc=akpm@linux-foundation.org \
--cc=ben.horgan@arm.com \
--cc=bp@alien8.de \
--cc=chang.seok.bae@intel.com \
--cc=corbet@lwn.net \
--cc=dapeng1.mi@linux.intel.com \
--cc=darwi@linutronix.de \
--cc=dave.hansen@linux.intel.com \
--cc=ebiggers@kernel.org \
--cc=elena.reshetova@intel.com \
--cc=elver@google.com \
--cc=enelsonmoore@gmail.com \
--cc=eranian@google.com \
--cc=feng.tang@linux.alibaba.com \
--cc=fenghuay@nvidia.com \
--cc=hpa@zytor.com \
--cc=james.morse@arm.com \
--cc=kim.phillips@amd.com \
--cc=kprateek.nayak@amd.com \
--cc=kuba@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lirongqing@baidu.com \
--cc=mingo@redhat.com \
--cc=naveen@kernel.org \
--cc=nikunj@amd.com \
--cc=pawan.kumar.gupta@linux.intel.com \
--cc=peternewman@google.com \
--cc=peterz@infradead.org \
--cc=prathyushi.nangia@amd.com \
--cc=qinyuntan@linux.alibaba.com \
--cc=rdunlap@infradead.org \
--cc=reinette.chatre@intel.com \
--cc=seanjc@google.com \
--cc=skhan@linuxfoundation.org \
--cc=tglx@kernel.org \
--cc=thomas.lendacky@amd.com \
--cc=tiala@microsoft.com \
--cc=tony.luck@intel.com \
--cc=x86@kernel.org \
--cc=xin@zytor.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