All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] arm64: cpufeature: Display the set of cores with a feature
@ 2023-10-13  1:30 ` Jeremy Linton
  0 siblings, 0 replies; 10+ messages in thread
From: Jeremy Linton @ 2023-10-13  1:30 UTC (permalink / raw
  To: linux-arm-kernel
  Cc: catalin.marinas, will, mark.rutland, maz, anshuman.khandual,
	krisman, broonie, james.morse, ionela.voinescu, linux-kernel,
	Jeremy Linton

The AMU feature can be enabled on a subset of the cores in a system.
Because of that, it prints a message for each core as it is detected.
This becomes tedious when there are hundreds of cores. Instead, for
CPU features which can be enabled on a subset of the present cores,
lets wait until update_cpu_capabilities() and print the subset of cores
the feature was enabled on.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
---
 arch/arm64/include/asm/cpufeature.h |  2 ++
 arch/arm64/kernel/cpufeature.c      | 16 +++++++++++++---
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h
index 5bba39376055..19b4d001d845 100644
--- a/arch/arm64/include/asm/cpufeature.h
+++ b/arch/arm64/include/asm/cpufeature.h
@@ -23,6 +23,7 @@
 #include <linux/bug.h>
 #include <linux/jump_label.h>
 #include <linux/kernel.h>
+#include <linux/cpumask.h>
 
 /*
  * CPU feature register tracking
@@ -380,6 +381,7 @@ struct arm64_cpu_capabilities {
 	 * method is robust against being called multiple times.
 	 */
 	const struct arm64_cpu_capabilities *match_list;
+	const struct cpumask *cpus;
 };
 
 static inline int cpucap_default_scope(const struct arm64_cpu_capabilities *cap)
diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
index 444a73c2e638..18711e35924c 100644
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -1944,8 +1944,6 @@ int get_cpu_with_amu_feat(void)
 static void cpu_amu_enable(struct arm64_cpu_capabilities const *cap)
 {
 	if (has_cpuid_feature(cap, SCOPE_LOCAL_CPU)) {
-		pr_info("detected CPU%d: Activity Monitors Unit (AMU)\n",
-			smp_processor_id());
 		cpumask_set_cpu(smp_processor_id(), &amu_cpus);
 
 		/* 0 reference values signal broken/disabled counters */
@@ -2411,10 +2409,12 @@ static const struct arm64_cpu_capabilities arm64_features[] = {
 		 * message to be shown until at least one CPU is detected to
 		 * support the feature.
 		 */
+		.desc = "Activity Monitors Unit (AMU)",
 		.capability = ARM64_HAS_AMU_EXTN,
 		.type = ARM64_CPUCAP_WEAK_LOCAL_CPU_FEATURE,
 		.matches = has_amu,
 		.cpu_enable = cpu_amu_enable,
+		.cpus = &amu_cpus,
 		ARM64_CPUID_FIELDS(ID_AA64PFR0_EL1, AMU, IMP)
 	},
 #endif /* CONFIG_ARM64_AMU_EXTN */
@@ -2981,7 +2981,7 @@ static void update_cpu_capabilities(u16 scope_mask)
 		    !caps->matches(caps, cpucap_default_scope(caps)))
 			continue;
 
-		if (caps->desc)
+		if (caps->desc && !caps->cpus)
 			pr_info("detected: %s\n", caps->desc);
 
 		__set_bit(caps->capability, system_cpucaps);
@@ -3330,6 +3330,7 @@ unsigned long cpu_get_elf_hwcap2(void)
 
 static void __init setup_system_capabilities(void)
 {
+	int i;
 	/*
 	 * We have finalised the system-wide safe feature
 	 * registers, finalise the capabilities that depend
@@ -3338,6 +3339,15 @@ static void __init setup_system_capabilities(void)
 	 */
 	update_cpu_capabilities(SCOPE_SYSTEM);
 	enable_cpu_capabilities(SCOPE_ALL & ~SCOPE_BOOT_CPU);
+
+	for (i = 0; i < ARM64_NCAPS; i++) {
+		const struct arm64_cpu_capabilities *caps = cpucap_ptrs[i];
+
+		if (caps && caps->cpus && caps->desc &&
+			cpumask_any(caps->cpus) < nr_cpu_ids)
+			pr_info("detected: %s on CPU%*pbl\n",
+				caps->desc, cpumask_pr_args(caps->cpus));
+	}
 }
 
 void __init setup_cpu_features(void)
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH] arm64: cpufeature: Display the set of cores with a feature
@ 2023-10-13  1:30 ` Jeremy Linton
  0 siblings, 0 replies; 10+ messages in thread
