* [PATCH v4 00/15] x86/resctrl: Add kernel-mode (e.g., PLZA) support to the resctrl subsystem
@ 2026-07-07 21:16 Babu Moger
2026-07-07 21:16 ` [PATCH v4 01/15] x86/resctrl: Support Privilege Level Zero Association (PLZA) Babu Moger
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Babu Moger @ 2026-07-07 21:16 UTC (permalink / raw)
To: corbet, tony.luck, reinette.chatre, Dave.Martin, james.morse,
tglx, bp, ben.horgan, fenghuay
Cc: skhan, x86, babu.moger, mingo, dave.hansen, hpa, akpm, rdunlap,
peterz, feng.tang, dapeng1.mi, elver, enelsonmoore, kuba,
ebiggers, lirongqing, seanjc, nikunj, xin, pawan.kumar.gupta,
tiala, chang.seok.bae, kprateek.nayak, prathyushi.nangia,
kim.phillips, naveen, darwi, elena.reshetova, linux-doc,
linux-kernel, thomas.lendacky, eranian, peternewman, qinyuntan
Hi All,
This series adds support for AMD's Privilege-Level Zero Association
(PLZA) so kernel work can be assigned to a resctrl group, and wires it
up through a small generic "kernel mode" (kmode) layer in fs/resctrl
so future architectures can plug in without touching core resctrl.
The features are documented in:
AMD64 Zen6 Platform Quality of Service (PQOS) Extensions,
Publication # 69193 Revision 1.00, Issue Date March 2026
available at https://bugzilla.kernel.org/show_bug.cgi?id=206537
The patches are based on top of commit (tip/master v7.2-rc2):
f705c6728b35 Merge branch into tip/master: 'x86/msr'
Background
==========
Customers have identified an issue while using the QoS resource Control
feature. If a memory bandwidth associated with a CLOSID is aggressively
throttled, and it moves into Kernel mode, the Kernel operations are also
aggressively throttled. This can stall forward progress and eventually
degrade overall system performance.
Privilege-Level Zero Association (PLZA) allows the user to specify a CLOSID
and/or RMID for execution at Privilege Level Zero. When PLZA is enabled on
a CPU, kernel work at PL0 uses the CLOSID and/or RMID from MSR
PQR_PLZA_ASSOC; otherwise, the CPU uses the CLOSID and RMID from PQR_ASSOC.
Design
======
A new sysfs file, info/kernel_mode, holds the global policy for resource
allocation and monitoring of kernel work and the resource group (when
applicable) associated with the policy. Reads list the supported modes
and the currently active binding; writes change the policy or rebind to a
different group. Look at the thread below for design discussion.
https://lore.kernel.org/lkml/14a8ad0a-e842-4268-871a-0762f1169e03@intel.com/
Per-rdtgroup files kmode_cpus and kmode_cpus_list scope the binding
to a subset of online CPUs without unbind/rebind churn. They are
visible only on the group that is currently the active kernel-mode
binding.
The arch hook, resctrl_arch_configure_kmode keep the fs/resctrl layer
arch-neutral.
Introduced `resctrl_set_kmode_support()` so architecture code
can register supported kernel-mode policies during resctrl initialization.
Only AMD PLZA is wired up here; Intel and ARM can add their own
support later by implementing the hooks.
Examples
========
(See Documentation/filesystems/resctrl.rst, "kernel_mode",
"kmode_cpus", and "Examples on working with kernel_mode", for the full
UAPI.)
# Mount resctrl
# mount -t resctrl resctrl /sys/fs/resctrl
# cd /sys/fs/resctrl
# Read the supported modes. The active mode is bracketed for display
# only. Inactive global-assign modes report ":group=uninitialized".
# cat info/kernel_mode
[inherit_ctrl_and_mon]
global_assign_ctrl_inherit_mon_per_cpu:group=uninitialized
global_assign_ctrl_assign_mon_per_cpu:group=uninitialized
# Create a CTRL_MON group and bind kernel-mode allocation to it.
# mkdir ctrl1
# echo "global_assign_ctrl_inherit_mon_per_cpu:group=ctrl1//" \
> info/kernel_mode
# cat info/kernel_mode
inherit_ctrl_and_mon
[global_assign_ctrl_inherit_mon_per_cpu:group=ctrl1//]
global_assign_ctrl_assign_mon_per_cpu:group=uninitialized
# kmode_cpus and kmode_cpus_list are visible only on the bound group.
# ls ctrl1/kmode_cpus*
ctrl1/kmode_cpus ctrl1/kmode_cpus_list
# Restrict the binding to a CPU subset; the write is incremental.
# echo 0-3 > ctrl1/kmode_cpus_list
# cat ctrl1/kmode_cpus
f
# cat ctrl1/kmode_cpus_list
0-3
# Return to the default inherit mode.
# echo "inherit_ctrl_and_mon" > info/kernel_mode
# cat info/kernel_mode
[inherit_ctrl_and_mon]
global_assign_ctrl_inherit_mon_per_cpu:group=uninitialized
global_assign_ctrl_assign_mon_per_cpu:group=uninitialized
Tested on AMD with PLZA; the generic bits build clean on x86 without
PLZA support and are no-ops at runtime.
Layout
======
01-03 x86: PLZA CPU feature, command-line option, and MSR/data-structure
plumbing.
04-07 fs/resctrl + x86: kmode data structures, arch hooks, supported-mode
initialization, and PLZA policy advertisement.
08 fs/resctrl: info/kernel_mode read-only introspection.
09-10 fs/resctrl: per-rdtgroup kmode_cpus[_list] exposure and reset of
the binding when the bound rdtgroup is removed.
11 fs/resctrl: program kernel-mode binding when a CPU comes online.
12 resctrl: hide kmode_cpus[_list] on groups not bound to kernel-mode.
13-14 fs/resctrl: info/kernel_mode write and incremental kmode_cpus[_list]
writes.
15 fs/resctrl: documentation and end-to-end examples.
Changelog
=========
v4:
- Reorder and split the series into 15 patches: separate read-only
info/kernel_mode display (08) from the write path (13);
add hotplug support when a CPU comes online (11); add an end-to-end
documentation/examples patch (15).
- Introduced `resctrl_set_kmode_support()` so architecture code can
register supported kernel-mode policies during resctrl initialization.
- info/kernel_mode UAPI: inactive global-assign modes report
":group=uninitialized" (not ":group=none"); the inherit mode has
no ":group=" suffix; square brackets mark the active mode on read
only and must not be included when writing.
- info/kernel_mode write: validate group type (assign_mon may bind an
RDTMON_GROUP or RDTCTRL_GROUP; inherit_mon only RDTCTRL_GROUP);
run fail paths before tearing down the active binding so errors
retain the old binding; reset any active global-assign binding
before reprogramming when rebinding.
- kmode_cpus / kmode_cpus_list: writable with incremental
enable/disable deltas; empty masks are allowed; offline CPUs and
writes through stale file descriptors (opened before an
info/kernel_mode change) are rejected; pseudo-locked and
pseudo-lock-setup groups are rejected.
- Hotplug: newly online CPUs are added to the bound group's
kmode_cpu_mask and programmed when a global-assign policy is
active.
- Documentation updated alongside the UAPI changes, including an
"Examples on working with kernel_mode" walk-through.
v3:
- Generalise the layer beyond AMD: rename "PLZA mode" to "kernel
mode" (kmode) in code, sysfs, and Documentation. The public
interface is now info/kernel_mode and per-group kmode_cpus[_list].
- info/kernel_mode UAPI cleanups: designated initialisers +
static_assert for the mode-name table; strim() the input; clearer
error messages via last_cmd_status.
- kmode_cpus / kmode_cpus_list: expose read-only, gate visibility on
the bound group, and allow incremental writes.
- Reset the binding when the bound rdtgroup is removed, instead of
leaving stale state.
- Kerneldoc/comment cleanups across the series.
v2:
- Similar to RFC with a new proposal; interface names were not final.
- Separated Global Bandwidth Enforcement (GLBE) from PLZA; this
series only adds PLZA support.
- Used "kmode" instead of "PLZA" in the generic layer.
Previous versions:
v3: https://lore.kernel.org/lkml/cover.1777591496.git.babu.moger@amd.com/
v2: https://lore.kernel.org/lkml/cover.1773347820.git.babu.moger@amd.com/
v1: https://lore.kernel.org/lkml/cover.1769029977.git.babu.moger@amd.com/
Babu Moger (15):
x86/resctrl: Support Privilege Level Zero Association (PLZA)
x86/resctrl: Add PLZA support to command-line options
x86/resctrl: Add data structures and definitions for PLZA
configuration
fs/resctrl: Introduce kernel mode (kmode) data structures
x86,fs/resctrl: Introduce architecture hooks to program kernel-mode
fs/resctrl: Introduce resctrl_set_kmode_support() to initialize
supported modes
x86/resctrl: Expose the supported PLZA kernel-mode policies during
init
fs/resctrl: Add interface to display supported and active kernel-mode
policy
fs/resctrl: Introduce kmode_cpus/kmode_cpus_list per rdtgroup
fs/resctrl: Reset the kernel-mode binding when an rdtgroup is removed
fs/resctrl: Program kernel-mode binding when CPU comes online
fs/resctrl: Hide kmode_cpus[_list] on groups not bound to kernel-mode
fs/resctrl: Add interface to modify kernel-mode via info/kernel_mode
fs/resctrl: Allow user space to write kmode_cpus/kmode_cpus_list
fs/resctrl: Add documentation on kernel_mode with example
.../admin-guide/kernel-parameters.txt | 2 +-
Documentation/filesystems/resctrl.rst | 195 ++++++
arch/x86/include/asm/cpufeatures.h | 1 +
arch/x86/include/asm/msr-index.h | 1 +
arch/x86/kernel/cpu/resctrl/core.c | 8 +
arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 36 +
arch/x86/kernel/cpu/resctrl/internal.h | 37 +
arch/x86/kernel/cpu/scattered.c | 1 +
drivers/resctrl/mpam_resctrl.c | 5 +
fs/resctrl/internal.h | 16 +
fs/resctrl/rdtgroup.c | 663 ++++++++++++++++++
include/linux/resctrl.h | 56 ++
12 files changed, 1020 insertions(+), 1 deletion(-)
--
2.43.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v4 01/15] x86/resctrl: Support Privilege Level Zero Association (PLZA)
2026-07-07 21:16 [PATCH v4 00/15] x86/resctrl: Add kernel-mode (e.g., PLZA) support to the resctrl subsystem Babu Moger
@ 2026-07-07 21:16 ` Babu Moger
2026-07-07 21:16 ` [PATCH v4 02/15] x86/resctrl: Add PLZA support to command-line options Babu Moger
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Babu Moger @ 2026-07-07 21:16 UTC (permalink / raw)
To: corbet, tony.luck, reinette.chatre, Dave.Martin, james.morse,
tglx, bp, ben.horgan, fenghuay
Cc: skhan, x86, babu.moger, mingo, dave.hansen, hpa, akpm, rdunlap,
peterz, feng.tang, dapeng1.mi, elver, enelsonmoore, kuba,
ebiggers, lirongqing, seanjc, nikunj, xin, pawan.kumar.gupta,
tiala, chang.seok.bae, kprateek.nayak, prathyushi.nangia,
kim.phillips, naveen, darwi, elena.reshetova, linux-doc,
linux-kernel, thomas.lendacky, eranian, peternewman, qinyuntan
Customers have identified an issue while using the QoS resource control
feature. If memory bandwidth associated with a CLOSID is aggressively
throttled, and a task with that CLOSID moves into kernel mode, the kernel
operations are also aggressively throttled. This can stall forward progress
and eventually degrade overall system performance.
AMD hardware supports a feature Privilege Level Zero Association (PLZA),
which allows the CPU's CLOSID association to be changed during the
transition from user mode to kernel mode. This allows the kernel to run
using a different CLOSID than user space, which can improve system
performance in certain scenarios.
The feature is detected via CPUID_Fn80000020_EBX_x00 [Bit 9]:
Privilege Level Zero Association (PLZA).
The PLZA feature details are documented in [1] available from [2].
[1] AMD64 Zen6 Platform Quality of Service (PQOS) Extensions:
Publication # 69193 Revision: 1.00, Issue Date: March 2026
Link: https://bugzilla.kernel.org/show_bug.cgi?id=206537 # [2]
Signed-off-by: Babu Moger <babu.moger@amd.com>
---
v4: Split the patch into 2. This patch only handles x86 changes.
Re-wrote the changelog along the ABMC changes.
v3: Code did not change. Patch order changed.
Added documentation link.
v2: Rebased on top of the latest tip.
---
arch/x86/include/asm/cpufeatures.h | 1 +
arch/x86/kernel/cpu/scattered.c | 1 +
2 files changed, 2 insertions(+)
diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h
index 1b4a48bff18f..bf6fc71f87fa 100644
--- a/arch/x86/include/asm/cpufeatures.h
+++ b/arch/x86/include/asm/cpufeatures.h
@@ -517,6 +517,7 @@
* and purposes if CLEAR_CPU_BUF_VM is set).
*/
#define X86_FEATURE_X2AVIC_EXT (21*32+20) /* AMD SVM x2AVIC support for 4k vCPUs */
+#define X86_FEATURE_PLZA (21*32+21) /* Privilege Level Zero Association */
/*
* BUG word(s)
diff --git a/arch/x86/kernel/cpu/scattered.c b/arch/x86/kernel/cpu/scattered.c
index 937129ce6a96..1fa4d5aef17e 100644
--- a/arch/x86/kernel/cpu/scattered.c
+++ b/arch/x86/kernel/cpu/scattered.c
@@ -61,6 +61,7 @@ static const struct cpuid_bit cpuid_bits[] = {
{ X86_FEATURE_BMEC, CPUID_EBX, 3, 0x80000020, 0 },
{ X86_FEATURE_ABMC, CPUID_EBX, 5, 0x80000020, 0 },
{ X86_FEATURE_SDCIAE, CPUID_EBX, 6, 0x80000020, 0 },
+ { X86_FEATURE_PLZA, CPUID_EBX, 9, 0x80000020, 0 },
{ X86_FEATURE_TSA_SQ_NO, CPUID_ECX, 1, 0x80000021, 0 },
{ X86_FEATURE_TSA_L1_NO, CPUID_ECX, 2, 0x80000021, 0 },
{ X86_FEATURE_AMD_WORKLOAD_CLASS, CPUID_EAX, 22, 0x80000021, 0 },
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v4 02/15] x86/resctrl: Add PLZA support to command-line options
2026-07-07 21:16 [PATCH v4 00/15] x86/resctrl: Add kernel-mode (e.g., PLZA) support to the resctrl subsystem Babu Moger
2026-07-07 21:16 ` [PATCH v4 01/15] x86/resctrl: Support Privilege Level Zero Association (PLZA) Babu Moger
@ 2026-07-07 21:16 ` Babu Moger
2026-07-07 21:16 ` [PATCH v4 03/15] x86/resctrl: Add data structures and definitions for PLZA configuration Babu Moger
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Babu Moger @ 2026-07-07 21:16 UTC (permalink / raw)
To: corbet, tony.luck, reinette.chatre, Dave.Martin, james.morse,
tglx, bp, ben.horgan, fenghuay
Cc: skhan, x86, babu.moger, mingo, dave.hansen, hpa, akpm, rdunlap,
peterz, feng.tang, dapeng1.mi, elver, enelsonmoore, kuba,
ebiggers, lirongqing, seanjc, nikunj, xin, pawan.kumar.gupta,
tiala, chang.seok.bae, kprateek.nayak, prathyushi.nangia,
kim.phillips, naveen, darwi, elena.reshetova, linux-doc,
linux-kernel, thomas.lendacky, eranian, peternewman, qinyuntan
Add a kernel command-line parameter to enable or disable the exposure of
the PLZA (Privilege Level Zero Association) feature to resctrl.
This allows administrators to control PLZA visibility at boot time via the
rdt= option (e.g. rdt=plza or rdt=!plza).
Signed-off-by: Babu Moger <babu.moger@amd.com>
---
v4: Split the patch 1 from v3 into 2 patches.
This patch contains changes for resctrl subsystem.
---
Documentation/admin-guide/kernel-parameters.txt | 2 +-
Documentation/filesystems/resctrl.rst | 1 +
arch/x86/kernel/cpu/resctrl/core.c | 2 ++
3 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index b5493a7f8f22..1de27055cb32 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -6401,7 +6401,7 @@ Kernel parameters
rdt= [HW,X86,RDT]
Turn on/off individual RDT features. List is:
cmt, mbmtotal, mbmlocal, l3cat, l3cdp, l2cat, l2cdp,
- mba, smba, bmec, abmc, sdciae, energy[:guid],
+ mba, smba, bmec, abmc, sdciae, plza, energy[:guid],
perf[:guid].
E.g. to turn on cmt and turn off mba use:
rdt=cmt,!mba
diff --git a/Documentation/filesystems/resctrl.rst b/Documentation/filesystems/resctrl.rst
index e4b66af55ffb..f3e941404967 100644
--- a/Documentation/filesystems/resctrl.rst
+++ b/Documentation/filesystems/resctrl.rst
@@ -28,6 +28,7 @@ SMBA (Slow Memory Bandwidth Allocation) ""
BMEC (Bandwidth Monitoring Event Configuration) ""
ABMC (Assignable Bandwidth Monitoring Counters) ""
SDCIAE (Smart Data Cache Injection Allocation Enforcement) ""
+PLZA (Privilege Level Zero Association) ""
=============================================================== ================================
Historically, new features were made visible by default in /proc/cpuinfo. This
diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c
index f452e8ce4cef..27e09cded829 100644
--- a/arch/x86/kernel/cpu/resctrl/core.c
+++ b/arch/x86/kernel/cpu/resctrl/core.c
@@ -803,6 +803,7 @@ enum {
RDT_FLAG_BMEC,
RDT_FLAG_ABMC,
RDT_FLAG_SDCIAE,
+ RDT_FLAG_PLZA,
};
#define RDT_OPT(idx, n, f) \
@@ -830,6 +831,7 @@ static struct rdt_options rdt_options[] __ro_after_init = {
RDT_OPT(RDT_FLAG_BMEC, "bmec", X86_FEATURE_BMEC),
RDT_OPT(RDT_FLAG_ABMC, "abmc", X86_FEATURE_ABMC),
RDT_OPT(RDT_FLAG_SDCIAE, "sdciae", X86_FEATURE_SDCIAE),
+ RDT_OPT(RDT_FLAG_PLZA, "plza", X86_FEATURE_PLZA),
};
#define NUM_RDT_OPTIONS ARRAY_SIZE(rdt_options)
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v4 03/15] x86/resctrl: Add data structures and definitions for PLZA configuration
2026-07-07 21:16 [PATCH v4 00/15] x86/resctrl: Add kernel-mode (e.g., PLZA) support to the resctrl subsystem Babu Moger
2026-07-07 21:16 ` [PATCH v4 01/15] x86/resctrl: Support Privilege Level Zero Association (PLZA) Babu Moger
2026-07-07 21:16 ` [PATCH v4 02/15] x86/resctrl: Add PLZA support to command-line options Babu Moger
@ 2026-07-07 21:16 ` Babu Moger
2026-07-07 21:16 ` [PATCH v4 04/15] fs/resctrl: Introduce kernel mode (kmode) data structures Babu Moger
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Babu Moger @ 2026-07-07 21:16 UTC (permalink / raw)
To: corbet, tony.luck, reinette.chatre, Dave.Martin, james.morse,
tglx, bp, ben.horgan, fenghuay
Cc: skhan, x86, babu.moger, mingo, dave.hansen, hpa, akpm, rdunlap,
peterz, feng.tang, dapeng1.mi, elver, enelsonmoore, kuba,
ebiggers, lirongqing, seanjc, nikunj, xin, pawan.kumar.gupta,
tiala, chang.seok.bae, kprateek.nayak, prathyushi.nangia,
kim.phillips, naveen, darwi, elena.reshetova, linux-doc,
linux-kernel, thomas.lendacky, eranian, peternewman, qinyuntan
Privilege Level Zero Association (PLZA) allows the kernel to use a
different CLOSID (and optionally RMID) than user mode on entry to kernel
mode. The CLOSID/RMID association is programmed per CPU via
MSR_IA32_PQR_PLZA_ASSOC (0xc00003fc), using RMID/CLOSID values and their
respective enable bits.
Add the MSR definition and union msr_pqr_plza_assoc to represent the MSR
bitfield layout used by subsequent PLZA programming.
Signed-off-by: Babu Moger <babu.moger@amd.com>
---
v4: Re-wrote the changelog and code comment.
v3: No code changes. Patch order changed. Improved changelog.
v2: No changes. Just rebasing on top of the latest tip branch.
---
arch/x86/include/asm/msr-index.h | 1 +
arch/x86/kernel/cpu/resctrl/internal.h | 37 ++++++++++++++++++++++++++
2 files changed, 38 insertions(+)
diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h
index 18c4be75e927..2503451a95fe 100644
--- a/arch/x86/include/asm/msr-index.h
+++ b/arch/x86/include/asm/msr-index.h
@@ -1292,6 +1292,7 @@
/* - AMD: */
#define MSR_IA32_MBA_BW_BASE 0xc0000200
#define MSR_IA32_SMBA_BW_BASE 0xc0000280
+#define MSR_IA32_PQR_PLZA_ASSOC 0xc00003fc
#define MSR_IA32_L3_QOS_ABMC_CFG 0xc00003fd
#define MSR_IA32_L3_QOS_EXT_CFG 0xc00003ff
#define MSR_IA32_EVT_CFG_BASE 0xc0000400
diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h
index e3cfa0c10e92..020ebc2c8a1f 100644
--- a/arch/x86/kernel/cpu/resctrl/internal.h
+++ b/arch/x86/kernel/cpu/resctrl/internal.h
@@ -222,6 +222,43 @@ union l3_qos_abmc_cfg {
unsigned long full;
};
+/*
+ * Privilege Level Zero Association (PLZA) is configured by writing to
+ * MSR_IA32_PQR_PLZA_ASSOC. The MSR must be programmed on every CPU in
+ * the QoS domain. Each domain supports only one PLZA CLOSID and/or RMID
+ * association. All fields other than PLZA_EN must hold the same value
+ * across the domain for consistent operation.
+ *
+ * When PLZA_EN is set, the CLOSID/RMID association used at CPL 0 is
+ * taken from MSR_IA32_PQR_PLZA_ASSOC instead of MSR_IA32_PQR_ASSOC.
+ *
+ * @rmid : RMID associated with PLZA.
+ * @reserved1 : Reserved.
+ * @rmid_en : Enable RMID association for PLZA.
+ * @closid : CLOSID associated with PLZA.
+ * @reserved2 : Reserved.
+ * @closid_en : Enable CLOSID association for PLZA.
+ * @reserved3 : Reserved.
+ * @plza_en : Enable PLZA. When enabled, PLZA applies to the
+ * given CPU. When PLZA is disabled for a CPU, the
+ * CLOSID and RMID association defined in the
+ * PQR_ASSOC MSR applies, regardless of the CPU's
+ * privilege level.
+ */
+union msr_pqr_plza_assoc {
+ struct {
+ unsigned long rmid :12,
+ reserved1 :19,
+ rmid_en : 1,
+ closid : 4,
+ reserved2 :11,
+ closid_en : 1,
+ reserved3 :15,
+ plza_en : 1;
+ } split;
+ unsigned long full;
+};
+
void rdt_ctrl_update(void *arg);
int rdt_get_l3_mon_config(struct rdt_resource *r);
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v4 04/15] fs/resctrl: Introduce kernel mode (kmode) data structures
2026-07-07 21:16 [PATCH v4 00/15] x86/resctrl: Add kernel-mode (e.g., PLZA) support to the resctrl subsystem Babu Moger
` (2 preceding siblings ...)
2026-07-07 21:16 ` [PATCH v4 03/15] x86/resctrl: Add data structures and definitions for PLZA configuration Babu Moger
@ 2026-07-07 21:16 ` Babu Moger
2026-07-07 21:16 ` [PATCH v4 05/15] x86,fs/resctrl: Introduce architecture hooks to program kernel-mode Babu Moger
2026-07-07 21:16 ` [PATCH v4 06/15] fs/resctrl: Introduce resctrl_set_kmode_support() to initialize supported modes Babu Moger
5 siblings, 0 replies; 7+ messages in thread
From: Babu Moger @ 2026-07-07 21:16 UTC (permalink / raw)
To: corbet, tony.luck, reinette.chatre, Dave.Martin, james.morse,
tglx, bp, ben.horgan, fenghuay
Cc: skhan, x86, babu.moger, mingo, dave.hansen, hpa, akpm, rdunlap,
peterz, feng.tang, dapeng1.mi, elver, enelsonmoore, kuba,
ebiggers, lirongqing, seanjc, nikunj, xin, pawan.kumar.gupta,
tiala, chang.seok.bae, kprateek.nayak, prathyushi.nangia,
kim.phillips, naveen, darwi, elena.reshetova, linux-doc,
linux-kernel, thomas.lendacky, eranian, peternewman, qinyuntan
Kernel-mode traffic can use a different allocation and monitoring context
than the originating user task. On x86, Privilege Level Zero Association
(PLZA) enables the kernel to switch to a different CLOSID (and optionally
RMID) when entering kernel mode.
Architectures need a common way to name kernel-mode policies before resctrl
can report what is active or what the platform supports.
Introduce enum resctrl_kernel_mode:
- INHERIT_CTRL_AND_MON: Kernel work inherits allocation and monitoring
from the user task (current behavior).
- GLOBAL_ASSIGN_CTRL_INHERIT_MON_PER_CPU: Assign allocation for kernel
work; inherit monitoring from the user task.
- GLOBAL_ASSIGN_CTRL_ASSIGN_MON_PER_CPU: Assign a dedicated allocation
and monitoring for kernel work.
Signed-off-by: Babu Moger <babu.moger@amd.com>
---
v4: Updated the changelog to be generic as possible.
Moved the enum resctrl_kernel_mode to include/linux/resctrl.h.
Updated the code comments to be generic.
Removed resctrl_kmode_cfg from the code. This definition can be fs
specific only and architectures dont need to know.
Changed enum name to resctrl_kernel_mode from resctrl_kernel_modes.
v3: Removed resctrl_kmode definition.
Changed the kernel mode definitions to enum resctrl_kernel_modes.
Used BIT() to set/test the features.
Added details to changelog.
v2: New patch to handle PLZA interfaces with /sys/fs/resctrl/info/ directory.
https://lore.kernel.org/lkml/2ab556af-095b-422b-9396-f845c6fd0342@intel.com/
---
include/linux/resctrl.h | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h
index 73ff522448a0..c7abed51cd5f 100644
--- a/include/linux/resctrl.h
+++ b/include/linux/resctrl.h
@@ -703,6 +703,37 @@ int resctrl_arch_io_alloc_enable(struct rdt_resource *r, bool enable);
*/
bool resctrl_arch_get_io_alloc_enabled(struct rdt_resource *r);
+/**
+ * enum resctrl_kernel_mode - Kernel-mode control and monitor association
+ * policy.
+ *
+ * @INHERIT_CTRL_AND_MON:
+ * Kernel work inherits the allocation and monitoring from the user space
+ * task. On x86 this means that kernel work shares the same CLOSID and
+ * RMID as the user space task. This matches today's resctrl behavior.
+ *
+ * @GLOBAL_ASSIGN_CTRL_INHERIT_MON_PER_CPU:
+ * Kernel work uses a globally assigned allocation while monitoring is
+ * inherited from the user space task. On x86 this means a CLOSID is
+ * assigned for kernel work and the RMID is inherited from the user space
+ * task. Default scope is all online CPUs; a subset may be selected via
+ * the resctrl group interface. A CTRL_MON group is bound to this mode.
+ *
+ * @GLOBAL_ASSIGN_CTRL_ASSIGN_MON_PER_CPU:
+ * Kernel work uses globally assigned allocation and monitoring. On x86
+ * this means both CLOSID and RMID are assigned for kernel work. Default
+ * scope is all online CPUs; a subset may be selected via the resctrl
+ * group interface. A CTRL_MON or MON group is bound to this mode.
+ */
+enum resctrl_kernel_mode {
+ INHERIT_CTRL_AND_MON,
+ GLOBAL_ASSIGN_CTRL_INHERIT_MON_PER_CPU,
+ GLOBAL_ASSIGN_CTRL_ASSIGN_MON_PER_CPU,
+ RESCTRL_KMODE_LAST = GLOBAL_ASSIGN_CTRL_ASSIGN_MON_PER_CPU,
+};
+
+#define RESCTRL_NUM_KERNEL_MODES (RESCTRL_KMODE_LAST + 1)
+
extern unsigned int resctrl_rmid_realloc_threshold;
extern unsigned int resctrl_rmid_realloc_limit;
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v4 05/15] x86,fs/resctrl: Introduce architecture hooks to program kernel-mode
2026-07-07 21:16 [PATCH v4 00/15] x86/resctrl: Add kernel-mode (e.g., PLZA) support to the resctrl subsystem Babu Moger
` (3 preceding siblings ...)
2026-07-07 21:16 ` [PATCH v4 04/15] fs/resctrl: Introduce kernel mode (kmode) data structures Babu Moger
@ 2026-07-07 21:16 ` Babu Moger
2026-07-07 21:16 ` [PATCH v4 06/15] fs/resctrl: Introduce resctrl_set_kmode_support() to initialize supported modes Babu Moger
5 siblings, 0 replies; 7+ messages in thread
From: Babu Moger @ 2026-07-07 21:16 UTC (permalink / raw)
To: corbet, tony.luck, reinette.chatre, Dave.Martin, james.morse,
tglx, bp, ben.horgan, fenghuay
Cc: skhan, x86, babu.moger, mingo, dave.hansen, hpa, akpm, rdunlap,
peterz, feng.tang, dapeng1.mi, elver, enelsonmoore, kuba,
ebiggers, lirongqing, seanjc, nikunj, xin, pawan.kumar.gupta,
tiala, chang.seok.bae, kprateek.nayak, prathyushi.nangia,
kim.phillips, naveen, darwi, elena.reshetova, linux-doc,
linux-kernel, thomas.lendacky, eranian, peternewman, qinyuntan
Kernel-mode policies defined by enum resctrl_kernel_mode must be applied to
each affected CPU whenever a policy is selected or its scope changes.
Generic resctrl therefore requires an architecture-specific interface to
program allocation and monitoring associations in hardware across a given
CPU mask.
Introduce a helper, resctrl_arch_configure_kmode(), to handle kernel-mode
programming. On x86/AMD systems, this helper programs the
MSR_IA32_PQR_PLZA_ASSOC register on all online CPUs in the specified mask
via on_each_cpu_mask(). Also provide a no-op stub for MPAM systems.
Generic resctrl does not invoke this hook yet; it will be used when user
space selects a kernel-mode policy or updates the associated CPU set.
Signed-off-by: Babu Moger <babu.moger@amd.com>
---
v4: Added assign_mon parameter in resctrl_arch_configure_kmode() to program the RMID
as discussed in below.
https://lore.kernel.org/lkml/20260605100642.1103628-1-qinyuntan@linux.alibaba.com/
Changed cpumask type to "const struct cpumask *cpu_mask".
Added MPAM stub to avoid any linking issues when resctrl_arch_configure_kmode()
is called from FS layer. Thanks to Qinyun.
Re-wrote the changelog to be generic.
Updated code comments.
v3: Removed task based PLZA implementation so related changes are removed.
Removed handling of rmid_en as it is not required. The group type assigned
will be different so the monitoring part is already taken care.
Updated the change log with details.
Removed resctrl_arch_set_kmode() as arch only provides the modes supported.
It is FS which decided which mode to apply.
v2: Updated the commit message to include the sequence of steps to enable PLZA.
Added mode code comments for clarity.
Added kmode to functin names to be generic.
---
arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 36 +++++++++++++++++++++++
drivers/resctrl/mpam_resctrl.c | 5 ++++
include/linux/resctrl.h | 15 ++++++++++
3 files changed, 56 insertions(+)
diff --git a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
index b20e705606b8..025f139434f2 100644
--- a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
+++ b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
@@ -131,3 +131,39 @@ int resctrl_arch_io_alloc_enable(struct rdt_resource *r, bool enable)
return 0;
}
+
+static void resctrl_kmode_set_one_amd(void *arg)
+{
+ union msr_pqr_plza_assoc *plza = arg;
+
+ wrmsrq(MSR_IA32_PQR_PLZA_ASSOC, plza->full);
+}
+
+/*
+ * Program Privilege Level Zero Association (PLZA) on @cpu_mask.
+ *
+ * When @enable is true, CPL 0 allocation traffic on the targeted CPUs uses
+ * @closid from MSR_IA32_PQR_PLZA_ASSOC instead of the CLOSID from
+ * MSR_IA32_PQR_ASSOC. Monitoring is redirected to @rmid only when
+ * @assign_mon is true; otherwise kernel-mode monitoring continues to use the
+ * RMID associated with the current task.
+ *
+ * @cpu_mask: CPUs whose PLZA MSR should be updated.
+ * @closid: CLOSID to use for kernel-mode allocation when PLZA is enabled.
+ * @rmid: RMID to use for kernel-mode monitoring when @assign_mon is true.
+ * @assign_mon: Whether PLZA should provide the kernel-mode RMID.
+ * @enable: Whether PLZA should provide the kernel-mode association.
+ */
+void resctrl_arch_configure_kmode(const struct cpumask *cpu_mask, u32 closid, u32 rmid,
+ bool assign_mon, bool enable)
+{
+ union msr_pqr_plza_assoc plza = { 0 };
+
+ plza.split.rmid = rmid;
+ plza.split.rmid_en = assign_mon;
+ plza.split.closid = closid;
+ plza.split.closid_en = 1;
+ plza.split.plza_en = enable;
+
+ on_each_cpu_mask(cpu_mask, resctrl_kmode_set_one_amd, &plza, 1);
+}
diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
index 226ff6f532fa..630b6cfc0269 100644
--- a/drivers/resctrl/mpam_resctrl.c
+++ b/drivers/resctrl/mpam_resctrl.c
@@ -158,6 +158,11 @@ bool resctrl_arch_get_io_alloc_enabled(struct rdt_resource *r)
return false;
}
+void resctrl_arch_configure_kmode(const struct cpumask *cpu_mask, u32 closid,
+ u32 rmid, bool assign_mon, bool enable)
+{
+}
+
void resctrl_arch_pre_mount(void)
{
}
diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h
index c7abed51cd5f..47db34dd167e 100644
--- a/include/linux/resctrl.h
+++ b/include/linux/resctrl.h
@@ -734,6 +734,21 @@ enum resctrl_kernel_mode {
#define RESCTRL_NUM_KERNEL_MODES (RESCTRL_KMODE_LAST + 1)
+/**
+ * resctrl_arch_configure_kmode() - Program kernel-mode association on CPUs
+ * @cpu_mask: CPUs to update; the architecture applies the change on the
+ * online subset of this mask.
+ * @closid: Allocation class for kernel-mode traffic. On x86 this is the
+ * CLOSID programmed when allocation is assigned for kernel work.
+ * @rmid: Monitoring context for kernel-mode traffic. On x86 this is the
+ * RMID programmed when monitoring is assigned for kernel work.
+ * @assign_mon: true to assign @rmid for kernel work; false to inherit
+ * monitoring from the user task.
+ * @enable: true to enable kernel-mode association on the targeted CPUs.
+ */
+void resctrl_arch_configure_kmode(const struct cpumask *cpu_mask, u32 closid, u32 rmid,
+ bool assign_mon, bool enable);
+
extern unsigned int resctrl_rmid_realloc_threshold;
extern unsigned int resctrl_rmid_realloc_limit;
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v4 06/15] fs/resctrl: Introduce resctrl_set_kmode_support() to initialize supported modes
2026-07-07 21:16 [PATCH v4 00/15] x86/resctrl: Add kernel-mode (e.g., PLZA) support to the resctrl subsystem Babu Moger
` (4 preceding siblings ...)
2026-07-07 21:16 ` [PATCH v4 05/15] x86,fs/resctrl: Introduce architecture hooks to program kernel-mode Babu Moger
@ 2026-07-07 21:16 ` Babu Moger
5 siblings, 0 replies; 7+ messages in thread
From: Babu Moger @ 2026-07-07 21:16 UTC (permalink / raw)
To: corbet, tony.luck, reinette.chatre, Dave.Martin, james.morse,
tglx, bp, ben.horgan, fenghuay
Cc: skhan, x86, babu.moger, mingo, dave.hansen, hpa, akpm, rdunlap,
peterz, feng.tang, dapeng1.mi, elver, enelsonmoore, kuba,
ebiggers, lirongqing, seanjc, nikunj, xin, pawan.kumar.gupta,
tiala, chang.seok.bae, kprateek.nayak, prathyushi.nangia,
kim.phillips, naveen, darwi, elena.reshetova, linux-doc,
linux-kernel, thomas.lendacky, eranian, peternewman, qinyuntan
Architectures need a way to advertise which kernel-mode resctrl policies
they support before generic resctrl exposes those policies through the
filesystem.
Add the `struct resctrl_kmode_cfg` to define the default mode statically,
and introduce `resctrl_set_kmode_support()` so architecture code can
register supported kernel-mode policies during resctrl initialization. The
`INHERIT_CTRL_AND_MON` policy is supported by default, so architectures
only need to register any additional modes.
Signed-off-by: Babu Moger <babu.moger@amd.com>
---
v4: New patch to initialize supported kernel-mode's.
https://lore.kernel.org/lkml/737a4228-52fb-4583-ac64-8efe79c107e6@intel.com/
Changed the kmode_cur to enum resctrl_kernel_mode in resctrl_kmode_cfg.
Moved the resctrl_kmode_cfg to filesystem code.
---
fs/resctrl/internal.h | 12 ++++++++++++
fs/resctrl/rdtgroup.c | 23 +++++++++++++++++++++++
include/linux/resctrl.h | 10 ++++++++++
3 files changed, 45 insertions(+)
diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h
index 48af75b9dc85..178126bb2da5 100644
--- a/fs/resctrl/internal.h
+++ b/fs/resctrl/internal.h
@@ -314,6 +314,18 @@ struct mbm_state {
u32 prev_bw;
};
+/**
+ * struct resctrl_kmode_cfg - Kernel-mode policy snapshot from architecture
+ * @kmode: Bitmap of supported &enum resctrl_kernel_mode values. Each
+ * supported mode is represented by BIT(mode).
+ * @kmode_cur: Currently selected kernel-mode policy.
+ * @k_rdtgrp: Resource group backing global-assign modes when applicable;
+ */
+struct resctrl_kmode_cfg {
+ unsigned long kmode;
+ enum resctrl_kernel_mode kmode_cur;
+ struct rdtgroup *k_rdtgrp;
+};
extern struct mutex rdtgroup_mutex;
static inline const char *rdt_kn_name(const struct kernfs_node *kn)
diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
index cc9966ff6cdf..0ee0dfaf9065 100644
--- a/fs/resctrl/rdtgroup.c
+++ b/fs/resctrl/rdtgroup.c
@@ -78,6 +78,16 @@ static void mon_put_kn_priv(void);
struct dentry *debugfs_resctrl;
+/*
+ * Global kernel-mode resctrl policy. Architectures add supported modes before
+ * resctrl is mounted; @kmode_cur tracks the active policy after user selection.
+ */
+static struct resctrl_kmode_cfg resctrl_kcfg = {
+ .kmode = BIT(INHERIT_CTRL_AND_MON),
+ .kmode_cur = INHERIT_CTRL_AND_MON,
+ .k_rdtgrp = NULL
+};
+
/*
* Memory bandwidth monitoring event to use for the default CTRL_MON group
* and each new CTRL_MON group created by the user. Only relevant when
@@ -888,6 +898,19 @@ static int rdtgroup_rmid_show(struct kernfs_open_file *of,
return ret;
}
+/**
+ * resctrl_set_kmode_support() - Advertise support for a kernel-mode policy
+ * @kmode: Kernel-mode policy supported by the architecture.
+ *
+ * Architectures call this during resctrl initialization to make @kmode visible
+ * to the resctrl filesystem. INHERIT_CTRL_AND_MON is always supported.
+ */
+void resctrl_set_kmode_support(enum resctrl_kernel_mode kmode)
+{
+ if (kmode <= RESCTRL_KMODE_LAST)
+ __set_bit(kmode, &resctrl_kcfg.kmode);
+}
+
#ifdef CONFIG_PROC_CPU_RESCTRL
/*
* A task can only be part of one resctrl control group and of one monitor
diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h
index 47db34dd167e..8dd02579f354 100644
--- a/include/linux/resctrl.h
+++ b/include/linux/resctrl.h
@@ -734,6 +734,16 @@ enum resctrl_kernel_mode {
#define RESCTRL_NUM_KERNEL_MODES (RESCTRL_KMODE_LAST + 1)
+/**
+ * resctrl_set_kmode_support() - Advertise a supported kernel-mode policy
+ * @kmode: Kernel-mode policy supported by the architecture.
+ *
+ * Architectures use this during resctrl initialization to make additional
+ * kernel-mode policies available to the filesystem. INHERIT_CTRL_AND_MON is
+ * supported by default and does not need to be registered.
+ */
+void resctrl_set_kmode_support(enum resctrl_kernel_mode kmode);
+
/**
* resctrl_arch_configure_kmode() - Program kernel-mode association on CPUs
* @cpu_mask: CPUs to update; the architecture applies the change on the
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-07-07 21:18 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-07 21:16 [PATCH v4 00/15] x86/resctrl: Add kernel-mode (e.g., PLZA) support to the resctrl subsystem Babu Moger
2026-07-07 21:16 ` [PATCH v4 01/15] x86/resctrl: Support Privilege Level Zero Association (PLZA) Babu Moger
2026-07-07 21:16 ` [PATCH v4 02/15] x86/resctrl: Add PLZA support to command-line options Babu Moger
2026-07-07 21:16 ` [PATCH v4 03/15] x86/resctrl: Add data structures and definitions for PLZA configuration Babu Moger
2026-07-07 21:16 ` [PATCH v4 04/15] fs/resctrl: Introduce kernel mode (kmode) data structures Babu Moger
2026-07-07 21:16 ` [PATCH v4 05/15] x86,fs/resctrl: Introduce architecture hooks to program kernel-mode Babu Moger
2026-07-07 21:16 ` [PATCH v4 06/15] fs/resctrl: Introduce resctrl_set_kmode_support() to initialize supported modes Babu Moger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox