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>, <mingo@redhat.com>,
<bp@alien8.de>, <dave.hansen@linux.intel.com>
Cc: <skhan@linuxfoundation.org>, <babu.moger@amd.com>,
<x86@kernel.org>, <hpa@zytor.com>, <peterz@infradead.org>,
<juri.lelli@redhat.com>, <vincent.guittot@linaro.org>,
<dietmar.eggemann@arm.com>, <rostedt@goodmis.org>,
<bsegall@google.com>, <mgorman@suse.de>, <vschneid@redhat.com>,
<kas@kernel.org>, <rick.p.edgecombe@intel.com>,
<akpm@linux-foundation.org>, <pmladek@suse.com>,
<rdunlap@infradead.org>, <dapeng1.mi@linux.intel.com>,
<kees@kernel.org>, <elver@google.com>, <paulmck@kernel.org>,
<lirongqing@baidu.com>, <safinaskar@gmail.com>, <fvdl@google.com>,
<seanjc@google.com>, <pawan.kumar.gupta@linux.intel.com>,
<xin@zytor.com>, <tiala@microsoft.com>, <Neeraj.Upadhyay@amd.com>,
<chang.seok.bae@intel.com>, <thomas.lendacky@amd.com>,
<elena.reshetova@intel.com>, <linux-doc@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <linux-coco@lists.linux.dev>,
<kvm@vger.kernel.org>, <eranian@google.com>,
<peternewman@google.com>
Subject: [PATCH v2 08/16] x86/resctrl: Add per-CPU and per-task kernel mode state
Date: Thu, 12 Mar 2026 15:36:53 -0500 [thread overview]
Message-ID: <cb7276e8ea2ddc392be79460efd5ed6cda76ebb0.1773347820.git.babu.moger@amd.com> (raw)
In-Reply-To: <cover.1773347820.git.babu.moger@amd.com>
Add per-CPU state and per-task state for resctrl kernel mode.
Signed-off-by: Babu Moger <babu.moger@amd.com>
---
v2: Minor name change from plza to kmode.
Tony suggested using global variables to store the kernel mode
CLOSID and RMID. However, the kernel mode CLOSID and RMID are
coming from rdtgroup structure with the new interface. Accessing
them requires holding the associated lock, which would make the
context switch path unnecessarily expensive.
https://lore.kernel.org/lkml/aXuxVSbk1GR2ttzF@agluck-desk3/
---
arch/x86/include/asm/resctrl.h | 14 +++++++++++++-
include/linux/sched.h | 2 ++
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/arch/x86/include/asm/resctrl.h b/arch/x86/include/asm/resctrl.h
index 4b4291006e78..e0a992abaeb4 100644
--- a/arch/x86/include/asm/resctrl.h
+++ b/arch/x86/include/asm/resctrl.h
@@ -21,9 +21,13 @@
/**
* struct resctrl_pqr_state - State cache for the PQR MSR
* @cur_rmid: The cached Resource Monitoring ID
- * @cur_closid: The cached Class Of Service ID
+ * @cur_closid: The cached Class Of Service ID
* @default_rmid: The user assigned Resource Monitoring ID
* @default_closid: The user assigned cached Class Of Service ID
+ * @cur_kmode: Currently active kernel mode (PLZA) bits for this CPU
+ * @default_kmode: Default kernel mode bits for this CPU (e.g. from resctrl mount)
+ * @kmode_rmid: RMID used when executing in kernel mode (PLZA)
+ * @kmode_closid: CLOSID used when executing in kernel mode (PLZA)
*
* The upper 32 bits of MSR_IA32_PQR_ASSOC contain closid and the
* lower 10 bits rmid. The update to MSR_IA32_PQR_ASSOC always
@@ -32,12 +36,20 @@
*
* The cache also helps to avoid pointless updates if the value does
* not change.
+ *
+ * Kernel mode (e.g. PLZA) state: cur_kmode/default_kmode hold the active
+ * and default mode bits; kmode_rmid and kmode_closid are the association
+ * used when the thread is in privilege level zero.
*/
struct resctrl_pqr_state {
u32 cur_rmid;
u32 cur_closid;
u32 default_rmid;
u32 default_closid;
+ u32 cur_kmode;
+ u32 default_kmode;
+ u32 kmode_rmid;
+ u32 kmode_closid;
};
DECLARE_PER_CPU(struct resctrl_pqr_state, pqr_state);
diff --git a/include/linux/sched.h b/include/linux/sched.h
index a7b4a980eb2f..2ec0530399be 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1328,6 +1328,8 @@ struct task_struct {
#ifdef CONFIG_X86_CPU_RESCTRL
u32 closid;
u32 rmid;
+ /* Resctrl kernel mode (e.g. PLZA) bits for this task */
+ u32 kmode;
#endif
#ifdef CONFIG_FUTEX
struct robust_list_head __user *robust_list;
--
2.43.0
next prev parent reply other threads:[~2026-03-12 20:38 UTC|newest]
Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-12 20:36 [PATCH v2 00/16] fs,x86/resctrl: Add kernel-mode (e.g., PLZA) support to the resctrl subsystem Babu Moger
2026-03-12 20:36 ` [PATCH v2 01/16] fs/resctrl: Add kernel mode (kmode) data structures and arch hook Babu Moger
2026-03-24 22:51 ` Reinette Chatre
2026-03-26 18:41 ` Babu Moger
2026-03-12 20:36 ` [PATCH v2 02/16] fs, x86/resctrl: Add architecture routines for kernel mode initialization Babu Moger
2026-03-24 22:53 ` Reinette Chatre
2026-03-26 19:10 ` Babu Moger
2026-03-12 20:36 ` [PATCH v2 03/16] fs/resctrl: Add info/kernel_mode file to show kernel mode options Babu Moger
2026-03-12 20:36 ` [PATCH v2 04/16] x86/resctrl: Support Privilege-Level Zero Association (PLZA) Babu Moger
2026-03-12 20:36 ` [PATCH v2 05/16] x86/resctrl: Initialize supported kernel modes when CPUID reports PLZA Babu Moger
2026-03-12 20:36 ` [PATCH v2 06/16] resctrl: Introduce kmode static key enable/disable helpers Babu Moger
2026-03-12 20:36 ` [PATCH v2 07/16] x86/resctrl: Add data structures and definitions for PLZA configuration Babu Moger
2026-03-12 20:36 ` Babu Moger [this message]
2026-03-12 20:36 ` [PATCH v2 09/16] x86,fs/resctrl: Add the functionality to configure PLZA Babu Moger
2026-03-12 20:36 ` [PATCH v2 10/16] x86/resctrl: Add PLZA state tracking and context switch handling Babu Moger
2026-03-12 20:36 ` [PATCH v2 11/16] fs/resctrl: Add write handler for info/kernel_mode Babu Moger
2026-03-12 20:36 ` [PATCH v2 12/16] fs/resctrl: Add info/kernel_mode_assignment to show kernel-mode rdtgroup Babu Moger
2026-03-12 20:36 ` [PATCH v2 13/16] fs/resctrl: Add write interface for kernel_mode_assignment Babu Moger
2026-03-12 20:36 ` [PATCH v2 14/16] fs/resctrl: Update kmode configuration when cpu_mask changes Babu Moger
2026-03-12 20:37 ` [PATCH v2 15/16] x86/resctrl: Refactor show_rdt_tasks() to support PLZA tasks Babu Moger
2026-03-12 20:37 ` [PATCH v2 16/16] fs/resctrl: Add per-task kmode enable support via rdtgroup Babu Moger
2026-03-24 6:15 ` [PATCH v2 00/16] fs,x86/resctrl: Add kernel-mode (e.g., PLZA) support to the resctrl subsystem Askar Safin
2026-03-24 22:51 ` Reinette Chatre
2026-03-26 17:12 ` Babu Moger
2026-03-27 22:11 ` Reinette Chatre
2026-03-30 18:46 ` Babu Moger
2026-03-31 22:24 ` Reinette Chatre
2026-04-06 22:45 ` Babu Moger
2026-04-07 17:48 ` Reinette Chatre
2026-04-08 1:01 ` Babu Moger
2026-04-08 4:45 ` Reinette Chatre
2026-04-08 20:45 ` Babu Moger
2026-04-08 21:24 ` Reinette Chatre
2026-04-08 23:07 ` Moger, Babu
2026-04-08 23:41 ` Reinette Chatre
2026-04-09 17:19 ` Moger, Babu
2026-04-09 17:26 ` Reinette Chatre
2026-04-09 18:05 ` Moger, Babu
2026-04-09 20:50 ` Reinette Chatre
2026-04-09 23:42 ` Moger, Babu
2026-04-10 3:41 ` Reinette Chatre
2026-04-10 22:52 ` Moger, Babu
2026-04-20 19:38 ` Babu Moger
2026-04-20 22:03 ` Reinette Chatre
2026-04-20 22:59 ` Moger, Babu
2026-04-20 23:34 ` Reinette Chatre
2026-04-21 0:40 ` Moger, Babu
2026-04-21 3:17 ` Reinette Chatre
2026-04-21 15:08 ` Babu Moger
2026-04-21 16:15 ` Reinette Chatre
2026-04-21 16:46 ` Babu Moger
2026-04-21 17:35 ` Reinette Chatre
2026-04-21 18:19 ` Babu Moger
2026-04-21 20:57 ` Reinette Chatre
2026-04-21 22:04 ` Moger, Babu
2026-04-21 22:44 ` Reinette Chatre
2026-04-22 0:17 ` Moger, Babu
2026-04-22 2:56 ` Reinette Chatre
2026-04-22 21:42 ` Moger, Babu
2026-04-21 0:03 ` Luck, Tony
2026-04-21 0:21 ` Reinette Chatre
2026-04-21 15:11 ` Luck, Tony
2026-04-21 16:12 ` 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=cb7276e8ea2ddc392be79460efd5ed6cda76ebb0.1773347820.git.babu.moger@amd.com \
--to=babu.moger@amd.com \
--cc=Dave.Martin@arm.com \
--cc=Neeraj.Upadhyay@amd.com \
--cc=akpm@linux-foundation.org \
--cc=bp@alien8.de \
--cc=bsegall@google.com \
--cc=chang.seok.bae@intel.com \
--cc=corbet@lwn.net \
--cc=dapeng1.mi@linux.intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=dietmar.eggemann@arm.com \
--cc=elena.reshetova@intel.com \
--cc=elver@google.com \
--cc=eranian@google.com \
--cc=fvdl@google.com \
--cc=hpa@zytor.com \
--cc=james.morse@arm.com \
--cc=juri.lelli@redhat.com \
--cc=kas@kernel.org \
--cc=kees@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linux-coco@lists.linux.dev \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lirongqing@baidu.com \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=paulmck@kernel.org \
--cc=pawan.kumar.gupta@linux.intel.com \
--cc=peternewman@google.com \
--cc=peterz@infradead.org \
--cc=pmladek@suse.com \
--cc=rdunlap@infradead.org \
--cc=reinette.chatre@intel.com \
--cc=rick.p.edgecombe@intel.com \
--cc=rostedt@goodmis.org \
--cc=safinaskar@gmail.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=vincent.guittot@linaro.org \
--cc=vschneid@redhat.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
all inboxes | Powered by JetHome®