[PATCH v3 36/38] fs/resctrl: Add boiler plate for external resctrl code

James Morse posted 38 patches 1 year, 6 months ago
There is a newer version of this series
[PATCH v3 36/38] fs/resctrl: Add boiler plate for external resctrl code
Posted by James Morse 1 year, 6 months ago
Add Makefile and Kconfig for fs/resctrl. Add ARCH_HAS_CPU_RESCTRL
for the common parts of the resctrl interface and make X86_CPU_RESCTRL
depend on this.

Adding an include of asm/resctrl.h to linux/resctrl.h allows some
of the files to switch over to using this header instead.

Co-developed-by: Dave Martin <Dave.Martin@arm.com>
Signed-off-by: Dave Martin <Dave.Martin@arm.com>
Signed-off-by: James Morse <james.morse@arm.com>
Tested-by: Peter Newman <peternewman@google.com>
Tested-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
---
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                          |  5 ++--
 arch/x86/kernel/cpu/resctrl/internal.h    |  3 +-
 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                        | 36 +++++++++++++++++++++++
 fs/resctrl/Makefile                       |  3 ++
 fs/resctrl/ctrlmondata.c                  |  0
 fs/resctrl/internal.h                     |  0
 fs/resctrl/monitor.c                      |  0
 fs/resctrl/pseudo_lock.c                  |  0
 fs/resctrl/rdtgroup.c                     |  0
 fs/resctrl/trace.h                        |  0
 include/linux/resctrl.h                   |  4 +++
 18 files changed, 61 insertions(+), 7 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/pseudo_lock.c
 create mode 100644 fs/resctrl/rdtgroup.c
 create mode 100644 fs/resctrl/trace.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 441b039068d8..64195c298baf 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -18859,6 +18859,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/
 
diff --git a/arch/Kconfig b/arch/Kconfig
index 975dd22a2dbd..4156604dd926 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -1431,6 +1431,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
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 446984277b45..e4dd4097e10f 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -490,8 +490,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.
diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h
index bad103f20663..6f6785a31efe 100644
--- a/arch/x86/kernel/cpu/resctrl/internal.h
+++ b/arch/x86/kernel/cpu/resctrl/internal.h
@@ -7,10 +7,9 @@
 #include <linux/kernfs.h>
 #include <linux/fs_context.h>
 #include <linux/jump_label.h>
+#include <linux/resctrl.h>
 #include <linux/tick.h>
 
-#include <asm/resctrl.h>
-
 #define L3_QOS_CDP_ENABLE		0x01ULL
 
 #define L2_QOS_CDP_ENABLE		0x01ULL
diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c
index 145bd05eafa5..a1539edb25fa 100644
--- a/arch/x86/kernel/cpu/resctrl/monitor.c
+++ b/arch/x86/kernel/cpu/resctrl/monitor.c
@@ -17,11 +17,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"
 #include "trace.h"
diff --git a/arch/x86/kernel/cpu/resctrl/pseudo_lock.c b/arch/x86/kernel/cpu/resctrl/pseudo_lock.c
index c096fa106b80..97e901009c91 100644
--- a/arch/x86/kernel/cpu/resctrl/pseudo_lock.c
+++ b/arch/x86/kernel/cpu/resctrl/pseudo_lock.c
@@ -19,12 +19,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() */
diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
index 969c454b67f1..c7cbd30ac0f2 100644
--- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
+++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
@@ -19,6 +19,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>
@@ -29,7 +30,6 @@
 
 #include <uapi/linux/magic.h>
 
-#include <asm/resctrl.h>
 #include "internal.h"
 
 DEFINE_STATIC_KEY_FALSE(rdt_enable_key);
diff --git a/fs/Kconfig b/fs/Kconfig
index a46b0cbc4d8f..d8a36383b6dc 100644
--- a/fs/Kconfig
+++ b/fs/Kconfig
@@ -331,6 +331,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/sysv/Kconfig"
diff --git a/fs/Makefile b/fs/Makefile
index 6ecc9b0a53f2..da6e2d028722 100644
--- a/fs/Makefile
+++ b/fs/Makefile
@@ -129,3 +129,4 @@ obj-$(CONFIG_EFIVAR_FS)		+= efivarfs/
 obj-$(CONFIG_EROFS_FS)		+= erofs/
 obj-$(CONFIG_VBOXSF_FS)		+= vboxsf/
 obj-$(CONFIG_ZONEFS_FS)		+= zonefs/
