Skip to content

Commit 664a231

Browse files
committed
Merge tag 'x86_cache_for_v6.16_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 resource control updates from Borislav Petkov: "Carve out the resctrl filesystem-related code into fs/resctrl/ so that multiple architectures can share the fs API for manipulating their respective hw resource control implementation. This is the second step in the work towards sharing the resctrl filesystem interface, the next one being plugging ARM's MPAM into the aforementioned fs API" * tag 'x86_cache_for_v6.16_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (25 commits) MAINTAINERS: Add reviewers for fs/resctrl x86,fs/resctrl: Move the resctrl filesystem code to live in /fs/resctrl x86/resctrl: Always initialise rid field in rdt_resources_all[] x86/resctrl: Relax some asm #includes x86/resctrl: Prefer alloc(sizeof(*foo)) idiom in rdt_init_fs_context() x86/resctrl: Squelch whitespace anomalies in resctrl core code x86/resctrl: Move pseudo lock prototypes to include/linux/resctrl.h x86/resctrl: Fix types in resctrl_arch_mon_ctx_{alloc,free}() stubs x86/resctrl: Move enum resctrl_event_id to resctrl.h x86/resctrl: Move the filesystem bits to headers visible to fs/resctrl fs/resctrl: Add boiler plate for external resctrl code x86/resctrl: Add 'resctrl' to the title of the resctrl documentation x86/resctrl: Split trace.h x86/resctrl: Expand the width of domid by replacing mon_data_bits x86/resctrl: Add end-marker to the resctrl_event_id enum x86/resctrl: Move is_mba_sc() out of core.c x86/resctrl: Drop __init/__exit on assorted symbols x86/resctrl: Resctrl_exit() teardown resctrl but leave the mount point x86/resctrl: Check all domains are offline in resctrl_exit() x86/resctrl: Rename resctrl_sched_in() to begin with "resctrl_arch_" ...
2 parents b1456f6 + 54d14f2 commit 664a231

32 files changed

+7906
-7401
lines changed

Documentation/arch/x86/index.rst

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

Documentation/filesystems/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ Documentation for filesystem implementations.
113113
qnx6
114114
ramfs-rootfs-initramfs
115115
relay
116+
resctrl
116117
romfs
117118
smb/index
118119
spufs/index

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
.. SPDX-License-Identifier: GPL-2.0
22
.. include:: <isonum.txt>
33

4-
===========================================
5-
User Interface for Resource Control feature
6-
===========================================
4+
=====================================================
5+
User Interface for Resource Control feature (resctrl)
6+
=====================================================
77

88
:Copyright: |copy| 2016 Intel Corporation
99
:Authors: - Fenghua Yu <fenghua.yu@intel.com>

MAINTAINERS

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20501,11 +20501,14 @@ F: tools/testing/selftests/net/rds/
2050120501
RDT - RESOURCE ALLOCATION
2050220502
M: Tony Luck <tony.luck@intel.com>
2050320503
M: Reinette Chatre <reinette.chatre@intel.com>
20504+
R: Dave Martin <Dave.Martin@arm.com>
20505+
R: James Morse <james.morse@arm.com>
2050420506
L: linux-kernel@vger.kernel.org
2050520507
S: Supported
20506-
F: Documentation/arch/x86/resctrl*
20508+
F: Documentation/filesystems/resctrl.rst
2050720509
F: arch/x86/include/asm/resctrl.h
2050820510
F: arch/x86/kernel/cpu/resctrl/
20511+
F: fs/resctrl/
2050920512
F: include/linux/resctrl*.h
2051020513
F: tools/testing/selftests/resctrl/
2051120514

arch/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1518,6 +1518,14 @@ config STRICT_MODULE_RWX
15181518
config ARCH_HAS_PHYS_TO_DMA
15191519
bool
15201520

1521+
config ARCH_HAS_CPU_RESCTRL
1522+
bool
1523+
help
1524+
An architecture selects this option to indicate that the necessary
1525+
hooks are provided to support the common memory system usage
1526+
monitoring and control interfaces provided by the 'resctrl'
1527+
filesystem (see RESCTRL_FS).
1528+
15211529
config HAVE_ARCH_COMPILER_H
15221530
bool
15231531
help

