Skip to content

Commit 2899aa3

Browse files
committed
Merge tag 'x86_cache_for_v6.15' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 resource control updates from Borislav Petkov: - First part of the MPAM work: split the architectural part of resctrl from the filesystem part so that ARM's MPAM varian of resource control can be added later while sharing the user interface with x86 (James Morse) * tag 'x86_cache_for_v6.15' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (30 commits) x86/resctrl: Move get_{mon,ctrl}_domain_from_cpu() to live with their callers x86/resctrl: Move get_config_index() to a header x86/resctrl: Handle throttle_mode for SMBA resources x86/resctrl: Move RFTYPE flags to be managed by resctrl x86/resctrl: Make resctrl_arch_pseudo_lock_fn() take a plr x86/resctrl: Make prefetch_disable_bits belong to the arch code x86/resctrl: Allow an architecture to disable pseudo lock x86/resctrl: Add resctrl_arch_ prefix to pseudo lock functions x86/resctrl: Move mbm_cfg_mask to struct rdt_resource x86/resctrl: Move mba_mbps_default_event init to filesystem code x86/resctrl: Change mon_event_config_{read,write}() to be arch helpers x86/resctrl: Add resctrl_arch_is_evt_configurable() to abstract BMEC x86/resctrl: Move the is_mbm_*_enabled() helpers to asm/resctrl.h x86/resctrl: Rewrite and move the for_each_*_rdt_resource() walkers x86/resctrl: Move monitor init work to a resctrl init call x86/resctrl: Move monitor exit work to a resctrl exit call x86/resctrl: Add an arch helper to reset one resource x86/resctrl: Move resctrl types to a separate header x86/resctrl: Move rdt_find_domain() to be visible to arch and fs code x86/resctrl: Expose resctrl fs's init function to the rest of the kernel ...
2 parents 9061747 + 823beb3 commit 2899aa3

File tree

12 files changed

+769
-479
lines changed

12 files changed

+769
-479
lines changed

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19934,6 +19934,7 @@ S: Supported
1993419934
F: Documentation/arch/x86/resctrl*
1993519935
F: arch/x86/include/asm/resctrl.h
1993619936
F: arch/x86/kernel/cpu/resctrl/
19937+
F: include/linux/resctrl*.h
1993719938
F: tools/testing/selftests/resctrl/
1993819939

1993919940
READ-COPY UPDATE (RCU)

arch/x86/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,7 @@ config X86_CPU_RESCTRL
498498
depends on X86 && (CPU_SUP_INTEL || CPU_SUP_AMD)
499499
select KERNFS
500500
select PROC_CPU_RESCTRL if PROC_FS
501+
select RESCTRL_FS_PSEUDO_LOCK
501502
help
502503
Enable x86 CPU resource control support.
503504

@@ -514,6 +515,12 @@ config X86_CPU_RESCTRL
514515

515516
Say N if unsure.
516517

518+
config RESCTRL_FS_PSEUDO_LOCK
519+
bool
520+
help
521+
Software mechanism to pin data in a cache portion using
522+
micro-architecture specific knowledge.
523+
517524
config X86_FRED
518525
bool "Flexible Return and Event Delivery"
519526
depends on X86_64

arch/x86/include/asm/resctrl.h

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44

55
#ifdef CONFIG_X86_CPU_RESCTRL
66

7-
#include <linux/sched.h>
87
#include <linux/jump_label.h>
8+
#include <linux/percpu.h>
9+
#include <linux/resctrl_types.h>
10+
#include <linux/sched.h>
911