+obj-$(CONFIG_RESCTRL_FS)	+= resctrl/
diff --git a/fs/resctrl/Kconfig b/fs/resctrl/Kconfig
new file mode 100644
index 000000000000..a5fbda54d32f
--- /dev/null
+++ b/fs/resctrl/Kconfig
@@ -0,0 +1,36 @@
+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.
+
+	  If unsure, it is safe to say N.
+
+	  See <file:Documentation/arch/x86/resctrl.rst> for more information.
+
+config RESCTRL_FS_PSEUDO_LOCK
+	bool
+	help
+	  Software mechanism to pin data in a cache portion using
+	  micro-architecture specific knowledge.
+
+config RESCTRL_RMID_DEPENDS_ON_CLOSID
+	bool
+	help
+	  Enable by the architecture when the RMID values depend on the CLOSID.
+	  This causes the closid allocator to search for CLOSID with clean
+	  RMID.
diff --git a/fs/resctrl/Makefile b/fs/resctrl/Makefile
new file mode 100644
index 000000000000..ee8c4463317a
--- /dev/null
+++ b/fs/resctrl/Makefile
@@ -0,0 +1,3 @@
+# 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
diff --git a/fs/resctrl/ctrlmondata.c b/fs/resctrl/ctrlmondata.c
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/fs/resctrl/pseudo_lock.c b/fs/resctrl/pseudo_lock.c
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/fs/resctrl/trace.h b/fs/resctrl/trace.h
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h
index 31ae6d9a224e..268e17276412 100644
--- a/include/linux/resctrl.h
+++ b/include/linux/resctrl.h
@@ -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
-- 
2.39.2
Re: [PATCH v3 36/38] fs/resctrl: Add boiler plate for external resctrl code
Posted by Reinette Chatre 1 year, 5 months ago
Hi James,

