The resctrl subsystem uses static keys to efficiently toggle allocation and monitoring features at runtime (e.g., rdt_alloc_enable_key, rdt_mon_enable_key). Privilege-Level Zero Association (PLZA) is a new, optional capability that should only impact fast paths when enabled. Introduce a new static key, rdt_plza_enable_key, and wire it up with arch helpers that mirror the existing alloc/mon pattern. This provides a lightweight, unified mechanism to guard PLZA-specific paths and to keep the global resctrl usage count accurate. Signed-off-by: Babu Moger --- arch/x86/include/asm/resctrl.h | 13 +++++++++++++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 2 ++ fs/resctrl/rdtgroup.c | 4 ++++ 3 files changed, 19 insertions(+) diff --git a/arch/x86/include/asm/resctrl.h b/arch/x86/include/asm/resctrl.h index 575f8408a9e7..fc0a7f64649e 100644 --- a/arch/x86/include/asm/resctrl.h +++ b/arch/x86/include/asm/resctrl.h @@ -48,6 +48,7 @@ extern bool rdt_mon_capable; DECLARE_STATIC_KEY_FALSE(rdt_enable_key); DECLARE_STATIC_KEY_FALSE(rdt_alloc_enable_key); DECLARE_STATIC_KEY_FALSE(rdt_mon_enable_key); +DECLARE_STATIC_KEY_FALSE(rdt_plza_enable_key); static inline bool resctrl_arch_alloc_capable(void) { @@ -83,6 +84,18 @@ static inline void resctrl_arch_disable_mon(void) static_branch_dec_cpuslocked(&rdt_enable_key); } +static inline void resctrl_arch_enable_plza(void) +{ + static_branch_enable_cpuslocked(&rdt_plza_enable_key); + static_branch_inc_cpuslocked(&rdt_enable_key); +} + +static inline void resctrl_arch_disable_plza(void) +{ + static_branch_disable_cpuslocked(&rdt_plza_enable_key); + static_branch_dec_cpuslocked(&rdt_enable_key); +} + /* * __resctrl_sched_in() - Writes the task's CLOSid/RMID to IA32_PQR_MSR * diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c index 540e1e719d7f..fe530216a6cc 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -38,6 +38,8 @@ DEFINE_STATIC_KEY_FALSE(rdt_mon_enable_key); DEFINE_STATIC_KEY_FALSE(rdt_alloc_enable_key); +DEFINE_STATIC_KEY_FALSE(rdt_plza_enable_key); + /* * This is safe against resctrl_arch_sched_in() called from __switch_to() * because __switch_to() is executed with interrupts disabled. A local call diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index d773bf77bcc6..616be6633a6d 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -2910,6 +2910,8 @@ static int rdt_get_tree(struct fs_context *fc) resctrl_arch_enable_alloc(); if (resctrl_arch_mon_capable()) resctrl_arch_enable_mon(); + if (resctrl_arch_get_plza_capable(RDT_RESOURCE_L3)) + resctrl_arch_enable_plza(); if (resctrl_arch_alloc_capable() || resctrl_arch_mon_capable()) resctrl_mounted = true; @@ -3232,6 +3234,8 @@ static void rdt_kill_sb(struct super_block *sb) resctrl_arch_disable_alloc(); if (resctrl_arch_mon_capable()) resctrl_arch_disable_mon(); + if (resctrl_arch_get_plza_capable(RDT_RESOURCE_L3)) + resctrl_arch_disable_plza(); resctrl_mounted = false; kernfs_kill_sb(sb); mutex_unlock(&rdtgroup_mutex); -- 2.34.1