Skip to content

Commit bff7040

Browse files
James Morsebp3tk0v
authored andcommitted
fs/resctrl: Add boiler plate for external resctrl code
Add Makefile and Kconfig for fs/resctrl. Add ARCH_HAS_CPU_RESCTRL for the common parts of the resctrl interface and make X86_CPU_RESCTRL select this. Adding an include of asm/resctrl.h to linux/resctrl.h allows the /fs/resctrl files to switch over to using this header instead. Co-developed-by: Dave Martin <Dave.Martin@arm.com> Signed-off-by: Dave Martin <Dave.Martin@arm.com> Signed-off-by: James Morse <james.morse@arm.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Reviewed-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com> Reviewed-by: Tony Luck <tony.luck@intel.com> Reviewed-by: Fenghua Yu <fenghuay@nvidia.com> Reviewed-by: Reinette Chatre <reinette.chatre@intel.com> Tested-by: Fenghua Yu <fenghuay@nvidia.com> Tested-by: Carl Worth <carl@os.amperecomputing.com> # arm64 Tested-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com> Tested-by: Peter Newman <peternewman@google.com> Tested-by: Amit Singh Tomar <amitsinght@marvell.com> # arm64 Tested-by: Shanker Donthineni <sdonthineni@nvidia.com> # arm64 Tested-by: Babu Moger <babu.moger@amd.com> Tested-by: Tony Luck <tony.luck@intel.com> Link: https://lore.kernel.org/20250515165855.31452-16-james.morse@arm.com
1 parent 003e860 commit bff7040

File tree

19 files changed

+66
-13
lines changed

19 files changed

+66
-13
lines changed

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20427,6 +20427,7 @@ S: Supported
2042720427
F: Documentation/arch/x86/resctrl*
2042820428
F: arch/x86/include/asm/resctrl.h
2042920429
F: arch/x86/kernel/cpu/resctrl/
20430+
F: fs/resctrl/
2043020431
F: include/linux/resctrl*.h
2043120432
F: tools/testing/selftests/resctrl/
2043220433

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/kernel/cpu/resctrl/internal.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
#include <linux/jump_label.h>
1010
#include <linux/tick.h>
1111

12-
#include <asm/resctrl.h>
13-
1412
#define L3_QOS_CDP_ENABLE 0x01ULL
1513

1614
#define L2_QOS_CDP_ENABLE 0x01ULL

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919

2020
#include <linux/cpu.h>
2121
#include <linux/module.h>
22+
#include <linux/resctrl.h>
2223
#include <linux/sizes.h>
2324
#include <linux/slab.h>
2425

2526
#include <asm/cpu_device_id.h>
26-
#include <asm/resctrl.h>
2727

2828
#include "internal.h"
2929

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
#include <linux/mman.h>
1919
#include <linux/perf_event.h>
2020
#include <linux/pm_qos.h>
21+
#include <linux/resctrl.h>
2122
#include <linux/slab.h>
2223
#include <linux/uaccess.h>
2324

2425
#include <asm/cacheflush.h>
2526
#include <asm/cpu_device_id.h>
26-
#include <asm/resctrl.h>
2727
#include <asm/perf_event.h>
2828

2929
#include "../../events/perf_event.h" /* For X86_CONFIG() */

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <linux/fs_parser.h>
1919
#include <linux/sysfs.h>
2020
#include <linux/kernfs.h>
21+
#include <linux/resctrl.h>
2122
#include <linux/seq_buf.h>
2223
#include <linux/seq_file.h>
2324
#include <linux/sched/signal.h>
@@ -28,7 +29,6 @@
2829

2930
#include <uapi/linux/magic.h>
3031

31-
#include <asm/resctrl.h>
3232
#include "internal.h"
3333

3434
DEFINE_STATIC_KEY_FALSE(rdt_enable_key);

fs/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ source "fs/omfs/Kconfig"
335335
source "fs/hpfs/Kconfig"
336336
source "fs/qnx4/Kconfig"
337337
source "fs/qnx6/Kconfig"
338+
source "fs/resctrl/Kconfig"
338339
source "fs/romfs/Kconfig"
339340
source "fs/pstore/Kconfig"
340341
source "fs/ufs/Kconfig"

fs/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,4 @@ obj-$(CONFIG_EROFS_FS) += erofs/
128128
obj-$(CONFIG_VBOXSF_FS) += vboxsf/
129129
obj-$(CONFIG_ZONEFS_FS) += zonefs/
130130
obj-$(CONFIG_BPF_LSM) += bpf_fs_kfuncs.o
131+
obj-$(CONFIG_RESCTRL_FS) += resctrl/

fs/resctrl/Kconfig

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
config RESCTRL_FS
2+
bool "CPU Resource Control Filesystem (resctrl)"
3+
depends on ARCH_HAS_CPU_RESCTRL
4+
select KERNFS
5+
select PROC_CPU_RESCTRL if PROC_FS
6+
help
7+
Some architectures provide hardware facilities to group tasks and
8+
monitor and control their usage of memory system resources such as
9+
caches and memory bandwidth. Examples of such facilities include
10+
Intel's Resource Director Technology (Intel(R) RDT) and AMD's
11+
Platform Quality of Service (AMD QoS).
12+
13+
If your system has the necessary support and you want to be able to
14+
assign tasks to groups and manipulate the associated resource
15+
monitors and controls from userspace, say Y here to get a mountable
16+
'resctrl' filesystem that lets you do just that.
17+
18+
If nothing mounts or prods the 'resctrl' filesystem, resource
19+
controls and monitors are left in a quiescent, permissive state.
20+
21+
On architectures where this can be disabled independently, it is
22+
safe to say N.
23+
24+
See <file:Documentation/arch/x86/resctrl.rst> for more information.
25+
26+
config RESCTRL_FS_PSEUDO_LOCK
27+
bool
28+
depends on RESCTRL_FS
29+
help
30+
Software mechanism to pin data in a cache portion using
31+
micro-architecture specific knowledge.
32+
33+
config RESCTRL_RMID_DEPENDS_ON_CLOSID
34+
bool
35+
depends on RESCTRL_FS
36+
help
37+
Enabled by the architecture when the RMID values depend on the CLOSID.
38+
This causes the CLOSID allocator to search for CLOSID with clean
39+
RMID.

0 commit comments

Comments
 (0)