From: Jeremy Linton @ 2023-10-13  1:30 UTC (permalink / raw
  To: linux-arm-kernel
  Cc: catalin.marinas, will, mark.rutland, maz, anshuman.khandual,
	krisman, broonie, james.morse, ionela.voinescu, linux-kernel,
	Jeremy Linton

The AMU feature can be enabled on a subset of the cores in a system.
Because of that, it prints a message for each core as it is detected.
This becomes tedious when there are hundreds of cores. Instead, for
CPU features which can be enabled on a subset of the present cores,
lets wait until update_cpu_capabilities() and print the subset of cores
the feature was enabled on.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
---
 arch/arm64/include/asm/cpufeature.h |  2 ++
 arch/arm64/kernel/cpufeature.c      | 16 +++++++++++++---
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h
index 5bba39376055..19b4d001d845 100644
--- a/arch/arm64/include/asm/cpufeature.h
+++ b/arch/arm64/include/asm/cpufeature.h
@@ -23,6 +23,7 @@
 #include <linux/bug.h>
 #include <linux/jump_label.h>
 #include <linux/kernel.h>
+#include <linux/cpumask.h>
 
 /*
  * CPU feature register tracking
@@ -380,6 +381,7 @@ struct arm64_cpu_capabilities {
 	 * method is robust against being called multiple times.
 	 */
 	const struct arm64_cpu_capabilities *match_list;
+	const struct cpumask *cpus;
 };
 
 static inline int cpucap_default_scope(const struct arm64_cpu_capabilities *cap)
diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
index 444a73c2e638..18711e35924c 100644
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -1944,8 +1944,6 @@ int get_cpu_with_amu_feat(void)
 static void cpu_amu_enable(struct arm64_cpu_capabilities const *cap)
 {
 	if (has_cpuid_feature(cap, SCOPE_LOCAL_CPU)) {
-		pr_info("detected CPU%d: Activity Monitors Unit (AMU)\n",
-			smp_processor_id());
 		cpumask_set_cpu(smp_processor_id(), &amu_cpus);
 
 		/* 0 reference values signal broken/disabled counters */
@@ -2411,10 +2409,12 @@ static const struct arm64_cpu_capabilities arm64_features[] = {
 		 * message to be shown until at least one CPU is detected to
 		 * support the feature.
 		 */
+		.desc = "Activity Monitors Unit (AMU)",
 		.capability = ARM64_HAS_AMU_EXTN,
 		.type = ARM64_CPUCAP_WEAK_LOCAL_CPU_FEATURE,
 		.matches = has_amu,
 		.cpu_enable = cpu_amu_enable,
+		.cpus = &amu_cpus,
 		ARM64_CPUID_FIELDS(ID_AA64PFR0_EL1, AMU, IMP)
 	},
 #endif /* CONFIG_ARM64_AMU_EXTN */
@@ -2981,7 +2981,7 @@ static void update_cpu_capabilities(u16 scope_mask)
 		    !caps->matches(caps, cpucap_default_scope(caps)))
 			continue;
 
-		if (caps->desc)
+		if (caps->desc && !caps->cpus)
 			pr_info("detected: %s\n", caps->desc);
 
 		__set_bit(caps->capability, system_cpucaps);
@@ -3330,6 +3330,7 @@ unsigned long cpu_get_elf_hwcap2(void)
 
 static void __init setup_system_capabilities(void)
 {
+	int i;
 	/*
 	 * We have finalised the system-wide safe feature
 	 * registers, finalise the capabilities that depend
@@ -3338,6 +3339,15 @@ static void __init setup_system_capabilities(void)
 	 */
 	update_cpu_capabilities(SCOPE_SYSTEM);
 	enable_cpu_capabilities(SCOPE_ALL & ~SCOPE_BOOT_CPU);
+
+	for (i = 0; i < ARM64_NCAPS; i++) {
+		const struct arm64_cpu_capabilities *caps = cpucap_ptrs[i];
+
+		if (caps && caps->cpus && caps->desc &&
+			cpumask_any(caps->cpus) < nr_cpu_ids)
+			pr_info("detected: %s on CPU%*pbl\n",
+				caps->desc, cpumask_pr_args(caps->cpus));
+	}
 }
 
 void __init setup_cpu_features(void)
-- 
2.41.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] arm64: cpufeature: Display the set of cores with a feature
  2023-10-13  1:30 ` Jeremy Linton
@ 2023-10-13  8:29   ` Will Deacon
  -1 siblings, 0 replies; 10+ messages in thread
