Skip to content

Commit 23b727d

Browse files
jlintonarmctmarinas
authored andcommitted
arm64: cpufeature: Display the set of cores with a feature
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> Reviewed-by: Ionela Voinescu <ionela.voinescu@arm.com> Tested-by: Ionela Voinescu <ionela.voinescu@arm.com> Reviewed-by: Punit Agrawal <punit.agrawal@bytedance.com> Tested-by: Punit Agrawal <punit.agrawal@bytedance.com> Link: https://lore.kernel.org/r/20231017052322.1211099-2-jeremy.linton@arm.com Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent 6465e26 commit 23b727d

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

arch/arm64/include/asm/cpufeature.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <linux/bug.h>
2424
#include <linux/jump_label.h>
2525
#include <linux/kernel.h>
26+
#include <linux/cpumask.h>
2627

2728
/*
2829
* CPU feature register tracking
@@ -380,6 +381,7 @@ struct arm64_cpu_capabilities {
380381
* method is robust against being called multiple times.
381382
*/
382383
const struct arm64_cpu_capabilities *match_list;
384+
const struct cpumask *cpus;
383385
};
384386

385387
static inline int cpucap_default_scope(const struct arm64_cpu_capabilities *cap)

arch/arm64/kernel/cpufeature.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1944,8 +1944,6 @@ int get_cpu_with_amu_feat(void)
19441944
static void cpu_amu_enable(struct arm64_cpu_capabilities const *cap)
19451945
{
19461946
if (has_cpuid_feature(cap, SCOPE_LOCAL_CPU)) {
1947-
pr_info("detected CPU%d: Activity Monitors Unit (AMU)\n",
1948-
smp_processor_id());
19491947
cpumask_set_cpu(smp_processor_id(), &amu_cpus);
19501948

19511949
/* 0 reference values signal broken/disabled counters */
@@ -2405,16 +2403,12 @@ static const struct arm64_cpu_capabilities arm64_features[] = {
24052403
#endif /* CONFIG_ARM64_RAS_EXTN */
24062404
#ifdef CONFIG_ARM64_AMU_EXTN
24072405
{
2408-
/*
2409-
* The feature is enabled by default if CONFIG_ARM64_AMU_EXTN=y.
2410-
* Therefore, don't provide .desc as we don't want the detection
2411-
* message to be shown until at least one CPU is detected to
2412-
* support the feature.
2413-
*/
2406+
.desc = "Activity Monitors Unit (AMU)",
24142407
.capability = ARM64_HAS_AMU_EXTN,
24152408
.type = ARM64_CPUCAP_WEAK_LOCAL_CPU_FEATURE,
24162409
.matches = has_amu,
24172410
.cpu_enable = cpu_amu_enable,
2411+
.cpus = &amu_cpus,
24182412
ARM64_CPUID_FIELDS(ID_AA64PFR0_EL1, AMU, IMP)
24192413
},
24202414
#endif /* CONFIG_ARM64_AMU_EXTN */
@@ -2981,7 +2975,7 @@ static void update_cpu_capabilities(u16 scope_mask)
29812975
!caps->matches(caps, cpucap_default_scope(caps)))
29822976
continue;
29832977

2984-
if (caps->desc)
2978+
if (caps->desc && !caps->cpus)
29852979
pr_info("detected: %s\n", caps->desc);
29862980

29872981
__set_bit(caps->capability, system_cpucaps);
@@ -3330,6 +3324,7 @@ unsigned long cpu_get_elf_hwcap2(void)
33303324

33313325
static void __init setup_system_capabilities(void)
33323326
{
3327+
int i;
33333328
/*
33343329
* We have finalised the system-wide safe feature
33353330
* registers, finalise the capabilities that depend
@@ -3338,6 +3333,15 @@ static void __init setup_system_capabilities(void)
33383333
*/
33393334
update_cpu_capabilities(SCOPE_SYSTEM);
33403335
enable_cpu_capabilities(SCOPE_ALL & ~SCOPE_BOOT_CPU);
3336+
3337+
for (i = 0; i < ARM64_NCAPS; i++) {
3338+
const struct arm64_cpu_capabilities *caps = cpucap_ptrs[i];
3339+
3340+
if (caps && caps->cpus && caps->desc &&
3341+
cpumask_any(caps->cpus) < nr_cpu_ids)
3342+
pr_info("detected: %s on CPU%*pbl\n",
3343+
caps->desc, cpumask_pr_args(caps->cpus));
3344+
}
33413345
}
33423346

33433347
void __init setup_cpu_features(void)

0 commit comments

Comments
 (0)