arch/x86/Kconfig

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -507,8 +507,9 @@ config X86_MPPARSE
507507
config X86_CPU_RESCTRL
508508
bool "x86 CPU resource control support"
509509
depends on X86 && (CPU_SUP_INTEL || CPU_SUP_AMD)
510-
select KERNFS
511-
select PROC_CPU_RESCTRL if PROC_FS
510+
depends on MISC_FILESYSTEMS
511+
select ARCH_HAS_CPU_RESCTRL
512+
select RESCTRL_FS
512513
select RESCTRL_FS_PSEUDO_LOCK
513514
help
514515
Enable x86 CPU resource control support.
@@ -526,12 +527,6 @@ config X86_CPU_RESCTRL
526527

527528
Say N if unsure.
528529

529-
config RESCTRL_FS_PSEUDO_LOCK
530-
bool
531-
help
532-
Software mechanism to pin data in a cache portion using
533-
micro-architecture specific knowledge.
534-
535530
config X86_FRED
536531
bool "Flexible Return and Event Delivery"
537532
depends on X86_64

arch/x86/include/asm/resctrl.h

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ static inline bool resctrl_arch_match_rmid(struct task_struct *tsk, u32 ignored,
177177
return READ_ONCE(tsk->rmid) == rmid;
178178
}
179179

180-
static inline void resctrl_sched_in(struct task_struct *tsk)
180+
static inline void resctrl_arch_sched_in(struct task_struct *tsk)
181181
{
182182
if (static_branch_likely(&rdt_enable_key))
183183
__resctrl_sched_in(tsk);
@@ -196,25 +196,22 @@ static inline u32 resctrl_arch_rmid_idx_encode(u32 ignored, u32 rmid)
196196

197197
/* x86 can always read an rmid, nothing needs allocating */
198198
struct rdt_resource;
199-
static inline void *resctrl_arch_mon_ctx_alloc(struct rdt_resource *r, int evtid)
199+
static inline void *resctrl_arch_mon_ctx_alloc(struct rdt_resource *r,
200+
enum resctrl_event_id evtid)
200201
{
201202
might_sleep();
202203
return NULL;
203-
};
204+
}
204205

205-
static inline void resctrl_arch_mon_ctx_free(struct rdt_resource *r, int evtid,
206-
void *ctx) { };
206+
static inline void resctrl_arch_mon_ctx_free(struct rdt_resource *r,
207+
enum resctrl_event_id evtid,
208+
void *ctx) { }
207209

208-
u64 resctrl_arch_get_prefetch_disable_bits(void);
209-
int resctrl_arch_pseudo_lock_fn(void *_plr);
210-
int resctrl_arch_measure_cycles_lat_fn(void *_plr);
211-
int resctrl_arch_measure_l2_residency(void *_plr);
212-
int resctrl_arch_measure_l3_residency(void *_plr);
213210
void resctrl_cpu_detect(struct cpuinfo_x86 *c);
214211

215212
#else
216213

217-
static inline void resctrl_sched_in(struct task_struct *tsk) {}
214+
static inline void resctrl_arch_sched_in(struct task_struct *tsk) {}
218215
static inline void resctrl_cpu_detect(struct cpuinfo_x86 *c) {}
219216

220217
#endif /* CONFIG_X86_CPU_RESCTRL */

