Skip to content

Commit 0a2f4d9

Browse files
James Morsebp3tk0v
authored andcommitted
x86/resctrl: Make rdt_enable_key the arch's decision to switch
rdt_enable_key is switched when resctrl is mounted. It was also previously used to prevent a second mount of the filesystem. Any other architecture that wants to support resctrl has to provide identical static keys. Now that there are helpers for enabling and disabling the alloc/mon keys, resctrl doesn't need to switch this extra key, it can be done by the arch code. Use the static-key increment and decrement helpers, and change resctrl to ensure the calls are balanced. Signed-off-by: James Morse <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Reviewed-by: Shaopeng Tan <[email protected]> Reviewed-by: Reinette Chatre <[email protected]> Reviewed-by: Babu Moger <[email protected]> Tested-by: Shaopeng Tan <[email protected]> Tested-by: Peter Newman <[email protected]> Tested-by: Babu Moger <[email protected]> Tested-by: Carl Worth <[email protected]> # arm64 Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Borislav Petkov (AMD) <[email protected]>
1 parent 5db6a4a commit 0a2f4d9

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

arch/x86/include/asm/resctrl.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,21 +45,25 @@ DECLARE_STATIC_KEY_FALSE(rdt_mon_enable_key);
4545
static inline void resctrl_arch_enable_alloc(void)
4646
{
4747
static_branch_enable_cpuslocked(&rdt_alloc_enable_key);
48+
static_branch_inc_cpuslocked(&rdt_enable_key);
4849
}
4950

5051
static inline void resctrl_arch_disable_alloc(void)
5152
{
5253
static_branch_disable_cpuslocked(&rdt_alloc_enable_key);
54+
static_branch_dec_cpuslocked(&rdt_enable_key);
5355
}
5456

5557
static inline void resctrl_arch_enable_mon(void)
5658
{
5759
static_branch_enable_cpuslocked(&rdt_mon_enable_key);
60+
static_branch_inc_cpuslocked(&rdt_enable_key);
5861
}
5962

6063
static inline void resctrl_arch_disable_mon(void)
6164
{
6265
static_branch_disable_cpuslocked(&rdt_mon_enable_key);
66+
static_branch_dec_cpuslocked(&rdt_enable_key);
6367
}
6468

6569
/*

arch/x86/kernel/cpu/resctrl/rdtgroup.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2672,10 +2672,8 @@ static int rdt_get_tree(struct fs_context *fc)
26722672
if (rdt_mon_capable)
26732673
resctrl_arch_enable_mon();
26742674

2675-
if (rdt_alloc_capable || rdt_mon_capable) {
2676-
static_branch_enable_cpuslocked(&rdt_enable_key);
2675+
if (rdt_alloc_capable || rdt_mon_capable)
26772676
resctrl_mounted = true;
2678-
}
26792677

26802678
if (is_mbm_enabled()) {
26812679
r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl;
@@ -2946,9 +2944,10 @@ static void rdt_kill_sb(struct super_block *sb)
29462944
rdtgroup_default.mode = RDT_MODE_SHAREABLE;
29472945
schemata_list_destroy();
29482946
rdtgroup_destroy_root();
2949-
resctrl_arch_disable_alloc();
2950-
resctrl_arch_disable_mon();
2951-
static_branch_disable_cpuslocked(&rdt_enable_key);
2947+
if (rdt_alloc_capable)
2948+
resctrl_arch_disable_alloc();
2949+
if (rdt_mon_capable)
2950+
resctrl_arch_disable_mon();
29522951
resctrl_mounted = false;
29532952
kernfs_kill_sb(sb);
29542953
mutex_unlock(&rdtgroup_mutex);

0 commit comments

Comments
 (0)