On 6/14/24 8:00 AM, James Morse wrote:
> Add Makefile and Kconfig for fs/resctrl. Add ARCH_HAS_CPU_RESCTRL
> for the common parts of the resctrl interface and make X86_CPU_RESCTRL
> depend on this.
> 
> Adding an include of asm/resctrl.h to linux/resctrl.h allows some
> of the files to switch over to using this header instead.
> 
> Co-developed-by: Dave Martin <Dave.Martin@arm.com>
> Signed-off-by: Dave Martin <Dave.Martin@arm.com>
> Signed-off-by: James Morse <james.morse@arm.com>
> Tested-by: Peter Newman <peternewman@google.com>
> Tested-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
> ---
> 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                          |  5 ++--
>   arch/x86/kernel/cpu/resctrl/internal.h    |  3 +-
>   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                        | 36 +++++++++++++++++++++++
>   fs/resctrl/Makefile                       |  3 ++
>   fs/resctrl/ctrlmondata.c                  |  0
>   fs/resctrl/internal.h                     |  0
>   fs/resctrl/monitor.c                      |  0
>   fs/resctrl/pseudo_lock.c                  |  0
>   fs/resctrl/rdtgroup.c                     |  0
>   fs/resctrl/trace.h                        |  0
>   include/linux/resctrl.h                   |  4 +++
>   18 files changed, 61 insertions(+), 7 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/pseudo_lock.c
>   create mode 100644 fs/resctrl/rdtgroup.c
>   create mode 100644 fs/resctrl/trace.h
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 441b039068d8..64195c298baf 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -18859,6 +18859,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/
>   
> diff --git a/arch/Kconfig b/arch/Kconfig
> index 975dd22a2dbd..4156604dd926 100644
> --- a/arch/Kconfig
> +++ b/arch/Kconfig
> @@ -1431,6 +1431,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
> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
> index 446984277b45..e4dd4097e10f 100644
> --- a/arch/x86/Kconfig
> +++ b/arch/x86/Kconfig
> @@ -490,8 +490,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.
> diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h
> index bad103f20663..6f6785a31efe 100644
> --- a/arch/x86/kernel/cpu/resctrl/internal.h
> +++ b/arch/x86/kernel/cpu/resctrl/internal.h
> @@ -7,10 +7,9 @@
>   #include <linux/kernfs.h>
>   #include <linux/fs_context.h>
>   #include <linux/jump_label.h>
> +#include <linux/resctrl.h>
>   #include <linux/tick.h>
>   
> -#include <asm/resctrl.h>
> -
>   #define L3_QOS_CDP_ENABLE		0x01ULL
>   
>   #define L2_QOS_CDP_ENABLE		0x01ULL
> diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c
> index 145bd05eafa5..a1539edb25fa 100644
> --- a/arch/x86/kernel/cpu/resctrl/monitor.c
> +++ b/arch/x86/kernel/cpu/resctrl/monitor.c
> @@ -17,11 +17,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"
>   #include "trace.h"
> diff --git a/arch/x86/kernel/cpu/resctrl/pseudo_lock.c b/arch/x86/kernel/cpu/resctrl/pseudo_lock.c
> index c096fa106b80..97e901009c91 100644
> --- a/arch/x86/kernel/cpu/resctrl/pseudo_lock.c
> +++ b/arch/x86/kernel/cpu/resctrl/pseudo_lock.c
> @@ -19,12 +19,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() */
> diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> index 969c454b67f1..c7cbd30ac0f2 100644
> --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> @@ -19,6 +19,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>
> @@ -29,7 +30,6 @@
>   
>   #include <uapi/linux/magic.h>
>   
> -#include <asm/resctrl.h>
>   #include "internal.h"
>   
>   DEFINE_STATIC_KEY_FALSE(rdt_enable_key);
> diff --git a/fs/Kconfig b/fs/Kconfig
> index a46b0cbc4d8f..d8a36383b6dc 100644
> --- a/fs/Kconfig
> +++ b/fs/Kconfig
> @@ -331,6 +331,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/sysv/Kconfig"
> diff --git a/fs/Makefile b/fs/Makefile
> index 6ecc9b0a53f2..da6e2d028722 100644
> --- a/fs/Makefile
> +++ b/fs/Makefile
> @@ -129,3 +129,4 @@ obj-$(CONFIG_EFIVAR_FS)		+= efivarfs/
>   obj-$(CONFIG_EROFS_FS)		+= erofs/
>   obj-$(CONFIG_VBOXSF_FS)		+= vboxsf/
>   obj-$(CONFIG_ZONEFS_FS)		+= zonefs/
> +obj-$(CONFIG_RESCTRL_FS)	+= resctrl/
> diff --git a/fs/resctrl/Kconfig b/fs/resctrl/Kconfig
> new file mode 100644
> index 000000000000..a5fbda54d32f
> --- /dev/null
> +++ b/fs/resctrl/Kconfig
> @@ -0,0 +1,36 @@
> +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.
> +
> +	  If unsure, it is safe to say N.
> +

Will user ever get opportunity to say "Y" or "N"? It looks to me that
RESCTRL_FS will be "forced" on user as it is selected by the arch specific
config X86_CPU_RESCTRL and be invisble otherwise because of the dependency
on ARCH_HAS_CPU_RESCTRL. The text about when to select "Y" or "N" thus does
not look practical to me and it may be helpful to instead provide
information about when it is selected? I do not know the customs for this
text and if it is intended to document any future usages also.


Reinette
Re: [PATCH v3 36/38] fs/resctrl: Add boiler plate for external resctrl code
Posted by James Morse 1 year, 5 months ago
Hi Reinette,

On 28/06/2024 17:54, Reinette Chatre wrote:
> On 6/14/24 8:00 AM, James Morse wrote:
>> Add Makefile and Kconfig for fs/resctrl. Add ARCH_HAS_CPU_RESCTRL
>> for the common parts of the resctrl interface and make X86_CPU_RESCTRL
>> depend on this.
>>
>> Adding an include of asm/resctrl.h to linux/resctrl.h allows some
>> of the files to switch over to using this header instead.


>> diff --git a/fs/resctrl/Kconfig b/fs/resctrl/Kconfig
>> new file mode 100644
>> index 000000000000..a5fbda54d32f
>> --- /dev/null
>> +++ b/fs/resctrl/Kconfig
>> @@ -0,0 +1,36 @@
>> +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.
>> +
>> +      If unsure, it is safe to say N.
>> +
> 
> Will user ever get opportunity to say "Y" or "N"?
> It looks to me that
> RESCTRL_FS will be "forced" on user as it is selected by the arch specific
> config X86_CPU_RESCTRL and be invisble otherwise because of the dependency
> on ARCH_HAS_CPU_RESCTRL.