1012
/*
1113
* This value can never be a valid CLOSID, and is used when mapping a
@@ -40,6 +42,7 @@ DECLARE_PER_CPU(struct resctrl_pqr_state, pqr_state);
4042

4143
extern bool rdt_alloc_capable;
4244
extern bool rdt_mon_capable;
45+
extern unsigned int rdt_mon_features;
4346

4447
DECLARE_STATIC_KEY_FALSE(rdt_enable_key);
4548
DECLARE_STATIC_KEY_FALSE(rdt_alloc_enable_key);
@@ -79,6 +82,21 @@ static inline void resctrl_arch_disable_mon(void)
7982
static_branch_dec_cpuslocked(&rdt_enable_key);
8083
}
8184

85+
static inline bool resctrl_arch_is_llc_occupancy_enabled(void)
86+
{
87+
return (rdt_mon_features & (1 << QOS_L3_OCCUP_EVENT_ID));
88+
}
89+
90+
static inline bool resctrl_arch_is_mbm_total_enabled(void)
91+
{
92+
return (rdt_mon_features & (1 << QOS_L3_MBM_TOTAL_EVENT_ID));
93+
}
94+
95+
static inline bool resctrl_arch_is_mbm_local_enabled(void)
96+
{
97+
return (rdt_mon_features & (1 << QOS_L3_MBM_LOCAL_EVENT_ID));
98+
}
99+
82100
/*
83101
* __resctrl_sched_in() - Writes the task's CLOSid/RMID to IA32_PQR_MSR
84102
*
@@ -96,8 +114,8 @@ static inline void resctrl_arch_disable_mon(void)
96114
static inline void __resctrl_sched_in(struct task_struct *tsk)
97115
{
98116
struct resctrl_pqr_state *state = this_cpu_ptr(&pqr_state);
99-
u32 closid = state->default_closid;
100-
u32 rmid = state->default_rmid;
117+
u32 closid = READ_ONCE(state->default_closid);
118+
u32 rmid = READ_ONCE(state->default_rmid);
101119
u32 tmp;
102120

103121
/*
@@ -132,6 +150,13 @@ static inline unsigned int resctrl_arch_round_mon_val(unsigned int val)
132150
return val * scale;
133151
}
134152

153+
static inline void resctrl_arch_set_cpu_default_closid_rmid(int cpu, u32 closid,
154+
u32 rmid)
155+
{
156+
WRITE_ONCE(per_cpu(pqr_state.default_closid, cpu), closid);
157+
WRITE_ONCE(per_cpu(pqr_state.default_rmid, cpu), rmid);
158+
}
159+
135160
static inline void resctrl_arch_set_closid_rmid(struct task_struct *tsk,
136161
u32 closid, u32 rmid)
137162
{
@@ -178,6 +203,11 @@ static inline void *resctrl_arch_mon_ctx_alloc(struct rdt_resource *r, int evtid
178203
static inline void resctrl_arch_mon_ctx_free(struct rdt_resource *r, int evtid,
179204
void *ctx) { };
180205

206+
u64 resctrl_arch_get_prefetch_disable_bits(void);
207+
int resctrl_arch_pseudo_lock_fn(void *_plr);
208+
int resctrl_arch_measure_cycles_lat_fn(void *_plr);
209+
int resctrl_arch_measure_l2_residency(void *_plr);
210+
int resctrl_arch_measure_l3_residency(void *_plr);
181211
void resctrl_cpu_detect(struct cpuinfo_x86 *c);
182212

183213
#else

arch/x86/kernel/cpu/resctrl/Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# SPDX-License-Identifier: GPL-2.0
2-
obj-$(CONFIG_X86_CPU_RESCTRL) += core.o rdtgroup.o monitor.o
3-
obj-$(CONFIG_X86_CPU_RESCTRL) += ctrlmondata.o pseudo_lock.o
2+
obj-$(CONFIG_X86_CPU_RESCTRL) += core.o rdtgroup.o monitor.o
3+
obj-$(CONFIG_X86_CPU_RESCTRL) += ctrlmondata.o
4+
obj-$(CONFIG_RESCTRL_FS_PSEUDO_LOCK) += pseudo_lock.o
45
CFLAGS_pseudo_lock.o = -I$(src)

0 commit comments

Comments
 (0)