From: Will Deacon @ 2023-10-13  8:29 UTC (permalink / raw
  To: Jeremy Linton
  Cc: linux-arm-kernel, catalin.marinas, mark.rutland, maz,
	anshuman.khandual, krisman, broonie, james.morse, ionela.voinescu,
	linux-kernel

On Thu, Oct 12, 2023 at 08:30:16PM -0500, Jeremy Linton wrote:
> The AMU feature can be enabled on a subset of the cores in a system.
> Because of that, it prints a message for each core as it is detected.
> This becomes tedious when there are hundreds of cores. Instead, for
> CPU features which can be enabled on a subset of the present cores,
> lets wait until update_cpu_capabilities() and print the subset of cores
> the feature was enabled on.
> 
> Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
> ---
>  arch/arm64/include/asm/cpufeature.h |  2 ++
>  arch/arm64/kernel/cpufeature.c      | 16 +++++++++++++---
>  2 files changed, 15 insertions(+), 3 deletions(-)

That's pretty neat. Are there any other caps we could switch over to this
new mechanism as well? We have a weird bodge, for example, in has_hw_dbm()
to print a "detected: ..." message and I wonder whether following the
example of the AMU would be better?

Will

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] arm64: cpufeature: Display the set of cores with a feature
@ 2023-10-13  8:29   ` Will Deacon
  0 siblings, 0 replies; 10+ messages in thread
From: Will Deacon @ 2023-10-13  8:29 UTC (permalink / raw
  To: Jeremy Linton
  Cc: linux-arm-kernel, catalin.marinas, mark.rutland, maz,
	anshuman.khandual, krisman, broonie, james.morse, ionela.voinescu,
	linux-kernel

On Thu, Oct 12, 2023 at 08:30:16PM -0500, Jeremy Linton wrote:
> The AMU feature can be enabled on a subset of the cores in a system.
> Because of that, it prints a message for each core as it is detected.
> This becomes tedious when there are hundreds of cores. Instead, for
> CPU features which can be enabled on a subset of the present cores,
> lets wait until update_cpu_capabilities() and print the subset of cores
> the feature was enabled on.
> 
> Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
> ---
>  arch/arm64/include/asm/cpufeature.h |  2 ++
>  arch/arm64/kernel/cpufeature.c      | 16 +++++++++++++---
>  2 files changed, 15 insertions(+), 3 deletions(-)

That's pretty neat. Are there any other caps we could switch over to this
new mechanism as well? We have a weird bodge, for example, in has_hw_dbm()
to print a "detected: ..." message and I wonder whether following the
example of the AMU would be better?

Will

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] arm64: cpufeature: Display the set of cores with a feature
  2023-10-13  8:29   ` Will Deacon
@ 2023-10-13 11:08     ` Mark Brown
  -1 siblings, 0 replies; 10+ messages in thread
From: Mark Brown @ 2023-10-13 11:08 UTC (permalink / raw
  To: Will Deacon
  Cc: Jeremy Linton, linux-arm-kernel, catalin.marinas, mark.rutland,
	maz, anshuman.khandual, krisman, james.morse, ionela.voinescu,
	linux-kernel

[-- Attachment #1: Type: text/plain, Size: 379 bytes --]

On Fri, Oct 13, 2023 at 09:29:48AM +0100, Will Deacon wrote:

> That's pretty neat. Are there any other caps we could switch over to this
> new mechanism as well? We have a weird bodge, for example, in has_hw_dbm()
> to print a "detected: ..." message and I wonder whether following the
> example of the AMU would be better?

There's 32 bit EL0, though that's a bit different...

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] arm64: cpufeature: Display the set of cores with a feature
@ 2023-10-13 11:08     ` Mark Brown
  0 siblings, 0 replies; 10+ messages in thread
