[PATCH v2 00/16] fs,x86/resctrl: Add kernel-mode (e.g., PLZA) support to the resctrl subsystem

Babu Moger
2026-03-12T20:37:20Z

This series adds support for Privilege-Level Zero Association (PLZA) to the
resctrl subsystem. PLZA is an AMD feature that allows specifying a CLOSID
and/or RMID for execution in kernel mode (privilege level zero), so that
kernel work is not subject to the same resource constrains as the current
user-space task. This avoids kernel operations being aggressively throttled
when a task's memory bandwidth is heavily limited.

The feature documentation is not yet publicly available, but it is expected
to be released in the next few weeks. In the meantime, a brief description
of the features is provided below.

Privilege Level Zero Association (PLZA)

Privilege Level Zero Association (PLZA) allows the hardware to
automatically associate execution in Privilege Level Zero (CPL=0) with a
specific COS (Class of Service) and/or RMID (Resource Monitoring
Identifier). The QoS feature set already has a mechanism to associate
execution on each logical processor with an RMID or COS. PLZA allows the
system to override this per-thread association for a thread that is
executing with CPL=0.
------------------------------------------------------------------------

The series introduces the feature in a way that supports the interface in
a generic manner to accomodate MPAM or other vendor specific implimentation.

Below is the detailed requirements provided by Reinette:
https://lore.kernel.org/lkml/2ab556af-095b-422b-9396-f845c6fd0342@intel.com/

Summary:
1. Kernel-mode/PLZA controls and status should be exposed under the resctrl
info directory:/sys/fs/resctrl/info/, not as a separate or arch-specific path.

2. Add two info files

a. kernel_mode
Purpose: Control how resource allocation and monitoring apply in kernel mode
(e.g. inherit from task vs global assign).

Read: List supported modes and show current one (e.g. with [brackets]).
Write: Set current mode by name (e.g. inherit_ctrl_and_mon, global_assign_ctrl_assign_mon).

b. kernel_mode_assignment

Purpose: When a “global assign” kernel mode is active, specify which resctrl group
(CLOSID/RMID) is used for kernel work.

Read: Show the assigned group in a path-like form (e.g. //, ctrl1//, ctrl1/mon1/).
Write: Assign or clear the group used for kernel mode (and optionally clear with an empty write).

The patches are based on top of commit (v7.0.0-rc3)
839e91ce3f41b (tip/master) Merge branch into tip/master: 'x86/tdx'
------------------------------------------------------------------------

Examples: kernel_mode and kernel_mode_assignment

All paths below are under /sys/fs/resctrl/ (e.g. info/kernel_mode means
/sys/fs/resctrl/info/kernel_mode). Resctrl must be mounted and the platform
must support the relevant modes (e.g. AMD with PLZA).

1) kernel_mode — show and set the current kernel mode

Read supported modes and which one is active (current in brackets):

$ cat info/kernel_mode
[inherit_ctrl_and_mon]
global_assign_ctrl_inherit_mon
global_assign_ctrl_assign_mon

Set the active mode (e.g. use one CLOSID+RMID for all kernel work):

$ echo "global_assign_ctrl_assign_mon" > info/kernel_mode
$ cat info/kernel_mode
inherit_ctrl_and_mon
global_assign_ctrl_inherit_mon
[global_assign_ctrl_assign_mon]

Mode meanings:
- inherit_ctrl_and_mon: kernel uses same CLOSID/RMID as the current task (default).
- global_assign_ctrl_inherit_mon: one CLOSID for all kernel work; RMID inherited from user.
- global_assign_ctrl_assign_mon: one resource group (CLOSID+RMID) for all kernel work.

2) kernel_mode_assignment — show and set which group is used for kernel work

Only relevant when kernel_mode is not "inherit_ctrl_and_mon". Read the
currently assigned group (path format is "CTRL_MON/MON/"):

$ cat info/kernel_mode_assignment
//

"//" means the default CTRL_MON group is assigned. Assign a specific
group instead (e.g. a CTRL_MON group "ctrl1", or a MON group "mon1" under it):

$ echo "ctrl1//" > info/kernel_mode_assignment
$ cat info/kernel_mode_assignment
ctrl1//

$ echo "ctrl1/mon1/" > info/kernel_mode_assignment
$ cat info/kernel_mode_assignment
ctrl1/mon1/

Clear the assignment (no dedicated group for kernel work):

$ echo >> info/kernel_mode_assignment
$ cat info/kernel_mode_assignment
Kmode is not configured

Errors (e.g. invalid group name or unsupported mode) are reported in
info/last_cmd_status.

---

