Skip to content

Commit 08f0fbd

Browse files
author
CKI KWF Bot
committed
Merge: Update resctrl to upstream 6.17
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/7438 JIRA: https://issues.redhat.com/browse/RHEL-118965 Doing so prepares the resctrl file system to work on multiple arches, which facilitates future development while bringing in some additional features. Signed-off-by: David Arcari <[email protected]> Approved-by: Tony Camuso <[email protected]> Approved-by: Steve Best <[email protected]> Approved-by: Carlos Maiolino <[email protected]> Approved-by: CKI KWF Bot <[email protected]> Merged-by: CKI GitLab Kmaint Pipeline Bot <[email protected]>
2 parents f2a288d + e14161e commit 08f0fbd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+9068
-7951
lines changed

Documentation/arch/x86/index.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ x86-specific Documentation
3131
pti
3232
mds
3333
microcode
34-
resctrl
3534
tsx_async_abort
3635
buslock
3736
usb-legacy-support

Documentation/filesystems/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ Documentation for filesystem implementations.
109109
qnx6
110110
ramfs-rootfs-initramfs
111111
relay
112+
resctrl
112113
romfs
113114
spufs/index
114115
squashfs

Documentation/arch/x86/resctrl.rst renamed to Documentation/filesystems/resctrl.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,16 @@ When monitoring is enabled all MON groups will also contain:
384384
Available only with debug option. The identifier used by hardware
385385
for the monitor group. On x86 this is the RMID.
386386

387+
When the "mba_MBps" mount option is used all CTRL_MON groups will also contain:
388+
389+
"mba_MBps_event":
390+
Reading this file shows which memory bandwidth event is used
391+
as input to the software feedback loop that keeps memory bandwidth
392+
below the value specified in the schemata file. Writing the
393+
name of one of the supported memory bandwidth events found in
394+
/sys/fs/resctrl/info/L3_MON/mon_features changes the input
395+
event.
396+
387397
Resource allocation rules
388398
-------------------------
389399

MAINTAINERS

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16543,9 +16543,11 @@ M: Fenghua Yu <[email protected]>
1654316543
M: Reinette Chatre <[email protected]>
1654416544
1654516545
S: Supported
16546-
F: Documentation/arch/x86/resctrl*
16546+
F: Documentation/filesystems/resctrl.rst
1654716547
F: arch/x86/include/asm/resctrl.h
1654816548
F: arch/x86/kernel/cpu/resctrl/
16549+
F: fs/resctrl/
16550+
F: include/linux/resctrl*.h
1654916551
F: tools/testing/selftests/resctrl/
1655016552

1655116553
READ-COPY UPDATE (RCU)

arch/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,6 +1314,14 @@ config STRICT_MODULE_RWX
13141314
config ARCH_HAS_PHYS_TO_DMA
13151315
bool
13161316

1317+
config ARCH_HAS_CPU_RESCTRL
1318+
bool
1319+
help
1320+
An architecture selects this option to indicate that the necessary
1321+
hooks are provided to support the common memory system usage
1322+
monitoring and control interfaces provided by the 'resctrl'
1323+
filesystem (see RESCTRL_FS).
1324+
13171325
config HAVE_ARCH_COMPILER_H
13181326
bool
13191327
help

arch/x86/Kconfig

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,8 +478,10 @@ config GOLDFISH
478478
config X86_CPU_RESCTRL
479479
bool "x86 CPU resource control support"
480480
depends on X86 && (CPU_SUP_INTEL || CPU_SUP_AMD)
481-
select KERNFS
482-
select PROC_CPU_RESCTRL if PROC_FS
481+
depends on MISC_FILESYSTEMS
482+
select ARCH_HAS_CPU_RESCTRL
483+
select RESCTRL_FS
484+
select RESCTRL_FS_PSEUDO_LOCK
483485
help
484486
Enable x86 CPU resource control support.
485487

arch/x86/include/asm/resctrl.h

Lines changed: 36 additions & 9 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
{
@@ -150,7 +175,7 @@ static inline bool resctrl_arch_match_rmid(struct task_struct *tsk, u32 ignored,
150175
return READ_ONCE(tsk->rmid) == rmid;
151176
}
152177

153-
static inline void resctrl_sched_in(struct task_struct *tsk)
178+
static inline void resctrl_arch_sched_in(struct task_struct *tsk)
154179
{
155180
if (static_branch_likely(&rdt_enable_key))
156181
__resctrl_sched_in(tsk);
@@ -169,20 +194,22 @@ static inline u32 resctrl_arch_rmid_idx_encode(u32 ignored, u32 rmid)
169194

170195
/* x86 can always read an rmid, nothing needs allocating */
171196
struct rdt_resource;
172-
static inline void *resctrl_arch_mon_ctx_alloc(struct rdt_resource *r, int evtid)
197+
static inline void *resctrl_arch_mon_ctx_alloc(struct rdt_resource *r,
198+
enum resctrl_event_id evtid)
173199
{
174200
might_sleep();
175201
return NULL;
176-
};
202+
}
177203

178-
static inline void resctrl_arch_mon_ctx_free(struct rdt_resource *r, int evtid,
179-
void *ctx) { };
204+
static inline void resctrl_arch_mon_ctx_free(struct rdt_resource *r,
205+
enum resctrl_event_id evtid,
206+
void *ctx) { }
180207

181208
void resctrl_cpu_detect(struct cpuinfo_x86 *c);
182209

183210
#else
184211

185-
static inline void resctrl_sched_in(struct task_struct *tsk) {}
212+
static inline void resctrl_arch_sched_in(struct task_struct *tsk) {}
186213
static inline void resctrl_cpu_detect(struct cpuinfo_x86 *c) {}
187214

188215
#endif /* CONFIG_X86_CPU_RESCTRL */
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
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
5+
6+
# To allow define_trace.h's recursive include:
47
CFLAGS_pseudo_lock.o = -I$(src)

0 commit comments

Comments
 (0)