x86/resctrl: Move the resctrl filesystem code to /fs/resctrl
Subsystems (6)
James Morse
reviewerv11 cover x86/resctrl: Move the resctrl filesystem code to /fs/resctrl
Changes since v10:
* Changes the online domains check in patch 7 to walk control and monitor domains separately.
---
Patches 24-29 should be squashed together when merged, taking the commit message of patch 25. It probably makes sense to drop the tags at that point as patch 25 is generated by a script, and impossible to review. They are posted like this to allow folk to re-generate patch 25, then review the differences on top. Not squashing them together would expose a ftrace build warning during bisect. (but who does that!)
The result should look like this:git://git.kernel.org/pub/scm/linux/kernel/git/morse/linux.git mpam/move_to_fs/v11_final
I can also post the 'final' version to be picked up if that is less work.
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/v11
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])
As ever - bugs welcome,
Thanks,
James
[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 (22):
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/resctrl: Remove a newline to avoid confusing the code move script x86,fs/resctrl: Move the resctrl filesystem code to live in
/fs/resctrl
x86,fs/resctrl: Remove duplicated trace header files fs/resctrl: Remove unnecessary includes
fs/resctrl: Change internal.h's header guard macros x86,fs/resctrl: Move resctrl.rst to live under
Documentation/filesystems
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 v11 1/30 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
Re: [PATCH v11 01/30] cpumask: relax cpumask_any_but()
Quoted 10 lines · James Morse
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.
Tested-by James Morse <[email protected]>Reviewed-by James Morse <[email protected]>Reviewed-by Reinette Chatre <[email protected]>Signed-off-by Yury Norov [NVIDIA] <[email protected]>Signed-off-by James Morse <[email protected]>
Thanks.
-Fenghua
James Morse
reviewerPATCH v11 2/30 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
Re: [PATCH v11 02/30] find: add find_first_andnot_bit()
Quoted 9 lines · James Morse
From: "Yury Norov [NVIDIA]" <[email protected]>
The function helps to implement
cpumask_andnot()APIs.Tested-by James Morse <[email protected]>Reviewed-by James Morse <[email protected]>Reviewed-by Reinette Chatre <[email protected]>Signed-off-by Yury Norov [NVIDIA] <[email protected]>Signed-off-by James Morse <[email protected]>
Thanks.
-Fenghua
Re: [PATCH v11 02/30] find: add find_first_andnot_bit()
In reply to James MorseHi, James and Yury,
Quoted 34 lines · James Morse
From: "Yury Norov [NVIDIA]" <[email protected]>
The function helps to implement
cpumask_andnot()APIs.Tested-by James Morse <[email protected]>Reviewed-by James Morse <[email protected]>Reviewed-by Reinette Chatre <[email protected]>Signed-off-by Yury Norov [NVIDIA] <[email protected]>Signed-off-by James Morse <[email protected]>--- include/linux/find.h | 25 +++++++++++++++++++++++++ lib/find_bit.c | 11 +++++++++++ 2 files changed, 36 insertions(+)include/linux/find.h +5
-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
include/linux/find.h unsigned long find_first_and_bit(const unsigned long *addr1, · line 364
Quoted 10 lines
include/linux/find.h +10
-0+* @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)
CHECK: Alignment should match open parenthesis
Quoted 18 lines
include/linux/find.h +10
-0+{ +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 +0
-0
lib/find_bit.c unsigned long _find_first_and_bit(const unsigned long *addr1, · line 124
Quoted 9 lines
lib/find_bit.c +6
-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)
Ditto.
lib/find_bit.c unsigned long _find_first_and_bit(const unsigned long *addr1, · line 132
Quoted 8 lines
lib/find_bit.c +5
-0+{ + 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. */
Thanks.
-Fenghua
Reinette Chatre
maintainerRe: [PATCH v11 02/30] find: add find_first_andnot_bit()
Hi Fenghua,
Quoted 39 lines · Fenghua Yu
Hi, James and Yury,
Quoted 36 lines · James Morse
From: "Yury Norov [NVIDIA]" <[email protected]>
The function helps to implement
cpumask_andnot()APIs.Tested-by James Morse <[email protected]>Reviewed-by James Morse <[email protected]>Reviewed-by Reinette Chatre <[email protected]>Signed-off-by Yury Norov [NVIDIA] <[email protected]>Signed-off-by James Morse <[email protected]>---
include/linux/find.h| 25 +++++++++++++++++++++++++ lib/find_bit.c | 11 +++++++++++2 files changed, 36 insertions(+)include/linux/find.h +2
-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
+ *
Quoted 9 lines
include/linux/find.h unsigned long find_first_and_bit(const unsigned long *addr1, · line 364
Quoted 7 lines
+ * Returns the bit number for the first set bit
+ * If no bits are set, returns >= @size.
+ */include/linux/find.h +4
-0+static __always_inline +unsigned long find_first_andnot_bit (const unsigned long *addr1, + const unsigned long *addr2, + unsigned long size)CHECK: Alignment should match open parenthesis
This was brought up [2] during review of V1 of this specific work [1].
Please compare this code to the rest of the file. Specifically, this alignment guidance is not adhered to in this file. In this contribution we thus accept the contribution from bitmap API maintainer (Yury) without dictating how formatting should be done.
Reinette
[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
Re: [PATCH v11 02/30] find: add find_first_andnot_bit()
Hi, Reinette,
Quoted 58 lines · Reinette Chatre
Hi Fenghua,
Quoted 39 lines · Fenghua Yu
Hi, James and Yury,
Quoted 36 lines · James Morse
From: "Yury Norov [NVIDIA]" <[email protected]>
The function helps to implement
cpumask_andnot()APIs.Tested-by James Morse <[email protected]>Reviewed-by James Morse <[email protected]>Reviewed-by Reinette Chatre <[email protected]>Signed-off-by Yury Norov [NVIDIA] <[email protected]>Signed-off-by James Morse <[email protected]>--- include/linux/find.h | 25 +++++++++++++++++++++++++ lib/find_bit.c | 11 +++++++++++ 2 files changed, 36 insertions(+)include/linux/find.h +7
-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 +* Quoted 9 lines
include/linux/find.h unsigned long find_first_and_bit(const unsigned long *addr1, · line 364
Quoted 7 lines
include/linux/find.h +7
-0+* 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)CHECK: Alignment should match open parenthesis
This was brought up [2] during review of V1 of this specific work [1].
Please compare this code to the rest of the file. Specifically, this alignment guidance is not adhered to in this file. In this contribution we thus accept the contribution from bitmap API maintainer (Yury) without dictating how formatting should be done.
Quoted 5 lines
Reinette
[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
Thanks for the info. This check is acceptable here. I already put my Reviewed-by on this patch.
-Fenghua
James Morse
reviewerPATCH v11 3/30 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
Re: [PATCH v11 03/30] cpumask: add cpumask_{first,next}_andnot() API
Quoted 10 lines · James Morse
From: "Yury Norov [NVIDIA]" <[email protected]>
With the lack of the functions, client code has to abuse less efficient
cpumask_nth().Tested-by James Morse <[email protected]>Reviewed-by James Morse <[email protected]>Reviewed-by Reinette Chatre <[email protected]>Signed-off-by Yury Norov [NVIDIA] <[email protected]>Signed-off-by James Morse <[email protected]>
Thanks.
-Fenghua
James Morse
reviewerPATCH v11 4/30 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
Re: [PATCH v11 04/30] x86/resctrl: Optimize cpumask_any_housekeeping()
Quoted 10 lines · James Morse
From: "Yury Norov [NVIDIA]" <[email protected]>
With the lack of
cpumask_any_andnot_but(),cpumask_any_housekeeping()has to abusecpumask_nth()functions.Update
cpumask_any_housekeeping()to use the newcpumask_any_but()andcpumask_any_andnot_but(). These two functions understandRESCTRL_PICK_ANY_CPU, which simplifiescpumask_any_housekeeping()significantly.
Quoted 7 lines
Tested-by James Morse <[email protected]>Tested-by Shaopeng Tan <[email protected]>Reviewed-by James Morse <[email protected]>Reviewed-by Reinette Chatre <[email protected]>Reviewed-by Shaopeng Tan <[email protected]>Signed-off-by Yury Norov [NVIDIA] <[email protected]>Signed-off-by James Morse <[email protected]>
Thanks.
-Fenghua
James Morse
reviewerPATCH v11 5/30 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
James Morse
reviewerPATCH v11 6/30 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
James Morse
reviewerPATCH v11 7/30 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
Re: [PATCH v11 07/30] x86/resctrl: Check all domains are offline in resctrl_exit()
Hi James,
Quoted 12 lines · James Morse
resctrl_exit()removes things like the resctrl mount point directory and unregisters the filesystem prior to freeing data structures that were allocated duringresctrl_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().
Quoted 5 lines
Suggested-by Reinette Chatre <[email protected]>Signed-off-by James Morse <[email protected]>Tested-by Babu Moger <[email protected]>Tested-by Shaopeng Tan <[email protected]>---
Reinette
Re: [PATCH v11 07/30] x86/resctrl: Check all domains are offline in resctrl_exit()
In reply to James MorseQuoted 8 lines · James Morse
resctrl_exit()removes things like the resctrl mount point directory and unregisters the filesystem prior to freeing data structures that were allocated duringresctrl_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.
Quoted 8 lines
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().Suggested-by Reinette Chatre <[email protected]>Signed-off-by James Morse <[email protected]>Tested-by Babu Moger <[email protected]>Tested-by Shaopeng Tan <[email protected]>
Thanks.
-Fenghua
James Morse
reviewerPATCH v11 8/30 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
Re: [PATCH v11 08/30] x86/resctrl: resctrl_exit() teardown resctrl but leave the mount point
Quoted 23 lines · James Morse
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.
Quoted 10 lines
Signed-off-by James Morse <[email protected]>Tested-by Carl Worth <[email protected]> # arm64Tested-by Shaopeng Tan <[email protected]>Tested-by Peter Newman <[email protected]>Tested-by Babu Moger <[email protected]>Reviewed-by Shaopeng Tan <[email protected]>Reviewed-by Tony Luck <[email protected]>Reviewed-by Reinette Chatre <[email protected]>
Thanks.
-Fenghua
James Morse
reviewerPATCH v11 9/30 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
James Morse
reviewerPATCH v11 10/30 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
James Morse
reviewerPATCH v11 11/30 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
Re: [PATCH v11 11/30] x86/resctrl: Add end-marker to the resctrl_event_id enum
Quoted 6 lines · James Morse
The
resctrl_event_idenum 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.
Quoted 8 lines
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 requiresget_arch_mbm_state()to have a default case.Signed-off-by James Morse <[email protected]>Tested-by Babu Moger <[email protected]>Tested-by Shaopeng Tan <[email protected]>Reviewed-by Reinette Chatre <[email protected]>
Thanks.
-Fenghua
James Morse
reviewerPATCH v11 12/30 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
Re: [PATCH v11 12/30] x86/resctrl: Expand the width of domid by replacing mon_data_bits
Quoted 20 lines · James Morse
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_bitsunion 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->privpointer. 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_bitsunion to a structure. These are shared between control and monitor groups, and are allocated on first use. The list of allocated structmon_datais free'd when the filesystem is umount()ed.
Quoted 6 lines
Co-developed-by Tony Luck <[email protected]>Signed-off-by Tony Luck <[email protected]>Signed-off-by James Morse <[email protected]>Tested-by Babu Moger <[email protected]>Tested-by Shaopeng Tan <[email protected]>Reviewed-by Reinette Chatre <[email protected]>
Thanks.
-Fenghua
Quoted 249 lines
---
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 indom_idin the patch subject.
* Change types in structmon_datato 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 inWARN_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@@ -45,6 +45,12 @@ LIST_HEAD(rdt_all_groups);/* list of entries for the schemata file */ LIST_HEAD (resctrl_schema_all); +/* +* List of struct mon_data containing private data of event files for use by +* rdtgroup_mondata_show(). Protected by rdtgroup_mutex. +*/ +static LIST_HEAD (mon_data_kn_priv_list); +/* The filesystem can only be mounted once. */ bool resctrl_mounted;@@ -3093,6 +3099,63 @@ static void rmdir_all_sub(void)kernfs_remove (kn_mondata); } +/** +* mon_get_kn_priv() - Get the mon_data priv data for this event. +* +* The same values are used across the mon_data directories of all control and +* monitor groups for the same event in the same domain. Keep a list of +* allocated structures and re-use an existing one with the same values for +* @rid, @domid, etc. +* +* @rid: The resource id for the event file being created. +* @domid: The domain id for the event file being created. +* @mevt: The type of event file being created. +* @do_sum: Whether SNC summing monitors are being created. +*/ +static struct mon_data *mon_get_kn_priv (enum resctrl_res_level rid,int domid, +struct mon_evt *mevt, +bool do_sum) +{ +struct mon_data *priv; + +lockdep_assert_held (&rdtgroup_mutex); + +list_for_each_entry (priv, &mon_data_kn_priv_list, list) { +if (priv->rid == rid && priv->domid == domid && + priv->sum == do_sum && priv->evtid == mevt->evtid) +return priv; + } + + priv =kzalloc (sizeof (*priv),GFP_KERNEL ); +if (!priv) +return NULL ; + + priv->rid = rid; + priv->domid = domid; + priv->sum = do_sum; + priv->evtid = mevt->evtid; +list_add_tail (&priv->list, &mon_data_kn_priv_list); + +return priv; +} + +/** +* mon_put_kn_priv() - Free all allocated mon_data structures. +* +* Called when resctrl file system is unmounted. +*/ +static void mon_put_kn_priv (void ) +{ +struct mon_data *priv, *tmp; + +lockdep_assert_held (&rdtgroup_mutex); + +list_for_each_entry_safe (priv, tmp, &mon_data_kn_priv_list, list) { +list_del (&priv->list); +kfree (priv); + } +} +static void resctrl_fs_teardown (void ) {lockdep_assert_held (&rdtgroup_mutex);@@ -3102,6 +3165,7 @@ static void resctrl_fs_teardown(void)return ;rmdir_all_sub (); +mon_put_kn_priv ();rdt_pseudo_lock_release (); rdtgroup_default.mode =RDT_MODE_SHAREABLE ;closid_exit ();@@ -3208,19 +3272,20 @@ static int mon_add_all_files(struct kernfs_node *kn, struct rdt_mon_domain *d, bool do_sum) {struct rmid_read rr = {0 }; -union mon_data_bits priv; +struct mon_data *priv;struct mon_evt *mevt; -int ret; +int ret, domid;if (WARN_ON (list_empty (&r->evt_list)))return -EPERM ; - priv.u.rid = r->rid; - priv.u.domid = do_sum ? d->ci->id : d->hdr.id; - priv.u.sum = do_sum;list_for_each_entry (mevt, &r->evt_list, list) { - priv.u.evtid = mevt->evtid; - ret =mon_addfile (kn, mevt->name, priv.priv); + domid = do_sum ? d->ci->id : d->hdr.id; + priv =mon_get_kn_priv (r->rid, domid, mevt, do_sum); +if (WARN_ON_ONCE (!priv)) +return -EINVAL ; + + ret =mon_addfile (kn, mevt->name, priv);if (ret)return ret;
James Morse
reviewerPATCH v11 13/30 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
James Morse
reviewerPATCH v11 14/30 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
James Morse
reviewerPATCH v11 15/30 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
James Morse
reviewerPATCH v11 16/30 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
James Morse
reviewerPATCH v11 17/30 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
Re: [PATCH v11 17/30] x86/resctrl: Move enum resctrl_event_id to resctrl.h
Quoted 7 lines · James Morse
resctrl_types.hcontains common types and constants to enable architectures to use these types in their definitions withinasm/resctrl.henum
resctrl_event_idwas placed inresctrl_types.hforresctrl_arch_get_cdp_enabled()andresctrl_arch_set_cdp_enabled(), but these two functions are no longer inlined by any architecture.
Quoted 6 lines
Move enum
resctrl_event_idtoresctrl.hSigned-off-by James Morse <[email protected]>Tested-by Babu Moger <[email protected]>Tested-by Shaopeng Tan <[email protected]>Reviewed-by Reinette Chatre <[email protected]>
Thanks.
-Fenghua
Quoted 53 lines
---
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.
James Morse
reviewerPATCH v11 18/30 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
Re: [PATCH v11 18/30] x86/resctrl: Fix types in resctrl_arch_mon_ctx_{alloc,free}() stubs
Quoted 10 lines · James Morse
resctrl_arch_mon_ctx_alloc()andresctrl_arch_mon_ctx_free()take an enumresctrl_event_idthat is already defined inresctrl_types.hto be accessible toasm/resctrl.h.The x86 stubs take an int. Fix that.
Signed-off-by James Morse <[email protected]>Tested-by Babu Moger <[email protected]>Tested-by Shaopeng Tan <[email protected]>Reviewed-by Reinette Chatre <[email protected]>
Thanks.
-Fenghua
James Morse
reviewerPATCH v11 19/30 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
Re: [PATCH v11 19/30] x86/resctrl: Move pseudo lock prototypes to include/linux/resctrl.h
Quoted 11 lines · James Morse
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.
Quoted 7 lines
Move the prototypes and stubs to
linux/resctrl.h, and switch between them using the existingKconfigsymbol.Signed-off-by James Morse <[email protected]>Tested-by Babu Moger <[email protected]>Tested-by Shaopeng Tan <[email protected]>Reviewed-by Reinette Chatre <[email protected]>
Thanks.
-Fenghua
James Morse
reviewerPATCH v11 20/30 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
James Morse
reviewerPATCH v11 21/30 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
James Morse
reviewerPATCH v11 22/30 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
Re: [PATCH v11 22/30] x86/resctrl: Relax some asm #includes
Quoted 10 lines · James Morse
From: 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.
Quoted 8 lines
Signed-off-by Dave Martin <[email protected]>Signed-off-by James Morse <[email protected]>Tested-by Peter Newman <[email protected]>Tested-by Shaopeng Tan <[email protected]>Tested-by Babu Moger <[email protected]>Reviewed-by Reinette Chatre <[email protected]>
Thanks.
-Fenghua
James Morse
reviewerPATCH v11 23/30 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
Re: [PATCH v11 23/30] x86/resctrl: Always initialise rid field in rdt_resources_all[]
Quoted 8 lines · James Morse
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.
Quoted 7 lines
Initialise all the rid values in
resctrl_arch_late_init()before any for-each-resource walker can be called.Signed-off-by James Morse <[email protected]>Tested-by Babu Moger <[email protected]>Tested-by Shaopeng Tan <[email protected]>Reviewed-by Reinette Chatre <[email protected]>
Thanks.
-Fenghua
James Morse
reviewerPATCH v11 24/30 x86/resctrl: Remove a newline to avoid confusing the code move script
In reply to James MorseThe resctrl filesystem code will shortly be moved to /fs/. This involves splitting all the existing files, with some functions remaining under arch/x86, and others moving to fs/resctrl.
To make this reproducible, a python script does the heavy lif^W copy-and-paste. This involves some clunky parsing of C code.
The parser gets confused by the newline after this #ifdef. Just remove it.
--- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 1 - 1 file changed, 1 deletion(-)
arch/x86/kernel/cpu/resctrl/rdtgroup.c +0 -1
@@ -903,7 +903,6 @@ static int rdtgroup_rmid_show(struct kernfs_open_file *of, }#ifdef CONFIG_PROC_CPU_RESCTRL -/* * A task can only be part of one resctrl control group and of one monitor * group which is associated to that control group.
Signature · 1 line
2.39.5
James Morse
reviewerPATCH v11 25/30 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.
---
Changes since *:
* This patch is generated by a script.
--- arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 637 --- arch/x86/kernel/cpu/resctrl/internal.h | 366 +- arch/x86/kernel/cpu/resctrl/monitor.c | 902 +--- arch/x86/kernel/cpu/resctrl/monitor_trace.h | 18 +- arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 1080 +--- .../kernel/cpu/resctrl/pseudo_lock_trace.h | 2 + arch/x86/kernel/cpu/resctrl/rdtgroup.c | 4320 +--------------- fs/resctrl/ctrlmondata.c | 661 +++ fs/resctrl/internal.h | 428 ++ fs/resctrl/monitor.c | 932 ++++ fs/resctrl/monitor_trace.h | 33 + fs/resctrl/pseudo_lock.c | 1115 +++++ fs/resctrl/pseudo_lock_trace.h | 17 + fs/resctrl/rdtgroup.c | 4355 +++++++++++++++++ 14 files changed, 7558 insertions(+), 7308 deletions(-)
arch/x86/kernel/cpu/resctrl/ctrlmondata.c +0 -637
@@ -23,270 +23,6 @@#include "internal.h" -struct rdt_parse_data { -struct rdtgroup *rdtgrp; -char *buf; -}; - -typedef int (ctrlval_parser_t )(struct rdt_parse_data *data, -struct resctrl_schema *s, -struct rdt_ctrl_domain *d); - -/* -* Check whether MBA bandwidth percentage value is correct. The value is -* checked against the minimum and max bandwidth values specified by the -* hardware. The allocated bandwidth percentage is rounded to the next -* control step available on the hardware. -*/ -static bool bw_validate (char *buf,u32 *data,struct rdt_resource *r) -{ -int ret; -u32 bw; - -/* -* Only linear delay values is supported for current Intel SKUs. -*/ -if (!r->membw.delay_linear && r->membw.arch_needs_linear) { -rdt_last_cmd_puts ("No support for non-linear MB domains\n" ); -return false; - } - - ret =kstrtou32 (buf,10 , &bw); -if (ret) { -rdt_last_cmd_printf ("Invalid MB value %s\n" , buf); -return false; - } - -/* Nothing else to do if software controller is enabled. */ -if (is_mba_sc (r)) { - *data = bw; -return true; - } - -if (bw < r->membw.min_bw || bw > r->membw.max_bw) { -rdt_last_cmd_printf ("MB value %u out of range [%d,%d]\n" , - bw, r->membw.min_bw, r->membw.max_bw); -return false; - } - - *data =roundup (bw, (unsigned long )r->membw.bw_gran); -return true; -} - -static int parse_bw (struct rdt_parse_data *data,struct resctrl_schema *s, -struct rdt_ctrl_domain *d) -{ -struct resctrl_staged_config *cfg; -u32 closid = data->rdtgrp->closid; -struct rdt_resource *r = s->res; -u32 bw_val; - - cfg = &d->staged_config[s->conf_type]; -if (cfg->have_new_ctrl) { -rdt_last_cmd_printf ("Duplicate domain %d\n" , d->hdr.id); -return -EINVAL ; - } - -if (!bw_validate (data->buf, &bw_val, r)) -return -EINVAL ; - -if (is_mba_sc (r)) { - d->mbps_val[closid] = bw_val; -return 0 ; - } - - cfg->new_ctrl = bw_val; - cfg->have_new_ctrl = true; - -return 0 ; -} - -/* -* Check whether a cache bit mask is valid. -* On Intel CPUs, non-contiguous 1s value support is indicated by CPUID: -* - CPUID.0x10.1:ECX[3]: L3 non-contiguous 1s value supported if 1 -* - CPUID.0x10.2:ECX[3]: L2 non-contiguous 1s value supported if 1 -* -* Haswell does not support a non-contiguous 1s value and additionally -* requires at least two bits set. -* AMD allows non-contiguous bitmasks. -*/ -static bool cbm_validate (char *buf,u32 *data,struct rdt_resource *r) -{ -u32 supported_bits =BIT_MASK (r->cache.cbm_len) -1 ; -unsigned int cbm_len = r->cache.cbm_len; -unsigned long first_bit, zero_bit, val; -int ret; - - ret =kstrtoul (buf,16 , &val); -if (ret) { -rdt_last_cmd_printf ("Non-hex character in the mask %s\n" , buf); -return false; - } - -if ((r->cache.min_cbm_bits >0 && val ==0 ) || val > supported_bits) { -rdt_last_cmd_puts ("Mask out of range\n" ); -return false; - } - - first_bit =find_first_bit (&val, cbm_len); - zero_bit =find_next_zero_bit (&val, cbm_len, first_bit); - -/* Are non-contiguous bitmasks allowed? */ -if (!r->cache.arch_has_sparse_bitmasks && - (find_next_bit (&val, cbm_len, zero_bit) < cbm_len)) { -rdt_last_cmd_printf ("The mask %lx has non-consecutive 1-bits\n" , val); -return false; - } - -if ((zero_bit - first_bit) < r->cache.min_cbm_bits) { -rdt_last_cmd_printf ("Need at least %d bits in the mask\n" , - r->cache.min_cbm_bits); -return false; - } - - *data = val; -return true; -} - -/* -* Read one cache bit mask (hex). Check that it is valid for the current -* resource type. -*/ -static int parse_cbm (struct rdt_parse_data *data,struct resctrl_schema *s, -struct rdt_ctrl_domain *d) -{ -struct rdtgroup *rdtgrp = data->rdtgrp; -struct resctrl_staged_config *cfg; -struct rdt_resource *r = s->res; -u32 cbm_val; - - cfg = &d->staged_config[s->conf_type]; -if (cfg->have_new_ctrl) { -rdt_last_cmd_printf ("Duplicate domain %d\n" , d->hdr.id); -return -EINVAL ; - } - -/* -* Cannot set up more than one pseudo-locked region in a cache -* hierarchy. -*/ -if (rdtgrp->mode ==RDT_MODE_PSEUDO_LOCKSETUP && -rdtgroup_pseudo_locked_in_hierarchy (d)) { -rdt_last_cmd_puts ("Pseudo-locked region in hierarchy\n" ); -return -EINVAL ; - } - -if (!cbm_validate (data->buf, &cbm_val, r)) -return -EINVAL ; - -if ((rdtgrp->mode ==RDT_MODE_EXCLUSIVE || - rdtgrp->mode ==RDT_MODE_SHAREABLE ) && -rdtgroup_cbm_overlaps_pseudo_locked (d, cbm_val)) { -rdt_last_cmd_puts ("CBM overlaps with pseudo-locked region\n" ); -return -EINVAL ; - } - -/* -* The CBM may not overlap with the CBM of another closid if -* either is exclusive. -*/ -if (rdtgroup_cbm_overlaps (s, d, cbm_val, rdtgrp->closid, true)) { -rdt_last_cmd_puts ("Overlaps with exclusive group\n" ); -return -EINVAL ; - } - -if (rdtgroup_cbm_overlaps (s, d, cbm_val, rdtgrp->closid, false)) { -if (rdtgrp->mode ==RDT_MODE_EXCLUSIVE || - rdtgrp->mode ==RDT_MODE_PSEUDO_LOCKSETUP ) { -rdt_last_cmd_puts ("Overlaps with other group\n" ); -return -EINVAL ; - } - } - - cfg->new_ctrl = cbm_val; - cfg->have_new_ctrl = true; - -return 0 ; -} - -/* -* For each domain in this resource we expect to find a series of: -* id=mask -* separated by ";". The "id" is in decimal, and must match one of -* the "id"s for this resource. -*/ -static int parse_line (char *line,struct resctrl_schema *s, -struct rdtgroup *rdtgrp) -{ -enum resctrl_conf_type t = s->conf_type; -ctrlval_parser_t *parse_ctrlval =NULL ; -struct resctrl_staged_config *cfg; -struct rdt_resource *r = s->res; -struct rdt_parse_data data; -struct rdt_ctrl_domain *d; -char *dom =NULL , *id; -unsigned long dom_id; - -/* Walking r->domains, ensure it can't race with cpuhp */ -lockdep_assert_cpus_held (); - -switch (r->schema_fmt) { -case RESCTRL_SCHEMA_BITMAP : - parse_ctrlval = &parse_cbm; -break ; -case RESCTRL_SCHEMA_RANGE : - parse_ctrlval = &parse_bw; -break ; - } - -if (WARN_ON_ONCE (!parse_ctrlval)) -return -EINVAL ; - -if (rdtgrp->mode ==RDT_MODE_PSEUDO_LOCKSETUP && - (r->rid ==RDT_RESOURCE_MBA || r->rid ==RDT_RESOURCE_SMBA )) { -rdt_last_cmd_puts ("Cannot pseudo-lock MBA resource\n" ); -return -EINVAL ; - } - -next: -if (!line || line[0 ] =='\0' ) -return 0 ; - dom =strsep (&line,";" ); - id =strsep (&dom,"=" ); -if (!dom ||kstrtoul (id,10 , &dom_id)) { -rdt_last_cmd_puts ("Missing '=' or non-numeric domain\n" ); -return -EINVAL ; - } - dom =strim (dom); -list_for_each_entry (d, &r->ctrl_domains, hdr.list) { -if (d->hdr.id == dom_id) { - data.buf = dom; - data.rdtgrp = rdtgrp; -if (parse_ctrlval (&data, s, d)) -return -EINVAL ; -if (rdtgrp->mode ==RDT_MODE_PSEUDO_LOCKSETUP ) { - cfg = &d->staged_config[t]; -/* -* In pseudo-locking setup mode and just -* parsed a valid CBM that should be -* pseudo-locked. Only one locked region per -* resource group and domain so just do -* the required initialization for single -* region and return. -*/ - rdtgrp->plr->s = s; - rdtgrp->plr->d = d; - rdtgrp->plr->cbm = cfg->new_ctrl; - d->plr = rdtgrp->plr; -return 0 ; - } - goto next; - } - } -return -EINVAL ; -} -int resctrl_arch_update_one (struct rdt_resource *r,struct rdt_ctrl_domain *d,u32 closid,enum resctrl_conf_type t,u32 cfg_val) {
@@ -351,100 +87,6 @@ int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid)return 0 ; } -static int rdtgroup_parse_resource (char *resname,char *tok, -struct rdtgroup *rdtgrp) -{ -struct resctrl_schema *s; - -list_for_each_entry (s, &resctrl_schema_all, list) { -if (!strcmp (resname, s->name) && rdtgrp->closid < s->num_closid) -return parse_line (tok, s, rdtgrp); - } -rdt_last_cmd_printf ("Unknown or unsupported resource name '%s'\n" , resname); -return -EINVAL ; -} - -ssize_t rdtgroup_schemata_write (struct kernfs_open_file *of, -char *buf,size_t nbytes,loff_t off) -{ -struct resctrl_schema *s; -struct rdtgroup *rdtgrp; -struct rdt_resource *r; -char *tok, *resname; -int ret =0 ; - -/* Valid input requires a trailing newline */ -if (nbytes ==0 || buf[nbytes -1 ] !='\n' ) -return -EINVAL ; - buf[nbytes -1 ] ='\0' ; - - rdtgrp =rdtgroup_kn_lock_live (of->kn); -if (!rdtgrp) { -rdtgroup_kn_unlock (of->kn); -return -ENOENT ; - } -rdt_last_cmd_clear (); - -/* -* No changes to pseudo-locked region allowed. It has to be removed -* and re-created instead. -*/ -if (rdtgrp->mode ==RDT_MODE_PSEUDO_LOCKED ) { - ret = -EINVAL ; -rdt_last_cmd_puts ("Resource group is pseudo-locked\n" ); - goto out; - } - -rdt_staged_configs_clear (); - -while ((tok =strsep (&buf,"\n" )) !=NULL ) { - resname =strim (strsep (&tok,":" )); -if (!tok) { -rdt_last_cmd_puts ("Missing ':'\n" ); - ret = -EINVAL ; - goto out; - } -if (tok[0 ] =='\0' ) { -rdt_last_cmd_printf ("Missing '%s' value\n" , resname); - ret = -EINVAL ; - goto out; - } - ret =rdtgroup_parse_resource (resname, tok, rdtgrp); -if (ret) - goto out; - } - -list_for_each_entry (s, &resctrl_schema_all, list) { - r = s->res; - -/* -* Writes to mba_sc resources update the software controller, -* not the control MSR. -*/ -if (is_mba_sc (r)) -continue ; - - ret =resctrl_arch_update_domains (r, rdtgrp->closid); -if (ret) - goto out; - } - -if (rdtgrp->mode ==RDT_MODE_PSEUDO_LOCKSETUP ) { -/* -* If pseudo-locking fails we keep the resource group in -* mode RDT_MODE_PSEUDO_LOCKSETUP with its class of service -* active and updated for just the domain the pseudo-locked -* region was requested for. -*/ - ret =rdtgroup_pseudo_lock_create (rdtgrp); - } - -out: -rdt_staged_configs_clear (); -rdtgroup_kn_unlock (of->kn); -return ret ?: nbytes; -} -u32 resctrl_arch_get_config (struct rdt_resource *r,struct rdt_ctrl_domain *d,u32 closid,enum resctrl_conf_type type) {
@@ -453,282 +95,3 @@ u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_ctrl_domain *d,return hw_dom->ctrl_val[idx]; } - -static void show_doms (struct seq_file *s,struct resctrl_schema *schema,int closid) -{ -struct rdt_resource *r = schema->res; -struct rdt_ctrl_domain *dom; -bool sep = false; -u32 ctrl_val; - -/* Walking r->domains, ensure it can't race with cpuhp */ -lockdep_assert_cpus_held (); - -seq_printf (s,"%*s:" , max_name_width, schema->name); -list_for_each_entry (dom, &r->ctrl_domains, hdr.list) { -if (sep) -seq_puts (s,";" ); - -if (is_mba_sc (r)) - ctrl_val = dom->mbps_val[closid]; -else - ctrl_val =resctrl_arch_get_config (r, dom, closid, - schema->conf_type); - -seq_printf (s, schema->fmt_str, dom->hdr.id, ctrl_val); - sep = true; - } -seq_puts (s,"\n" ); -} - -int rdtgroup_schemata_show (struct kernfs_open_file *of, -struct seq_file *s,void *v) -{ -struct resctrl_schema *schema; -struct rdtgroup *rdtgrp; -int ret =0 ; -u32 closid; - - rdtgrp =rdtgroup_kn_lock_live (of->kn); -if (rdtgrp) { -if (rdtgrp->mode ==RDT_MODE_PSEUDO_LOCKSETUP ) { -list_for_each_entry (schema, &resctrl_schema_all, list) { -seq_printf (s,"%s:uninitialized\n" , schema->name); - } - }else if (rdtgrp->mode ==RDT_MODE_PSEUDO_LOCKED ) { -if (!rdtgrp->plr->d) { -rdt_last_cmd_clear (); -rdt_last_cmd_puts ("Cache domain offline\n" ); - ret = -ENODEV ; - }else { -seq_printf (s,"%s:%d=%x\n" , - rdtgrp->plr->s->res->name, - rdtgrp->plr->d->hdr.id, - rdtgrp->plr->cbm); - } - }else { - closid = rdtgrp->closid; -list_for_each_entry (schema, &resctrl_schema_all, list) { -if (closid < schema->num_closid) -show_doms (s, schema, closid); - } - } - }else { - ret = -ENOENT ; - } -rdtgroup_kn_unlock (of->kn); -return ret; -} - -static int smp_mon_event_count (void *arg) -{ -mon_event_count (arg); - -return 0 ; -} - -ssize_t rdtgroup_mba_mbps_event_write (struct kernfs_open_file *of, -char *buf,size_t nbytes,loff_t off) -{ -struct rdtgroup *rdtgrp; -int ret =0 ; - -/* Valid input requires a trailing newline */ -if (nbytes ==0 || buf[nbytes -1 ] !='\n' ) -return -EINVAL ; - buf[nbytes -1 ] ='\0' ; - - rdtgrp =rdtgroup_kn_lock_live (of->kn); -if (!rdtgrp) { -rdtgroup_kn_unlock (of->kn); -return -ENOENT ; - } -rdt_last_cmd_clear (); - -if (!strcmp (buf,"mbm_local_bytes" )) { -if (resctrl_arch_is_mbm_local_enabled ()) - rdtgrp->mba_mbps_event =QOS_L3_MBM_LOCAL_EVENT_ID ; -else - ret = -EINVAL ; - }else if (!strcmp (buf,"mbm_total_bytes" )) { -if (resctrl_arch_is_mbm_total_enabled ()) - rdtgrp->mba_mbps_event =QOS_L3_MBM_TOTAL_EVENT_ID ; -else - ret = -EINVAL ; - }else { - ret = -EINVAL ; - } - -if (ret) -rdt_last_cmd_printf ("Unsupported event id '%s'\n" , buf); - -rdtgroup_kn_unlock (of->kn); - -return ret ?: nbytes; -} - -int rdtgroup_mba_mbps_event_show (struct kernfs_open_file *of, -struct seq_file *s,void *v) -{ -struct rdtgroup *rdtgrp; -int ret =0 ; - - rdtgrp =rdtgroup_kn_lock_live (of->kn); - -if (rdtgrp) { -switch (rdtgrp->mba_mbps_event) { -case QOS_L3_MBM_LOCAL_EVENT_ID : -seq_puts (s,"mbm_local_bytes\n" ); -break ; -case QOS_L3_MBM_TOTAL_EVENT_ID : -seq_puts (s,"mbm_total_bytes\n" ); -break ; -default : -pr_warn_once ("Bad event %d\n" , rdtgrp->mba_mbps_event); - ret = -EINVAL ; -break ; - } - }else { - ret = -ENOENT ; - } - -rdtgroup_kn_unlock (of->kn); - -return ret; -} - -struct rdt_domain_hdr *resctrl_find_domain (struct list_head *h,int id, -struct list_head **pos) -{ -struct rdt_domain_hdr *d; -struct list_head *l; - -list_for_each (l, h) { - d = list_entry(l, struct rdt_domain_hdr, list); -/* When id is found, return its domain. */ -if (id == d->id) -return d; -/* Stop searching when finding id's position in sorted list. */ -if (id < d->id) -break ; - } - -if (pos) - *pos = l; - -return NULL ; -} - -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 cpu; - -/* When picking a CPU from cpu_mask, ensure it can't race with cpuhp */ -lockdep_assert_cpus_held (); - -/* -* Setup the parameters to pass to mon_event_count() to read the data. -*/ - rr->rgrp = rdtgrp; - rr->evtid = evtid; - rr->r = r; - rr->d = d; - rr->first = first; - rr->arch_mon_ctx =resctrl_arch_mon_ctx_alloc (r, evtid); -if (IS_ERR (rr->arch_mon_ctx)) { - rr->err = -EINVAL ; -return ; - } - - cpu =cpumask_any_housekeeping (cpumask,RESCTRL_PICK_ANY_CPU ); - -/* -* cpumask_any_housekeeping() prefers housekeeping CPUs, but -* are all the CPUs nohz_full? If yes, pick a CPU to IPI. -* MPAM's resctrl_arch_rmid_read() is unable to read the -* counters on some platforms if its called in IRQ context. -*/ -if (tick_nohz_full_cpu (cpu)) -smp_call_function_any (cpumask, mon_event_count, rr,1 ); -else -smp_call_on_cpu (cpu, smp_mon_event_count, rr, false); - -resctrl_arch_mon_ctx_free (r, evtid, rr->arch_mon_ctx); -} - -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; -struct rdtgroup *rdtgrp; -struct rdt_resource *r; -struct mon_data *md; -int domid, ret =0 ; - - rdtgrp =rdtgroup_kn_lock_live (of->kn); -if (!rdtgrp) { - ret = -ENOENT ; - goto out; - } - - 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->sum) { -/* -* This file requires summing across all domains that share -* the L3 cache id that was provided in the "domid" field of the -* 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) { -if (d->ci->id == domid) { - rr.ci = d->ci; -mon_event_read (&rr, r,NULL , rdtgrp, - &d->ci->shared_cpu_map, evtid, false); - goto checkresult; - } - } - ret = -ENOENT ; - goto out; - }else { -/* -* This file provides data from a single domain. Search -* the resource to find the domain with "domid". -*/ - hdr =resctrl_find_domain (&r->mon_domains, domid,NULL ); -if (!hdr ||WARN_ON_ONCE (hdr->type !=RESCTRL_MON_DOMAIN )) { - ret = -ENOENT ; - goto out; - } - d = container_of(hdr, struct rdt_mon_domain, hdr); -mon_event_read (&rr, r, d, rdtgrp, &d->hdr.cpu_mask, evtid, false); - } - -checkresult: - -if (rr.err == -EIO ) -seq_puts (m,"Error\n" ); -else if (rr.err == -EINVAL ) -seq_puts (m,"Unavailable\n" ); -else -seq_printf (m,"%llu\n" , rr.val); - -out: -rdtgroup_kn_unlock (of->kn); -return ret; -}
arch/x86/kernel/cpu/resctrl/internal.h +8 -358
401 lines not on this page · raw message
arch/x86/kernel/cpu/resctrl/monitor.c +2 -900
946 lines not on this page · raw message
arch/x86/kernel/cpu/resctrl/monitor_trace.h +2 -16
@@ -7,25 +7,11 @@#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 -1079
974 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 -4318
4,320 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 +428 -0
428 lines not on this page · raw message
fs/resctrl/monitor.c +932 -0
932 lines not on this page · raw message
fs/resctrl/pseudo_lock.c +1115 -0
1,115 lines not on this page · raw message
fs/resctrl/rdtgroup.c +4355 -0
4,355 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.
Re: [PATCH v11 25/30] x86,fs/resctrl: Move the resctrl filesystem code to live in /fs/resctrl
Hi James,
Quoted 10 lines · James Morse
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.
Signed-off-by James Morse <[email protected]>---
Reinette
Re: [PATCH v11 25/30] x86,fs/resctrl: Move the resctrl filesystem code to live in /fs/resctrl
In reply to James MorseQuoted 9 lines · James Morse
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.
Signed-off-by James Morse <[email protected]>
Thanks.
-Fenghua
James Morse
reviewerPATCH v11 26/30 x86,fs/resctrl: Remove duplicated trace header files
In reply to James MorseThe copy-pasting python script creates some empty trace point header files. These can cause a build warning from ftrace.
Remove them.
---
Changes since v8:
* Removed stale CFLAGS_monitor.o for ftrace from arch/x86's Makefile.
--- arch/x86/kernel/cpu/resctrl/Makefile | 1 - arch/x86/kernel/cpu/resctrl/monitor.c | 4 ---- arch/x86/kernel/cpu/resctrl/monitor_trace.h | 17 ----------------- fs/resctrl/pseudo_lock.c | 4 ---- fs/resctrl/pseudo_lock_trace.h | 17 ----------------- 5 files changed, 43 deletions(-) delete mode 100644 arch/x86/kernel/cpu/resctrl/monitor_trace.h delete mode 100644 fs/resctrl/pseudo_lock_trace.h
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/monitor.c +0 -4
@@ -27,10 +27,6 @@#include "internal.h" -#define CREATE_TRACE_POINTS - -#include "monitor_trace.h" -/* * Global boolean for rdt_monitor which is true if any * resource monitoring is enabled.
arch/x86/kernel/cpu/resctrl/monitor_trace.h deleted +0 -17
@@ -1,17 +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> - -#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>
fs/resctrl/pseudo_lock.c +0 -4
@@ -30,10 +30,6 @@#include "../../events/perf_event.h" /* For X86_CONFIG() */ #include "internal.h" -#define CREATE_TRACE_POINTS - -#include "pseudo_lock_trace.h" -/* * Major number assigned to and shared by all devices exposing * pseudo-locked regions.
fs/resctrl/pseudo_lock_trace.h deleted +0 -17
@@ -1,17 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#undef TRACE_SYSTEM -#define TRACE_SYSTEM resctrl - -#if !defined(_X86_RESCTRL_PSEUDO_LOCK_TRACE_H) || defined(TRACE_HEADER_MULTI_READ ) -#define _X86_RESCTRL_PSEUDO_LOCK_TRACE_H - -#include <linux/tracepoint.h> - -#endif /* _X86_RESCTRL_PSEUDO_LOCK_TRACE_H */ - -#undef TRACE_INCLUDE_PATH -#define TRACE_INCLUDE_PATH . - -#define TRACE_INCLUDE_FILE pseudo_lock_trace - -#include <trace/define_trace.h>
Signature · 1 line
2.39.5
Re: [PATCH v11 26/30] x86,fs/resctrl: Remove duplicated trace header files
Quoted 5 lines · James Morse
The copy-pasting python script creates some empty trace point header files. These can cause a build warning from ftrace.
Remove them.
Quoted 7 lines
Signed-off-by James Morse <[email protected]>Tested-by Peter Newman <[email protected]>Tested-by Shaopeng Tan <[email protected]>Tested-by Babu Moger <[email protected]>Reviewed-by Reinette Chatre <[email protected]>
Thanks.
-Fenghua
James Morse
reviewerPATCH v11 27/30 fs/resctrl: Remove unnecessary includes
In reply to James MorseWhen splitting and moving the resctrl code to live in fs/resctrl and arch/x86, some code was duplicated. This was done to keep the parser in the script that does the moving simple. This results in unnecessary includes in the arch and filesystem code.
Remove them.
---
Changes since v7:
* Expanded the scope, removed many more includes.
--- arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 4 ---- arch/x86/kernel/cpu/resctrl/internal.h | 5 ----- arch/x86/kernel/cpu/resctrl/monitor.c | 3 --- arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 7 ------- fs/resctrl/internal.h | 2 -- fs/resctrl/monitor.c | 3 --- fs/resctrl/pseudo_lock.c | 6 ------ fs/resctrl/rdtgroup.c | 2 -- 8 files changed, 32 deletions(-)
arch/x86/kernel/cpu/resctrl/ctrlmondata.c +0 -4
@@ -16,10 +16,6 @@#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt#include <linux/cpu.h> -#include <linux/kernfs.h> -#include <linux/seq_file.h> -#include <linux/slab.h> -#include <linux/tick.h> #include "internal.h"
arch/x86/kernel/cpu/resctrl/internal.h +0 -5
@@ -3,11 +3,6 @@#define _ASM_X86_RESCTRL_INTERNAL_H#include <linux/resctrl.h> -#include <linux/sched.h> -#include <linux/kernfs.h> -#include <linux/fs_context.h> -#include <linux/jump_label.h> -#include <linux/tick.h> #define L3_QOS_CDP_ENABLE 0x01ULL
arch/x86/kernel/cpu/resctrl/monitor.c +0 -3
@@ -18,10 +18,7 @@#define pr_fmt (fmt) "resctrl: " fmt#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>
arch/x86/kernel/cpu/resctrl/pseudo_lock.c +0 -7
@@ -12,17 +12,10 @@#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> -#include <linux/kthread.h> -#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/cpu_device_id.h> #include <asm/perf_event.h>
fs/resctrl/internal.h +0 -2
@@ -3,10 +3,8 @@#define _ASM_X86_RESCTRL_INTERNAL_H#include <linux/resctrl.h> -#include <linux/sched.h> #include <linux/kernfs.h> #include <linux/fs_context.h> -#include <linux/jump_label.h> #include <linux/tick.h> #define CQM_LIMBOCHECK_INTERVAL 1000
fs/resctrl/monitor.c +0 -3
@@ -18,13 +18,10 @@#define pr_fmt (fmt) "resctrl: " fmt#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 "internal.h" #define CREATE_TRACE_POINTS
fs/resctrl/pseudo_lock.c +0 -6
@@ -11,23 +11,17 @@#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> #include <linux/kthread.h> #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/cpu_device_id.h> -#include <asm/perf_event.h> - -#include "../../events/perf_event.h" /* For X86_CONFIG() */ #include "internal.h" /*
fs/resctrl/rdtgroup.c +0 -2
@@ -21,10 +21,8 @@#include <linux/resctrl.h> #include <linux/seq_buf.h> #include <linux/seq_file.h> -#include <linux/sched/signal.h> #include <linux/sched/task.h> #include <linux/slab.h> -#include <linux/task_work.h> #include <linux/user_namespace.h> #include <uapi/linux/magic.h>
Signature · 1 line
2.39.5
James Morse
reviewerPATCH v11 28/30 fs/resctrl: Change internal.h's header guard macros
In reply to James MorseThe code in internal.h was moved by a script. The script didn't know to change the header guard macros. Do that.
--- fs/resctrl/internal.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/resctrl/internal.h +3 -3
@@ -1,6 +1,6 @@/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _ASM_X86_RESCTRL_INTERNAL_H -#define _ASM_X86_RESCTRL_INTERNAL_H +#ifndef _FS_RESCTRL_INTERNAL_H +#define _FS_RESCTRL_INTERNAL_H#include <linux/resctrl.h> #include <linux/kernfs.h>
@@ -423,4 +423,4 @@ static inline int rdtgroup_pseudo_lock_create(struct rdtgroup *rdtgrp)static inline void rdtgroup_pseudo_lock_remove (struct rdtgroup *rdtgrp) { }#endif /* CONFIG_RESCTRL_FS_PSEUDO_LOCK */ -#endif /* _ASM_X86_RESCTRL_INTERNAL_H */ +#endif /* _FS_RESCTRL_INTERNAL_H */
Signature · 1 line
2.39.5
James Morse
reviewerPATCH v11 29/30 x86,fs/resctrl: Move resctrl.rst to live under Documentation/filesystems
In reply to James MorseThe filesystem code has moved from arch/x86 to fs. Move the documentation too.
---
Documentation/arch/x86/index.rst | 1 -
Documentation/filesystems/index.rst | 1 +
Documentation/{arch/x86 => filesystems}/resctrl.rst | 0
MAINTAINERS | 2 +-
arch/x86/kernel/cpu/resctrl/monitor.c | 2 +-
fs/resctrl/Kconfig | 2 +-
6 files changed, 4 insertions(+), 4 deletions(-)
rename Documentation/{arch/x86 => filesystems}/resctrl.rst (100%)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/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/monitor.c +1 -1
@@ -40,7 +40,7 @@ unsigned int rdt_mon_features;static int snc_nodes_per_l3_cache =1 ;/* -* The correction factor table is documented in Documentation/arch/x86/resctrl.rst. +* The correction factor table is documented in Documentation/filesystems/resctrl.rst. * If rmid > rmid threshold, MBM total and local values should be multiplied * by the correction factor. *
fs/resctrl/Kconfig +1 -1
@@ -21,7 +21,7 @@ config RESCTRL_FS On architectures where this can be disabled independently, it is safe to say N. - See <file:Documentation/arch/x86/resctrl.rst> for more information. + See <file:Documentation/filesystems/resctrl.rst> for more information. config RESCTRL_FS_PSEUDO_LOCK bool
Signature · 1 line
2.39.5
James Morse
reviewerPATCH v11 30/30 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
Quoted 3 lines · James Morse
Changes since v10:
* Changes the online domains check in patch 7 to walk control and monitor domains separately.
Built, booted, and lightly tested on regular and SNC systems. All looks fine to me.
-Tony
James Morse
reviewerHi Tony,
Quoted 9 lines · Tony
Quoted 3 lines · James Morse
Changes since v10:
* Changes the online domains check in patch 7 to walk control and monitor domains separately.Built, booted, and lightly tested on regular and SNC systems. All looks fine to me.
Tested-by Tony Luck <[email protected]>
Thanks for testing that!
James
Reinette Chatre
maintainerHi James,
Quoted 6 lines · James Morse
Changes since v10:
* Changes the online domains check in patch 7 to walk control and monitor domains separately.---
Quoted 8 lines
Patches 24-29 should be squashed together when merged, taking the commit message of patch 25. It probably makes sense to drop the tags at that point as patch 25 is generated by a script, and impossible to review. They are posted like this to allow folk to re-generate patch 25, then review the differences on top. Not squashing them together would expose a ftrace build warning during bisect. (but who does that!)
The result should look like this:
git://git.kernel.org/pub/scm/linux/kernel/git/morse/linux.gitmpam/move_to_fs/v11_final
This branch does not exist.
Reinette
Hi, Reinette,
Quoted 15 lines · Reinette Chatre
Hi James,
Quoted 12 lines · James Morse
Changes since v10:
* Changes the online domains check in patch 7 to walk control and monitor domains separately.---
Patches 24-29 should be squashed together when merged, taking the commit message of patch 25. It probably makes sense to drop the tags at that point as patch 25 is generated by a script, and impossible to review. They are posted like this to allow folk to re-generate patch 25, then review the differences on top. Not squashing them together would expose a ftrace build warning during bisect. (but who does that!)
Quoted 3 lines
Quoted 2 lines
The result should look like this:
git://git.kernel.org/pub/scm/linux/kernel/git/morse/linux.gitmpam/move_to_fs/v11_finalThis branch does not exist.
This branch is existing now. I can clone, build, boot, and run some light tests on this branch. All work fine for me.
Thanks.
-Fenghua
Reinette Chatre
maintainerDear Boris and x86 maintainers,
Quoted 8 lines · James Morse
Patches 24-29 should be squashed together when merged, taking the commit message of patch 25. It probably makes sense to drop the tags at that point as patch 25 is generated by a script, and impossible to review. They are posted like this to allow folk to re-generate patch 25, then review the differences on top. Not squashing them together would expose a ftrace build warning during bisect. (but who does that!)
The result should look like this:
git://git.kernel.org/pub/scm/linux/kernel/git/morse/linux.gitmpam/move_to_fs/v11_final
(awaiting this branch's availability)
Quoted 7 lines
I can also post the 'final' version to be picked up if that is less work.
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/v11
Quoted 9 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.
Could you please consider this work for inclusion? Please provide guidance on how to support inclusion of this work ... James mentions a couple of options above.
Thank you very much.
Reinette
Reinette Chatre
maintainerHi James,
Quoted 3 lines · James Morse
I can also post the 'final' version to be picked up if that is less work.
Could you please go ahead and post the "final" version? Boris confirmed that this would work best with the tip processes and the series will be considered if it can be ready soon.
Thank you very much.
Reinette
Quoted 12 lines · James Morse
Changes since v10:
* Changes the online domains check in patch 7 to walk control and monitor domains separately.---
Patches 24-29 should be squashed together when merged, taking the commit message of patch 25. It probably makes sense to drop the tags at that point as patch 25 is generated by a script, and impossible to review. They are posted like this to allow folk to re-generate patch 25, then review the differences on top. Not squashing them together would expose a ftrace build warning during bisect. (but who does that!)
Quoted 9 lines
The result should look like this:
git://git.kernel.org/pub/scm/linux/kernel/git/morse/linux.gitmpam/move_to_fs/v11_finalI can also post the 'final' version to be picked up if that is less work.
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/v11
Hi James,
sorry for late jumping in.
I've tested this v11 patch series (also v10 from last week) based on Intel 5th Gen Xeon server platform, all basic resctrl functions work fine.
Quoted 115 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.
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])
As ever - bugs welcome,
Thanks,James
[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 CLOSIDDave Martin (3):
x86/resctrl: Squelch whitespace anomalies in resctrl core code x86/resctrl: Prefer alloc(sizeof(*foo)) idiom inrdt_init_fs_context()x86/resctrl: Relax some asm #includesJames Morse (22):
x86/resctrl: Renameresctrl_sched_in()to begin with "resctrl_arch_" x86/resctrl: Check all domains are offline inresctrl_exit()x86/resctrl:resctrl_exit()teardown resctrl but leave the mount point x86/resctrl: Drop __init/__exit on assorted symbols x86/resctrl: Moveis_mba_sc()out ofcore.c
x86/resctrl: Add end-marker to theresctrl_event_idenum x86/resctrl: Expand the width of domid by replacingmon_data_bitsx86/resctrl: Splittrace.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 enumresctrl_event_idtoresctrl.hx86/resctrl: Fix types in resctrl_arch_mon_ctx_{alloc,free}() stubs x86/resctrl: Move pseudo lock prototypes toinclude/linux/resctrl.hx86/resctrl: Always initialise rid field in rdt_resources_all[] x86/resctrl: Remove a newline to avoid confusing the code move script x86,fs/resctrl: Move the resctrl filesystem code to live in
/fs/resctrl
x86,fs/resctrl: Remove duplicated trace header files fs/resctrl: Remove unnecessary includes
fs/resctrl: Change internal.h's header guard macros x86,fs/resctrl: Moveresctrl.rstto live under
Documentation/filesystems
MAINTAINERS: Add reviewers for fs/resctrlYury Norov [NVIDIA] (4):
cpumask: relaxcpumask_any_but()
find: addfind_first_andnot_bit()
cpumask: add cpumask_{first,next}_andnot() API x86/resctrl: Optimizecpumask_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%) renamearch/x86/kernel/cpu/resctrl/{trace.h=>pseudo_lock_trace.h} (56%) create mode 100644fs/resctrl/Kconfig
create mode 100644fs/resctrl/Makefile
create mode 100644fs/resctrl/ctrlmondata.c
create mode 100644fs/resctrl/internal.h
create mode 100644fs/resctrl/monitor.c
create mode 100644fs/resctrl/monitor_trace.h
create mode 100644fs/resctrl/pseudo_lock.c
create mode 100644fs/resctrl/rdtgroup.c
James Morse
reviewerHello!
Quoted 23 lines · Hongyu
Quoted 12 lines · James Morse
Changes since v10:
* Changes the online domains check in patch 7 to walk control and monitor domains separately.---
Patches 24-29 should be squashed together when merged, taking the commit message of patch 25. It probably makes sense to drop the tags at that point as patch 25 is generated by a script, and impossible to review. They are posted like this to allow folk to re-generate patch 25, then review the differences on top. Not squashing them together would expose a ftrace build warning during bisect. (but who does that!)
Quoted 9 lines
The result should look like this:
git://git.kernel.org/pub/scm/linux/kernel/git/morse/linux.gitmpam/move_to_fs/v11_finalI can also post the 'final' version to be picked up if that is less work.
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/v11
Quoted 8 lines
Hi James,
sorry for late jumping in.
I've tested this v11 patch series (also v10 from last week) based on Intel 5th Gen Xeon server platform, all basic resctrl functions work fine.
Tested-by Hongyu Ning <[email protected]>
Ah - just missed the v12. Thanks for taking it for a spin though!
James