v2:
This is similar to RFC with new proposal. Names of the some interfaces
are not final. Lets fix that later as we move forward.

Separated the two features: Global Bandwidth Enforcement (GLBE) and
Privilege Level Zero Association (PLZA).

This series only adds support for PLZA.

Used the name of the feature as kmode instead of PLZA. That can be changed as well.

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. So, dropped the idea.
https://lore.kernel.org/lkml/aXuxVSbk1GR2ttzF@agluck-desk3/
Let me know if there are other ways to optimize this.

Patch 1: Data structures and arch hook: Add resctrl_kmode,
resctrl_kmode_cfg, kernel-mode bits, and resctrl_arch_get_kmode_cfg()
for generic resctrl kernel mode (e.g. PLZA).

Patch 2: Implement resctrl_arch_get_kmode_cfg() on x86, add global resctrl_kcfg
and resctrl_kmode_init() to set default kmode.

Patch 3: Add info/kernel_mode and resctrl_kernel_mode_show() to list supported
kernel modes and show the current one in brackets.

Patch 4: Add x86 PLZA support and boot option rdt=plza.

Patch 5: Add supported modes from CPUID.

Patch 6: Add rdt_kmode_enable_key and arch enable/disable helpers so PLZA only
touches fast paths when enabled.

Patch 7: Add MSR_IA32_PQR_PLZA_ASSOC, bit defines, and union qos_pqr_plza_assoc
for programming PLZA.

Patch 8: Add Per-CPU and per-task state.

Patch 9: Add resctrl_arch_configure_kmode() and resctrl_arch_set_kmode()
to program PLZA per domain and set/clear it on a CPU.

Patch 10: In the sched-in path, program MSR_IA32_PQR_PLZA_ASSOC from task or
per-CPU kmode; only write when kmode changes; guard with rdt_kmode_enable_key.

Patch 11: Add write handler so the current kernel mode can be set by name.

Patch 12: Add info/kernel_mode_assignment and show which rdtgroup is assigned
for kernel mode in CTRL_MON/MON/ form.

Patch 13: Add write handler to assign/clear the group used for kernel mode;
enforce single assignment and clear on rmdir.

Patch 14: Update per-CPU PLZA state when its cpu_mask changes (add/remove CPUs)
via cpus_write_kmode() and helpers.

Patch 15: Refactor so task list respects t->kmode when the group has kmode (PLZA),
so tasks are shown correctly.

Patch 16: Add arch helper to set task kmode.
--------------------------------------------------------------------------------

v1 : https://lore.kernel.org/lkml/cover.1769029977.git.babu.moger@amd.com/

Babu Moger (16):
fs/resctrl: Add kernel mode (kmode) data structures and arch hook
fs, x86/resctrl: Add architecture routines for kernel mode
initialization
fs/resctrl: Add info/kernel_mode file to show kernel mode options
x86/resctrl: Support Privilege-Level Zero Association (PLZA)
x86/resctrl: Initialize supported kernel modes when CPUID reports PLZA
resctrl: Introduce kmode static key enable/disable helpers
x86/resctrl: Add data structures and definitions for PLZA
configuration
x86/resctrl: Add per-CPU and per-task kernel mode state
x86,fs/resctrl: Add the functionality to configure PLZA
x86/resctrl: Add PLZA state tracking and context switch handling
fs/resctrl: Add write handler for info/kernel_mode
fs/resctrl: Add info/kernel_mode_assignment to show kernel-mode
rdtgroup
fs/resctrl: Add write interface for kernel_mode_assignment
fs/resctrl: Update kmode configuration when cpu_mask changes
x86/resctrl: Refactor show_rdt_tasks() to support PLZA tasks
fs/resctrl: Add per-task kmode enable support via rdtgroup

.../admin-guide/kernel-parameters.txt | 2 +-
Documentation/filesystems/resctrl.rst | 69 ++
arch/x86/include/asm/cpufeatures.h | 1 +
arch/x86/include/asm/msr-index.h | 7 +
arch/x86/include/asm/resctrl.h | 92 ++-
arch/x86/kernel/cpu/resctrl/core.c | 12 +
arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 77 +++
arch/x86/kernel/cpu/resctrl/internal.h | 26 +
arch/x86/kernel/cpu/resctrl/rdtgroup.c | 2 +
arch/x86/kernel/cpu/scattered.c | 1 +
fs/resctrl/internal.h | 2 +
fs/resctrl/rdtgroup.c | 635 +++++++++++++++++-
include/linux/resctrl.h | 40 ++
include/linux/resctrl_types.h | 30 +
include/linux/sched.h | 2 +
15 files changed, 989 insertions(+), 9 deletions(-)

--
2.43.0