Skip to content

Commit 5db6a4a

Browse files
James Morsebp3tk0v
authored andcommitted
x86/resctrl: Move alloc/mon static keys into helpers
resctrl enables three static keys depending on the features it has enabled. Another architecture's context switch code may look different, any static keys that control it should be buried behind helpers. Move the alloc/mon logic into arch-specific helpers as a preparatory step for making the rdt_enable_key's status something the arch code decides. This means other architectures don't have to mirror the static keys. 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 13e5769 commit 5db6a4a

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed

arch/x86/include/asm/resctrl.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,26 @@ DECLARE_STATIC_KEY_FALSE(rdt_enable_key);
4242
DECLARE_STATIC_KEY_FALSE(rdt_alloc_enable_key);
4343
DECLARE_STATIC_KEY_FALSE(rdt_mon_enable_key);
4444

45+
static inline void resctrl_arch_enable_alloc(void)
46+
{
47+
static_branch_enable_cpuslocked(&rdt_alloc_enable_key);
48+
}
49+
50+
static inline void resctrl_arch_disable_alloc(void)
51+
{
52+
static_branch_disable_cpuslocked(&rdt_alloc_enable_key);
53+
}
54+
55+
static inline void resctrl_arch_enable_mon(void)
56+
{
57+
static_branch_enable_cpuslocked(&rdt_mon_enable_key);
58+
}
59+
60+
static inline void resctrl_arch_disable_mon(void)
61+
{
62+
static_branch_disable_cpuslocked(&rdt_mon_enable_key);
63+
}
64+
4565
/*
4666
* __resctrl_sched_in() - Writes the task's CLOSid/RMID to IA32_PQR_MSR
4767
*

arch/x86/kernel/cpu/resctrl/internal.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,6 @@ static inline struct rdt_fs_context *rdt_fc2context(struct fs_context *fc)
9494
return container_of(kfc, struct rdt_fs_context, kfc);
9595
}
9696

97-
DECLARE_STATIC_KEY_FALSE(rdt_enable_key);
98-
DECLARE_STATIC_KEY_FALSE(rdt_mon_enable_key);
99-
10097
/**
10198
* struct mon_evt - Entry in the event list of a resource
10299
* @evtid: event id
@@ -452,8 +449,6 @@ extern struct mutex rdtgroup_mutex;
452449

453450
extern struct rdt_hw_resource rdt_resources_all[];
454451
extern struct rdtgroup rdtgroup_default;
455-
DECLARE_STATIC_KEY_FALSE(rdt_alloc_enable_key);
456-
457452
extern struct dentry *debugfs_resctrl;
458453

459454
enum resctrl_res_level {

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2668,9 +2668,9 @@ static int rdt_get_tree(struct fs_context *fc)
26682668
goto out_psl;
26692669

26702670
if (rdt_alloc_capable)
2671-
static_branch_enable_cpuslocked(&rdt_alloc_enable_key);
2671+
resctrl_arch_enable_alloc();
26722672
if (rdt_mon_capable)
2673-
static_branch_enable_cpuslocked(&rdt_mon_enable_key);
2673+
resctrl_arch_enable_mon();
26742674

26752675
if (rdt_alloc_capable || rdt_mon_capable) {
26762676
static_branch_enable_cpuslocked(&rdt_enable_key);
@@ -2946,8 +2946,8 @@ static void rdt_kill_sb(struct super_block *sb)
29462946
rdtgroup_default.mode = RDT_MODE_SHAREABLE;
29472947
schemata_list_destroy();
29482948
rdtgroup_destroy_root();
2949-
static_branch_disable_cpuslocked(&rdt_alloc_enable_key);
2950-
static_branch_disable_cpuslocked(&rdt_mon_enable_key);
2949+
resctrl_arch_disable_alloc();
2950+
resctrl_arch_disable_mon();
29512951
static_branch_disable_cpuslocked(&rdt_enable_key);
29522952
resctrl_mounted = false;
29532953
kernfs_kill_sb(sb);

0 commit comments

Comments
 (0)