I did it like this so that this change is invisible for x86 config files on the principle
of 'least noise'. Users can't enable RDT but disable resctrl today.
It isn't actually possible to enable RDT and disable resctrl until after the code has been
split from the architecture code.

I have ended up supporting this for MPAM - you can enable the architecture's MPAM code and
the driver, but not resctrl. This will eventually be for in-kernel users of resources that
resctrl doesn't understand.


> The text about when to select "Y" or "N" thus does
> not look practical to me and it may be helpful to instead provide
> information about when it is selected? I do not know the customs for this
> text and if it is intended to document any future usages also.

I think Dave wrote this text because its traditional for Kconfig options to say this.

Describing when it is selected gets messy as this varies by architecture, and Kconfig can
already tell you this:
| Selected by [y]:
│   - X86_CPU_RESCTRL [=y] && X86 [=y] && (CPU_SUP_INTEL [=y] || CPU_SUP_AMD [=y]) &&
MISC_FILESYSTEMS [=y]

I don't think it makes sense for resctrl to be enabled/disabled independently on x86.
If you want to support this, we need a few more IS_ENABLED() checks and stubs to make it
build. The only reason I can see to do it is to ensure the architecture code is self
contained.

I'll reword this as "On architectures where this can be disabled independently, it is safe
to say N".


Thanks,

James
Re: [PATCH v3 36/38] fs/resctrl: Add boiler plate for external resctrl code
Posted by Reinette Chatre 1 year, 5 months ago
Hi James,

On 7/4/24 9:40 AM, James Morse wrote:
> Hi Reinette,
> 
> On 28/06/2024 17:54, Reinette Chatre wrote:
>> On 6/14/24 8:00 AM, James Morse wrote:
>>> Add Makefile and Kconfig for fs/resctrl. Add ARCH_HAS_CPU_RESCTRL
>>> for the common parts of the resctrl interface and make X86_CPU_RESCTRL
>>> depend on this.
>>>
>>> Adding an include of asm/resctrl.h to linux/resctrl.h allows some
>>> of the files to switch over to using this header instead.
> 
> 
>>> diff --git a/fs/resctrl/Kconfig b/fs/resctrl/Kconfig
>>> new file mode 100644
>>> index 000000000000..a5fbda54d32f
>>> --- /dev/null
>>> +++ b/fs/resctrl/Kconfig
>>> @@ -0,0 +1,36 @@
>>> +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.
>>> +
>>> +      If unsure, it is safe to say N.
>>> +
>>
>> Will user ever get opportunity to say "Y" or "N"?
>> It looks to me that
>> RESCTRL_FS will be "forced" on user as it is selected by the arch specific
>> config X86_CPU_RESCTRL and be invisble otherwise because of the dependency
>> on ARCH_HAS_CPU_RESCTRL.
> 
> I did it like this so that this change is invisible for x86 config files on the principle
> of 'least noise'. Users can't enable RDT but disable resctrl today.
> It isn't actually possible to enable RDT and disable resctrl until after the code has been
> split from the architecture code.
> 
> I have ended up supporting this for MPAM - you can enable the architecture's MPAM code and
> the driver, but not resctrl. This will eventually be for in-kernel users of resources that
> resctrl doesn't understand.
> 
> 
>> The text about when to select "Y" or "N" thus does
>> not look practical to me and it may be helpful to instead provide
>> information about when it is selected? I do not know the customs for this
>> text and if it is intended to document any future usages also.
> 
> I think Dave wrote this text because its traditional for Kconfig options to say this.
> 
> Describing when it is selected gets messy as this varies by architecture, and Kconfig can
> already tell you this:
> | Selected by [y]:
> │   - X86_CPU_RESCTRL [=y] && X86 [=y] && (CPU_SUP_INTEL [=y] || CPU_SUP_AMD [=y]) &&
> MISC_FILESYSTEMS [=y]

Right.

> 
> I don't think it makes sense for resctrl to be enabled/disabled independently on x86.

I was not asking for resctrl to be enabled/disabled independently on x86. I commented on this
patch that adds text to guide user for options that the user is never able to select.

> If you want to support this, we need a few more IS_ENABLED() checks and stubs to make it

I did not intend to suggest this at all.

> build. The only reason I can see to do it is to ensure the architecture code is self
> contained.
> 
> I'll reword this as "On architectures where this can be disabled independently, it is safe
> to say N".

ok

Reinette