arch/x86/kernel/cpu/resctrl/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
obj-$(CONFIG_X86_CPU_RESCTRL) += core.o rdtgroup.o monitor.o
33
obj-$(CONFIG_X86_CPU_RESCTRL) += ctrlmondata.o
44
obj-$(CONFIG_RESCTRL_FS_PSEUDO_LOCK) += pseudo_lock.o
5+
6+
# To allow define_trace.h's recursive include:
57
CFLAGS_pseudo_lock.o = -I$(src)

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

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ struct rdt_hw_resource rdt_resources_all[RDT_NUM_RESOURCES] = {
6161
[RDT_RESOURCE_L3] =
6262
{
6363
.r_resctrl = {
64-
.rid = RDT_RESOURCE_L3,
6564
.name = "L3",
6665
.ctrl_scope = RESCTRL_L3_CACHE,
6766
.mon_scope = RESCTRL_L3_CACHE,
@@ -75,7 +74,6 @@ struct rdt_hw_resource rdt_resources_all[RDT_NUM_RESOURCES] = {
7574
[RDT_RESOURCE_L2] =
7675
{
7776
.r_resctrl = {
78-
.rid = RDT_RESOURCE_L2,
7977
.name = "L2",
8078
.ctrl_scope = RESCTRL_L2_CACHE,
8179
.ctrl_domains = ctrl_domain_init(RDT_RESOURCE_L2),
@@ -87,7 +85,6 @@ struct rdt_hw_resource rdt_resources_all[RDT_NUM_RESOURCES] = {
8785
[RDT_RESOURCE_MBA] =
8886
{
8987
.r_resctrl = {
90-
.rid = RDT_RESOURCE_MBA,
9188
.name = "MB",
9289
.ctrl_scope = RESCTRL_L3_CACHE,
9390
.ctrl_domains = ctrl_domain_init(RDT_RESOURCE_MBA),
@@ -97,7 +94,6 @@ struct rdt_hw_resource rdt_resources_all[RDT_NUM_RESOURCES] = {
9794
[RDT_RESOURCE_SMBA] =
9895
{
9996
.r_resctrl = {
100-
.rid = RDT_RESOURCE_SMBA,
10197
.name = "SMBA",
10298
.ctrl_scope = RESCTRL_L3_CACHE,
10399
.ctrl_domains = ctrl_domain_init(RDT_RESOURCE_SMBA),
@@ -165,21 +161,6 @@ static inline void cache_alloc_hsw_probe(void)
165161
rdt_alloc_capable = true;
166162
}
167163

168-
bool is_mba_sc(struct rdt_resource *r)
169-
{
170-
if (!r)
171-
r = resctrl_arch_get_resource(RDT_RESOURCE_MBA);
172-
173-
/*
174-
* The software controller support is only applicable to MBA resource.
175-
* Make sure to check for resource type.
176-
*/
177-
if (r->rid != RDT_RESOURCE_MBA)
178-
return false;
179-
180-
return r->membw.mba_sc;
181-
}
182-
183164
/*
184165
* rdt_get_mb_table() - get a mapping of bandwidth(b/w) percentage values
185166
* exposed to user interface and the h/w understandable delay values.
@@ -738,7 +719,7 @@ struct rdt_options {
738719
bool force_off, force_on;
739720
};
740721

741-
static struct rdt_options rdt_options[] __initdata = {
722+
static struct rdt_options rdt_options[] __ro_after_init = {
742723
RDT_OPT(RDT_FLAG_CMT, "cmt", X86_FEATURE_CQM_OCCUP_LLC),
743724
RDT_OPT(RDT_FLAG_MBM_TOTAL, "mbmtotal", X86_FEATURE_CQM_MBM_TOTAL),
744725
RDT_OPT(RDT_FLAG_MBM_LOCAL, "mbmlocal", X86_FEATURE_CQM_MBM_LOCAL),
@@ -778,7 +759,7 @@ static int __init set_rdt_options(char *str)
778759
}
779760
__setup("rdt", set_rdt_options);
780761

781-
bool __init rdt_cpu_has(int flag)
762+
bool rdt_cpu_has(int flag)
782763
{
783764
bool ret = boot_cpu_has(flag);
784765
struct rdt_options *o;
@@ -798,7 +779,7 @@ bool __init rdt_cpu_has(int flag)
798779
return ret;
799780
}
800781

801-
__init bool resctrl_arch_is_evt_configurable(enum resctrl_event_id evt)
782+
bool resctrl_arch_is_evt_configurable(enum resctrl_event_id evt)
802783
{
803784
if (!rdt_cpu_has(X86_FEATURE_BMEC))
804785
return false;
@@ -1012,7 +993,11 @@ void resctrl_cpu_detect(struct cpuinfo_x86 *c)
1012993
static int __init resctrl_arch_late_init(void)
1013994
{
1014995
struct rdt_resource *r;
1015-
int state, ret;
996+
int state, ret, i;
997+
998+
/* for_each_rdt_resource() requires all rid to be initialised. */
999+
for (i = 0; i < RDT_NUM_RESOURCES; i++)
1000+
rdt_resources_all[i].r_resctrl.rid = i;
10161001

10171002
/*
10181003
* Initialize functions(or definitions) that are different

0 commit comments

Comments
 (0)