From: Mark Brown @ 2023-10-13 11:08 UTC (permalink / raw
  To: Will Deacon
  Cc: Jeremy Linton, linux-arm-kernel, catalin.marinas, mark.rutland,
	maz, anshuman.khandual, krisman, james.morse, ionela.voinescu,
	linux-kernel


[-- Attachment #1.1: Type: text/plain, Size: 379 bytes --]

On Fri, Oct 13, 2023 at 09:29:48AM +0100, Will Deacon wrote:

> That's pretty neat. Are there any other caps we could switch over to this
> new mechanism as well? We have a weird bodge, for example, in has_hw_dbm()
> to print a "detected: ..." message and I wonder whether following the
> example of the AMU would be better?

There's 32 bit EL0, though that's a bit different...

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] arm64: cpufeature: Display the set of cores with a feature
  2023-10-13  1:30 ` Jeremy Linton
@ 2023-10-13 14:57   ` Ionela Voinescu
  -1 siblings, 0 replies; 10+ messages in thread
From: Ionela Voinescu @ 2023-10-13 14:57 UTC (permalink / raw
  To: Jeremy Linton
  Cc: linux-arm-kernel, catalin.marinas, will, mark.rutland, maz,
	anshuman.khandual, krisman, broonie, james.morse, linux-kernel

Hi,

On Thursday 12 Oct 2023 at 20:30:16 (-0500), Jeremy Linton wrote:
> The AMU feature can be enabled on a subset of the cores in a system.
> Because of that, it prints a message for each core as it is detected.
> This becomes tedious when there are hundreds of cores. Instead, for
> CPU features which can be enabled on a subset of the present cores,
> lets wait until update_cpu_capabilities() and print the subset of cores
> the feature was enabled on.
> 
> Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
> ---
>  arch/arm64/include/asm/cpufeature.h |  2 ++
>  arch/arm64/kernel/cpufeature.c      | 16 +++++++++++++---
>  2 files changed, 15 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h
> index 5bba39376055..19b4d001d845 100644
> --- a/arch/arm64/include/asm/cpufeature.h
> +++ b/arch/arm64/include/asm/cpufeature.h
> @@ -23,6 +23,7 @@
>  #include <linux/bug.h>
>  #include <linux/jump_label.h>
>  #include <linux/kernel.h>
> +#include <linux/cpumask.h>
>  
>  /*
>   * CPU feature register tracking
> @@ -380,6 +381,7 @@ struct arm64_cpu_capabilities {
>  	 * method is robust against being called multiple times.
>  	 */
>  	const struct arm64_cpu_capabilities *match_list;
> +	const struct cpumask *cpus;
>  };
>  
>  static inline int cpucap_default_scope(const struct arm64_cpu_capabilities *cap)
> diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
> index 444a73c2e638..18711e35924c 100644
> --- a/arch/arm64/kernel/cpufeature.c
> +++ b/arch/arm64/kernel/cpufeature.c
> @@ -1944,8 +1944,6 @@ int get_cpu_with_amu_feat(void)
>  static void cpu_amu_enable(struct arm64_cpu_capabilities const *cap)
>  {
>  	if (has_cpuid_feature(cap, SCOPE_LOCAL_CPU)) {
> -		pr_info("detected CPU%d: Activity Monitors Unit (AMU)\n",
> -			smp_processor_id());
>  		cpumask_set_cpu(smp_processor_id(), &amu_cpus);
>  
>  		/* 0 reference values signal broken/disabled counters */
> @@ -2411,10 +2409,12 @@ static const struct arm64_cpu_capabilities arm64_features[] = {
>  		 * message to be shown until at least one CPU is detected to
>  		 * support the feature.
>  		 */
> +		.desc = "Activity Monitors Unit (AMU)",
>  		.capability = ARM64_HAS_AMU_EXTN,
>  		.type = ARM64_CPUCAP_WEAK_LOCAL_CPU_FEATURE,
>  		.matches = has_amu,
>  		.cpu_enable = cpu_amu_enable,
> +		.cpus = &amu_cpus,
>  		ARM64_CPUID_FIELDS(ID_AA64PFR0_EL1, AMU, IMP)
>  	},
>  #endif /* CONFIG_ARM64_AMU_EXTN */
> @@ -2981,7 +2981,7 @@ static void update_cpu_capabilities(u16 scope_mask)
>  		    !caps->matches(caps, cpucap_default_scope(caps)))
>  			continue;
>  
> -		if (caps->desc)
> +		if (caps->desc && !caps->cpus)
>  			pr_info("detected: %s\n", caps->desc);
>  
>  		__set_bit(caps->capability, system_cpucaps);
> @@ -3330,6 +3330,7 @@ unsigned long cpu_get_elf_hwcap2(void)
>  
>  static void __init setup_system_capabilities(void)
>  {
> +	int i;
>  	/*
>  	 * We have finalised the system-wide safe feature
>  	 * registers, finalise the capabilities that depend
> @@ -3338,6 +3339,15 @@ static void __init setup_system_capabilities(void)
>  	 */
>  	update_cpu_capabilities(SCOPE_SYSTEM);
>  	enable_cpu_capabilities(SCOPE_ALL & ~SCOPE_BOOT_CPU);
> +
> +	for (i = 0; i < ARM64_NCAPS; i++) {
> +		const struct arm64_cpu_capabilities *caps = cpucap_ptrs[i];
> +
> +		if (caps && caps->cpus && caps->desc &&
> +			cpumask_any(caps->cpus) < nr_cpu_ids)
> +			pr_info("detected: %s on CPU%*pbl\n",
> +				caps->desc, cpumask_pr_args(caps->cpus));
> +	}
>  }
>  
>  void __init setup_cpu_features(void)
> -- 
> 2.41.0
> 

It looks very nice to me! I gave it a run on an RD-N2 FVP so FWIW:

Reviewed-by: Ionela Voinescu <ionela.voinescu@arm.com>
Tested-by: Ionela Voinescu <ionela.voinescu@arm.com>

The same could be used for DBM, but I'm not sure if creating a mask of
supporting CPUs is worth it, for this purpose only.

Hope it helps,
Ionela.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] arm64: cpufeature: Display the set of cores with a feature
@ 2023-10-13 14:57   ` Ionela Voinescu
  0 siblings, 0 replies; 10+ messages in thread
From: Ionela Voinescu @ 2023-10-13 14:57 UTC (permalink / raw
  To: Jeremy Linton
  Cc: linux-arm-kernel, catalin.marinas, will, mark.rutland, maz,
	anshuman.khandual, krisman, broonie, james.morse, linux-kernel

Hi,

On Thursday 12 Oct 2023 at 20:30:16 (-0500), Jeremy Linton wrote:
> The AMU feature can be enabled on a subset of the cores in a system.
> Because of that, it prints a message for each core as it is detected.
> This becomes tedious when there are hundreds of cores. Instead, for
> CPU features which can be enabled on a subset of the present cores,
> lets wait until update_cpu_capabilities() and print the subset of cores
> the feature was enabled on.
> 
> Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
> ---
>  arch/arm64/include/asm/cpufeature.h |  2 ++
>  arch/arm64/kernel/cpufeature.c      | 16 +++++++++++++---
>  2 files changed, 15 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h
> index 5bba39376055..19b4d001d845 100644
> --- a/arch/arm64/include/asm/cpufeature.h
> +++ b/arch/arm64/include/asm/cpufeature.h
> @@ -23,6 +23,7 @@
>  #include <linux/bug.h>
>  #include <linux/jump_label.h>
>  #include <linux/kernel.h>
> +#include <linux/cpumask.h>
>  
>  /*
>   * CPU feature register tracking
> @@ -380,6 +381,7 @@ struct arm64_cpu_capabilities {
>  	 * method is robust against being called multiple times.
>  	 */
>  	const struct arm64_cpu_capabilities *match_list;
> +	const struct cpumask *cpus;
>  };
>  
>  static inline int cpucap_default_scope(const struct arm64_cpu_capabilities *cap)
> diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
> index 444a73c2e638..18711e35924c 100644
> --- a/arch/arm64/kernel/cpufeature.c
> +++ b/arch/arm64/kernel/cpufeature.c
> @@ -1944,8 +1944,6 @@ int get_cpu_with_amu_feat(void)
>  static void cpu_amu_enable(struct arm64_cpu_capabilities const *cap)
>  {
>  	if (has_cpuid_feature(cap, SCOPE_LOCAL_CPU)) {
> -		pr_info("detected CPU%d: Activity Monitors Unit (AMU)\n",
> -			smp_processor_id());
>  		cpumask_set_cpu(smp_processor_id(), &amu_cpus);
>  
>  		/* 0 reference values signal broken/disabled counters */
> @@ -2411,10 +2409,12 @@ static const struct arm64_cpu_capabilities arm64_features[] = {
>  		 * message to be shown until at least one CPU is detected to
>  		 * support the feature.
>  		 */
> +		.desc = "Activity Monitors Unit (AMU)",
>  		.capability = ARM64_HAS_AMU_EXTN,
>  		.type = ARM64_CPUCAP_WEAK_LOCAL_CPU_FEATURE,
>  		.matches = has_amu,
>  		.cpu_enable = cpu_amu_enable,
> +		.cpus = &amu_cpus,
>  		ARM64_CPUID_FIELDS(ID_AA64PFR0_EL1, AMU, IMP)
>  	},
>  #endif /* CONFIG_ARM64_AMU_EXTN */
> @@ -2981,7 +2981,7 @@ static void update_cpu_capabilities(u16 scope_mask)
>  		    !caps->matches(caps, cpucap_default_scope(caps)))
>  			continue;
>  
> -		if (caps->desc)
> +		if (caps->desc && !caps->cpus)
>  			pr_info("detected: %s\n", caps->desc);
>  
>  		__set_bit(caps->capability, system_cpucaps);
> @@ -3330,6 +3330,7 @@ unsigned long cpu_get_elf_hwcap2(void)
>  
>  static void __init setup_system_capabilities(void)
>  {
> +	int i;
>  	/*
>  	 * We have finalised the system-wide safe feature
>  	 * registers, finalise the capabilities that depend
> @@ -3338,6 +3339,15 @@ static void __init setup_system_capabilities(void)
>  	 */
>  	update_cpu_capabilities(SCOPE_SYSTEM);
>  	enable_cpu_capabilities(SCOPE_ALL & ~SCOPE_BOOT_CPU);
> +
> +	for (i = 0; i < ARM64_NCAPS; i++) {
> +		const struct arm64_cpu_capabilities *caps = cpucap_ptrs[i];
> +
> +		if (caps && caps->cpus && caps->desc &&
> +			cpumask_any(caps->cpus) < nr_cpu_ids)
> +			pr_info("detected: %s on CPU%*pbl\n",
> +				caps->desc, cpumask_pr_args(caps->cpus));
> +	}
>  }
>  
>  void __init setup_cpu_features(void)
> -- 
> 2.41.0
> 

It looks very nice to me! I gave it a run on an RD-N2 FVP so FWIW:

Reviewed-by: Ionela Voinescu <ionela.voinescu@arm.com>
Tested-by: Ionela Voinescu <ionela.voinescu@arm.com>

The same could be used for DBM, but I'm not sure if creating a mask of
supporting CPUs is worth it, for this purpose only.

Hope it helps,
Ionela.


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] arm64: cpufeature: Display the set of cores with a feature
  2023-10-13  1:30 ` Jeremy Linton
@ 2023-10-20 12:51   ` Punit Agrawal
  -1 siblings, 0 replies; 10+ messages in thread
From: Punit Agrawal @ 2023-10-20 12:51 UTC (permalink / raw
  To: Jeremy Linton
  Cc: linux-arm-kernel, catalin.marinas, will, mark.rutland, maz,
	anshuman.khandual, krisman, broonie, james.morse, ionela.voinescu,
	linux-kernel

Jeremy Linton <jeremy.linton@arm.com> writes:

> The AMU feature can be enabled on a subset of the cores in a system.
> Because of that, it prints a message for each core as it is detected.
> This becomes tedious when there are hundreds of cores. Instead, for
> CPU features which can be enabled on a subset of the present cores,
> lets wait until update_cpu_capabilities() and print the subset of cores
> the feature was enabled on.
>
> Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
> ---
>  arch/arm64/include/asm/cpufeature.h |  2 ++
>  arch/arm64/kernel/cpufeature.c      | 16 +++++++++++++---
>  2 files changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h
> index 5bba39376055..19b4d001d845 100644
> --- a/arch/arm64/include/asm/cpufeature.h
> +++ b/arch/arm64/include/asm/cpufeature.h
> @@ -23,6 +23,7 @@
>  #include <linux/bug.h>
>  #include <linux/jump_label.h>
>  #include <linux/kernel.h>
> +#include <linux/cpumask.h>
>  
>  /*
>   * CPU feature register tracking
> @@ -380,6 +381,7 @@ struct arm64_cpu_capabilities {
>  	 * method is robust against being called multiple times.
>  	 */
>  	const struct arm64_cpu_capabilities *match_list;
> +	const struct cpumask *cpus;
>  };
>  
>  static inline int cpucap_default_scope(const struct arm64_cpu_capabilities *cap)
> diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
> index 444a73c2e638..18711e35924c 100644
> --- a/arch/arm64/kernel/cpufeature.c
> +++ b/arch/arm64/kernel/cpufeature.c
> @@ -1944,8 +1944,6 @@ int get_cpu_with_amu_feat(void)
>  static void cpu_amu_enable(struct arm64_cpu_capabilities const *cap)
>  {
>  	if (has_cpuid_feature(cap, SCOPE_LOCAL_CPU)) {
> -		pr_info("detected CPU%d: Activity Monitors Unit (AMU)\n",
> -			smp_processor_id());
>  		cpumask_set_cpu(smp_processor_id(), &amu_cpus);
>  
>  		/* 0 reference values signal broken/disabled counters */
> @@ -2411,10 +2409,12 @@ static const struct arm64_cpu_capabilities arm64_features[] = {
>  		 * message to be shown until at least one CPU is detected to
>  		 * support the feature.
>  		 */
> +		.desc = "Activity Monitors Unit (AMU)",
>  		.capability = ARM64_HAS_AMU_EXTN,
>  		.type = ARM64_CPUCAP_WEAK_LOCAL_CPU_FEATURE,
>  		.matches = has_amu,
>  		.cpu_enable = cpu_amu_enable,
> +		.cpus = &amu_cpus,
>  		ARM64_CPUID_FIELDS(ID_AA64PFR0_EL1, AMU, IMP)
>  	},
>  #endif /* CONFIG_ARM64_AMU_EXTN */
> @@ -2981,7 +2981,7 @@ static void update_cpu_capabilities(u16 scope_mask)
>  		    !caps->matches(caps, cpucap_default_scope(caps)))
>  			continue;
>  
> -		if (caps->desc)
> +		if (caps->desc && !caps->cpus)
>  			pr_info("detected: %s\n", caps->desc);
>  
>  		__set_bit(caps->capability, system_cpucaps);
> @@ -3330,6 +3330,7 @@ unsigned long cpu_get_elf_hwcap2(void)
>  
>  static void __init setup_system_capabilities(void)
>  {
> +	int i;
>  	/*
>  	 * We have finalised the system-wide safe feature
>  	 * registers, finalise the capabilities that depend
> @@ -3338,6 +3339,15 @@ static void __init setup_system_capabilities(void)
>  	 */
>  	update_cpu_capabilities(SCOPE_SYSTEM);
>  	enable_cpu_capabilities(SCOPE_ALL & ~SCOPE_BOOT_CPU);
> +
> +	for (i = 0; i < ARM64_NCAPS; i++) {
> +		const struct arm64_cpu_capabilities *caps = cpucap_ptrs[i];
> +
> +		if (caps && caps->cpus && caps->desc &&
> +			cpumask_any(caps->cpus) < nr_cpu_ids)
> +			pr_info("detected: %s on CPU%*pbl\n",
> +				caps->desc, cpumask_pr_args(caps->cpus));
> +	}
>  }
>  
>  void __init setup_cpu_features(void)

Thanks, Jeremy for putting this patch together. The duplicated prints
bothered me too every time I stared at the boot logs.

Fwiw,,

Reviewed-by: Punit Agrawal <punit.agrawal@bytedance.com>
Tested-by: Punit Agrawal <punit.agrawal@bytedance.com>

The patch was verified on an N2 based platform.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] arm64: cpufeature: Display the set of cores with a feature
@ 2023-10-20 12:51   ` Punit Agrawal
  0 siblings, 0 replies; 10+ messages in thread
From: Punit Agrawal @ 2023-10-20 12:51 UTC (permalink / raw
  To: Jeremy Linton
  Cc: linux-arm-kernel, catalin.marinas, will, mark.rutland, maz,
	anshuman.khandual, krisman, broonie, james.morse, ionela.voinescu,
	linux-kernel

Jeremy Linton <jeremy.linton@arm.com> writes:

> The AMU feature can be enabled on a subset of the cores in a system.
> Because of that, it prints a message for each core as it is detected.
> This becomes tedious when there are hundreds of cores. Instead, for
> CPU features which can be enabled on a subset of the present cores,
> lets wait until update_cpu_capabilities() and print the subset of cores
> the feature was enabled on.
>
> Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
> ---
>  arch/arm64/include/asm/cpufeature.h |  2 ++
>  arch/arm64/kernel/cpufeature.c      | 16 +++++++++++++---
>  2 files changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h
> index 5bba39376055..19b4d001d845 100644
> --- a/arch/arm64/include/asm/cpufeature.h
> +++ b/arch/arm64/include/asm/cpufeature.h
> @@ -23,6 +23,7 @@
>  #include <linux/bug.h>
>  #include <linux/jump_label.h>
>  #include <linux/kernel.h>
> +#include <linux/cpumask.h>
>  
>  /*
>   * CPU feature register tracking
> @@ -380,6 +381,7 @@ struct arm64_cpu_capabilities {
>  	 * method is robust against being called multiple times.
>  	 */
>  	const struct arm64_cpu_capabilities *match_list;
> +	const struct cpumask *cpus;
>  };
>  
>  static inline int cpucap_default_scope(const struct arm64_cpu_capabilities *cap)
> diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
> index 444a73c2e638..18711e35924c 100644
> --- a/arch/arm64/kernel/cpufeature.c
> +++ b/arch/arm64/kernel/cpufeature.c
> @@ -1944,8 +1944,6 @@ int get_cpu_with_amu_feat(void)
>  static void cpu_amu_enable(struct arm64_cpu_capabilities const *cap)
>  {
>  	if (has_cpuid_feature(cap, SCOPE_LOCAL_CPU)) {
> -		pr_info("detected CPU%d: Activity Monitors Unit (AMU)\n",
> -			smp_processor_id());
>  		cpumask_set_cpu(smp_processor_id(), &amu_cpus);
>  
>  		/* 0 reference values signal broken/disabled counters */
> @@ -2411,10 +2409,12 @@ static const struct arm64_cpu_capabilities arm64_features[] = {
>  		 * message to be shown until at least one CPU is detected to
>  		 * support the feature.
>  		 */
> +		.desc = "Activity Monitors Unit (AMU)",
>  		.capability = ARM64_HAS_AMU_EXTN,
>  		.type = ARM64_CPUCAP_WEAK_LOCAL_CPU_FEATURE,
>  		.matches = has_amu,
>  		.cpu_enable = cpu_amu_enable,
> +		.cpus = &amu_cpus,
>  		ARM64_CPUID_FIELDS(ID_AA64PFR0_EL1, AMU, IMP)
>  	},
>  #endif /* CONFIG_ARM64_AMU_EXTN */
> @@ -2981,7 +2981,7 @@ static void update_cpu_capabilities(u16 scope_mask)
>  		    !caps->matches(caps, cpucap_default_scope(caps)))
>  			continue;
>  
> -		if (caps->desc)
> +		if (caps->desc && !caps->cpus)
>  			pr_info("detected: %s\n", caps->desc);
>  
>  		__set_bit(caps->capability, system_cpucaps);
> @@ -3330,6 +3330,7 @@ unsigned long cpu_get_elf_hwcap2(void)
>  
>  static void __init setup_system_capabilities(void)
>  {
> +	int i;
>  	/*
>  	 * We have finalised the system-wide safe feature
>  	 * registers, finalise the capabilities that depend
> @@ -3338,6 +3339,15 @@ static void __init setup_system_capabilities(void)
>  	 */
>  	update_cpu_capabilities(SCOPE_SYSTEM);
>  	enable_cpu_capabilities(SCOPE_ALL & ~SCOPE_BOOT_CPU);
> +
> +	for (i = 0; i < ARM64_NCAPS; i++) {
> +		const struct arm64_cpu_capabilities *caps = cpucap_ptrs[i];
> +
> +		if (caps && caps->cpus && caps->desc &&
> +			cpumask_any(caps->cpus) < nr_cpu_ids)
> +			pr_info("detected: %s on CPU%*pbl\n",
> +				caps->desc, cpumask_pr_args(caps->cpus));
> +	}
>  }
>  
>  void __init setup_cpu_features(void)

Thanks, Jeremy for putting this patch together. The duplicated prints
bothered me too every time I stared at the boot logs.

Fwiw,,

Reviewed-by: Punit Agrawal <punit.agrawal@bytedance.com>
Tested-by: Punit Agrawal <punit.agrawal@bytedance.com>

The patch was verified on an N2 based platform.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-10-20 12:52 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-13  1:30 [PATCH] arm64: cpufeature: Display the set of cores with a feature Jeremy Linton
2023-10-13  1:30 ` Jeremy Linton
2023-10-13  8:29 ` Will Deacon
2023-10-13  8:29   ` Will Deacon
2023-10-13 11:08   ` Mark Brown
2023-10-13 11:08     ` Mark Brown
2023-10-13 14:57 ` Ionela Voinescu
2023-10-13 14:57   ` Ionela Voinescu
2023-10-20 12:51 ` Punit Agrawal
2023-10-20 12:51   ` Punit Agrawal

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.