x86/resctrl: Move the resctrl filesystem code to /fs/resctrl
Subsystems (6)
James Morse
reviewerv12 cover x86/resctrl: Move the resctrl filesystem code to /fs/resctrl
Hello!
No code changes since v11 - this is the 'final' form of the series with patches v11:24-29 squashed together. See [v11] for the breakdown.
The first four patches are a series from Yury which I've rebased onto.
This series is based on rc5, and can be retrieved from:git://git.kernel.org/pub/scm/linux/kernel/git/morse/linux.git mpam/move_to_fs/v12
With the exception of invalid configurations for the configurable-events, there should be no changes in behaviour caused by this series. It is now possible for throttle_mode to report 'undefined', but no known platform will do this. resctrl_exit() is now something that can be called, but x86 doesn't do this.
The driving pattern is to make things like struct rdtgroup private to resctrl. Features like pseudo-lock aren't going to work on arm64, the ability to disable it at compile time is added.
After this, I can start posting the MPAM driver to make use of resctrl on arm64. (What's MPAM? See the cover letter of the first series. [1])
Bugs are still welcome!
Thanks,
James
[v11] https://lore.kernel.org/all/[email protected]
[v10] https://lore.kernel.org/all/[email protected]
[v9] https://lore.kernel.org/all/[email protected]
[v8] https://lore.kernel.org/all/[email protected]
[v7] https://lore.kernel.org/all/[email protected]/
[v6] https://lore.kernel.org/lkml/[email protected]/
[v5] https://lore.kernel.org/r/[email protected]
[v4] https://lore.kernel.org/all/[email protected]/
[v3] https://lore.kernel.org/r/[email protected]
[v2] https://lore.kernel.org/r/[email protected]
[v1] https://lore.kernel.org/r/[email protected]
[1] https://lore.kernel.org/lkml/[email protected]/
Amit Singh Tomar (1):
x86/resctrl: Remove the limit on the number of CLOSID
Dave Martin (3):
x86/resctrl: Squelch whitespace anomalies in resctrl core code x86/resctrl: Prefer alloc(sizeof(*foo)) idiom in rdt_init_fs_context() x86/resctrl: Relax some asm #includes
James Morse (17):
x86/resctrl: Rename resctrl_sched_in() to begin with "resctrl_arch_" x86/resctrl: Check all domains are offline in resctrl_exit() x86/resctrl: resctrl_exit() teardown resctrl but leave the mount point x86/resctrl: Drop __init/__exit on assorted symbols x86/resctrl: Move is_mba_sc() out of core.c
x86/resctrl: Add end-marker to the resctrl_event_id enum x86/resctrl: Expand the width of domid by replacing mon_data_bits x86/resctrl: Split trace.h
x86/resctrl: Add 'resctrl' to the title of the resctrl documentation fs/resctrl: Add boiler plate for external resctrl code x86/resctrl: Move the filesystem bits to headers visible to fs/resctrl x86/resctrl: Move enum resctrl_event_id to resctrl.h x86/resctrl: Fix types in resctrl_arch_mon_ctx_{alloc,free}() stubs x86/resctrl: Move pseudo lock prototypes to include/linux/resctrl.h x86/resctrl: Always initialise rid field in rdt_resources_all[] x86,fs/resctrl: Move the resctrl filesystem code to live in
/fs/resctrl
MAINTAINERS: Add reviewers for fs/resctrl
Yury Norov [NVIDIA] (4):
cpumask: relax cpumask_any_but()
find: add find_first_andnot_bit()
cpumask: add cpumask_{first,next}_andnot() API x86/resctrl: Optimize cpumask_any_housekeeping()
Documentation/arch/x86/index.rst | 1 -
Documentation/filesystems/index.rst | 1 +
.../{arch/x86 => filesystems}/resctrl.rst | 6 +-
MAINTAINERS | 5 +-
arch/Kconfig | 8 +
arch/x86/Kconfig | 11 +-
arch/x86/include/asm/resctrl.h | 19 +-
arch/x86/kernel/cpu/resctrl/Makefile | 2 +
arch/x86/kernel/cpu/resctrl/core.c | 31 +-
arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 635 ---
arch/x86/kernel/cpu/resctrl/internal.h | 399 +-
arch/x86/kernel/cpu/resctrl/monitor.c | 918 +---
arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 1092 +----
.../resctrl/{trace.h => pseudo_lock_trace.h} | 26 +-
arch/x86/kernel/cpu/resctrl/rdtgroup.c | 4164 +---------------
arch/x86/kernel/process_32.c | 2 +-
arch/x86/kernel/process_64.c | 2 +-
fs/Kconfig | 1 +
fs/Makefile | 1 +
fs/resctrl/Kconfig | 39 +
fs/resctrl/Makefile | 6 +
fs/resctrl/ctrlmondata.c | 661 +++
fs/resctrl/internal.h | 426 ++
fs/resctrl/monitor.c | 929 ++++
fs/resctrl/monitor_trace.h | 33 +
fs/resctrl/pseudo_lock.c | 1105 +++++
fs/resctrl/rdtgroup.c | 4353 +++++++++++++++++
include/linux/cpumask.h | 75 +-
include/linux/find.h | 25 +
include/linux/resctrl.h | 36 +-
include/linux/resctrl_types.h | 16 +-
lib/find_bit.c | 11 +
32 files changed, 7772 insertions(+), 7267 deletions(-)
rename Documentation/{arch/x86 => filesystems}/resctrl.rst (99%)
rename arch/x86/kernel/cpu/resctrl/{trace.h => pseudo_lock_trace.h} (56%)
create mode 100644 fs/resctrl/Kconfig
create mode 100644 fs/resctrl/Makefile
create mode 100644 fs/resctrl/ctrlmondata.c
create mode 100644 fs/resctrl/internal.h
create mode 100644 fs/resctrl/monitor.c
create mode 100644 fs/resctrl/monitor_trace.h
create mode 100644 fs/resctrl/pseudo_lock.c
create mode 100644 fs/resctrl/rdtgroup.cSignature · 1 line
2.39.5
James Morse
reviewerPATCH v12 1/25 cpumask: relax cpumask_any_but()
From: "Yury Norov [NVIDIA]" <[email protected]>
Similarly to other cpumask search functions, accept -1, and consider it as 'any cpu' hint. This helps users to avoid coding special cases.
--- include/linux/cpumask.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
include/linux/cpumask.h +12 -4
@@ -413,14 +413,18 @@ unsigned int cpumask_next_wrap(int n, const struct cpumask *src)* @cpu: the cpu to ignore. * * Often used to find any cpu but smp_processor_id() in a mask. +* If @cpu == -1, the function is equivalent to cpumask_any(). * Return: >= nr_cpu_ids if no cpus set. */ static __always_inline -unsigned int cpumask_any_but(const struct cpumask *mask, unsigned int cpu) +unsigned int cpumask_any_but(const struct cpumask *mask, int cpu) {unsigned int i; -cpumask_check (cpu); +/* -1 is a legal arg here. */ +if (cpu !=-1 ) +cpumask_check (cpu); +for_each_cpu (i, mask)if (i != cpu)break ;
@@ -433,16 +437,20 @@ unsigned int cpumask_any_but(const struct cpumask *mask, unsigned int cpu)* @mask2: the second input cpumask * @cpu: the cpu to ignore * +* If @cpu == -1, the function is equivalent to cpumask_any_and(). * Returns >= nr_cpu_ids if no cpus set. */ static __always_inline unsigned int cpumask_any_and_but(const struct cpumask *mask1,const struct cpumask *mask2, -unsigned int cpu) +int cpu) {unsigned int i; -cpumask_check (cpu); +/* -1 is a legal arg here. */ +if (cpu !=-1 ) +cpumask_check (cpu); + i =cpumask_first_and (mask1, mask2);if (i != cpu)return i;
Signature · 1 line
2.39.5
[tip: x86/cache] cpumask: Relax cpumask_any_but()
The following commit has been merged into the x86/cache branch of tip:
The following commit has been merged into the x86/cache branch of tip:
Commit-ID: 189572bf4e005431051319def435ac4b7e4489ca Gitweb: https://git.kernel.org/tip/189572bf4e005431051319def435ac4b7e4489ca Author: Yury Norov [NVIDIA] <[email protected]> AuthorDate: Thu, 15 May 2025 16:58:31 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Thu, 15 May 2025 20:24:22 +02:00
cpumask: Relax cpumask_any_but()
Similarly to other cpumask search functions, accept -1, and consider it as 'any CPU' hint. This helps users to avoid coding special cases.
--- include/linux/cpumask.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
include/linux/cpumask.h +12 -4
@@ -413,14 +413,18 @@ unsigned int cpumask_next_wrap(int n, const struct cpumask *src)* @cpu: the cpu to ignore. * * Often used to find any cpu but smp_processor_id() in a mask. +* If @cpu == -1, the function is equivalent to cpumask_any(). * Return: >= nr_cpu_ids if no cpus set. */ static __always_inline -unsigned int cpumask_any_but(const struct cpumask *mask, unsigned int cpu) +unsigned int cpumask_any_but(const struct cpumask *mask, int cpu) {unsigned int i; -cpumask_check (cpu); +/* -1 is a legal arg here. */ +if (cpu !=-1 ) +cpumask_check (cpu); +for_each_cpu (i, mask)if (i != cpu)break ;
@@ -433,16 +437,20 @@ unsigned int cpumask_any_but(const struct cpumask *mask, unsigned int cpu)* @mask2: the second input cpumask * @cpu: the cpu to ignore * +* If @cpu == -1, the function is equivalent to cpumask_any_and(). * Returns >= nr_cpu_ids if no cpus set. */ static __always_inline unsigned int cpumask_any_and_but(const struct cpumask *mask1,const struct cpumask *mask2, -unsigned int cpu) +int cpu) {unsigned int i; -cpumask_check (cpu); +/* -1 is a legal arg here. */ +if (cpu !=-1 ) +cpumask_check (cpu); + i =cpumask_first_and (mask1, mask2);if (i != cpu)return i;
James Morse
reviewerPATCH v12 2/25 find: add find_first_andnot_bit()
In reply to James MorseFrom: "Yury Norov [NVIDIA]" <[email protected]>
The function helps to implement cpumask_andnot() APIs.
--- include/linux/find.h | 25 +++++++++++++++++++++++++ lib/find_bit.c | 11 +++++++++++ 2 files changed, 36 insertions(+)
include/linux/find.h +25 -0
@@ -29,6 +29,8 @@ unsigned long __find_nth_and_andnot_bit(const unsigned long *addr1, const unsign unsigned long n);extern unsigned long _find_first_and_bit (const unsigned long *addr1,const unsigned long *addr2,unsigned long size); +unsigned long _find_first_andnot_bit (const unsigned long *addr1,const unsigned long *addr2, +unsigned long size);unsigned long _find_first_and_and_bit (const unsigned long *addr1,const unsigned long *addr2,const unsigned long *addr3,unsigned long size);extern unsigned long _find_first_zero_bit (const unsigned long *addr,unsigned long size);
@@ -347,6 +349,29 @@ unsigned long find_first_and_bit(const unsigned long *addr1, }#endif +/** +* find_first_andnot_bit - find the first bit set in 1st memory region and unset in 2nd +* @addr1: The first address to base the search on +* @addr2: The second address to base the search on +* @size: The bitmap size in bits +* +* Returns the bit number for the first set bit +* If no bits are set, returns >= @size. +*/ +static __always_inline +unsigned long find_first_andnot_bit (const unsigned long *addr1, +const unsigned long *addr2, +unsigned long size) +{ +if (small_const_nbits (size)) { +unsigned long val = *addr1 & (~*addr2) &GENMASK (size -1 ,0 ); + +return val ?__ffs (val) : size; + } + +return _find_first_andnot_bit (addr1, addr2, size); +} +/** * find_first_and_and_bit - find the first set bit in 3 memory regions * @addr1: The first address to base the search on
lib/find_bit.c +11 -0
@@ -116,6 +116,17 @@ unsigned long _find_first_and_bit(const unsigned long *addr1,EXPORT_SYMBOL (_find_first_and_bit);#endif +/* +* Find the first bit set in 1st memory region and unset in 2nd. +*/ +unsigned long _find_first_andnot_bit (const unsigned long *addr1, +const unsigned long *addr2, +unsigned long size) +{ + return FIND_FIRST_BIT(addr1[idx] & ~addr2[idx], /* nop */, size); +} +EXPORT_SYMBOL (_find_first_andnot_bit); +/* * Find the first set bit in three memory regions. */
Signature · 1 line
2.39.5
[tip: x86/cache] find: Add find_first_andnot_bit()
The following commit has been merged into the x86/cache branch of tip:
The following commit has been merged into the x86/cache branch of tip:
Commit-ID: 13f0a02bf4c1c5888c736cedef9ca50de666adb3 Gitweb: https://git.kernel.org/tip/13f0a02bf4c1c5888c736cedef9ca50de666adb3 Author: Yury Norov [NVIDIA] <[email protected]> AuthorDate: Thu, 15 May 2025 16:58:32 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Thu, 15 May 2025 20:24:40 +02:00
find: Add find_first_andnot_bit()
The function helps to implement cpumask_andnot() APIs.
--- include/linux/find.h | 25 +++++++++++++++++++++++++ lib/find_bit.c | 11 +++++++++++ 2 files changed, 36 insertions(+)
include/linux/find.h +25 -0
@@ -29,6 +29,8 @@ unsigned long __find_nth_and_andnot_bit(const unsigned long *addr1, const unsign unsigned long n);extern unsigned long _find_first_and_bit (const unsigned long *addr1,const unsigned long *addr2,unsigned long size); +unsigned long _find_first_andnot_bit (const unsigned long *addr1,const unsigned long *addr2, +unsigned long size);unsigned long _find_first_and_and_bit (const unsigned long *addr1,const unsigned long *addr2,const unsigned long *addr3,unsigned long size);extern unsigned long _find_first_zero_bit (const unsigned long *addr,unsigned long size);
@@ -348,6 +350,29 @@ unsigned long find_first_and_bit(const unsigned long *addr1,#endif /** +* find_first_andnot_bit - find the first bit set in 1st memory region and unset in 2nd +* @addr1: The first address to base the search on +* @addr2: The second address to base the search on +* @size: The bitmap size in bits +* +* Returns the bit number for the first set bit +* If no bits are set, returns >= @size. +*/ +static __always_inline +unsigned long find_first_andnot_bit (const unsigned long *addr1, +const unsigned long *addr2, +unsigned long size) +{ +if (small_const_nbits (size)) { +unsigned long val = *addr1 & (~*addr2) &GENMASK (size -1 ,0 ); + +return val ?__ffs (val) : size; + } + +return _find_first_andnot_bit (addr1, addr2, size); +} + +/** * find_first_and_and_bit - find the first set bit in 3 memory regions * @addr1: The first address to base the search on * @addr2: The second address to base the search on
lib/find_bit.c +11 -0
@@ -117,6 +117,17 @@ EXPORT_SYMBOL(_find_first_and_bit);#endif /* +* Find the first bit set in 1st memory region and unset in 2nd. +*/ +unsigned long _find_first_andnot_bit (const unsigned long *addr1, +const unsigned long *addr2, +unsigned long size) +{ + return FIND_FIRST_BIT(addr1[idx] & ~addr2[idx], /* nop */, size); +} +EXPORT_SYMBOL (_find_first_andnot_bit); + +/* * Find the first set bit in three memory regions. */ unsigned long _find_first_and_and_bit(const unsigned long *addr1,
James Morse
reviewerPATCH v12 3/25 cpumask: add cpumask_{first,next}_andnot() API
In reply to James MorseFrom: "Yury Norov [NVIDIA]" <[email protected]>
With the lack of the functions, client code has to abuse less efficient cpumask_nth().
--- include/linux/cpumask.h | 59 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+)
include/linux/cpumask.h +59 -0
@@ -178,6 +178,19 @@ unsigned int cpumask_first_and(const struct cpumask *srcp1, const struct cpumaskreturn find_first_and_bit (cpumask_bits (srcp1),cpumask_bits (srcp2), small_cpumask_bits); } +/** +* cpumask_first_andnot - return the first cpu from *srcp1 & ~*srcp2 +* @srcp1: the first input +* @srcp2: the second input +* +* Return: >= nr_cpu_ids if no such cpu found. +*/ +static __always_inline +unsigned int cpumask_first_andnot(const struct cpumask *srcp1, const struct cpumask *srcp2) +{ +return find_first_andnot_bit (cpumask_bits (srcp1),cpumask_bits (srcp2), small_cpumask_bits); +} +/** * cpumask_first_and_and - return the first cpu from *srcp1 & *srcp2 & *srcp3 * @srcp1: the first input
@@ -284,6 +297,25 @@ unsigned int cpumask_next_and(int n, const struct cpumask *src1p, small_cpumask_bits, n + 1); } +/** +* cpumask_next_andnot - get the next cpu in *src1p & ~*src2p +* @n: the cpu prior to the place to search (i.e. return will be > @n) +* @src1p: the first cpumask pointer +* @src2p: the second cpumask pointer +* +* Return: >= nr_cpu_ids if no further cpus set in both. +*/ +static __always_inline +unsigned int cpumask_next_andnot(int n, const struct cpumask *src1p, +const struct cpumask *src2p) +{ +/* -1 is a legal arg here. */ +if (n !=-1 ) +cpumask_check (n); +return find_next_andnot_bit (cpumask_bits (src1p),cpumask_bits (src2p), + small_cpumask_bits, n +1 ); +} +/** * cpumask_next_and_wrap - get the next cpu in *src1p & *src2p, starting from * @n+1. If nothing found, wrap around and start from
@@ -458,6 +490,33 @@ unsigned int cpumask_any_and_but(const struct cpumask *mask1,return cpumask_next_and (cpu, mask1, mask2); } +/** +* cpumask_any_andnot_but - pick an arbitrary cpu from *mask1 & ~*mask2, but not this one. +* @mask1: the first input cpumask +* @mask2: the second input cpumask +* @cpu: the cpu to ignore +* +* If @cpu == -1, the function returns the first matching cpu. +* Returns >= nr_cpu_ids if no cpus set. +*/ +static __always_inline +unsigned int cpumask_any_andnot_but(const struct cpumask *mask1, +const struct cpumask *mask2, +int cpu) +{ +unsigned int i; + +/* -1 is a legal arg here. */ +if (cpu !=-1 ) +cpumask_check (cpu); + + i =cpumask_first_andnot (mask1, mask2); +if (i != cpu) +return i; + +return cpumask_next_andnot (cpu, mask1, mask2); +} +/** * cpumask_nth - get the Nth cpu in a cpumask * @srcp: the cpumask pointer
Signature · 1 line
2.39.5
[tip: x86/cache] cpumask: Add cpumask_{first,next}_andnot() API
The following commit has been merged into the x86/cache branch of tip:
The following commit has been merged into the x86/cache branch of tip:
Commit-ID: 5da703ef4e4a82b2f9a00f2b3a1eae5657e68a92 Gitweb: https://git.kernel.org/tip/5da703ef4e4a82b2f9a00f2b3a1eae5657e68a92 Author: Yury Norov [NVIDIA] <[email protected]> AuthorDate: Thu, 15 May 2025 16:58:33 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Thu, 15 May 2025 20:28:12 +02:00
cpumask: Add cpumask_{first,next}_andnot() API
With the lack of the functions, client code has to abuse less efficient cpumask_nth().
--- include/linux/cpumask.h | 59 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+)
include/linux/cpumask.h +59 -0
@@ -179,6 +179,19 @@ unsigned int cpumask_first_and(const struct cpumask *srcp1, const struct cpumask }/** +* cpumask_first_andnot - return the first cpu from *srcp1 & ~*srcp2 +* @srcp1: the first input +* @srcp2: the second input +* +* Return: >= nr_cpu_ids if no such cpu found. +*/ +static __always_inline +unsigned int cpumask_first_andnot(const struct cpumask *srcp1, const struct cpumask *srcp2) +{ +return find_first_andnot_bit (cpumask_bits (srcp1),cpumask_bits (srcp2), small_cpumask_bits); +} + +/** * cpumask_first_and_and - return the first cpu from *srcp1 & *srcp2 & *srcp3 * @srcp1: the first input * @srcp2: the second input
@@ -285,6 +298,25 @@ unsigned int cpumask_next_and(int n, const struct cpumask *src1p, }/** +* cpumask_next_andnot - get the next cpu in *src1p & ~*src2p +* @n: the cpu prior to the place to search (i.e. return will be > @n) +* @src1p: the first cpumask pointer +* @src2p: the second cpumask pointer +* +* Return: >= nr_cpu_ids if no further cpus set in both. +*/ +static __always_inline +unsigned int cpumask_next_andnot(int n, const struct cpumask *src1p, +const struct cpumask *src2p) +{ +/* -1 is a legal arg here. */ +if (n !=-1 ) +cpumask_check (n); +return find_next_andnot_bit (cpumask_bits (src1p),cpumask_bits (src2p), + small_cpumask_bits, n +1 ); +} + +/** * cpumask_next_and_wrap - get the next cpu in *src1p & *src2p, starting from * @n+1. If nothing found, wrap around and start from * the beginning
@@ -459,6 +491,33 @@ unsigned int cpumask_any_and_but(const struct cpumask *mask1, }/** +* cpumask_any_andnot_but - pick an arbitrary cpu from *mask1 & ~*mask2, but not this one. +* @mask1: the first input cpumask +* @mask2: the second input cpumask +* @cpu: the cpu to ignore +* +* If @cpu == -1, the function returns the first matching cpu. +* Returns >= nr_cpu_ids if no cpus set. +*/ +static __always_inline +unsigned int cpumask_any_andnot_but(const struct cpumask *mask1, +const struct cpumask *mask2, +int cpu) +{ +unsigned int i; + +/* -1 is a legal arg here. */ +if (cpu !=-1 ) +cpumask_check (cpu); + + i =cpumask_first_andnot (mask1, mask2); +if (i != cpu) +return i; + +return cpumask_next_andnot (cpu, mask1, mask2); +} + +/** * cpumask_nth - get the Nth cpu in a cpumask * @srcp: the cpumask pointer * @cpu: the Nth cpu to find, starting from 0
James Morse
reviewerPATCH v12 4/25 x86/resctrl: Optimize cpumask_any_housekeeping()
In reply to James MorseFrom: "Yury Norov [NVIDIA]" <[email protected]>
With the lack of cpumask_any_andnot_but(), cpumask_any_housekeeping() has to abuse cpumask_nth() functions.
Update cpumask_any_housekeeping() to use the new cpumask_any_but() and cpumask_any_andnot_but(). These two functions understand RESCTRL_PICK_ANY_CPU, which simplifies cpumask_any_housekeeping() significantly.
--- arch/x86/kernel/cpu/resctrl/internal.h | 28 +++++++------------------- 1 file changed, 7 insertions(+), 21 deletions(-)
arch/x86/kernel/cpu/resctrl/internal.h +7 -21
@@ -47,30 +47,16 @@static inline unsigned int cpumask_any_housekeeping (const struct cpumask *mask,int exclude_cpu) { -unsigned int cpu, hk_cpu; - -if (exclude_cpu ==RESCTRL_PICK_ANY_CPU ) - cpu =cpumask_any (mask); -else - cpu =cpumask_any_but (mask, exclude_cpu); - -/* Only continue if tick_nohz_full_mask has been initialized. */ -if (!tick_nohz_full_enabled ()) -return cpu; - -/* If the CPU picked isn't marked nohz_full nothing more needs doing. */ -if (cpu < nr_cpu_ids && !tick_nohz_full_cpu (cpu)) -return cpu; +unsigned int cpu;/* Try to find a CPU that isn't nohz_full to use in preference */ - hk_cpu =cpumask_nth_andnot (0 , mask, tick_nohz_full_mask); -if (hk_cpu == exclude_cpu) - hk_cpu =cpumask_nth_andnot (1 , mask, tick_nohz_full_mask); +if (tick_nohz_full_enabled ()) { + cpu =cpumask_any_andnot_but (mask, tick_nohz_full_mask, exclude_cpu); +if (cpu < nr_cpu_ids) +return cpu; + } -if (hk_cpu < nr_cpu_ids) - cpu = hk_cpu; - -return cpu; +return cpumask_any_but (mask, exclude_cpu); }struct rdt_fs_context {
Signature · 1 line
2.39.5
[tip: x86/cache] x86/resctrl: Optimize cpumask_any_housekeeping()
The following commit has been merged into the x86/cache branch of tip:
The following commit has been merged into the x86/cache branch of tip:
Commit-ID: 94f7531430285b4ec600693f7222c2ca29bd7472 Gitweb: https://git.kernel.org/tip/94f7531430285b4ec600693f7222c2ca29bd7472 Author: Yury Norov [NVIDIA] <[email protected]> AuthorDate: Thu, 15 May 2025 16:58:34 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Thu, 15 May 2025 20:53:26 +02:00
x86/resctrl: Optimize cpumask_any_housekeeping()
With the lack of cpumask_any_andnot_but(), cpumask_any_housekeeping() has to abuse cpumask_nth() functions.
Update cpumask_any_housekeeping() to use the new cpumask_any_but() and cpumask_any_andnot_but(). These two functions understand RESCTRL_PICK_ANY_CPU, which simplifies cpumask_any_housekeeping() significantly.
--- arch/x86/kernel/cpu/resctrl/internal.h | 28 ++++++------------------- 1 file changed, 7 insertions(+), 21 deletions(-)
arch/x86/kernel/cpu/resctrl/internal.h +7 -21
@@ -47,30 +47,16 @@static inline unsigned int cpumask_any_housekeeping (const struct cpumask *mask,int exclude_cpu) { -unsigned int cpu, hk_cpu; - -if (exclude_cpu ==RESCTRL_PICK_ANY_CPU ) - cpu =cpumask_any (mask); -else - cpu =cpumask_any_but (mask, exclude_cpu); - -/* Only continue if tick_nohz_full_mask has been initialized. */ -if (!tick_nohz_full_enabled ()) -return cpu; - -/* If the CPU picked isn't marked nohz_full nothing more needs doing. */ -if (cpu < nr_cpu_ids && !tick_nohz_full_cpu (cpu)) -return cpu; +unsigned int cpu;/* Try to find a CPU that isn't nohz_full to use in preference */ - hk_cpu =cpumask_nth_andnot (0 , mask, tick_nohz_full_mask); -if (hk_cpu == exclude_cpu) - hk_cpu =cpumask_nth_andnot (1 , mask, tick_nohz_full_mask); - -if (hk_cpu < nr_cpu_ids) - cpu = hk_cpu; +if (tick_nohz_full_enabled ()) { + cpu =cpumask_any_andnot_but (mask, tick_nohz_full_mask, exclude_cpu); +if (cpu < nr_cpu_ids) +return cpu; + } -return cpu; +return cpumask_any_but (mask, exclude_cpu); }struct rdt_fs_context {
James Morse
reviewerPATCH v12 5/25 x86/resctrl: Remove the limit on the number of CLOSID
In reply to James MorseFrom: Amit Singh Tomar <[email protected]>
Resctrl allocates and finds free CLOSID values using the bits of a u32. This restricts the number of control groups that can be created by user-space.
MPAM has an architectural limit of 2^16 CLOSID values, Intel x86 could be extended beyond 32 values. There is at least one MPAM platform which supports more than 32 CLOSID values.
Replace the fixed size bitmap with calls to the bitmap API to allocate an array of a sufficient size.
ffs() returns '1' for bit 0, hence the existing code subtracts 1 from the index to get the CLOSID value. find_first_bit() returns the bit number which does not need adjusting.
[ morse: fixed the off-by-one in the allocator and the wrong
not-found value. Removed the limit. Rephrase the commit message. ]
---
Changes since v8:
* Added check for closid_init() on monitor only platforms.
Changes since v7:
* Moved closid_exit() earlier in rdt_kill_sb() to match what rdt_get_tree() does.
Changes since v6:
* Set variable to NULL after kfree()ing it.
* Call closid_exit() from rdt_kill_sb() to prevent a memory leak.
Changes since v5:
* This patch got pulled into this series.
--- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 51 ++++++++++++++++++-------- 1 file changed, 35 insertions(+), 16 deletions(-)
arch/x86/kernel/cpu/resctrl/rdtgroup.c +35 -16
@@ -130,8 +130,8 @@ static bool resctrl_is_mbm_event(int e) }/* -* Trivial allocator for CLOSIDs. Since h/w only supports a small number, -* we can keep a bitmap of free CLOSIDs in a single integer. +* Trivial allocator for CLOSIDs. Use BITMAP APIs to manipulate a bitmap +* of free CLOSIDs. * * Using a global CLOSID across all resources has some advantages and * some drawbacks:
@@ -144,7 +144,7 @@ static bool resctrl_is_mbm_event(int e)* - Our choices on how to configure each resource become progressively more * limited as the number of resources grows. */ -static unsigned long closid_free_map; +static unsigned long *closid_free_map;static int closid_free_map_len;int closids_supported (void )
@@ -152,20 +152,35 @@ int closids_supported(void)return closid_free_map_len; } -static void closid_init (void ) +static int closid_init (void ) {struct resctrl_schema *s; -u32 rdt_min_closid =32 ; +u32 rdt_min_closid = ~0 ; + +/* Monitor only platforms still call closid_init() */ +if (list_empty (&resctrl_schema_all)) +return 0 ;/* Compute rdt_min_closid across all resources */ list_for_each_entry (s, &resctrl_schema_all, list) rdt_min_closid =min (rdt_min_closid, s->num_closid); - closid_free_map =BIT_MASK (rdt_min_closid) -1 ; + closid_free_map =bitmap_alloc (rdt_min_closid,GFP_KERNEL ); +if (!closid_free_map) +return -ENOMEM ; +bitmap_fill (closid_free_map, rdt_min_closid);/* RESCTRL_RESERVED_CLOSID is always reserved for the default group */ -__clear_bit (RESCTRL_RESERVED_CLOSID , &closid_free_map); +__clear_bit (RESCTRL_RESERVED_CLOSID , closid_free_map); closid_free_map_len = rdt_min_closid; + +return 0 ; +} + +static void closid_exit (void ) +{ +bitmap_free (closid_free_map); + closid_free_map =NULL ; }static int closid_alloc (void )
@@ -182,12 +197,11 @@ static int closid_alloc(void)return cleanest_closid; closid = cleanest_closid; }else { - closid =ffs (closid_free_map); -if (closid ==0 ) + closid =find_first_bit (closid_free_map, closid_free_map_len); +if (closid == closid_free_map_len)return -ENOSPC ; - closid--; } -__clear_bit (closid, &closid_free_map); +__clear_bit (closid, closid_free_map);return closid; }
@@ -196,7 +210,7 @@ void closid_free(int closid) {lockdep_assert_held (&rdtgroup_mutex); -__set_bit (closid, &closid_free_map); +__set_bit (closid, closid_free_map); }/**
@@ -210,7 +224,7 @@ bool closid_allocated(unsigned int closid) {lockdep_assert_held (&rdtgroup_mutex); -return !test_bit (closid, &closid_free_map); +return !test_bit (closid, closid_free_map); }/**
@@ -2765,20 +2779,22 @@ static int rdt_get_tree(struct fs_context *fc) goto out_ctx; } -closid_init (); + ret =closid_init (); +if (ret) + goto out_schemata_free;if (resctrl_arch_mon_capable ()) flags |=RFTYPE_MON ; ret =rdtgroup_add_files (rdtgroup_default.kn, flags);if (ret) - goto out_schemata_free; + goto out_closid_exit;kernfs_activate (rdtgroup_default.kn); ret =rdtgroup_create_info_dir (rdtgroup_default.kn);if (ret <0 ) - goto out_schemata_free; + goto out_closid_exit;if (resctrl_arch_mon_capable ()) { ret = mongroup_create_dir(rdtgroup_default.kn,
@@ -2829,6 +2845,8 @@ static int rdt_get_tree(struct fs_context *fc)kernfs_remove (kn_mongrp); out_info:kernfs_remove (kn_info); +out_closid_exit: +closid_exit (); out_schemata_free:schemata_list_destroy (); out_ctx:
@@ -3076,6 +3094,7 @@ static void rdt_kill_sb(struct super_block *sb)rmdir_all_sub ();rdt_pseudo_lock_release (); rdtgroup_default.mode =RDT_MODE_SHAREABLE ; +closid_exit ();schemata_list_destroy ();rdtgroup_destroy_root ();if (resctrl_arch_alloc_capable ())
Signature · 1 line
2.39.5
[tip: x86/cache] x86/resctrl: Remove the limit on the number of CLOSID
The following commit has been merged into the x86/cache branch of tip:
The following commit has been merged into the x86/cache branch of tip:
Commit-ID: dcb1d3d3b77bdb30d2ec97f540d58ee35f1b1c82 Gitweb: https://git.kernel.org/tip/dcb1d3d3b77bdb30d2ec97f540d58ee35f1b1c82 Author: Amit Singh Tomar <[email protected]> AuthorDate: Thu, 15 May 2025 16:58:35 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Thu, 15 May 2025 20:55:40 +02:00
x86/resctrl: Remove the limit on the number of CLOSID
Resctrl allocates and finds free CLOSID values using the bits of a u32. This restricts the number of control groups that can be created by user-space.
MPAM has an architectural limit of 2^16 CLOSID values, Intel x86 could be extended beyond 32 values. There is at least one MPAM platform which supports more than 32 CLOSID values.
Replace the fixed size bitmap with calls to the bitmap API to allocate an array of a sufficient size.
ffs() returns '1' for bit 0, hence the existing code subtracts 1 from the index to get the CLOSID value. find_first_bit() returns the bit number which does not need adjusting.
[ morse: fixed the off-by-one in the allocator and the wrong not-found
value. Removed the limit. Rephrase the commit message. ]
--- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 51 +++++++++++++++++-------- 1 file changed, 35 insertions(+), 16 deletions(-)
arch/x86/kernel/cpu/resctrl/rdtgroup.c +35 -16
@@ -130,8 +130,8 @@ static bool resctrl_is_mbm_event(int e) }/* -* Trivial allocator for CLOSIDs. Since h/w only supports a small number, -* we can keep a bitmap of free CLOSIDs in a single integer. +* Trivial allocator for CLOSIDs. Use BITMAP APIs to manipulate a bitmap +* of free CLOSIDs. * * Using a global CLOSID across all resources has some advantages and * some drawbacks:
@@ -144,7 +144,7 @@ static bool resctrl_is_mbm_event(int e)* - Our choices on how to configure each resource become progressively more * limited as the number of resources grows. */ -static unsigned long closid_free_map; +static unsigned long *closid_free_map;static int closid_free_map_len;int closids_supported (void )
@@ -152,20 +152,35 @@ int closids_supported(void)return closid_free_map_len; } -static void closid_init (void ) +static int closid_init (void ) {struct resctrl_schema *s; -u32 rdt_min_closid =32 ; +u32 rdt_min_closid = ~0 ; + +/* Monitor only platforms still call closid_init() */ +if (list_empty (&resctrl_schema_all)) +return 0 ;/* Compute rdt_min_closid across all resources */ list_for_each_entry (s, &resctrl_schema_all, list) rdt_min_closid =min (rdt_min_closid, s->num_closid); - closid_free_map =BIT_MASK (rdt_min_closid) -1 ; + closid_free_map =bitmap_alloc (rdt_min_closid,GFP_KERNEL ); +if (!closid_free_map) +return -ENOMEM ; +bitmap_fill (closid_free_map, rdt_min_closid);/* RESCTRL_RESERVED_CLOSID is always reserved for the default group */ -__clear_bit (RESCTRL_RESERVED_CLOSID , &closid_free_map); +__clear_bit (RESCTRL_RESERVED_CLOSID , closid_free_map); closid_free_map_len = rdt_min_closid; + +return 0 ; +} + +static void closid_exit (void ) +{ +bitmap_free (closid_free_map); + closid_free_map =NULL ; }static int closid_alloc (void )
@@ -182,12 +197,11 @@ static int closid_alloc(void)return cleanest_closid; closid = cleanest_closid; }else { - closid =ffs (closid_free_map); -if (closid ==0 ) + closid =find_first_bit (closid_free_map, closid_free_map_len); +if (closid == closid_free_map_len)return -ENOSPC ; - closid--; } -__clear_bit (closid, &closid_free_map); +__clear_bit (closid, closid_free_map);return closid; }
@@ -196,7 +210,7 @@ void closid_free(int closid) {lockdep_assert_held (&rdtgroup_mutex); -__set_bit (closid, &closid_free_map); +__set_bit (closid, closid_free_map); }/**
@@ -210,7 +224,7 @@ bool closid_allocated(unsigned int closid) {lockdep_assert_held (&rdtgroup_mutex); -return !test_bit (closid, &closid_free_map); +return !test_bit (closid, closid_free_map); }/**
@@ -2765,20 +2779,22 @@ static int rdt_get_tree(struct fs_context *fc) goto out_ctx; } -closid_init (); + ret =closid_init (); +if (ret) + goto out_schemata_free;if (resctrl_arch_mon_capable ()) flags |=RFTYPE_MON ; ret =rdtgroup_add_files (rdtgroup_default.kn, flags);if (ret) - goto out_schemata_free; + goto out_closid_exit;kernfs_activate (rdtgroup_default.kn); ret =rdtgroup_create_info_dir (rdtgroup_default.kn);if (ret <0 ) - goto out_schemata_free; + goto out_closid_exit;if (resctrl_arch_mon_capable ()) { ret = mongroup_create_dir(rdtgroup_default.kn,
@@ -2829,6 +2845,8 @@ out_mongrp:kernfs_remove (kn_mongrp); out_info:kernfs_remove (kn_info); +out_closid_exit: +closid_exit (); out_schemata_free:schemata_list_destroy (); out_ctx:
@@ -3076,6 +3094,7 @@ static void rdt_kill_sb(struct super_block *sb)rmdir_all_sub ();rdt_pseudo_lock_release (); rdtgroup_default.mode =RDT_MODE_SHAREABLE ; +closid_exit ();schemata_list_destroy ();rdtgroup_destroy_root ();if (resctrl_arch_alloc_capable ())
James Morse
reviewerPATCH v12 6/25 x86/resctrl: Rename resctrl_sched_in() to begin with "resctrl_arch_"
In reply to James Morseresctrl_sched_in() loads the architecture specific CPU MSRs with the CLOSID and RMID values. This function was named before resctrl was split to have architecture specific code, and generic filesystem code.
This function is obviously architecture specific, but does not begin with 'resctrl_arch_', making it the odd one out in the functions an architecture needs to support to enable resctrl.
Rename it for consistency. This is purely cosmetic.
--- arch/x86/include/asm/resctrl.h | 4 ++-- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 12 ++++++------ arch/x86/kernel/process_32.c | 2 +- arch/x86/kernel/process_64.c | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-)
arch/x86/include/asm/resctrl.h +2 -2
@@ -175,7 +175,7 @@ static inline bool resctrl_arch_match_rmid(struct task_struct *tsk, u32 ignored,return READ_ONCE (tsk->rmid) == rmid; } -static inline void resctrl_sched_in (struct task_struct *tsk) +static inline void resctrl_arch_sched_in (struct task_struct *tsk) {if (static_branch_likely (&rdt_enable_key))__resctrl_sched_in (tsk);
@@ -212,7 +212,7 @@ void resctrl_cpu_detect(struct cpuinfo_x86 *c);#else -static inline void resctrl_sched_in (struct task_struct *tsk) {} +static inline void resctrl_arch_sched_in (struct task_struct *tsk) {}static inline void resctrl_cpu_detect (struct cpuinfo_x86 *c) {}#endif /* CONFIG_X86_CPU_RESCTRL */
arch/x86/kernel/cpu/resctrl/rdtgroup.c +6 -6
@@ -376,7 +376,7 @@ static int rdtgroup_cpus_show(struct kernfs_open_file *of, }/* -* This is safe against resctrl_sched_in() called from __switch_to() +* This is safe against resctrl_arch_sched_in() called from __switch_to() * because __switch_to() is executed with interrupts disabled. A local call * from update_closid_rmid() is protected against __switch_to() because * preemption is disabled.
@@ -395,7 +395,7 @@ void resctrl_arch_sync_cpu_closid_rmid(void *info)* executing task might have its own closid selected. Just reuse * the context switch code. */ -resctrl_sched_in (current); +resctrl_arch_sched_in (current); }/*
@@ -620,7 +620,7 @@ static void _update_task_closid_rmid(void *task)* Otherwise, the MSR is updated when the task is scheduled in. */ if (task == current) -resctrl_sched_in (task); +resctrl_arch_sched_in (task); }static void update_task_closid_rmid (struct task_struct *t)
@@ -678,7 +678,7 @@ static int __rdtgroup_move_task(struct task_struct *tsk,* Ensure the task's closid and rmid are written before determining if * the task is current that will decide if it will be interrupted. * This pairs with the full barrier between the rq->curr update and -* resctrl_sched_in() during context switch. +* resctrl_arch_sched_in() during context switch. */ smp_mb ();
@@ -2994,8 +2994,8 @@ static void rdt_move_group_tasks(struct rdtgroup *from, struct rdtgroup *to,/* * Order the closid/rmid stores above before the loads * in task_curr(). This pairs with the full barrier -* between the rq->curr update and resctrl_sched_in() -* during context switch. +* between the rq->curr update and +* resctrl_arch_sched_in() during context switch. */ smp_mb ();
arch/x86/kernel/process_32.c +1 -1
@@ -211,7 +211,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)switch_fpu_finish (next_p);/* Load the Intel cache allocation PQR MSR. */ -resctrl_sched_in (next_p); +resctrl_arch_sched_in (next_p);return prev_p; }
arch/x86/kernel/process_64.c +1 -1
@@ -707,7 +707,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p) }/* Load the Intel cache allocation PQR MSR. */ -resctrl_sched_in (next_p); +resctrl_arch_sched_in (next_p);return prev_p; }
Signature · 1 line
2.39.5
[tip: x86/cache] x86/resctrl: Rename resctrl_sched_in() to begin with "resctrl_arch_"
The following commit has been merged into the x86/cache branch of tip:
The following commit has been merged into the x86/cache branch of tip:
Commit-ID: 7704fb81bc87254e8772f387b62153b135bb1932 Gitweb: https://git.kernel.org/tip/7704fb81bc87254e8772f387b62153b135bb1932 Author: James Morse <[email protected]> AuthorDate: Thu, 15 May 2025 16:58:36 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Thu, 15 May 2025 21:01:00 +02:00
x86/resctrl: Rename resctrl_sched_in() to begin with "resctrl_arch_"
resctrl_sched_in() loads the architecture specific CPU MSRs with the CLOSID and RMID values. This function was named before resctrl was split to have architecture specific code, and generic filesystem code.
This function is obviously architecture specific, but does not begin with 'resctrl_arch_', making it the odd one out in the functions an architecture needs to support to enable resctrl.
Rename it for consistency. This is purely cosmetic.
--- arch/x86/include/asm/resctrl.h | 4 ++-- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 12 ++++++------ arch/x86/kernel/process_32.c | 2 +- arch/x86/kernel/process_64.c | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-)
arch/x86/include/asm/resctrl.h +2 -2
@@ -175,7 +175,7 @@ static inline bool resctrl_arch_match_rmid(struct task_struct *tsk, u32 ignored,return READ_ONCE (tsk->rmid) == rmid; } -static inline void resctrl_sched_in (struct task_struct *tsk) +static inline void resctrl_arch_sched_in (struct task_struct *tsk) {if (static_branch_likely (&rdt_enable_key))__resctrl_sched_in (tsk);
@@ -212,7 +212,7 @@ void resctrl_cpu_detect(struct cpuinfo_x86 *c);#else -static inline void resctrl_sched_in (struct task_struct *tsk) {} +static inline void resctrl_arch_sched_in (struct task_struct *tsk) {}static inline void resctrl_cpu_detect (struct cpuinfo_x86 *c) {}#endif /* CONFIG_X86_CPU_RESCTRL */
arch/x86/kernel/cpu/resctrl/rdtgroup.c +6 -6
@@ -376,7 +376,7 @@ static int rdtgroup_cpus_show(struct kernfs_open_file *of, }/* -* This is safe against resctrl_sched_in() called from __switch_to() +* This is safe against resctrl_arch_sched_in() called from __switch_to() * because __switch_to() is executed with interrupts disabled. A local call * from update_closid_rmid() is protected against __switch_to() because * preemption is disabled.
@@ -395,7 +395,7 @@ void resctrl_arch_sync_cpu_closid_rmid(void *info)* executing task might have its own closid selected. Just reuse * the context switch code. */ -resctrl_sched_in (current); +resctrl_arch_sched_in (current); }/*
@@ -620,7 +620,7 @@ static void _update_task_closid_rmid(void *task)* Otherwise, the MSR is updated when the task is scheduled in. */ if (task == current) -resctrl_sched_in (task); +resctrl_arch_sched_in (task); }static void update_task_closid_rmid (struct task_struct *t)
@@ -678,7 +678,7 @@ static int __rdtgroup_move_task(struct task_struct *tsk,* Ensure the task's closid and rmid are written before determining if * the task is current that will decide if it will be interrupted. * This pairs with the full barrier between the rq->curr update and -* resctrl_sched_in() during context switch. +* resctrl_arch_sched_in() during context switch. */ smp_mb ();
@@ -2994,8 +2994,8 @@ static void rdt_move_group_tasks(struct rdtgroup *from, struct rdtgroup *to,/* * Order the closid/rmid stores above before the loads * in task_curr(). This pairs with the full barrier -* between the rq->curr update and resctrl_sched_in() -* during context switch. +* between the rq->curr update and +* resctrl_arch_sched_in() during context switch. */ smp_mb ();
arch/x86/kernel/process_32.c +1 -1
@@ -211,7 +211,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)switch_fpu_finish (next_p);/* Load the Intel cache allocation PQR MSR. */ -resctrl_sched_in (next_p); +resctrl_arch_sched_in (next_p);return prev_p; }
arch/x86/kernel/process_64.c +1 -1
@@ -707,7 +707,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p) }/* Load the Intel cache allocation PQR MSR. */ -resctrl_sched_in (next_p); +resctrl_arch_sched_in (next_p);return prev_p; }
James Morse
reviewerPATCH v12 7/25 x86/resctrl: Check all domains are offline in resctrl_exit()
In reply to James Morseresctrl_exit() removes things like the resctrl mount point directory and unregisters the filesystem prior to freeing data structures that were allocated during resctrl_init().
This assumes that there are no online domains when resctrl_exit() is called. If any domain were online, the limbo or overflow handler could be scheduled to run.
Add a check for any online control or monitor domains, and document that the architecture code is required to offline all monitor and control domains before calling resctrl_exit().
---
Changes since v10:
* Only walk capable resources in resctrl_online_domains_exist().
Changes since v9:
* Clarified commit message.
Changes since v8:
* This patch is new.
--- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 33 ++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
arch/x86/kernel/cpu/resctrl/rdtgroup.c +33 -0
@@ -4420,8 +4420,41 @@ int __init resctrl_init(void)return ret; } +static bool __exit resctrl_online_domains_exist(void) +{ +struct rdt_resource *r; + +/* +* Only walk capable resources to allow resctrl_arch_get_resource() +* to return dummy 'not capable' resources. +*/ +for_each_alloc_capable_rdt_resource (r) { +if (!list_empty (&r->ctrl_domains)) +return true; + } + +for_each_mon_capable_rdt_resource (r) { +if (!list_empty (&r->mon_domains)) +return true; + } + +return false; +} + +/* +* resctrl_exit() - Remove the resctrl filesystem and free resources. +* +* When called by the architecture code, all CPUs and resctrl domains must be +* offline. This ensures the limbo and overflow handlers are not scheduled to +* run, meaning the data structures they access can be freed by +* resctrl_mon_resource_exit(). +*/ void __exit resctrl_exit(void) { +cpus_read_lock (); +WARN_ON_ONCE (resctrl_online_domains_exist ()); +cpus_read_unlock (); +debugfs_remove_recursive (debugfs_resctrl);unregister_filesystem (&rdt_fs_type);sysfs_remove_mount_point (fs_kobj,"resctrl" );
Signature · 1 line
2.39.5
[tip: x86/cache] x86/resctrl: Check all domains are offline in resctrl_exit()
The following commit has been merged into the x86/cache branch of tip:
The following commit has been merged into the x86/cache branch of tip:
Commit-ID: 8eb7ad66badc71e0d8547cf6195a2a6190090152 Gitweb: https://git.kernel.org/tip/8eb7ad66badc71e0d8547cf6195a2a6190090152 Author: James Morse <[email protected]> AuthorDate: Thu, 15 May 2025 16:58:37 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Thu, 15 May 2025 21:02:21 +02:00
x86/resctrl: Check all domains are offline in resctrl_exit()
resctrl_exit() removes things like the resctrl mount point directory and unregisters the filesystem prior to freeing data structures that were allocated during resctrl_init().
This assumes that there are no online domains when resctrl_exit() is called. If any domain were online, the limbo or overflow handler could be scheduled to run.
Add a check for any online control or monitor domains, and document that the architecture code is required to offline all monitor and control domains before calling resctrl_exit().
--- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 33 +++++++++++++++++++++++++- 1 file changed, 33 insertions(+)
arch/x86/kernel/cpu/resctrl/rdtgroup.c +33 -0
@@ -4420,8 +4420,41 @@ cleanup_mountpoint:return ret; } +static bool __exit resctrl_online_domains_exist(void) +{ +struct rdt_resource *r; + +/* +* Only walk capable resources to allow resctrl_arch_get_resource() +* to return dummy 'not capable' resources. +*/ +for_each_alloc_capable_rdt_resource (r) { +if (!list_empty (&r->ctrl_domains)) +return true; + } + +for_each_mon_capable_rdt_resource (r) { +if (!list_empty (&r->mon_domains)) +return true; + } + +return false; +} + +/* +* resctrl_exit() - Remove the resctrl filesystem and free resources. +* +* When called by the architecture code, all CPUs and resctrl domains must be +* offline. This ensures the limbo and overflow handlers are not scheduled to +* run, meaning the data structures they access can be freed by +* resctrl_mon_resource_exit(). +*/ void __exit resctrl_exit(void) { +cpus_read_lock (); +WARN_ON_ONCE (resctrl_online_domains_exist ()); +cpus_read_unlock (); +debugfs_remove_recursive (debugfs_resctrl);unregister_filesystem (&rdt_fs_type);sysfs_remove_mount_point (fs_kobj,"resctrl" );
James Morse
reviewerPATCH v12 8/25 x86/resctrl: resctrl_exit() teardown resctrl but leave the mount point
In reply to James Morseresctrl_exit() was intended for use when the 'resctrl' module was unloaded. resctrl can't be built as a module, and the kernfs helpers are not exported so this is unlikely to change. MPAM has an error interrupt which indicates the MPAM driver has gone haywire. Should this occur tasks could run with the wrong control values, leading to bad performance for important tasks. In this scenario the MPAM driver will reset the hardware, but it needs a way to tell resctrl that no further configuration should be attempted.
In particular, moving tasks between control or monitor groups does not interact with the architecture code, so there is no opportunity for the arch code to indicate that the hardware is no-longer functioning.
Using resctrl_exit() for this leaves the system in a funny state as resctrl is still mounted, but cannot be un-mounted because the sysfs directory that is typically used has been removed. Dave Martin suggests this may cause systemd trouble in the future as not all filesystems can be unmounted.
Add calls to remove all the files and directories in resctrl, and remove the sysfs_remove_mount_point() call that leaves the system in a funny state. When triggered, this causes all the resctrl files to disappear. resctrl can be unmounted, but not mounted again.
---
Changes since v9:
* Removed 'this function' from a comment, added the missing word 'errno'.
Changes since v8:
* Call resctrl_fs_teardown() under cpuhp lock, for good measure.
* Set debugfs_resctrl to NULL to be robust against a second call.
* Added more documentation commentary.
* Moved some words around to change the tone.
Changes since v7:
* Moved kernfs cleanup functions to resctrl_fs_teardown(), and call this from rescrl_exit().
* Added description of MPAM resetting the hardware to the commit message.
Changes since v6:
* Added kdoc and comment to resctrl_exit().
Changes since v5:
* Serialise rdtgroup_destroy_root() against umount().
* Check rdtgroup_default.kn to protect against duplicate calls.
--- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 48 +++++++++++++++++++++----- 1 file changed, 40 insertions(+), 8 deletions(-)
arch/x86/kernel/cpu/resctrl/rdtgroup.c +40 -8
@@ -3078,6 +3078,22 @@ static void rmdir_all_sub(void)kernfs_remove (kn_mondata); } +static void resctrl_fs_teardown (void ) +{ +lockdep_assert_held (&rdtgroup_mutex); + +/* Cleared by rdtgroup_destroy_root() */ +if (!rdtgroup_default.kn) +return ; + +rmdir_all_sub (); +rdt_pseudo_lock_release (); + rdtgroup_default.mode =RDT_MODE_SHAREABLE ; +closid_exit (); +schemata_list_destroy (); +rdtgroup_destroy_root (); +} +static void rdt_kill_sb (struct super_block *sb) {struct rdt_resource *r;
@@ -3091,12 +3107,7 @@ static void rdt_kill_sb(struct super_block *sb)for_each_alloc_capable_rdt_resource (r)resctrl_arch_reset_all_ctrls (r); -rmdir_all_sub (); -rdt_pseudo_lock_release (); - rdtgroup_default.mode =RDT_MODE_SHAREABLE ; -closid_exit (); -schemata_list_destroy (); -rdtgroup_destroy_root (); +resctrl_fs_teardown ();if (resctrl_arch_alloc_capable ())resctrl_arch_disable_alloc ();if (resctrl_arch_mon_capable ())
@@ -4127,6 +4138,8 @@ static int rdtgroup_setup_root(struct rdt_fs_context *ctx)static void rdtgroup_destroy_root (void ) { +lockdep_assert_held (&rdtgroup_mutex); +kernfs_destroy_root (rdt_root); rdtgroup_default.kn =NULL ; }
@@ -4441,23 +4454,42 @@ static bool __exit resctrl_online_domains_exist(void)return false; } -/* +/** * resctrl_exit() - Remove the resctrl filesystem and free resources. * +* Called by the architecture code in response to a fatal error. +* Removes resctrl files and structures from kernfs to prevent further +* configuration. +* * When called by the architecture code, all CPUs and resctrl domains must be * offline. This ensures the limbo and overflow handlers are not scheduled to * run, meaning the data structures they access can be freed by * resctrl_mon_resource_exit(). +* +* After resctrl_exit() returns, the architecture code should return an +* error from all resctrl_arch_ functions that can do this. +* resctrl_arch_get_resource() must continue to return struct rdt_resources +* with the correct rid field to ensure the filesystem can be unmounted. */ void __exit resctrl_exit(void) {cpus_read_lock ();WARN_ON_ONCE (resctrl_online_domains_exist ()); + +mutex_lock (&rdtgroup_mutex); +resctrl_fs_teardown (); +mutex_unlock (&rdtgroup_mutex); +cpus_read_unlock ();debugfs_remove_recursive (debugfs_resctrl); + debugfs_resctrl =NULL ;unregister_filesystem (&rdt_fs_type); -sysfs_remove_mount_point (fs_kobj,"resctrl" ); + +/* +* Do not remove the sysfs mount point added by resctrl_init() so that +* it can be used to umount resctrl. +*/ resctrl_mon_resource_exit (); }
Signature · 1 line
2.39.5
[tip: x86/cache] x86/resctrl: Resctrl_exit() teardown resctrl but leave the mount point
The following commit has been merged into the x86/cache branch of tip:
The following commit has been merged into the x86/cache branch of tip:
Commit-ID: 8c992e24a0627a6ba508184c07766862c8bb3e54 Gitweb: https://git.kernel.org/tip/8c992e24a0627a6ba508184c07766862c8bb3e54 Author: James Morse <[email protected]> AuthorDate: Thu, 15 May 2025 16:58:38 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Thu, 15 May 2025 21:04:49 +02:00
x86/resctrl: Resctrl_exit() teardown resctrl but leave the mount point
resctrl_exit() was intended for use when the 'resctrl' module was unloaded. resctrl can't be built as a module, and the kernfs helpers are not exported so this is unlikely to change. MPAM has an error interrupt which indicates the MPAM driver has gone haywire. Should this occur tasks could run with the wrong control values, leading to bad performance for important tasks. In this scenario the MPAM driver will reset the hardware, but it needs a way to tell resctrl that no further configuration should be attempted.
In particular, moving tasks between control or monitor groups does not interact with the architecture code, so there is no opportunity for the arch code to indicate that the hardware is no-longer functioning.
Using resctrl_exit() for this leaves the system in a funny state as resctrl is still mounted, but cannot be un-mounted because the sysfs directory that is typically used has been removed. Dave Martin suggests this may cause systemd trouble in the future as not all filesystems can be unmounted.
Add calls to remove all the files and directories in resctrl, and remove the sysfs_remove_mount_point() call that leaves the system in a funny state. When triggered, this causes all the resctrl files to disappear. resctrl can be unmounted, but not mounted again.
--- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 48 ++++++++++++++++++++----- 1 file changed, 40 insertions(+), 8 deletions(-)
arch/x86/kernel/cpu/resctrl/rdtgroup.c +40 -8
@@ -3078,6 +3078,22 @@ static void rmdir_all_sub(void)kernfs_remove (kn_mondata); } +static void resctrl_fs_teardown (void ) +{ +lockdep_assert_held (&rdtgroup_mutex); + +/* Cleared by rdtgroup_destroy_root() */ +if (!rdtgroup_default.kn) +return ; + +rmdir_all_sub (); +rdt_pseudo_lock_release (); + rdtgroup_default.mode =RDT_MODE_SHAREABLE ; +closid_exit (); +schemata_list_destroy (); +rdtgroup_destroy_root (); +} +static void rdt_kill_sb (struct super_block *sb) {struct rdt_resource *r;
@@ -3091,12 +3107,7 @@ static void rdt_kill_sb(struct super_block *sb)for_each_alloc_capable_rdt_resource (r)resctrl_arch_reset_all_ctrls (r); -rmdir_all_sub (); -rdt_pseudo_lock_release (); - rdtgroup_default.mode =RDT_MODE_SHAREABLE ; -closid_exit (); -schemata_list_destroy (); -rdtgroup_destroy_root (); +resctrl_fs_teardown ();if (resctrl_arch_alloc_capable ())resctrl_arch_disable_alloc ();if (resctrl_arch_mon_capable ())
@@ -4127,6 +4138,8 @@ static int rdtgroup_setup_root(struct rdt_fs_context *ctx)static void rdtgroup_destroy_root (void ) { +lockdep_assert_held (&rdtgroup_mutex); +kernfs_destroy_root (rdt_root); rdtgroup_default.kn =NULL ; }
@@ -4441,23 +4454,42 @@ static bool __exit resctrl_online_domains_exist(void)return false; } -/* +/** * resctrl_exit() - Remove the resctrl filesystem and free resources. * +* Called by the architecture code in response to a fatal error. +* Removes resctrl files and structures from kernfs to prevent further +* configuration. +* * When called by the architecture code, all CPUs and resctrl domains must be * offline. This ensures the limbo and overflow handlers are not scheduled to * run, meaning the data structures they access can be freed by * resctrl_mon_resource_exit(). +* +* After resctrl_exit() returns, the architecture code should return an +* error from all resctrl_arch_ functions that can do this. +* resctrl_arch_get_resource() must continue to return struct rdt_resources +* with the correct rid field to ensure the filesystem can be unmounted. */ void __exit resctrl_exit(void) {cpus_read_lock ();WARN_ON_ONCE (resctrl_online_domains_exist ()); + +mutex_lock (&rdtgroup_mutex); +resctrl_fs_teardown (); +mutex_unlock (&rdtgroup_mutex); +cpus_read_unlock ();debugfs_remove_recursive (debugfs_resctrl); + debugfs_resctrl =NULL ;unregister_filesystem (&rdt_fs_type); -sysfs_remove_mount_point (fs_kobj,"resctrl" ); + +/* +* Do not remove the sysfs mount point added by resctrl_init() so that +* it can be used to umount resctrl. +*/ resctrl_mon_resource_exit (); }
James Morse
reviewerPATCH v12 9/25 x86/resctrl: Drop __init/__exit on assorted symbols
In reply to James MorseBecause ARM's MPAM controls are probed using MMIO, resctrl can't be initialised until enough CPUs are online to have determined the system-wide supported num_closid. Arm64 also supports 'late onlined secondaries', where only a subset of CPUs are online during boot.
These two combine to mean the MPAM driver may not be able to initialise resctrl until user-space has brought 'enough' CPUs online.
To allow MPAM to initialise resctrl after __init text has been free'd, remove all the __init markings from resctrl.
The existing __exit markings cause these functions to be removed by the linker as it has never been possible to build resctrl as a module. MPAM has an error interrupt which causes the driver to reset and disable itself. Remove the __exit markings to allow the MPAM driver to tear down resctrl when an error occurs.
---
Changes since v8:
* Removed __exit from a new symbol.
Changes since v4:
* Earlier __init marker removal migrated here.
--- arch/x86/kernel/cpu/resctrl/core.c | 6 +++--- arch/x86/kernel/cpu/resctrl/internal.h | 4 ++-- arch/x86/kernel/cpu/resctrl/monitor.c | 2 +- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 8 ++++---- include/linux/resctrl.h | 6 +++--- 5 files changed, 13 insertions(+), 13 deletions(-)
arch/x86/kernel/cpu/resctrl/core.c +3 -3
@@ -737,7 +737,7 @@ struct rdt_options {bool force_off, force_on; }; -static struct rdt_options rdt_options[]__initdata = { +static struct rdt_options rdt_options[]__ro_after_init = {RDT_OPT (RDT_FLAG_CMT ,"cmt" ,X86_FEATURE_CQM_OCCUP_LLC ),RDT_OPT (RDT_FLAG_MBM_TOTAL ,"mbmtotal" ,X86_FEATURE_CQM_MBM_TOTAL ),RDT_OPT (RDT_FLAG_MBM_LOCAL ,"mbmlocal" ,X86_FEATURE_CQM_MBM_LOCAL ),
@@ -777,7 +777,7 @@ static int __init set_rdt_options(char *str) }__setup ("rdt" , set_rdt_options); -bool __init rdt_cpu_has (int flag) +bool rdt_cpu_has (int flag) {bool ret =boot_cpu_has (flag);struct rdt_options *o;
@@ -797,7 +797,7 @@ bool __init rdt_cpu_has(int flag)return ret; } -__init bool resctrl_arch_is_evt_configurable (enum resctrl_event_id evt) +bool resctrl_arch_is_evt_configurable (enum resctrl_event_id evt) {if (!rdt_cpu_has (X86_FEATURE_BMEC ))return false;
arch/x86/kernel/cpu/resctrl/internal.h +2 -2
@@ -472,13 +472,13 @@ int alloc_rmid(u32 closid);void free_rmid (u32 closid,u32 rmid);int rdt_get_mon_l3_config (struct rdt_resource *r);void resctrl_mon_resource_exit (void ); -bool __init rdt_cpu_has (int flag); +bool rdt_cpu_has (int flag);void mon_event_count (void *info);int rdtgroup_mondata_show (struct seq_file *m,void *arg);void mon_event_read (struct rmid_read *rr,struct rdt_resource *r,struct rdt_mon_domain *d,struct rdtgroup *rdtgrp,cpumask_t *cpumask,int evtid,int first); -int __init resctrl_mon_resource_init (void ); +int resctrl_mon_resource_init (void );void mbm_setup_overflow_handler (struct rdt_mon_domain *dom,unsigned long delay_ms,int exclude_cpu);
arch/x86/kernel/cpu/resctrl/monitor.c +1 -1
@@ -1204,7 +1204,7 @@ static __init int snc_get_config(void)* * Returns 0 for success, or -ENOMEM. */ -int __init resctrl_mon_resource_init (void ) +int resctrl_mon_resource_init (void ) {struct rdt_resource *r =resctrl_arch_get_resource (RDT_RESOURCE_L3 );int ret;
arch/x86/kernel/cpu/resctrl/rdtgroup.c +4 -4
@@ -4144,7 +4144,7 @@ static void rdtgroup_destroy_root(void) rdtgroup_default.kn =NULL ; } -static void __init rdtgroup_setup_default (void ) +static void rdtgroup_setup_default (void ) {mutex_lock (&rdtgroup_mutex);
@@ -4376,7 +4376,7 @@ void resctrl_offline_cpu(unsigned int cpu)* * Return: 0 on success or -errno */ -int __init resctrl_init (void ) +int resctrl_init (void ) {int ret =0 ;
@@ -4433,7 +4433,7 @@ int __init resctrl_init(void)return ret; } -static bool __exit resctrl_online_domains_exist(void) +static bool resctrl_online_domains_exist (void ) {struct rdt_resource *r;
@@ -4471,7 +4471,7 @@ static bool __exit resctrl_online_domains_exist(void)* resctrl_arch_get_resource() must continue to return struct rdt_resources * with the correct rid field to ensure the filesystem can be unmounted. */ -void __exit resctrl_exit(void) +void resctrl_exit (void ) {cpus_read_lock ();WARN_ON_ONCE (resctrl_online_domains_exist ());
include/linux/resctrl.h +3 -3
@@ -358,7 +358,7 @@ u32 resctrl_arch_get_num_closid(struct rdt_resource *r);u32 resctrl_arch_system_num_rmid_idx (void );int resctrl_arch_update_domains (struct rdt_resource *r,u32 closid); -__init bool resctrl_arch_is_evt_configurable (enum resctrl_event_id evt); +bool resctrl_arch_is_evt_configurable (enum resctrl_event_id evt);/** * resctrl_arch_mon_event_config_write() - Write the config for an event.
@@ -514,7 +514,7 @@ void resctrl_arch_reset_all_ctrls(struct rdt_resource *r);extern unsigned int resctrl_rmid_realloc_threshold;extern unsigned int resctrl_rmid_realloc_limit; -int __init resctrl_init (void ); -void __exit resctrl_exit(void); +int resctrl_init (void ); +void resctrl_exit (void );#endif /* _RESCTRL_H */
Signature · 1 line
2.39.5
[tip: x86/cache] x86/resctrl: Drop __init/__exit on assorted symbols
The following commit has been merged into the x86/cache branch of tip:
The following commit has been merged into the x86/cache branch of tip:
Commit-ID: bc740420d7ae7878696d5ad9f3dbcb11e2599b2e Gitweb: https://git.kernel.org/tip/bc740420d7ae7878696d5ad9f3dbcb11e2599b2e Author: James Morse <[email protected]> AuthorDate: Thu, 15 May 2025 16:58:39 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Thu, 15 May 2025 21:06:02 +02:00
x86/resctrl: Drop __init/__exit on assorted symbols
Because ARM's MPAM controls are probed using MMIO, resctrl can't be initialised until enough CPUs are online to have determined the system-wide supported num_closid. Arm64 also supports 'late onlined secondaries', where only a subset of CPUs are online during boot.
These two combine to mean the MPAM driver may not be able to initialise resctrl until user-space has brought 'enough' CPUs online.
To allow MPAM to initialise resctrl after __init text has been free'd, remove all the __init markings from resctrl.
The existing __exit markings cause these functions to be removed by the linker as it has never been possible to build resctrl as a module. MPAM has an error interrupt which causes the driver to reset and disable itself. Remove the __exit markings to allow the MPAM driver to tear down resctrl when an error occurs.
--- arch/x86/kernel/cpu/resctrl/core.c | 6 +++--- arch/x86/kernel/cpu/resctrl/internal.h | 4 ++-- arch/x86/kernel/cpu/resctrl/monitor.c | 2 +- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 8 ++++---- include/linux/resctrl.h | 6 +++--- 5 files changed, 13 insertions(+), 13 deletions(-)
arch/x86/kernel/cpu/resctrl/core.c +3 -3
@@ -737,7 +737,7 @@ struct rdt_options {bool force_off, force_on; }; -static struct rdt_options rdt_options[]__initdata = { +static struct rdt_options rdt_options[]__ro_after_init = {RDT_OPT (RDT_FLAG_CMT ,"cmt" ,X86_FEATURE_CQM_OCCUP_LLC ),RDT_OPT (RDT_FLAG_MBM_TOTAL ,"mbmtotal" ,X86_FEATURE_CQM_MBM_TOTAL ),RDT_OPT (RDT_FLAG_MBM_LOCAL ,"mbmlocal" ,X86_FEATURE_CQM_MBM_LOCAL ),
@@ -777,7 +777,7 @@ static int __init set_rdt_options(char *str) }__setup ("rdt" , set_rdt_options); -bool __init rdt_cpu_has (int flag) +bool rdt_cpu_has (int flag) {bool ret =boot_cpu_has (flag);struct rdt_options *o;
@@ -797,7 +797,7 @@ bool __init rdt_cpu_has(int flag)return ret; } -__init bool resctrl_arch_is_evt_configurable (enum resctrl_event_id evt) +bool resctrl_arch_is_evt_configurable (enum resctrl_event_id evt) {if (!rdt_cpu_has (X86_FEATURE_BMEC ))return false;
arch/x86/kernel/cpu/resctrl/internal.h +2 -2
@@ -472,13 +472,13 @@ int alloc_rmid(u32 closid);void free_rmid (u32 closid,u32 rmid);int rdt_get_mon_l3_config (struct rdt_resource *r);void resctrl_mon_resource_exit (void ); -bool __init rdt_cpu_has (int flag); +bool rdt_cpu_has (int flag);void mon_event_count (void *info);int rdtgroup_mondata_show (struct seq_file *m,void *arg);void mon_event_read (struct rmid_read *rr,struct rdt_resource *r,struct rdt_mon_domain *d,struct rdtgroup *rdtgrp,cpumask_t *cpumask,int evtid,int first); -int __init resctrl_mon_resource_init (void ); +int resctrl_mon_resource_init (void );void mbm_setup_overflow_handler (struct rdt_mon_domain *dom,unsigned long delay_ms,int exclude_cpu);
arch/x86/kernel/cpu/resctrl/monitor.c +1 -1
@@ -1204,7 +1204,7 @@ static __init int snc_get_config(void)* * Returns 0 for success, or -ENOMEM. */ -int __init resctrl_mon_resource_init (void ) +int resctrl_mon_resource_init (void ) {struct rdt_resource *r =resctrl_arch_get_resource (RDT_RESOURCE_L3 );int ret;
arch/x86/kernel/cpu/resctrl/rdtgroup.c +4 -4
@@ -4144,7 +4144,7 @@ static void rdtgroup_destroy_root(void) rdtgroup_default.kn =NULL ; } -static void __init rdtgroup_setup_default (void ) +static void rdtgroup_setup_default (void ) {mutex_lock (&rdtgroup_mutex);
@@ -4376,7 +4376,7 @@ out_unlock:* * Return: 0 on success or -errno */ -int __init resctrl_init (void ) +int resctrl_init (void ) {int ret =0 ;
@@ -4433,7 +4433,7 @@ cleanup_mountpoint:return ret; } -static bool __exit resctrl_online_domains_exist(void) +static bool resctrl_online_domains_exist (void ) {struct rdt_resource *r;
@@ -4471,7 +4471,7 @@ static bool __exit resctrl_online_domains_exist(void)* resctrl_arch_get_resource() must continue to return struct rdt_resources * with the correct rid field to ensure the filesystem can be unmounted. */ -void __exit resctrl_exit(void) +void resctrl_exit (void ) {cpus_read_lock ();WARN_ON_ONCE (resctrl_online_domains_exist ());
include/linux/resctrl.h +3 -3
@@ -358,7 +358,7 @@ u32 resctrl_arch_get_num_closid(struct rdt_resource *r);u32 resctrl_arch_system_num_rmid_idx (void );int resctrl_arch_update_domains (struct rdt_resource *r,u32 closid); -__init bool resctrl_arch_is_evt_configurable (enum resctrl_event_id evt); +bool resctrl_arch_is_evt_configurable (enum resctrl_event_id evt);/** * resctrl_arch_mon_event_config_write() - Write the config for an event.
@@ -514,7 +514,7 @@ void resctrl_arch_reset_all_ctrls(struct rdt_resource *r);extern unsigned int resctrl_rmid_realloc_threshold;extern unsigned int resctrl_rmid_realloc_limit; -int __init resctrl_init (void ); -void __exit resctrl_exit(void); +int resctrl_init (void ); +void resctrl_exit (void );#endif /* _RESCTRL_H */
James Morse
reviewerPATCH v12 10/25 x86/resctrl: Move is_mba_sc() out of core.c
In reply to James Morseis_mba_sc() is defined in core.c, but has no callers there. It does not access any architecture private structures.
Move this to rdtgroup.c where the majority of callers are. This makes the move of the filesystem code to /fs/ cleaner.
---
Changes since v2:
* This patch is new.
--- arch/x86/kernel/cpu/resctrl/core.c | 15 --------------- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 15 deletions(-)
arch/x86/kernel/cpu/resctrl/core.c +0 -15
@@ -164,21 +164,6 @@ static inline void cache_alloc_hsw_probe(void) rdt_alloc_capable = true; } -bool is_mba_sc (struct rdt_resource *r) -{ -if (!r) - r =resctrl_arch_get_resource (RDT_RESOURCE_MBA ); - -/* -* The software controller support is only applicable to MBA resource. -* Make sure to check for resource type. -*/ -if (r->rid !=RDT_RESOURCE_MBA ) -return false; - -return r->membw.mba_sc; -} -/* * rdt_get_mb_table() - get a mapping of bandwidth(b/w) percentage values * exposed to user interface and the h/w understandable delay values.
arch/x86/kernel/cpu/resctrl/rdtgroup.c +15 -0
@@ -1535,6 +1535,21 @@ unsigned int rdtgroup_cbm_to_size(struct rdt_resource *r,return size; } +bool is_mba_sc (struct rdt_resource *r) +{ +if (!r) + r =resctrl_arch_get_resource (RDT_RESOURCE_MBA ); + +/* +* The software controller support is only applicable to MBA resource. +* Make sure to check for resource type. +*/ +if (r->rid !=RDT_RESOURCE_MBA ) +return false; + +return r->membw.mba_sc; +} +/* * rdtgroup_size_show - Display size in bytes of allocated regions *
Signature · 1 line
2.39.5
[tip: x86/cache] x86/resctrl: Move is_mba_sc() out of core.c
The following commit has been merged into the x86/cache branch of tip:
The following commit has been merged into the x86/cache branch of tip:
Commit-ID: 6c72fb8d8bd7bfaafdeda3a91c535ecf52283ec9 Gitweb: https://git.kernel.org/tip/6c72fb8d8bd7bfaafdeda3a91c535ecf52283ec9 Author: James Morse <[email protected]> AuthorDate: Thu, 15 May 2025 16:58:40 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Fri, 16 May 2025 10:06:45 +02:00
x86/resctrl: Move is_mba_sc() out of core.c
is_mba_sc() is defined in core.c, but has no callers there. It does not access any architecture private structures.
Move this to rdtgroup.c where the majority of callers are. This makes the move of the filesystem code to /fs/ cleaner.
--- arch/x86/kernel/cpu/resctrl/core.c | 15 --------------- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 15 deletions(-)
arch/x86/kernel/cpu/resctrl/core.c +0 -15
@@ -164,21 +164,6 @@ static inline void cache_alloc_hsw_probe(void) rdt_alloc_capable = true; } -bool is_mba_sc (struct rdt_resource *r) -{ -if (!r) - r =resctrl_arch_get_resource (RDT_RESOURCE_MBA ); - -/* -* The software controller support is only applicable to MBA resource. -* Make sure to check for resource type. -*/ -if (r->rid !=RDT_RESOURCE_MBA ) -return false; - -return r->membw.mba_sc; -} -/* * rdt_get_mb_table() - get a mapping of bandwidth(b/w) percentage values * exposed to user interface and the h/w understandable delay values.
arch/x86/kernel/cpu/resctrl/rdtgroup.c +15 -0
@@ -1535,6 +1535,21 @@ unsigned int rdtgroup_cbm_to_size(struct rdt_resource *r,return size; } +bool is_mba_sc (struct rdt_resource *r) +{ +if (!r) + r =resctrl_arch_get_resource (RDT_RESOURCE_MBA ); + +/* +* The software controller support is only applicable to MBA resource. +* Make sure to check for resource type. +*/ +if (r->rid !=RDT_RESOURCE_MBA ) +return false; + +return r->membw.mba_sc; +} +/* * rdtgroup_size_show - Display size in bytes of allocated regions *
James Morse
reviewerPATCH v12 11/25 x86/resctrl: Add end-marker to the resctrl_event_id enum
In reply to James MorseThe resctrl_event_id enum gives names to the counter event numbers on x86. These are used directly by resctrl.
To allow the MPAM driver to keep an array of these the size of the enum needs to be known.
Add a 'num_events' enum entry which can be used to size an array. This is added to the enum to reduce conflicts with another series, which in turn requires get_arch_mbm_state() to have a default case.
---
Changes since v8:
* Move the last marker into the enum and add a default case.
--- arch/x86/kernel/cpu/resctrl/monitor.c | 9 ++++----- include/linux/resctrl_types.h | 3 +++ 2 files changed, 7 insertions(+), 5 deletions(-)
arch/x86/kernel/cpu/resctrl/monitor.c +4 -5
@@ -260,12 +260,11 @@ static struct arch_mbm_state *get_arch_mbm_state(struct rdt_hw_mon_domain *hw_doreturn &hw_dom->arch_mbm_total[rmid];case QOS_L3_MBM_LOCAL_EVENT_ID :return &hw_dom->arch_mbm_local[rmid]; +default : +/* Never expect to get here */ +WARN_ON_ONCE (1 ); +return NULL ; } - -/* Never expect to get here */ -WARN_ON_ONCE (1 ); - -return NULL ; } void resctrl_arch_reset_rmid(struct rdt_resource *r, struct rdt_mon_domain *d,
include/linux/resctrl_types.h +3 -0
@@ -49,6 +49,9 @@ enum resctrl_event_id {QOS_L3_OCCUP_EVENT_ID =0x01 ,QOS_L3_MBM_TOTAL_EVENT_ID =0x02 ,QOS_L3_MBM_LOCAL_EVENT_ID =0x03 , + +/* Must be the last */ + QOS_NUM_EVENTS, };#endif /* __LINUX_RESCTRL_TYPES_H */
Signature · 1 line
2.39.5
[tip: x86/cache] x86/resctrl: Add end-marker to the resctrl_event_id enum
The following commit has been merged into the x86/cache branch of tip:
The following commit has been merged into the x86/cache branch of tip:
Commit-ID: d4fb6b8e4640adeff9673ae398525be7382d3197 Gitweb: https://git.kernel.org/tip/d4fb6b8e4640adeff9673ae398525be7382d3197 Author: James Morse <[email protected]> AuthorDate: Thu, 15 May 2025 16:58:41 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Fri, 16 May 2025 10:44:36 +02:00
x86/resctrl: Add end-marker to the resctrl_event_id enum
The resctrl_event_id enum gives names to the counter event numbers on x86. These are used directly by resctrl.
To allow the MPAM driver to keep an array of these the size of the enum needs to be known.
Add a 'num_events' enum entry which can be used to size an array. This is added to the enum to reduce conflicts with another series, which in turn requires get_arch_mbm_state() to have a default case.
--- arch/x86/kernel/cpu/resctrl/monitor.c | 9 ++++----- include/linux/resctrl_types.h | 3 +++ 2 files changed, 7 insertions(+), 5 deletions(-)
arch/x86/kernel/cpu/resctrl/monitor.c +4 -5
@@ -260,12 +260,11 @@ static struct arch_mbm_state *get_arch_mbm_state(struct rdt_hw_mon_domain *hw_doreturn &hw_dom->arch_mbm_total[rmid];case QOS_L3_MBM_LOCAL_EVENT_ID :return &hw_dom->arch_mbm_local[rmid]; +default : +/* Never expect to get here */ +WARN_ON_ONCE (1 ); +return NULL ; } - -/* Never expect to get here */ -WARN_ON_ONCE (1 ); - -return NULL ; } void resctrl_arch_reset_rmid(struct rdt_resource *r, struct rdt_mon_domain *d,
include/linux/resctrl_types.h +3 -0
@@ -49,6 +49,9 @@ enum resctrl_event_id {QOS_L3_OCCUP_EVENT_ID =0x01 ,QOS_L3_MBM_TOTAL_EVENT_ID =0x02 ,QOS_L3_MBM_LOCAL_EVENT_ID =0x03 , + +/* Must be the last */ + QOS_NUM_EVENTS, };#endif /* __LINUX_RESCTRL_TYPES_H */
James Morse
reviewerPATCH v12 12/25 x86/resctrl: Expand the width of domid by replacing mon_data_bits
In reply to James MorseMPAM platforms retrieve the cache-id property from the ACPI PPTT table. The cache-id field is 32 bits wide. Under resctrl, the cache-id becomes the domain-id, and is packed into the mon_data_bits union bitfield. The width of cache-id in this field is 14 bits.
Expanding the union would break 32bit x86 platforms as this union is stored as the kernfs kn->priv pointer. This saved allocating memory for the priv data storage.
The firmware on MPAM platforms have used the PPTT cache-id field to expose the interconnect's id for the cache, which is sparse and uses more than 14 bits. Use of this id is to enable PCIe direct cache injection hints. Using this feature with VFIO means the value provided by the ACPI table should be exposed to user-space.
To support cache-id values greater than 14 bits, convert the mon_data_bits union to a structure. These are shared between control and monitor groups, and are allocated on first use. The list of allocated struct mon_data is free'd when the filesystem is umount()ed.
---
Previously the MPAM tree repainted the cache-id to compact them, argue-ing there was no other user. With VFIO use of this PCIe feature, this is no longer an option.
Changes since v9:
* Used more specific enum types for resid/rid and evtid.
Changes since v8:
* Removed underscore in dom_id in the patch subject.
* Change types in struct mon_data to match the data.
* Renamed the global list to be more descriptive.
* Numerous comments were clarified.
Changes since v7:
* Replaced with Tony Luck's list based version.
Changes since v6:
* Added the get/put helpers.
* Special case the creation of the mondata files for the default control group.
* Removed wording about files living longer than expected, the corresponding error handling is wrapped in WARN_ON_ONCE() as this indicates a bug.
--- arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 24 ++++--- arch/x86/kernel/cpu/resctrl/internal.h | 39 ++++++----- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 79 +++++++++++++++++++++-- 3 files changed, 106 insertions(+), 36 deletions(-)
arch/x86/kernel/cpu/resctrl/ctrlmondata.c +15 -9
@@ -661,14 +661,15 @@ void mon_event_read(struct rmid_read *rr, struct rdt_resource *r,int rdtgroup_mondata_show (struct seq_file *m,void *arg) {struct kernfs_open_file *of = m->private; +enum resctrl_res_level resid; +enum resctrl_event_id evtid;struct rdt_domain_hdr *hdr;struct rmid_read rr = {0 };struct rdt_mon_domain *d; -u32 resid, evtid, domid;struct rdtgroup *rdtgrp;struct rdt_resource *r; -union mon_data_bits md; -int ret =0 ; +struct mon_data *md; +int domid, ret =0 ; rdtgrp =rdtgroup_kn_lock_live (of->kn);if (!rdtgrp) {
@@ -676,17 +677,22 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg) goto out; } - md.priv = of->kn->priv; - resid = md.u.rid; - domid = md.u.domid; - evtid = md.u.evtid; + md = of->kn->priv; +if (WARN_ON_ONCE (!md)) { + ret = -EIO ; + goto out; + } + + resid = md->rid; + domid = md->domid; + evtid = md->evtid; r =resctrl_arch_get_resource (resid); -if (md.u.sum) { +if (md->sum) {/* * This file requires summing across all domains that share * the L3 cache id that was provided in the "domid" field of the -* mon_data_bits union. Search all domains in the resource for +* struct mon_data. Search all domains in the resource for * one that matches this cache id. */ list_for_each_entry (d, &r->mon_domains, hdr.list) {
arch/x86/kernel/cpu/resctrl/internal.h +19 -20
@@ -89,27 +89,26 @@ struct mon_evt { };/** -* union mon_data_bits - Monitoring details for each event file. -* @priv: Used to store monitoring event data in @u -* as kernfs private data. -* @u.rid: Resource id associated with the event file. -* @u.evtid: Event id associated with the event file. -* @u.sum: Set when event must be summed across multiple -* domains. -* @u.domid: When @u.sum is zero this is the domain to which -* the event file belongs. When @sum is one this -* is the id of the L3 cache that all domains to be -* summed share. -* @u: Name of the bit fields struct. +* struct mon_data - Monitoring details for each event file. +* @list: Member of the global @mon_data_kn_priv_list list. +* @rid: Resource id associated with the event file. +* @evtid: Event id associated with the event file. +* @sum: Set when event must be summed across multiple +* domains. +* @domid: When @sum is zero this is the domain to which +* the event file belongs. When @sum is one this +* is the id of the L3 cache that all domains to be +* summed share. +* +* Pointed to by the kernfs kn->priv field of monitoring event files. +* Readers and writers must hold rdtgroup_mutex. */ -union mon_data_bits { -void *priv; -struct { -unsigned int rid :10 ; -enum resctrl_event_id evtid :7 ; -unsigned int sum :1 ; -unsigned int domid :14 ; - } u; +struct mon_data { +struct list_head list; +enum resctrl_res_level rid; +enum resctrl_event_id evtid; +int domid; +bool sum; };/**
arch/x86/kernel/cpu/resctrl/rdtgroup.c +72 -7
109 lines not on this page · raw message
Signature · 1 line
2.39.5
[tip: x86/cache] x86/resctrl: Expand the width of domid by replacing mon_data_bits
The following commit has been merged into the x86/cache branch of tip:
The following commit has been merged into the x86/cache branch of tip:
Commit-ID: 2a65660385444e9d9deffe995c71ee20443ef76e Gitweb: https://git.kernel.org/tip/2a65660385444e9d9deffe995c71ee20443ef76e Author: James Morse <[email protected]> AuthorDate: Thu, 15 May 2025 16:58:42 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Fri, 16 May 2025 10:46:45 +02:00
x86/resctrl: Expand the width of domid by replacing mon_data_bits
MPAM platforms retrieve the cache-id property from the ACPI PPTT table. The cache-id field is 32 bits wide. Under resctrl, the cache-id becomes the domain-id, and is packed into the mon_data_bits union bitfield. The width of cache-id in this field is 14 bits.
Expanding the union would break 32bit x86 platforms as this union is stored as the kernfs kn->priv pointer. This saved allocating memory for the priv data storage.
The firmware on MPAM platforms have used the PPTT cache-id field to expose the interconnect's id for the cache, which is sparse and uses more than 14 bits. Use of this id is to enable PCIe direct cache injection hints. Using this feature with VFIO means the value provided by the ACPI table should be exposed to user-space.
To support cache-id values greater than 14 bits, convert the mon_data_bits union to a structure. These are shared between control and monitor groups, and are allocated on first use. The list of allocated struct mon_data is free'd when the filesystem is umount()ed.
--- arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 24 ++++--- arch/x86/kernel/cpu/resctrl/internal.h | 39 +++++------ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 79 ++++++++++++++++++++-- 3 files changed, 106 insertions(+), 36 deletions(-)
arch/x86/kernel/cpu/resctrl/ctrlmondata.c +15 -9
@@ -661,14 +661,15 @@ void mon_event_read(struct rmid_read *rr, struct rdt_resource *r,int rdtgroup_mondata_show (struct seq_file *m,void *arg) {struct kernfs_open_file *of = m->private; +enum resctrl_res_level resid; +enum resctrl_event_id evtid;struct rdt_domain_hdr *hdr;struct rmid_read rr = {0 };struct rdt_mon_domain *d; -u32 resid, evtid, domid;struct rdtgroup *rdtgrp;struct rdt_resource *r; -union mon_data_bits md; -int ret =0 ; +struct mon_data *md; +int domid, ret =0 ; rdtgrp =rdtgroup_kn_lock_live (of->kn);if (!rdtgrp) {
@@ -676,17 +677,22 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg) goto out; } - md.priv = of->kn->priv; - resid = md.u.rid; - domid = md.u.domid; - evtid = md.u.evtid; + md = of->kn->priv; +if (WARN_ON_ONCE (!md)) { + ret = -EIO ; + goto out; + } + + resid = md->rid; + domid = md->domid; + evtid = md->evtid; r =resctrl_arch_get_resource (resid); -if (md.u.sum) { +if (md->sum) {/* * This file requires summing across all domains that share * the L3 cache id that was provided in the "domid" field of the -* mon_data_bits union. Search all domains in the resource for +* struct mon_data. Search all domains in the resource for * one that matches this cache id. */ list_for_each_entry (d, &r->mon_domains, hdr.list) {
arch/x86/kernel/cpu/resctrl/internal.h +19 -20
@@ -89,27 +89,26 @@ struct mon_evt { };/** -* union mon_data_bits - Monitoring details for each event file. -* @priv: Used to store monitoring event data in @u -* as kernfs private data. -* @u.rid: Resource id associated with the event file. -* @u.evtid: Event id associated with the event file. -* @u.sum: Set when event must be summed across multiple -* domains. -* @u.domid: When @u.sum is zero this is the domain to which -* the event file belongs. When @sum is one this -* is the id of the L3 cache that all domains to be -* summed share. -* @u: Name of the bit fields struct. +* struct mon_data - Monitoring details for each event file. +* @list: Member of the global @mon_data_kn_priv_list list. +* @rid: Resource id associated with the event file. +* @evtid: Event id associated with the event file. +* @sum: Set when event must be summed across multiple +* domains. +* @domid: When @sum is zero this is the domain to which +* the event file belongs. When @sum is one this +* is the id of the L3 cache that all domains to be +* summed share. +* +* Pointed to by the kernfs kn->priv field of monitoring event files. +* Readers and writers must hold rdtgroup_mutex. */ -union mon_data_bits { -void *priv; -struct { -unsigned int rid :10 ; -enum resctrl_event_id evtid :7 ; -unsigned int sum :1 ; -unsigned int domid :14 ; - } u; +struct mon_data { +struct list_head list; +enum resctrl_res_level rid; +enum resctrl_event_id evtid; +int domid; +bool sum; };/**
arch/x86/kernel/cpu/resctrl/rdtgroup.c +72 -7
109 lines not on this page · raw message
James Morse
reviewerPATCH v12 13/25 x86/resctrl: Split trace.h
In reply to James Morsetrace.h contains all the tracepoints. After the move to /fs/resctrl, some of these will be left behind. All the pseudo_lock tracepoints remain part of the architecture. The lone tracepoint in monitor.c moves to /fs/resctrl.
Split trace.h so that each C file includes a different trace header file. This means the trace header files are not modified when they are moved.
---
arch/x86/kernel/cpu/resctrl/Makefile | 3 ++
arch/x86/kernel/cpu/resctrl/monitor.c | 4 ++-
arch/x86/kernel/cpu/resctrl/monitor_trace.h | 31 +++++++++++++++++++
arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 2 +-
.../resctrl/{trace.h => pseudo_lock_trace.h} | 24 +++-----------
5 files changed, 42 insertions(+), 22 deletions(-)
create mode 100644 arch/x86/kernel/cpu/resctrl/monitor_trace.h
rename arch/x86/kernel/cpu/resctrl/{trace.h => pseudo_lock_trace.h} (56%)arch/x86/kernel/cpu/resctrl/Makefile +3 -0
@@ -2,4 +2,7 @@ obj-$(CONFIG_X86_CPU_RESCTRL) += core.o rdtgroup.o monitor.o obj-$(CONFIG_X86_CPU_RESCTRL) += ctrlmondata.o obj-$(CONFIG_RESCTRL_FS_PSEUDO_LOCK) += pseudo_lock.o + +# To allow define_trace.h's recursive include: CFLAGS_pseudo_lock.o = -I$(src) +CFLAGS_monitor.o = -I$(src)
arch/x86/kernel/cpu/resctrl/monitor.c +3 -1
@@ -26,7 +26,9 @@#include <asm/resctrl.h> #include "internal.h" -#include "trace.h" + +#define CREATE_TRACE_POINTS +#include "monitor_trace.h" /** * struct rmid_entry - dirty tracking for all RMID.
arch/x86/kernel/cpu/resctrl/monitor_trace.h new file +31 -0
@@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM resctrl + +#if !defined(_FS_RESCTRL_MONITOR_TRACE_H) || defined(TRACE_HEADER_MULTI_READ ) +#define _FS_RESCTRL_MONITOR_TRACE_H + +#include <linux/tracepoint.h> + +TRACE_EVENT (mon_llc_occupancy_limbo, + TP_PROTO(u32 ctrl_hw_id, u32 mon_hw_id, int domain_id, u64 llc_occupancy_bytes), +TP_ARGS (ctrl_hw_id, mon_hw_id, domain_id, llc_occupancy_bytes), + TP_STRUCT__entry(__field(u32, ctrl_hw_id) + __field(u32, mon_hw_id) + __field(int, domain_id) +__field (u64, llc_occupancy_bytes)), + TP_fast_assign(__entry->ctrl_hw_id = ctrl_hw_id; + __entry->mon_hw_id = mon_hw_id; + __entry->domain_id = domain_id; + __entry->llc_occupancy_bytes = llc_occupancy_bytes;), +TP_printk ("ctrl_hw_id=%u mon_hw_id=%u domain_id=%d llc_occupancy_bytes=%llu" , + __entry->ctrl_hw_id, __entry->mon_hw_id, __entry->domain_id, + __entry->llc_occupancy_bytes) + ); + +#endif /* _FS_RESCTRL_MONITOR_TRACE_H */ + +#undef TRACE_INCLUDE_PATH +#define TRACE_INCLUDE_PATH . +#define TRACE_INCLUDE_FILE monitor_trace +#include <trace/define_trace.h>
arch/x86/kernel/cpu/resctrl/pseudo_lock.c +1 -1
@@ -30,7 +30,7 @@#include "internal.h" #define CREATE_TRACE_POINTS -#include "trace.h" +#include "pseudo_lock_trace.h" /* * The bits needed to disable hardware prefetching varies based on the
arch/x86/kernel/cpu/resctrl/pseudo_lock_trace.h renamed from arch/x86/kernel/cpu/resctrl/trace.h +4 -20
@@ -2,8 +2,8 @@#undef TRACE_SYSTEM#define TRACE_SYSTEM resctrl -#if !defined(_TRACE_RESCTRL_H) || defined(TRACE_HEADER_MULTI_READ ) -#define _TRACE_RESCTRL_H +#if !defined(_X86_RESCTRL_PSEUDO_LOCK_TRACE_H) || defined(TRACE_HEADER_MULTI_READ ) +#define _X86_RESCTRL_PSEUDO_LOCK_TRACE_H#include <linux/tracepoint.h>
@@ -35,25 +35,9 @@ TRACE_EVENT(pseudo_lock_l3,TP_printk ("hits=%llu miss=%llu" , __entry->l3_hits, __entry->l3_miss)); -TRACE_EVENT (mon_llc_occupancy_limbo, - TP_PROTO(u32 ctrl_hw_id, u32 mon_hw_id, int domain_id, u64 llc_occupancy_bytes), -TP_ARGS (ctrl_hw_id, mon_hw_id, domain_id, llc_occupancy_bytes), - TP_STRUCT__entry(__field(u32, ctrl_hw_id) - __field(u32, mon_hw_id) - __field(int, domain_id) -__field (u64, llc_occupancy_bytes)), - TP_fast_assign(__entry->ctrl_hw_id = ctrl_hw_id; - __entry->mon_hw_id = mon_hw_id; - __entry->domain_id = domain_id; - __entry->llc_occupancy_bytes = llc_occupancy_bytes;), -TP_printk ("ctrl_hw_id=%u mon_hw_id=%u domain_id=%d llc_occupancy_bytes=%llu" , - __entry->ctrl_hw_id, __entry->mon_hw_id, __entry->domain_id, - __entry->llc_occupancy_bytes) - ); - -#endif /* _TRACE_RESCTRL_H */ +#endif /* _X86_RESCTRL_PSEUDO_LOCK_TRACE_H */ #undef TRACE_INCLUDE_PATH#define TRACE_INCLUDE_PATH . -#define TRACE_INCLUDE_FILE trace +#define TRACE_INCLUDE_FILE pseudo_lock_trace#include <trace/define_trace.h>
Signature · 1 line
2.39.5
[tip: x86/cache] x86/resctrl: Split trace.h
The following commit has been merged into the x86/cache branch of tip:
The following commit has been merged into the x86/cache branch of tip:
Commit-ID: 270f00bcc9525c8ba667349ba3e8c4dbcbbf70fb Gitweb: https://git.kernel.org/tip/270f00bcc9525c8ba667349ba3e8c4dbcbbf70fb Author: James Morse <[email protected]> AuthorDate: Thu, 15 May 2025 16:58:43 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Fri, 16 May 2025 10:47:49 +02:00
x86/resctrl: Split trace.h
trace.h contains all the tracepoints. After the move to /fs/resctrl, some of these will be left behind. All the pseudo_lock tracepoints remain part of the architecture. The lone tracepoint in monitor.c moves to /fs/resctrl.
Split trace.h so that each C file includes a different trace header file. This means the trace header files are not modified when they are moved.
--- arch/x86/kernel/cpu/resctrl/Makefile | 3 +- arch/x86/kernel/cpu/resctrl/monitor.c | 4 +- arch/x86/kernel/cpu/resctrl/monitor_trace.h | 31 ++++++++- arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 2 +- arch/x86/kernel/cpu/resctrl/pseudo_lock_trace.h | 43 ++++++++++++- arch/x86/kernel/cpu/resctrl/trace.h | 59 +---------------- 6 files changed, 81 insertions(+), 61 deletions(-) create mode 100644 arch/x86/kernel/cpu/resctrl/monitor_trace.h create mode 100644 arch/x86/kernel/cpu/resctrl/pseudo_lock_trace.h delete mode 100644 arch/x86/kernel/cpu/resctrl/trace.h
arch/x86/kernel/cpu/resctrl/Makefile +3 -0
@@ -2,4 +2,7 @@ obj-$(CONFIG_X86_CPU_RESCTRL) += core.o rdtgroup.o monitor.o obj-$(CONFIG_X86_CPU_RESCTRL) += ctrlmondata.o obj-$(CONFIG_RESCTRL_FS_PSEUDO_LOCK) += pseudo_lock.o + +# To allow define_trace.h's recursive include: CFLAGS_pseudo_lock.o = -I$(src) +CFLAGS_monitor.o = -I$(src)
arch/x86/kernel/cpu/resctrl/monitor.c +3 -1
@@ -26,7 +26,9 @@#include <asm/resctrl.h> #include "internal.h" -#include "trace.h" + +#define CREATE_TRACE_POINTS +#include "monitor_trace.h" /** * struct rmid_entry - dirty tracking for all RMID.
arch/x86/kernel/cpu/resctrl/monitor_trace.h new file +31 -0
@@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM resctrl + +#if !defined(_FS_RESCTRL_MONITOR_TRACE_H) || defined(TRACE_HEADER_MULTI_READ ) +#define _FS_RESCTRL_MONITOR_TRACE_H + +#include <linux/tracepoint.h> + +TRACE_EVENT (mon_llc_occupancy_limbo, + TP_PROTO(u32 ctrl_hw_id, u32 mon_hw_id, int domain_id, u64 llc_occupancy_bytes), +TP_ARGS (ctrl_hw_id, mon_hw_id, domain_id, llc_occupancy_bytes), + TP_STRUCT__entry(__field(u32, ctrl_hw_id) + __field(u32, mon_hw_id) + __field(int, domain_id) +__field (u64, llc_occupancy_bytes)), + TP_fast_assign(__entry->ctrl_hw_id = ctrl_hw_id; + __entry->mon_hw_id = mon_hw_id; + __entry->domain_id = domain_id; + __entry->llc_occupancy_bytes = llc_occupancy_bytes;), +TP_printk ("ctrl_hw_id=%u mon_hw_id=%u domain_id=%d llc_occupancy_bytes=%llu" , + __entry->ctrl_hw_id, __entry->mon_hw_id, __entry->domain_id, + __entry->llc_occupancy_bytes) + ); + +#endif /* _FS_RESCTRL_MONITOR_TRACE_H */ + +#undef TRACE_INCLUDE_PATH +#define TRACE_INCLUDE_PATH . +#define TRACE_INCLUDE_FILE monitor_trace +#include <trace/define_trace.h>
arch/x86/kernel/cpu/resctrl/pseudo_lock.c +1 -1
@@ -30,7 +30,7 @@#include "internal.h" #define CREATE_TRACE_POINTS -#include "trace.h" +#include "pseudo_lock_trace.h" /* * The bits needed to disable hardware prefetching varies based on the
arch/x86/kernel/cpu/resctrl/pseudo_lock_trace.h new file +43 -0
43 lines not on this page · raw message
arch/x86/kernel/cpu/resctrl/trace.h deleted +0 -59
59 lines not on this page · raw message
James Morse
reviewerPATCH v12 14/25 x86/resctrl: Add 'resctrl' to the title of the resctrl documentation
In reply to James MorseThe resctrl documentation is titled "User Interface for Resource Control feature".
Once the documentation follows the code in a move to the filesystem, this appears in the list of filesystems, but doesn't contain the name of the filesystem, making it hard to find.
Add 'resctrl' to the title.
---
Changes since v9:
* Fixed typs in tags.
Changes since v8:
* This patch is new.
--- Documentation/arch/x86/resctrl.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Documentation/arch/x86/resctrl.rst +3 -3
@@ -1,9 +1,9 @@ .. SPDX-License-Identifier: GPL-2.0 .. include:: <isonum.txt> -=========================================== -User Interface for Resource Control feature -=========================================== +===================================================== +User Interface for Resource Control feature (resctrl) +===================================================== :Copyright: |copy| 2016 Intel Corporation :Authors: - Fenghua Yu <[email protected]>
Signature · 1 line
2.39.5
[tip: x86/cache] x86/resctrl: Add 'resctrl' to the title of the resctrl documentation
The following commit has been merged into the x86/cache branch of tip:
The following commit has been merged into the x86/cache branch of tip:
Commit-ID: 003e86077143ebeaa5299fb2bc907ae3b6650028 Gitweb: https://git.kernel.org/tip/003e86077143ebeaa5299fb2bc907ae3b6650028 Author: James Morse <[email protected]> AuthorDate: Thu, 15 May 2025 16:58:44 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Fri, 16 May 2025 10:53:45 +02:00
x86/resctrl: Add 'resctrl' to the title of the resctrl documentation
The resctrl documentation is titled "User Interface for Resource Control feature".
Once the documentation follows the code in a move to the filesystem, this appears in the list of filesystems, but doesn't contain the name of the filesystem, making it hard to find.
Add 'resctrl' to the title.
--- Documentation/arch/x86/resctrl.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Documentation/arch/x86/resctrl.rst +3 -3
@@ -1,9 +1,9 @@ .. SPDX-License-Identifier: GPL-2.0 .. include:: <isonum.txt> -=========================================== -User Interface for Resource Control feature -=========================================== +===================================================== +User Interface for Resource Control feature (resctrl) +===================================================== :Copyright: |copy| 2016 Intel Corporation :Authors: - Fenghua Yu <[email protected]>
James Morse
reviewerPATCH v12 15/25 fs/resctrl: Add boiler plate for external resctrl code
In reply to James MorseAdd 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.
---
Changes since v6:
* Added 'depends on RESCTRL_FS' to the hidden kconfig options.
Changes since v5:
* Removed double include.
* Removed duplicate pseudo lock Kconfig define
* Grammar fix and closid capitalisation change.
Changes since v4:
* Tweaking of the commit message.
Changes since v3:
* Reworded 'if unsure say N' from the Kconfig text, the user doesn't have the choice anyway at this point.
* Added PWD to monitor.o's CFLAGS for the ftrace rube-goldberg build machine.
* Added split trace files.
Changes since v2:
* Dropped KERNFS dependency from arch side Kconfig.
* Added empty trace.h file.
* Merged asm->linux includes from Dave's patch to decouple those patches from this series.
Changes since v1:
* Rename new file psuedo_lock.c to pseudo_lock.c, to match the name of the original file (and to be less surprising).
* [Whitespace only] Under RESCTRL_FS in fs/resctrl/Kconfig, delete alignment space in orphaned select ... if (which has nothing to line up with any more).
* [Whitespace only] Reflow and re-tab Kconfig additions.
--- MAINTAINERS | 1 + arch/Kconfig | 8 +++++ arch/x86/Kconfig | 11 ++----- arch/x86/kernel/cpu/resctrl/internal.h | 2 -- arch/x86/kernel/cpu/resctrl/monitor.c | 2 +- arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 2 +- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 2 +- fs/Kconfig | 1 + fs/Makefile | 1 + fs/resctrl/Kconfig | 39 +++++++++++++++++++++++ fs/resctrl/Makefile | 6 ++++ fs/resctrl/ctrlmondata.c | 0 fs/resctrl/internal.h | 0 fs/resctrl/monitor.c | 0 fs/resctrl/monitor_trace.h | 0 fs/resctrl/pseudo_lock.c | 0 fs/resctrl/pseudo_lock_trace.h | 0 fs/resctrl/rdtgroup.c | 0 include/linux/resctrl.h | 4 +++ 19 files changed, 66 insertions(+), 13 deletions(-) create mode 100644 fs/resctrl/Kconfig create mode 100644 fs/resctrl/Makefile create mode 100644 fs/resctrl/ctrlmondata.c create mode 100644 fs/resctrl/internal.h create mode 100644 fs/resctrl/monitor.c create mode 100644 fs/resctrl/monitor_trace.h create mode 100644 fs/resctrl/pseudo_lock.c create mode 100644 fs/resctrl/pseudo_lock_trace.h create mode 100644 fs/resctrl/rdtgroup.c
MAINTAINERS +1 -0
@@ -20368,6 +20368,7 @@ S: Supported F: Documentation/arch/x86/resctrl* F: arch/x86/include/asm/resctrl.h F: arch/x86/kernel/cpu/resctrl/ +F: fs/resctrl/ F: include/linux/resctrl*.h F: tools/testing/selftests/resctrl/
arch/Kconfig +8 -0
@@ -1518,6 +1518,14 @@ config STRICT_MODULE_RWX config ARCH_HAS_PHYS_TO_DMA bool +config ARCH_HAS_CPU_RESCTRL + bool + help + An architecture selects this option to indicate that the necessary + hooks are provided to support the common memory system usage + monitoring and control interfaces provided by the 'resctrl' + filesystem (see RESCTRL_FS). + config HAVE_ARCH_COMPILER_H bool help
arch/x86/Kconfig +3 -8
@@ -507,8 +507,9 @@ config X86_MPPARSE config X86_CPU_RESCTRL bool "x86 CPU resource control support" depends on X86 && (CPU_SUP_INTEL || CPU_SUP_AMD) - select KERNFS - select PROC_CPU_RESCTRL if PROC_FS + depends on MISC_FILESYSTEMS + select ARCH_HAS_CPU_RESCTRL + select RESCTRL_FS select RESCTRL_FS_PSEUDO_LOCK help Enable x86 CPU resource control support.
@@ -526,12 +527,6 @@ config X86_CPU_RESCTRL Say N if unsure. -config RESCTRL_FS_PSEUDO_LOCK - bool - help - Software mechanism to pin data in a cache portion using - micro-architecture specific knowledge. - config X86_FRED bool "Flexible Return and Event Delivery" depends on X86_64
arch/x86/kernel/cpu/resctrl/internal.h +0 -2
@@ -9,8 +9,6 @@#include <linux/jump_label.h> #include <linux/tick.h> -#include <asm/resctrl.h> -#define L3_QOS_CDP_ENABLE 0x01ULL#define L2_QOS_CDP_ENABLE 0x01ULL
arch/x86/kernel/cpu/resctrl/monitor.c +1 -1
@@ -19,11 +19,11 @@#include <linux/cpu.h> #include <linux/module.h> +#include <linux/resctrl.h> #include <linux/sizes.h> #include <linux/slab.h> #include <asm/cpu_device_id.h> -#include <asm/resctrl.h> #include "internal.h"
arch/x86/kernel/cpu/resctrl/pseudo_lock.c +1 -1
@@ -18,12 +18,12 @@#include <linux/mman.h> #include <linux/perf_event.h> #include <linux/pm_qos.h> +#include <linux/resctrl.h> #include <linux/slab.h> #include <linux/uaccess.h> #include <asm/cacheflush.h> #include <asm/cpu_device_id.h> -#include <asm/resctrl.h> #include <asm/perf_event.h> #include "../../events/perf_event.h" /* For X86_CONFIG() */
arch/x86/kernel/cpu/resctrl/rdtgroup.c +1 -1
@@ -18,6 +18,7 @@#include <linux/fs_parser.h> #include <linux/sysfs.h> #include <linux/kernfs.h> +#include <linux/resctrl.h> #include <linux/seq_buf.h> #include <linux/seq_file.h> #include <linux/sched/signal.h>
@@ -28,7 +29,6 @@#include <uapi/linux/magic.h> -#include <asm/resctrl.h> #include "internal.h" DEFINE_STATIC_KEY_FALSE (rdt_enable_key);
fs/Kconfig +1 -0
@@ -335,6 +335,7 @@ source "fs/omfs/Kconfig" source "fs/hpfs/Kconfig" source "fs/qnx4/Kconfig" source "fs/qnx6/Kconfig" +source "fs/resctrl/Kconfig" source "fs/romfs/Kconfig" source "fs/pstore/Kconfig" source "fs/ufs/Kconfig"
fs/Makefile +1 -0
@@ -128,3 +128,4 @@ obj-$(CONFIG_EROFS_FS) += erofs/ obj-$(CONFIG_VBOXSF_FS) += vboxsf/ obj-$(CONFIG_ZONEFS_FS) += zonefs/ obj-$(CONFIG_BPF_LSM) += bpf_fs_kfuncs.o +obj-$(CONFIG_RESCTRL_FS) += resctrl/
fs/resctrl/Kconfig new file +39 -0
@@ -0,0 +1,39 @@ +config RESCTRL_FS + bool "CPU Resource Control Filesystem (resctrl)" + depends on ARCH_HAS_CPU_RESCTRL + select KERNFS + select PROC_CPU_RESCTRL if PROC_FS + help + Some architectures provide hardware facilities to group tasks and + monitor and control their usage of memory system resources such as + caches and memory bandwidth. Examples of such facilities include + Intel's Resource Director Technology (Intel(R) RDT) and AMD's + Platform Quality of Service (AMD QoS). + + If your system has the necessary support and you want to be able to + assign tasks to groups and manipulate the associated resource + monitors and controls from userspace, say Y here to get a mountable + 'resctrl' filesystem that lets you do just that. + + If nothing mounts or prods the 'resctrl' filesystem, resource + controls and monitors are left in a quiescent, permissive state. + + On architectures where this can be disabled independently, it is + safe to say N. + + See <file:Documentation/arch/x86/resctrl.rst> for more information. + +config RESCTRL_FS_PSEUDO_LOCK + bool + depends on RESCTRL_FS + help + Software mechanism to pin data in a cache portion using + micro-architecture specific knowledge. + +config RESCTRL_RMID_DEPENDS_ON_CLOSID + bool + depends on RESCTRL_FS + help + Enabled by the architecture when the RMID values depend on the CLOSID. + This causes the CLOSID allocator to search for CLOSID with clean + RMID.
fs/resctrl/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0 +obj-$(CONFIG_RESCTRL_FS) += rdtgroup.o ctrlmondata.o monitor.o +obj-$(CONFIG_RESCTRL_FS_PSEUDO_LOCK) += pseudo_lock.o + +# To allow define_trace.h's recursive include: +CFLAGS_monitor.o = -I$(src)
fs/resctrl/ctrlmondata.c new file +0 -0
fs/resctrl/internal.h new file +0 -0
fs/resctrl/monitor.c new file +0 -0
fs/resctrl/monitor_trace.h new file +0 -0
fs/resctrl/pseudo_lock.c new file +0 -0
fs/resctrl/pseudo_lock_trace.h new file +0 -0
fs/resctrl/rdtgroup.c new file +0 -0
include/linux/resctrl.h +4 -0
@@ -8,6 +8,10 @@#include <linux/pid.h> #include <linux/resctrl_types.h> +#ifdef CONFIG_ARCH_HAS_CPU_RESCTRL +#include <asm/resctrl.h> +#endif +/* CLOSID, RMID value used by the default control group */ #define RESCTRL_RESERVED_CLOSID 0#define RESCTRL_RESERVED_RMID 0
Signature · 1 line
2.39.5
[tip: x86/cache] fs/resctrl: Add boiler plate for external resctrl code
The following commit has been merged into the x86/cache branch of tip:
The following commit has been merged into the x86/cache branch of tip:
Commit-ID: bff70402d6d67843fe319338e4c56e1cba13fbd8 Gitweb: https://git.kernel.org/tip/bff70402d6d67843fe319338e4c56e1cba13fbd8 Author: James Morse <[email protected]> AuthorDate: Thu, 15 May 2025 16:58:45 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Fri, 16 May 2025 11:05:40 +02:00
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.
--- MAINTAINERS | 1 +- arch/Kconfig | 8 +++++- arch/x86/Kconfig | 11 +----- arch/x86/kernel/cpu/resctrl/internal.h | 2 +- arch/x86/kernel/cpu/resctrl/monitor.c | 2 +- arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 2 +- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 2 +- fs/Kconfig | 1 +- fs/Makefile | 1 +- fs/resctrl/Kconfig | 39 ++++++++++++++++++++++- fs/resctrl/Makefile | 6 +++- fs/resctrl/ctrlmondata.c | 0 fs/resctrl/internal.h | 0 fs/resctrl/monitor.c | 0 fs/resctrl/monitor_trace.h | 0 fs/resctrl/pseudo_lock.c | 0 fs/resctrl/pseudo_lock_trace.h | 0 fs/resctrl/rdtgroup.c | 0 include/linux/resctrl.h | 4 ++- 19 files changed, 66 insertions(+), 13 deletions(-) create mode 100644 fs/resctrl/Kconfig create mode 100644 fs/resctrl/Makefile create mode 100644 fs/resctrl/ctrlmondata.c create mode 100644 fs/resctrl/internal.h create mode 100644 fs/resctrl/monitor.c create mode 100644 fs/resctrl/monitor_trace.h create mode 100644 fs/resctrl/pseudo_lock.c create mode 100644 fs/resctrl/pseudo_lock_trace.h create mode 100644 fs/resctrl/rdtgroup.c
MAINTAINERS +1 -0
@@ -20427,6 +20427,7 @@ S: Supported F: Documentation/arch/x86/resctrl* F: arch/x86/include/asm/resctrl.h F: arch/x86/kernel/cpu/resctrl/ +F: fs/resctrl/ F: include/linux/resctrl*.h F: tools/testing/selftests/resctrl/
arch/Kconfig +8 -0
@@ -1518,6 +1518,14 @@ config STRICT_MODULE_RWX config ARCH_HAS_PHYS_TO_DMA bool +config ARCH_HAS_CPU_RESCTRL + bool + help + An architecture selects this option to indicate that the necessary + hooks are provided to support the common memory system usage + monitoring and control interfaces provided by the 'resctrl' + filesystem (see RESCTRL_FS). + config HAVE_ARCH_COMPILER_H bool help
arch/x86/Kconfig +3 -8
@@ -507,8 +507,9 @@ config X86_MPPARSE config X86_CPU_RESCTRL bool "x86 CPU resource control support" depends on X86 && (CPU_SUP_INTEL || CPU_SUP_AMD) - select KERNFS - select PROC_CPU_RESCTRL if PROC_FS + depends on MISC_FILESYSTEMS + select ARCH_HAS_CPU_RESCTRL + select RESCTRL_FS select RESCTRL_FS_PSEUDO_LOCK help Enable x86 CPU resource control support.
@@ -526,12 +527,6 @@ config X86_CPU_RESCTRL Say N if unsure. -config RESCTRL_FS_PSEUDO_LOCK - bool - help - Software mechanism to pin data in a cache portion using - micro-architecture specific knowledge. - config X86_FRED bool "Flexible Return and Event Delivery" depends on X86_64
arch/x86/kernel/cpu/resctrl/internal.h +0 -2
@@ -9,8 +9,6 @@#include <linux/jump_label.h> #include <linux/tick.h> -#include <asm/resctrl.h> -#define L3_QOS_CDP_ENABLE 0x01ULL#define L2_QOS_CDP_ENABLE 0x01ULL
arch/x86/kernel/cpu/resctrl/monitor.c +1 -1
@@ -19,11 +19,11 @@#include <linux/cpu.h> #include <linux/module.h> +#include <linux/resctrl.h> #include <linux/sizes.h> #include <linux/slab.h> #include <asm/cpu_device_id.h> -#include <asm/resctrl.h> #include "internal.h"
arch/x86/kernel/cpu/resctrl/pseudo_lock.c +1 -1
@@ -18,12 +18,12 @@#include <linux/mman.h> #include <linux/perf_event.h> #include <linux/pm_qos.h> +#include <linux/resctrl.h> #include <linux/slab.h> #include <linux/uaccess.h> #include <asm/cacheflush.h> #include <asm/cpu_device_id.h> -#include <asm/resctrl.h> #include <asm/perf_event.h> #include "../../events/perf_event.h" /* For X86_CONFIG() */
arch/x86/kernel/cpu/resctrl/rdtgroup.c +1 -1
@@ -18,6 +18,7 @@#include <linux/fs_parser.h> #include <linux/sysfs.h> #include <linux/kernfs.h> +#include <linux/resctrl.h> #include <linux/seq_buf.h> #include <linux/seq_file.h> #include <linux/sched/signal.h>
@@ -28,7 +29,6 @@#include <uapi/linux/magic.h> -#include <asm/resctrl.h> #include "internal.h" DEFINE_STATIC_KEY_FALSE (rdt_enable_key);
fs/Kconfig +1 -0
@@ -335,6 +335,7 @@ source "fs/omfs/Kconfig" source "fs/hpfs/Kconfig" source "fs/qnx4/Kconfig" source "fs/qnx6/Kconfig" +source "fs/resctrl/Kconfig" source "fs/romfs/Kconfig" source "fs/pstore/Kconfig" source "fs/ufs/Kconfig"
fs/Makefile +1 -0
@@ -128,3 +128,4 @@ obj-$(CONFIG_EROFS_FS) += erofs/ obj-$(CONFIG_VBOXSF_FS) += vboxsf/ obj-$(CONFIG_ZONEFS_FS) += zonefs/ obj-$(CONFIG_BPF_LSM) += bpf_fs_kfuncs.o +obj-$(CONFIG_RESCTRL_FS) += resctrl/
fs/resctrl/Kconfig new file +39 -0
@@ -0,0 +1,39 @@ +config RESCTRL_FS + bool "CPU Resource Control Filesystem (resctrl)" + depends on ARCH_HAS_CPU_RESCTRL + select KERNFS + select PROC_CPU_RESCTRL if PROC_FS + help + Some architectures provide hardware facilities to group tasks and + monitor and control their usage of memory system resources such as + caches and memory bandwidth. Examples of such facilities include + Intel's Resource Director Technology (Intel(R) RDT) and AMD's + Platform Quality of Service (AMD QoS). + + If your system has the necessary support and you want to be able to + assign tasks to groups and manipulate the associated resource + monitors and controls from userspace, say Y here to get a mountable + 'resctrl' filesystem that lets you do just that. + + If nothing mounts or prods the 'resctrl' filesystem, resource + controls and monitors are left in a quiescent, permissive state. + + On architectures where this can be disabled independently, it is + safe to say N. + + See <file:Documentation/arch/x86/resctrl.rst> for more information. + +config RESCTRL_FS_PSEUDO_LOCK + bool + depends on RESCTRL_FS + help + Software mechanism to pin data in a cache portion using + micro-architecture specific knowledge. + +config RESCTRL_RMID_DEPENDS_ON_CLOSID + bool + depends on RESCTRL_FS + help + Enabled by the architecture when the RMID values depend on the CLOSID. + This causes the CLOSID allocator to search for CLOSID with clean + RMID.
fs/resctrl/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0 +obj-$(CONFIG_RESCTRL_FS) += rdtgroup.o ctrlmondata.o monitor.o +obj-$(CONFIG_RESCTRL_FS_PSEUDO_LOCK) += pseudo_lock.o + +# To allow define_trace.h's recursive include: +CFLAGS_monitor.o = -I$(src)
fs/resctrl/ctrlmondata.c new file +0 -0
fs/resctrl/internal.h new file +0 -0
fs/resctrl/monitor.c new file +0 -0
fs/resctrl/monitor_trace.h new file +0 -0
fs/resctrl/pseudo_lock.c new file +0 -0
fs/resctrl/pseudo_lock_trace.h new file +0 -0
fs/resctrl/rdtgroup.c new file +0 -0
include/linux/resctrl.h +4 -0
@@ -8,6 +8,10 @@#include <linux/pid.h> #include <linux/resctrl_types.h> +#ifdef CONFIG_ARCH_HAS_CPU_RESCTRL +#include <asm/resctrl.h> +#endif +/* CLOSID, RMID value used by the default control group */ #define RESCTRL_RESERVED_CLOSID 0#define RESCTRL_RESERVED_RMID 0
James Morse
reviewerPATCH v12 16/25 x86/resctrl: Move the filesystem bits to headers visible to fs/resctrl
In reply to James MorseOnce the filesystem parts of resctrl move to fs/resctrl, it cannot rely on definitions in x86's internal.h.
Move definitions in internal.h that need to be shared between the filesystem and architecture code to header files that fs/resctrl can include.
Doing this separately means the filesystem code only moves between files of the same name, instead of having these changes mixed in too.
---
Changes since v8:
* Moved resctrl_arch_get_cdp_enabled()/resctrl_arch_set_cdp_enabled() to include/linux/resctrl.h
Changes since v6:
* Moved resctrl_arch_set_cdp_enabled() to rdtgroup.c instead of core.c
Changes since v3:
* Changed the number of hyphens at the end of the commit message.
Changes since v2:
* Dropped the rfflags and some other defines from being moved.
Changes since v1:
* Revert apparently unintentional duplication of a couple of variable declarations in <linux/resctrl.h>.
No functional change.
--- arch/x86/kernel/cpu/resctrl/internal.h | 9 --------- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 5 +++++ include/linux/resctrl.h | 3 +++ include/linux/resctrl_types.h | 3 +++ 4 files changed, 11 insertions(+), 9 deletions(-)
arch/x86/kernel/cpu/resctrl/internal.h +0 -9
@@ -16,8 +16,6 @@#define CQM_LIMBOCHECK_INTERVAL 1000#define MBM_CNTR_WIDTH_BASE 24 -#define MBM_OVERFLOW_INTERVAL 1000 -#define MAX_MBA_BW 100u#define MBA_IS_LINEAR 0x4#define MBM_CNTR_WIDTH_OFFSET_AMD 20
@@ -396,13 +394,6 @@ extern struct rdtgroup rdtgroup_default;extern struct dentry *debugfs_resctrl;extern enum resctrl_event_id mba_mbps_default_event; -static inline bool resctrl_arch_get_cdp_enabled (enum resctrl_res_level l) -{ -return rdt_resources_all[l].cdp_enabled; -} - -int resctrl_arch_set_cdp_enabled (enum resctrl_res_level l,bool enable); -void arch_mon_domain_online (struct rdt_resource *r,struct rdt_mon_domain *d);/* CPUID.(EAX=10H, ECX=ResID=1).EAX */
arch/x86/kernel/cpu/resctrl/rdtgroup.c +5 -0
@@ -2541,6 +2541,11 @@ int resctrl_arch_set_cdp_enabled(enum resctrl_res_level l, bool enable)return 0 ; } +bool resctrl_arch_get_cdp_enabled (enum resctrl_res_level l) +{ +return rdt_resources_all[l].cdp_enabled; +} +/* * We don't allow rdtgroup directories to be created anywhere * except the root directory. Thus when looking for the rdtgroup
include/linux/resctrl.h +3 -0
@@ -403,6 +403,9 @@ static inline u32 resctrl_get_config_index(u32 closid, } } +bool resctrl_arch_get_cdp_enabled (enum resctrl_res_level l); +int resctrl_arch_set_cdp_enabled (enum resctrl_res_level l,bool enable); +/* * Update the ctrl_val and apply this config right now. * Must be called on one of the domain's CPUs.
include/linux/resctrl_types.h +3 -0
@@ -7,6 +7,9 @@#ifndef __LINUX_RESCTRL_TYPES_H#define __LINUX_RESCTRL_TYPES_H +#define MAX_MBA_BW 100u +#define MBM_OVERFLOW_INTERVAL 1000 +/* Reads to Local DRAM Memory */ #define READS_TO_LOCAL_MEM BIT(0)
Signature · 1 line
2.39.5
[tip: x86/cache] x86/resctrl: Move the filesystem bits to headers visible to fs/resctrl
The following commit has been merged into the x86/cache branch of tip:
The following commit has been merged into the x86/cache branch of tip:
Commit-ID: 3d95a49b365e06d1b4c4e5a426fdc70449a334f3 Gitweb: https://git.kernel.org/tip/3d95a49b365e06d1b4c4e5a426fdc70449a334f3 Author: James Morse <[email protected]> AuthorDate: Thu, 15 May 2025 16:58:46 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Fri, 16 May 2025 11:35:23 +02:00
x86/resctrl: Move the filesystem bits to headers visible to fs/resctrl
Once the filesystem parts of resctrl move to fs/resctrl, it cannot rely on definitions in x86's internal.h.
Move definitions in internal.h that need to be shared between the filesystem and architecture code to header files that fs/resctrl can include.
Doing this separately means the filesystem code only moves between files of the same name, instead of having these changes mixed in too.
--- arch/x86/kernel/cpu/resctrl/internal.h | 9 --------- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 5 +++++ include/linux/resctrl.h | 3 +++ include/linux/resctrl_types.h | 3 +++ 4 files changed, 11 insertions(+), 9 deletions(-)
arch/x86/kernel/cpu/resctrl/internal.h +0 -9
@@ -16,8 +16,6 @@#define CQM_LIMBOCHECK_INTERVAL 1000#define MBM_CNTR_WIDTH_BASE 24 -#define MBM_OVERFLOW_INTERVAL 1000 -#define MAX_MBA_BW 100u#define MBA_IS_LINEAR 0x4#define MBM_CNTR_WIDTH_OFFSET_AMD 20
@@ -396,13 +394,6 @@ extern struct rdtgroup rdtgroup_default;extern struct dentry *debugfs_resctrl;extern enum resctrl_event_id mba_mbps_default_event; -static inline bool resctrl_arch_get_cdp_enabled (enum resctrl_res_level l) -{ -return rdt_resources_all[l].cdp_enabled; -} - -int resctrl_arch_set_cdp_enabled (enum resctrl_res_level l,bool enable); -void arch_mon_domain_online (struct rdt_resource *r,struct rdt_mon_domain *d);/* CPUID.(EAX=10H, ECX=ResID=1).EAX */
arch/x86/kernel/cpu/resctrl/rdtgroup.c +5 -0
@@ -2541,6 +2541,11 @@ int resctrl_arch_set_cdp_enabled(enum resctrl_res_level l, bool enable)return 0 ; } +bool resctrl_arch_get_cdp_enabled (enum resctrl_res_level l) +{ +return rdt_resources_all[l].cdp_enabled; +} +/* * We don't allow rdtgroup directories to be created anywhere * except the root directory. Thus when looking for the rdtgroup
include/linux/resctrl.h +3 -0
@@ -403,6 +403,9 @@ static inline u32 resctrl_get_config_index(u32 closid, } } +bool resctrl_arch_get_cdp_enabled (enum resctrl_res_level l); +int resctrl_arch_set_cdp_enabled (enum resctrl_res_level l,bool enable); +/* * Update the ctrl_val and apply this config right now. * Must be called on one of the domain's CPUs.
include/linux/resctrl_types.h +3 -0
@@ -7,6 +7,9 @@#ifndef __LINUX_RESCTRL_TYPES_H#define __LINUX_RESCTRL_TYPES_H +#define MAX_MBA_BW 100u +#define MBM_OVERFLOW_INTERVAL 1000 +/* Reads to Local DRAM Memory */ #define READS_TO_LOCAL_MEM BIT(0)
James Morse
reviewerPATCH v12 17/25 x86/resctrl: Move enum resctrl_event_id to resctrl.h
In reply to James Morseresctrl_types.h contains common types and constants to enable architectures to use these types in their definitions within asm/resctrl.h
enum resctrl_event_id was placed in resctrl_types.h for resctrl_arch_get_cdp_enabled() and resctrl_arch_set_cdp_enabled(), but these two functions are no longer inlined by any architecture.
Move enum resctrl_event_id to resctrl.h
---
Changes since v9:
* Replaced commit message with Reinette's version.
Changes since v8:
* This patch is new.
--- include/linux/resctrl.h | 10 ++++++++++ include/linux/resctrl_types.h | 10 ---------- 2 files changed, 10 insertions(+), 10 deletions(-)
include/linux/resctrl.h +10 -0
@@ -48,6 +48,16 @@ int proc_resctrl_show(struct seq_file *m, for_each_rdt_resource((r)) \if ((r)->mon_capable) +enum resctrl_res_level { +RDT_RESOURCE_L3 , +RDT_RESOURCE_L2 , +RDT_RESOURCE_MBA , +RDT_RESOURCE_SMBA , + +/* Must be the last */ + RDT_NUM_RESOURCES, +}; +/** * enum resctrl_conf_type - The type of configuration. * @CDP_NONE: No prioritisation, both code and data are controlled or monitored.
include/linux/resctrl_types.h +0 -10
@@ -34,16 +34,6 @@/* Max event bits supported */ #define MAX_EVT_CONFIG_BITS GENMASK(6, 0) -enum resctrl_res_level { -RDT_RESOURCE_L3 , -RDT_RESOURCE_L2 , -RDT_RESOURCE_MBA , -RDT_RESOURCE_SMBA , - -/* Must be the last */ -RDT_NUM_RESOURCES , -}; -/* * Event IDs, the values match those used to program IA32_QM_EVTSEL before * reading IA32_QM_CTR on RDT systems.
Signature · 1 line
2.39.5
[tip: x86/cache] x86/resctrl: Move enum resctrl_event_id to resctrl.h
The following commit has been merged into the x86/cache branch of tip:
The following commit has been merged into the x86/cache branch of tip:
Commit-ID: 7bdb619c7f9f0a7264b2d69ad0472bf2c785e52a Gitweb: https://git.kernel.org/tip/7bdb619c7f9f0a7264b2d69ad0472bf2c785e52a Author: James Morse <[email protected]> AuthorDate: Thu, 15 May 2025 16:58:47 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Fri, 16 May 2025 12:10:20 +02:00
x86/resctrl: Move enum resctrl_event_id to resctrl.h
resctrl_types.h contains common types and constants to enable architectures to use these types in their definitions within asm/resctrl.h.
enum resctrl_event_id was placed in resctrl_types.h for resctrl_arch_get_cdp_enabled() and resctrl_arch_set_cdp_enabled(), but these two functions are no longer inlined by any architecture.
Move enum resctrl_event_id to resctrl.h.
--- include/linux/resctrl.h | 10 ++++++++++ include/linux/resctrl_types.h | 10 ---------- 2 files changed, 10 insertions(+), 10 deletions(-)
include/linux/resctrl.h +10 -0
@@ -48,6 +48,16 @@ int proc_resctrl_show(struct seq_file *m, for_each_rdt_resource((r)) \if ((r)->mon_capable) +enum resctrl_res_level { +RDT_RESOURCE_L3 , +RDT_RESOURCE_L2 , +RDT_RESOURCE_MBA , +RDT_RESOURCE_SMBA , + +/* Must be the last */ + RDT_NUM_RESOURCES, +}; +/** * enum resctrl_conf_type - The type of configuration. * @CDP_NONE: No prioritisation, both code and data are controlled or monitored.
include/linux/resctrl_types.h +0 -10
@@ -34,16 +34,6 @@/* Max event bits supported */ #define MAX_EVT_CONFIG_BITS GENMASK(6, 0) -enum resctrl_res_level { -RDT_RESOURCE_L3 , -RDT_RESOURCE_L2 , -RDT_RESOURCE_MBA , -RDT_RESOURCE_SMBA , - -/* Must be the last */ -RDT_NUM_RESOURCES , -}; -/* * Event IDs, the values match those used to program IA32_QM_EVTSEL before * reading IA32_QM_CTR on RDT systems.
James Morse
reviewerPATCH v12 18/25 x86/resctrl: Fix types in resctrl_arch_mon_ctx_{alloc,free}() stubs
In reply to James Morseresctrl_arch_mon_ctx_alloc() and resctrl_arch_mon_ctx_free() take an enum resctrl_event_id that is already defined in resctrl_types.h to be accessible to asm/resctrl.h.
The x86 stubs take an int. Fix that.
---
Changes since v10:
* Removed a stray semicolon in the commit message.
Changes since v9:
* Removed two stray semicolons.
* Reworded the commit message.
Changes since v8:
* This patch is new.
--- arch/x86/include/asm/resctrl.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
arch/x86/include/asm/resctrl.h +6 -4
@@ -194,14 +194,16 @@ static inline u32 resctrl_arch_rmid_idx_encode(u32 ignored, u32 rmid)/* x86 can always read an rmid, nothing needs allocating */ struct rdt_resource ; -static inline void *resctrl_arch_mon_ctx_alloc (struct rdt_resource *r,int evtid) +static inline void *resctrl_arch_mon_ctx_alloc (struct rdt_resource *r, +enum resctrl_event_id evtid) {might_sleep ();return NULL ; -}; +} -static inline void resctrl_arch_mon_ctx_free (struct rdt_resource *r,int evtid, -void *ctx) { }; +static inline void resctrl_arch_mon_ctx_free (struct rdt_resource *r, +enum resctrl_event_id evtid, +void *ctx) { }u64 resctrl_arch_get_prefetch_disable_bits (void );int resctrl_arch_pseudo_lock_fn (void *_plr);
Signature · 1 line
2.39.5
[tip: x86/cache] x86/resctrl: Fix types in resctrl_arch_mon_ctx_{alloc,free}() stubs
The following commit has been merged into the x86/cache branch of tip:
The following commit has been merged into the x86/cache branch of tip:
Commit-ID: 272ed1c28c9db60b9bd50d49feae463df50b3ef6 Gitweb: https://git.kernel.org/tip/272ed1c28c9db60b9bd50d49feae463df50b3ef6 Author: James Morse <[email protected]> AuthorDate: Thu, 15 May 2025 16:58:48 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Fri, 16 May 2025 12:10:51 +02:00
x86/resctrl: Fix types in resctrl_arch_mon_ctx_{alloc,free}() stubs
resctrl_arch_mon_ctx_alloc() and resctrl_arch_mon_ctx_free() take an enum resctrl_event_id that is already defined in resctrl_types.h to be accessible to asm/resctrl.h.
The x86 stubs take an int. Fix that.
--- arch/x86/include/asm/resctrl.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
arch/x86/include/asm/resctrl.h +6 -4
@@ -194,14 +194,16 @@ static inline u32 resctrl_arch_rmid_idx_encode(u32 ignored, u32 rmid)/* x86 can always read an rmid, nothing needs allocating */ struct rdt_resource ; -static inline void *resctrl_arch_mon_ctx_alloc (struct rdt_resource *r,int evtid) +static inline void *resctrl_arch_mon_ctx_alloc (struct rdt_resource *r, +enum resctrl_event_id evtid) {might_sleep ();return NULL ; -}; +} -static inline void resctrl_arch_mon_ctx_free (struct rdt_resource *r,int evtid, -void *ctx) { }; +static inline void resctrl_arch_mon_ctx_free (struct rdt_resource *r, +enum resctrl_event_id evtid, +void *ctx) { }u64 resctrl_arch_get_prefetch_disable_bits (void );int resctrl_arch_pseudo_lock_fn (void *_plr);
James Morse
reviewerPATCH v12 19/25 x86/resctrl: Move pseudo lock prototypes to include/linux/resctrl.h
In reply to James MorseThe resctrl pseudo-lock feature allows an architecture to allocate data into particular cache portions, which are then treated as reserved to avoid that data ever being evicted. Setting this up is deeply architecture specific as it involves disabling prefetchers etc. It is not possible to support this kind of feature on arm64. Risc-V is assumed to be the same.
The prototypes for the architecture code were added to x86's asm/resctrl.h, with other architectures able to provide stubs for their architecture. This forces other architectures to provide identical stubs.
Move the prototypes and stubs to linux/resctrl.h, and switch between them using the existing Kconfig symbol.
---
I'm assuming risc-v's hardware prefetcher controls are restricted to the higehst privilege level, and that this isn't where linux runs.
Changes since v9:
* Typo fix in commit message.
Changse since v8:
* This patch is new.
--- arch/x86/include/asm/resctrl.h | 5 ----- include/linux/resctrl.h | 13 +++++++++++++ 2 files changed, 13 insertions(+), 5 deletions(-)
arch/x86/include/asm/resctrl.h +0 -5
@@ -205,11 +205,6 @@ static inline void resctrl_arch_mon_ctx_free(struct rdt_resource *r,enum resctrl_event_id evtid, void *ctx) { } -u64 resctrl_arch_get_prefetch_disable_bits(void); -int resctrl_arch_pseudo_lock_fn (void *_plr); -int resctrl_arch_measure_cycles_lat_fn (void *_plr); -int resctrl_arch_measure_l2_residency (void *_plr); -int resctrl_arch_measure_l3_residency (void *_plr); void resctrl_cpu_detect(struct cpuinfo_x86 *c);#else
include/linux/resctrl.h +13 -0
@@ -534,4 +534,17 @@ extern unsigned int resctrl_rmid_realloc_limit;int resctrl_init (void );void resctrl_exit (void ); +#ifdef CONFIG_RESCTRL_FS_PSEUDO_LOCK +u64 resctrl_arch_get_prefetch_disable_bits (void ); +int resctrl_arch_pseudo_lock_fn (void *_plr); +int resctrl_arch_measure_cycles_lat_fn (void *_plr); +int resctrl_arch_measure_l2_residency (void *_plr); +int resctrl_arch_measure_l3_residency (void *_plr); +#else +static inline u64 resctrl_arch_get_prefetch_disable_bits (void ) {return 0 ; } +static inline int resctrl_arch_pseudo_lock_fn (void *_plr) {return 0 ; } +static inline int resctrl_arch_measure_cycles_lat_fn (void *_plr) {return 0 ; } +static inline int resctrl_arch_measure_l2_residency (void *_plr) {return 0 ; } +static inline int resctrl_arch_measure_l3_residency (void *_plr) {return 0 ; } +#endif /* CONFIG_RESCTRL_FS_PSEUDO_LOCK */ #endif /* _RESCTRL_H */
Signature · 1 line
2.39.5
[tip: x86/cache] x86/resctrl: Move pseudo lock prototypes to include/linux/resctrl.h
The following commit has been merged into the x86/cache branch of tip:
The following commit has been merged into the x86/cache branch of tip:
Commit-ID: 279f225951e3c77a1708d77f557b4cc7bdbd76ed Gitweb: https://git.kernel.org/tip/279f225951e3c77a1708d77f557b4cc7bdbd76ed Author: James Morse <[email protected]> AuthorDate: Thu, 15 May 2025 16:58:49 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Fri, 16 May 2025 12:21:00 +02:00
x86/resctrl: Move pseudo lock prototypes to include/linux/resctrl.h
The resctrl pseudo-lock feature allows an architecture to allocate data into particular cache portions, which are then treated as reserved to avoid that data ever being evicted. Setting this up is deeply architecture specific as it involves disabling prefetchers etc. It is not possible to support this kind of feature on arm64. Risc-V is assumed to be the same.
The prototypes for the architecture code were added to x86's asm/resctrl.h, with other architectures able to provide stubs for their architecture. This forces other architectures to provide identical stubs.
Move the prototypes and stubs to linux/resctrl.h, and switch between them using the existing Kconfig symbol.
--- arch/x86/include/asm/resctrl.h | 5 ----- include/linux/resctrl.h | 13 +++++++++++++ 2 files changed, 13 insertions(+), 5 deletions(-)
arch/x86/include/asm/resctrl.h +0 -5
@@ -205,11 +205,6 @@ static inline void resctrl_arch_mon_ctx_free(struct rdt_resource *r,enum resctrl_event_id evtid, void *ctx) { } -u64 resctrl_arch_get_prefetch_disable_bits(void); -int resctrl_arch_pseudo_lock_fn (void *_plr); -int resctrl_arch_measure_cycles_lat_fn (void *_plr); -int resctrl_arch_measure_l2_residency (void *_plr); -int resctrl_arch_measure_l3_residency (void *_plr); void resctrl_cpu_detect(struct cpuinfo_x86 *c);#else
include/linux/resctrl.h +13 -0
@@ -534,4 +534,17 @@ extern unsigned int resctrl_rmid_realloc_limit;int resctrl_init (void );void resctrl_exit (void ); +#ifdef CONFIG_RESCTRL_FS_PSEUDO_LOCK +u64 resctrl_arch_get_prefetch_disable_bits (void ); +int resctrl_arch_pseudo_lock_fn (void *_plr); +int resctrl_arch_measure_cycles_lat_fn (void *_plr); +int resctrl_arch_measure_l2_residency (void *_plr); +int resctrl_arch_measure_l3_residency (void *_plr); +#else +static inline u64 resctrl_arch_get_prefetch_disable_bits (void ) {return 0 ; } +static inline int resctrl_arch_pseudo_lock_fn (void *_plr) {return 0 ; } +static inline int resctrl_arch_measure_cycles_lat_fn (void *_plr) {return 0 ; } +static inline int resctrl_arch_measure_l2_residency (void *_plr) {return 0 ; } +static inline int resctrl_arch_measure_l3_residency (void *_plr) {return 0 ; } +#endif /* CONFIG_RESCTRL_FS_PSEUDO_LOCK */ #endif /* _RESCTRL_H */
James Morse
reviewerPATCH v12 20/25 x86/resctrl: Squelch whitespace anomalies in resctrl core code
In reply to James MorseFrom: Dave Martin <[email protected]>
checkpatch.pl complains about some whitespace anomalies in the resctrl core code.
This doesn't matter, but since this code is about to be factored out and made generic, this is a good opportunity to fix these issues and so reduce future checkpatch fuzz.
Fix them.
No functional change.
--- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
arch/x86/kernel/cpu/resctrl/rdtgroup.c +5 -7
@@ -1024,7 +1024,7 @@ static int rdt_num_closids_show(struct kernfs_open_file *of, }static int rdt_default_ctrl_show (struct kernfs_open_file *of, -struct seq_file *seq,void *v) +struct seq_file *seq,void *v) {struct resctrl_schema *s =rdt_kn_parent_priv (of->kn);struct rdt_resource *r = s->res;
@@ -1034,7 +1034,7 @@ static int rdt_default_ctrl_show(struct kernfs_open_file *of, }static int rdt_min_cbm_bits_show (struct kernfs_open_file *of, -struct seq_file *seq,void *v) +struct seq_file *seq,void *v) {struct resctrl_schema *s =rdt_kn_parent_priv (of->kn);struct rdt_resource *r = s->res;
@@ -1150,7 +1150,7 @@ static int rdt_bit_usage_show(struct kernfs_open_file *of, }static int rdt_min_bw_show (struct kernfs_open_file *of, -struct seq_file *seq,void *v) +struct seq_file *seq,void *v) {struct resctrl_schema *s =rdt_kn_parent_priv (of->kn);struct rdt_resource *r = s->res;
@@ -1185,7 +1185,7 @@ static int rdt_mon_features_show(struct kernfs_open_file *of, }static int rdt_bw_gran_show (struct kernfs_open_file *of, -struct seq_file *seq,void *v) +struct seq_file *seq,void *v) {struct resctrl_schema *s =rdt_kn_parent_priv (of->kn);struct rdt_resource *r = s->res;
@@ -1195,7 +1195,7 @@ static int rdt_bw_gran_show(struct kernfs_open_file *of, }static int rdt_delay_linear_show (struct kernfs_open_file *of, -struct seq_file *seq,void *v) +struct seq_file *seq,void *v) {struct resctrl_schema *s =rdt_kn_parent_priv (of->kn);struct rdt_resource *r = s->res;
@@ -2068,7 +2068,6 @@ static struct rftype res_common_files[] = { .seq_show = rdtgroup_closid_show, .fflags = RFTYPE_CTRL_BASE | RFTYPE_DEBUG, }, - };static int rdtgroup_add_files (struct kernfs_node *kn,unsigned long fflags)
@@ -3628,7 +3627,6 @@ static int rdtgroup_init_alloc(struct rdtgroup *rdtgrp)rdt_last_cmd_puts ("Failed to initialize allocations\n" ); goto out; } - } rdtgrp->mode =RDT_MODE_SHAREABLE ;
Signature · 1 line
2.39.5
[tip: x86/cache] x86/resctrl: Squelch whitespace anomalies in resctrl core code
The following commit has been merged into the x86/cache branch of tip:
The following commit has been merged into the x86/cache branch of tip:
Commit-ID: 556f48a5093b1edb1b8a594af633303269dec329 Gitweb: https://git.kernel.org/tip/556f48a5093b1edb1b8a594af633303269dec329 Author: Dave Martin <[email protected]> AuthorDate: Thu, 15 May 2025 16:58:50 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Fri, 16 May 2025 14:09:18 +02:00
x86/resctrl: Squelch whitespace anomalies in resctrl core code
checkpatch.pl complains about some whitespace anomalies in the resctrl core code.
This doesn't matter, but since this code is about to be factored out and made generic, this is a good opportunity to fix these issues and so reduce future checkpatch fuzz.
Fix them.
No functional change.
--- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
arch/x86/kernel/cpu/resctrl/rdtgroup.c +5 -7
@@ -1024,7 +1024,7 @@ static int rdt_num_closids_show(struct kernfs_open_file *of, }static int rdt_default_ctrl_show (struct kernfs_open_file *of, -struct seq_file *seq,void *v) +struct seq_file *seq,void *v) {struct resctrl_schema *s =rdt_kn_parent_priv (of->kn);struct rdt_resource *r = s->res;
@@ -1034,7 +1034,7 @@ static int rdt_default_ctrl_show(struct kernfs_open_file *of, }static int rdt_min_cbm_bits_show (struct kernfs_open_file *of, -struct seq_file *seq,void *v) +struct seq_file *seq,void *v) {struct resctrl_schema *s =rdt_kn_parent_priv (of->kn);struct rdt_resource *r = s->res;
@@ -1150,7 +1150,7 @@ static int rdt_bit_usage_show(struct kernfs_open_file *of, }static int rdt_min_bw_show (struct kernfs_open_file *of, -struct seq_file *seq,void *v) +struct seq_file *seq,void *v) {struct resctrl_schema *s =rdt_kn_parent_priv (of->kn);struct rdt_resource *r = s->res;
@@ -1185,7 +1185,7 @@ static int rdt_mon_features_show(struct kernfs_open_file *of, }static int rdt_bw_gran_show (struct kernfs_open_file *of, -struct seq_file *seq,void *v) +struct seq_file *seq,void *v) {struct resctrl_schema *s =rdt_kn_parent_priv (of->kn);struct rdt_resource *r = s->res;
@@ -1195,7 +1195,7 @@ static int rdt_bw_gran_show(struct kernfs_open_file *of, }static int rdt_delay_linear_show (struct kernfs_open_file *of, -struct seq_file *seq,void *v) +struct seq_file *seq,void *v) {struct resctrl_schema *s =rdt_kn_parent_priv (of->kn);struct rdt_resource *r = s->res;
@@ -2068,7 +2068,6 @@ static struct rftype res_common_files[] = { .seq_show = rdtgroup_closid_show, .fflags = RFTYPE_CTRL_BASE | RFTYPE_DEBUG, }, - };static int rdtgroup_add_files (struct kernfs_node *kn,unsigned long fflags)
@@ -3628,7 +3627,6 @@ static int rdtgroup_init_alloc(struct rdtgroup *rdtgrp)rdt_last_cmd_puts ("Failed to initialize allocations\n" ); goto out; } - } rdtgrp->mode =RDT_MODE_SHAREABLE ;
James Morse
reviewerPATCH v12 21/25 x86/resctrl: Prefer alloc(sizeof(*foo)) idiom in rdt_init_fs_context()
In reply to James MorseFrom: Dave Martin <[email protected]>
rdt_init_fs_context() sizes a typed allocation using an explicit sizeof(type) expression, which checkpatch.pl complains about.
Since this code is about to be factored out and made generic, this is a good opportunity to fix the code to size the allocation based on the target pointer instead, to reduce the chance of future mis- maintenance.
Fix it.
No functional change.
--- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/resctrl/rdtgroup.c +1 -1
@@ -2951,7 +2951,7 @@ static int rdt_init_fs_context(struct fs_context *fc) {struct rdt_fs_context *ctx; - ctx =kzalloc (sizeof (struct rdt_fs_context ),GFP_KERNEL ); + ctx =kzalloc (sizeof (*ctx),GFP_KERNEL );if (!ctx)return -ENOMEM ;
Signature · 1 line
2.39.5
[tip: x86/cache] x86/resctrl: Prefer alloc(sizeof(*foo)) idiom in rdt_init_fs_context()
The following commit has been merged into the x86/cache branch of tip:
The following commit has been merged into the x86/cache branch of tip:
Commit-ID: df3dc0efcc01d6aae8ebd3e479fe0d55f894854b Gitweb: https://git.kernel.org/tip/df3dc0efcc01d6aae8ebd3e479fe0d55f894854b Author: Dave Martin <[email protected]> AuthorDate: Thu, 15 May 2025 16:58:51 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Fri, 16 May 2025 14:33:56 +02:00
x86/resctrl: Prefer alloc(sizeof(*foo)) idiom in rdt_init_fs_context()
rdt_init_fs_context() sizes a typed allocation using an explicit sizeof(type) expression, which checkpatch.pl complains about.
Since this code is about to be factored out and made generic, this is a good opportunity to fix the code to size the allocation based on the target pointer instead, to reduce the chance of future mis- maintenance.
Fix it.
No functional change.
--- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/resctrl/rdtgroup.c +1 -1
@@ -2951,7 +2951,7 @@ static int rdt_init_fs_context(struct fs_context *fc) {struct rdt_fs_context *ctx; - ctx =kzalloc (sizeof (struct rdt_fs_context ),GFP_KERNEL ); + ctx =kzalloc (sizeof (*ctx),GFP_KERNEL );if (!ctx)return -ENOMEM ;
James Morse
reviewerPATCH v12 22/25 x86/resctrl: Relax some asm #includes
In reply to James MorseFrom: Dave Martin <[email protected]>
checkpatch.pl identifies some direct #includes of asm headers that can be satisfied by including the corresponding <linux/...> header instead.
Fix them.
No intentional functional change.
---
Changes since v2:
* asm->linux for resctrl.h moved into an earlier patch.
--- arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/resctrl/pseudo_lock.c +2 -1
@@ -11,6 +11,8 @@#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt +#include <linux/cacheflush.h> +#include <linux/cacheinfo.h> #include <linux/cpu.h> #include <linux/cpumask.h> #include <linux/debugfs.h>
@@ -22,7 +24,6 @@#include <linux/slab.h> #include <linux/uaccess.h> -#include <asm/cacheflush.h> #include <asm/cpu_device_id.h> #include <asm/perf_event.h>
Signature · 1 line
2.39.5
[tip: x86/cache] x86/resctrl: Relax some asm #includes
The following commit has been merged into the x86/cache branch of tip:
The following commit has been merged into the x86/cache branch of tip:
Commit-ID: b7b57edbf5681c7d0ed504a3a4e912bb68661ab9 Gitweb: https://git.kernel.org/tip/b7b57edbf5681c7d0ed504a3a4e912bb68661ab9 Author: Dave Martin <[email protected]> AuthorDate: Thu, 15 May 2025 16:58:52 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Fri, 16 May 2025 14:34:31 +02:00
x86/resctrl: Relax some asm #includes
checkpatch.pl identifies some direct #includes of asm headers that can be satisfied by including the corresponding <linux/...> header instead.
Fix them.
No intentional functional change.
--- arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/resctrl/pseudo_lock.c +2 -1
@@ -11,6 +11,8 @@#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt +#include <linux/cacheflush.h> +#include <linux/cacheinfo.h> #include <linux/cpu.h> #include <linux/cpumask.h> #include <linux/debugfs.h>
@@ -22,7 +24,6 @@#include <linux/slab.h> #include <linux/uaccess.h> -#include <asm/cacheflush.h> #include <asm/cpu_device_id.h> #include <asm/perf_event.h>
James Morse
reviewerPATCH v12 23/25 x86/resctrl: Always initialise rid field in rdt_resources_all[]
In reply to James Morsex86 has an array, rdt_resources_all[], of all possible resources. The for-each-resource walkers depend on the rid field of all resources being initialised.
If the array ever grows due to another architecture adding a resource type that is not defined on x86, the for-each-resources walkers will loop forever.
Initialise all the rid values in resctrl_arch_late_init() before any for-each-resource walker can be called.
---
Changes since v8:
* Clarified a comment.
Changes since v7:
* Split out of a previous patch due to a botched merged conflict.
--- arch/x86/kernel/cpu/resctrl/core.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
arch/x86/kernel/cpu/resctrl/core.c +5 -5
@@ -60,7 +60,6 @@ struct rdt_hw_resource rdt_resources_all[RDT_NUM_RESOURCES] = { [RDT_RESOURCE_L3] = { .r_resctrl = { - .rid = RDT_RESOURCE_L3, .name = "L3", .ctrl_scope = RESCTRL_L3_CACHE, .mon_scope = RESCTRL_L3_CACHE,
@@ -74,7 +73,6 @@ struct rdt_hw_resource rdt_resources_all[RDT_NUM_RESOURCES] = { [RDT_RESOURCE_L2] = { .r_resctrl = { - .rid = RDT_RESOURCE_L2, .name = "L2", .ctrl_scope = RESCTRL_L2_CACHE, .ctrl_domains = ctrl_domain_init(RDT_RESOURCE_L2),
@@ -86,7 +84,6 @@ struct rdt_hw_resource rdt_resources_all[RDT_NUM_RESOURCES] = { [RDT_RESOURCE_MBA] = { .r_resctrl = { - .rid = RDT_RESOURCE_MBA, .name = "MB", .ctrl_scope = RESCTRL_L3_CACHE, .ctrl_domains = ctrl_domain_init(RDT_RESOURCE_MBA),
@@ -96,7 +93,6 @@ struct rdt_hw_resource rdt_resources_all[RDT_NUM_RESOURCES] = { [RDT_RESOURCE_SMBA] = { .r_resctrl = { - .rid = RDT_RESOURCE_SMBA, .name = "SMBA", .ctrl_scope = RESCTRL_L3_CACHE, .ctrl_domains = ctrl_domain_init(RDT_RESOURCE_SMBA),
@@ -996,7 +992,11 @@ void resctrl_cpu_detect(struct cpuinfo_x86 *c)static int __init resctrl_arch_late_init (void ) {struct rdt_resource *r; -int state, ret; +int state, ret, i; + +/* for_each_rdt_resource() requires all rid to be initialised. */ +for (i =0 ; i <RDT_NUM_RESOURCES ; i++) + rdt_resources_all[i].r_resctrl.rid = i;/* * Initialize functions(or definitions) that are different
Signature · 1 line
2.39.5
[tip: x86/cache] x86/resctrl: Always initialise rid field in rdt_resources_all[]
The following commit has been merged into the x86/cache branch of tip:
The following commit has been merged into the x86/cache branch of tip:
Commit-ID: f6b25be204b8661e4c32fa770a4c9e3a113ee325 Gitweb: https://git.kernel.org/tip/f6b25be204b8661e4c32fa770a4c9e3a113ee325 Author: James Morse <[email protected]> AuthorDate: Thu, 15 May 2025 16:58:53 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Fri, 16 May 2025 14:35:22 +02:00
x86/resctrl: Always initialise rid field in rdt_resources_all[]
x86 has an array, rdt_resources_all[], of all possible resources. The for-each-resource walkers depend on the rid field of all resources being initialised.
If the array ever grows due to another architecture adding a resource type that is not defined on x86, the for-each-resources walkers will loop forever.
Initialise all the rid values in resctrl_arch_late_init() before any for-each-resource walker can be called.
--- arch/x86/kernel/cpu/resctrl/core.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
arch/x86/kernel/cpu/resctrl/core.c +5 -5
@@ -60,7 +60,6 @@ struct rdt_hw_resource rdt_resources_all[RDT_NUM_RESOURCES] = { [RDT_RESOURCE_L3] = { .r_resctrl = { - .rid = RDT_RESOURCE_L3, .name = "L3", .ctrl_scope = RESCTRL_L3_CACHE, .mon_scope = RESCTRL_L3_CACHE,
@@ -74,7 +73,6 @@ struct rdt_hw_resource rdt_resources_all[RDT_NUM_RESOURCES] = { [RDT_RESOURCE_L2] = { .r_resctrl = { - .rid = RDT_RESOURCE_L2, .name = "L2", .ctrl_scope = RESCTRL_L2_CACHE, .ctrl_domains = ctrl_domain_init(RDT_RESOURCE_L2),
@@ -86,7 +84,6 @@ struct rdt_hw_resource rdt_resources_all[RDT_NUM_RESOURCES] = { [RDT_RESOURCE_MBA] = { .r_resctrl = { - .rid = RDT_RESOURCE_MBA, .name = "MB", .ctrl_scope = RESCTRL_L3_CACHE, .ctrl_domains = ctrl_domain_init(RDT_RESOURCE_MBA),
@@ -96,7 +93,6 @@ struct rdt_hw_resource rdt_resources_all[RDT_NUM_RESOURCES] = { [RDT_RESOURCE_SMBA] = { .r_resctrl = { - .rid = RDT_RESOURCE_SMBA, .name = "SMBA", .ctrl_scope = RESCTRL_L3_CACHE, .ctrl_domains = ctrl_domain_init(RDT_RESOURCE_SMBA),
@@ -996,7 +992,11 @@ void resctrl_cpu_detect(struct cpuinfo_x86 *c)static int __init resctrl_arch_late_init (void ) {struct rdt_resource *r; -int state, ret; +int state, ret, i; + +/* for_each_rdt_resource() requires all rid to be initialised. */ +for (i =0 ; i <RDT_NUM_RESOURCES ; i++) + rdt_resources_all[i].r_resctrl.rid = i;/* * Initialize functions(or definitions) that are different
James Morse
reviewerPATCH v12 24/25 x86,fs/resctrl: Move the resctrl filesystem code to live in /fs/resctrl
In reply to James MorseResctrl is a filesystem interface to hardware that provides cache allocation policy and bandwidth control for groups of tasks or CPUs.
To support more than one architecture, resctrl needs to live in /fs/.
Move the code that is concerned with the filesystem interface to /fs/resctrl.
---
This patch was generated by a script - then had additional patches squashed into it. These tags were present on all the patches that were combined.
---
Documentation/arch/x86/index.rst | 1 -
Documentation/filesystems/index.rst | 1 +
.../{arch/x86 => filesystems}/resctrl.rst | 0
MAINTAINERS | 2 +-
arch/x86/kernel/cpu/resctrl/Makefile | 1 -
arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 641 ---
arch/x86/kernel/cpu/resctrl/internal.h | 371 +-
arch/x86/kernel/cpu/resctrl/monitor.c | 909 +---
arch/x86/kernel/cpu/resctrl/monitor_trace.h | 31 -
arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 1087 +---
.../kernel/cpu/resctrl/pseudo_lock_trace.h | 2 +
arch/x86/kernel/cpu/resctrl/rdtgroup.c | 4321 +---------------
fs/resctrl/Kconfig | 2 +-
fs/resctrl/ctrlmondata.c | 661 +++
fs/resctrl/internal.h | 426 ++
fs/resctrl/monitor.c | 929 ++++
fs/resctrl/monitor_trace.h | 33 +
fs/resctrl/pseudo_lock.c | 1105 +++++
fs/resctrl/pseudo_lock_trace.h | 0
fs/resctrl/rdtgroup.c | 4353 +++++++++++++++++
20 files changed, 7525 insertions(+), 7351 deletions(-)
rename Documentation/{arch/x86 => filesystems}/resctrl.rst (100%)
delete mode 100644 arch/x86/kernel/cpu/resctrl/monitor_trace.h
delete mode 100644 fs/resctrl/pseudo_lock_trace.hDocumentation/arch/x86/index.rst +0 -1
@@ -31,7 +31,6 @@ x86-specific Documentation pti mds microcode - resctrl tsx_async_abort buslock usb-legacy-support
Documentation/filesystems/index.rst +1 -0
@@ -113,6 +113,7 @@ Documentation for filesystem implementations. qnx6 ramfs-rootfs-initramfs relay + resctrl romfs smb/index spufs/index
Documentation/filesystems/resctrl.rst renamed from Documentation/arch/x86/resctrl.rst +0 -0
MAINTAINERS +1 -1
@@ -20365,7 +20365,7 @@ M: Tony Luck <[email protected]> M: Reinette Chatre <[email protected]> L: [email protected] S: Supported -F: Documentation/arch/x86/resctrl* +F: Documentation/filesystems/resctrl.rst F: arch/x86/include/asm/resctrl.h F: arch/x86/kernel/cpu/resctrl/ F: fs/resctrl/
arch/x86/kernel/cpu/resctrl/Makefile +0 -1
@@ -5,4 +5,3 @@ obj-$(CONFIG_RESCTRL_FS_PSEUDO_LOCK) += pseudo_lock.o # To allow define_trace.h's recursive include: CFLAGS_pseudo_lock.o = -I$(src) -CFLAGS_monitor.o = -I$(src)
arch/x86/kernel/cpu/resctrl/ctrlmondata.c +0 -641
659 lines not on this page · raw message
arch/x86/kernel/cpu/resctrl/internal.h +8 -363
411 lines not on this page · raw message
arch/x86/kernel/cpu/resctrl/monitor.c +2 -907
962 lines not on this page · raw message
arch/x86/kernel/cpu/resctrl/monitor_trace.h deleted +0 -31
@@ -1,31 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#undef TRACE_SYSTEM -#define TRACE_SYSTEM resctrl - -#if !defined(_FS_RESCTRL_MONITOR_TRACE_H) || defined(TRACE_HEADER_MULTI_READ ) -#define _FS_RESCTRL_MONITOR_TRACE_H - -#include <linux/tracepoint.h> - -TRACE_EVENT (mon_llc_occupancy_limbo, - TP_PROTO(u32 ctrl_hw_id, u32 mon_hw_id, int domain_id, u64 llc_occupancy_bytes), -TP_ARGS (ctrl_hw_id, mon_hw_id, domain_id, llc_occupancy_bytes), - TP_STRUCT__entry(__field(u32, ctrl_hw_id) - __field(u32, mon_hw_id) - __field(int, domain_id) -__field (u64, llc_occupancy_bytes)), - TP_fast_assign(__entry->ctrl_hw_id = ctrl_hw_id; - __entry->mon_hw_id = mon_hw_id; - __entry->domain_id = domain_id; - __entry->llc_occupancy_bytes = llc_occupancy_bytes;), -TP_printk ("ctrl_hw_id=%u mon_hw_id=%u domain_id=%d llc_occupancy_bytes=%llu" , - __entry->ctrl_hw_id, __entry->mon_hw_id, __entry->domain_id, - __entry->llc_occupancy_bytes) - ); - -#endif /* _FS_RESCTRL_MONITOR_TRACE_H */ - -#undef TRACE_INCLUDE_PATH -#define TRACE_INCLUDE_PATH . -#define TRACE_INCLUDE_FILE monitor_trace -#include <trace/define_trace.h>
arch/x86/kernel/cpu/resctrl/pseudo_lock.c +1 -1086
911 lines not on this page · raw message
arch/x86/kernel/cpu/resctrl/pseudo_lock_trace.h +2 -0
Lines of this file are not shown. View the raw message.
arch/x86/kernel/cpu/resctrl/rdtgroup.c +2 -4319
4,321 lines not on this page · raw message
fs/resctrl/ctrlmondata.c +661 -0
661 lines not on this page · raw message
fs/resctrl/internal.h +426 -0
426 lines not on this page · raw message
fs/resctrl/monitor.c +929 -0
929 lines not on this page · raw message
fs/resctrl/pseudo_lock.c +1105 -0
1,105 lines not on this page · raw message
fs/resctrl/pseudo_lock_trace.h deleted +0 -0
fs/resctrl/rdtgroup.c +4353 -0
4,353 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.5
Part of the diff is not shown here. View the raw message.
[tip: x86/cache] x86,fs/resctrl: Move the resctrl filesystem code to live in /fs/resctrl
The following commit has been merged into the x86/cache branch of tip:
The following commit has been merged into the x86/cache branch of tip:
Commit-ID: 7168ae330e8105296210b2b2d31d791d5c073345 Gitweb: https://git.kernel.org/tip/7168ae330e8105296210b2b2d31d791d5c073345 Author: James Morse <[email protected]> AuthorDate: Thu, 15 May 2025 16:58:54 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Fri, 16 May 2025 14:36:09 +02:00
x86,fs/resctrl: Move the resctrl filesystem code to live in /fs/resctrl
Resctrl is a filesystem interface to hardware that provides cache allocation policy and bandwidth control for groups of tasks or CPUs.
To support more than one architecture, resctrl needs to live in /fs/.
Move the code that is concerned with the filesystem interface to /fs/resctrl.
--- Documentation/arch/x86/index.rst | 1 +- Documentation/arch/x86/resctrl.rst | 1523 +----- Documentation/filesystems/index.rst | 1 +- Documentation/filesystems/resctrl.rst | 1523 +++++- MAINTAINERS | 2 +- arch/x86/kernel/cpu/resctrl/Makefile | 1 +- arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 641 +-- arch/x86/kernel/cpu/resctrl/internal.h | 371 +- arch/x86/kernel/cpu/resctrl/monitor.c | 909 +--- arch/x86/kernel/cpu/resctrl/monitor_trace.h | 31 +- arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 1087 +--- arch/x86/kernel/cpu/resctrl/pseudo_lock_trace.h | 2 +- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 4597 +-------------- fs/resctrl/Kconfig | 2 +- fs/resctrl/ctrlmondata.c | 661 ++- fs/resctrl/internal.h | 426 +- fs/resctrl/monitor.c | 929 +++- fs/resctrl/monitor_trace.h | 33 +- fs/resctrl/pseudo_lock.c | 1105 +++- fs/resctrl/pseudo_lock_trace.h | 0 fs/resctrl/rdtgroup.c | 4353 +++++++++++++- 21 files changed, 9186 insertions(+), 9012 deletions(-) delete mode 100644 Documentation/arch/x86/resctrl.rst create mode 100644 Documentation/filesystems/resctrl.rst delete mode 100644 arch/x86/kernel/cpu/resctrl/monitor_trace.h delete mode 100644 fs/resctrl/pseudo_lock_trace.h
Documentation/arch/x86/index.rst +0 -1
@@ -31,7 +31,6 @@ x86-specific Documentation pti mds microcode - resctrl tsx_async_abort buslock usb-legacy-support
Documentation/arch/x86/resctrl.rst deleted +0 -1523
1,523 lines not on this page · raw message
Documentation/filesystems/index.rst +1 -0
@@ -113,6 +113,7 @@ Documentation for filesystem implementations. qnx6 ramfs-rootfs-initramfs relay + resctrl romfs smb/index spufs/index
Documentation/filesystems/resctrl.rst new file +1523 -0
1,463 lines not on this page · raw message
arch/x86/kernel/cpu/resctrl/ctrlmondata.c +0 -641
641 lines not on this page · raw message
arch/x86/kernel/cpu/resctrl/internal.h +8 -363
371 lines not on this page · raw message
arch/x86/kernel/cpu/resctrl/monitor.c +2 -907
909 lines not on this page · raw message
arch/x86/kernel/cpu/resctrl/monitor_trace.h deleted +0 -31
Lines of this file are not shown. View the raw message.
arch/x86/kernel/cpu/resctrl/pseudo_lock.c +1 -1086
1,087 lines not on this page · raw message
arch/x86/kernel/cpu/resctrl/pseudo_lock_trace.h +2 -0
Lines of this file are not shown. View the raw message.
arch/x86/kernel/cpu/resctrl/rdtgroup.c +140 -4457
4,597 lines not on this page · raw message
fs/resctrl/ctrlmondata.c +661 -0
661 lines not on this page · raw message
fs/resctrl/internal.h +426 -0
426 lines not on this page · raw message
fs/resctrl/monitor.c +929 -0
929 lines not on this page · raw message
fs/resctrl/pseudo_lock.c +1105 -0
1,105 lines not on this page · raw message
fs/resctrl/pseudo_lock_trace.h deleted +0 -0
fs/resctrl/rdtgroup.c +4353 -0
4,353 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
James Morse
reviewerPATCH v12 25/25 MAINTAINERS: Add reviewers for fs/resctrl
In reply to James Morseresctrl has existed for quite a while as a filesystem interface private to arch/x86. To allow other architectures to support the same user interface for similar hardware features, it has been moved to /fs/.
Add those with a vested interest in the common code as reviewers.
--- MAINTAINERS | 2 ++ 1 file changed, 2 insertions(+)
MAINTAINERS +2 -0
@@ -20363,6 +20363,8 @@ F: tools/testing/selftests/net/rds/ RDT - RESOURCE ALLOCATION M: Tony Luck <[email protected]> M: Reinette Chatre <[email protected]> +R: Dave Martin <[email protected]> +R: James Morse <[email protected]> L: [email protected] S: Supported F: Documentation/filesystems/resctrl.rst
Signature · 1 line
2.39.5
[tip: x86/cache] MAINTAINERS: Add reviewers for fs/resctrl
The following commit has been merged into the x86/cache branch of tip:
The following commit has been merged into the x86/cache branch of tip:
Commit-ID: 54d14f25664bbb75c2928dd0d64a095c0f488176 Gitweb: https://git.kernel.org/tip/54d14f25664bbb75c2928dd0d64a095c0f488176 Author: James Morse <[email protected]> AuthorDate: Thu, 15 May 2025 16:58:55 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Fri, 16 May 2025 14:36:42 +02:00
MAINTAINERS: Add reviewers for fs/resctrl
resctrl has existed for quite a while as a filesystem interface private to arch/x86. To allow other architectures to support the same user interface for similar hardware features, it has been moved to /fs/.
Add those with a vested interest in the common code as reviewers.
--- MAINTAINERS | 2 ++ 1 file changed, 2 insertions(+)
MAINTAINERS +2 -0
@@ -20422,6 +20422,8 @@ F: tools/testing/selftests/net/rds/ RDT - RESOURCE ALLOCATION M: Tony Luck <[email protected]> M: Reinette Chatre <[email protected]> +R: Dave Martin <[email protected]> +R: James Morse <[email protected]> L: [email protected] S: Supported F: Documentation/filesystems/resctrl.rst
Borislav Petkov
maintainerQuoted 4 lines · James Morse
Hello!
No code changes since v11 - this is the 'final' form of the series with patches v11:24-29 squashed together. See [v11] for the breakdown.
Thx, lemme see if I can queue them...
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteQuoted 7 lines · Borislav Petkov
Quoted 4 lines · James Morse
Hello!
No code changes since v11 - this is the 'final' form of the series with patches v11:24-29 squashed together. See [v11] for the breakdown.
Thx, lemme see if I can queue them...
I build and test this series. Everything looks good to me.
Thanks.
-Fenghua
Quoted 10 lines · Fenghua Yu
Quoted 7 lines · Borislav Petkov
Quoted 4 lines · James Morse
Hello!
No code changes since v11 - this is the 'final' form of the series with patches v11:24-29 squashed together. See [v11] for the breakdown.
Thx, lemme see if I can queue them...
I build and test this series. Everything looks good to me.
Is that you giving a
tag?
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteFenghua Yu
Tested-byHi, Boris,
Quoted 7 lines · Borislav Petkov
Quoted 6 lines · Fenghua Yu
Quoted 5 lines · Borislav Petkov
Quoted 4 lines · James Morse
Hello!
No code changes since v11 - this is the 'final' form of the series with patches v11:24-29 squashed together. See [v11] for the breakdown.
Quoted 8 lines
Quoted 3 lines
Quoted 2 lines
Thx, lemme see if I can queue them...
I build and test this series. Everything looks good to me.
Is that you giving a
Tested-by youtag?
Yes.
Thanks.
-Fenghua
Reinette Chatre
maintainerHi Boris and x86 Maintainers,
Quoted 9 lines · James Morse
Hello!
No code changes since v11 - this is the 'final' form of the series with patches v11:24-29 squashed together. See [v11] for the breakdown.
The first four patches are a series from Yury which I've rebased onto.
This series is based on rc5, and can be retrieved from:
git://git.kernel.org/pub/scm/linux/kernel/git/morse/linux.gitmpam/move_to_fs/v12
(mpam/move_to_fs/v12 -> mpam/move_to_fs/v12_final)
Quoted 10 lines
With the exception of invalid configurations for the configurable-events, there should be no changes in behaviour caused by this series. It is now possible for
throttle_modeto report 'undefined', but no known platform will do this.resctrl_exit()is now something that can be called, but x86 doesn't do this.The driving pattern is to make things like struct rdtgroup private to resctrl. Features like pseudo-lock aren't going to work on arm64, the ability to disable it at compile time is added.
Quoted 8 lines
After this, I can start posting the MPAM driver to make use of resctrl on arm64. (What's MPAM? See the cover letter of the first series. [1])
Bugs are still welcome!
Thanks,James
Could you please consider this work for inclusion?
Thank you very much.
Reinette