Skip to content

Commit 673a500

Browse files
Kan Liangtorvalds
authored andcommitted
perf: Fix topology_sibling_cpumask check warning on ARM
The below warning is triggered when building with arm multi_v7_defconfig. kernel/events/core.c: In function 'perf_event_setup_cpumask': kernel/events/core.c:14012:13: warning: the comparison will always evaluate as 'true' for the address of 'thread_sibling' will never be NULL [-Waddress] 14012 | if (!topology_sibling_cpumask(cpu)) { The perf_event_init_cpu() may be invoked at the early boot stage, while the topology_*_cpumask hasn't been initialized yet. The check is to specially handle the case, and initialize the perf_online_<domain>_masks on the boot CPU. X86 uses a per-cpu cpumask pointer, which could be NULL at the early boot stage. However, ARM uses a global variable, which never be NULL. Use perf_online_mask as an indicator instead. Only initialize the perf_online_<domain>_masks when perf_online_mask is empty. Fix a typo as well. Fixes: 4ba4f1a ("perf: Generic hotplug support for a PMU with a scope") Reported-by: Stephen Rothwell <[email protected]> Closes: https://lore.kernel.org/lkml/[email protected]/ Reported-by: Steven Price <[email protected]> Closes: https://lore.kernel.org/lkml/[email protected]/ Signed-off-by: Kan Liang <[email protected]> Tested-by: Steven Price <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 8826498 commit 673a500

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

kernel/events/core.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14002,21 +14002,19 @@ static void perf_event_setup_cpumask(unsigned int cpu)
1400214002
struct cpumask *pmu_cpumask;
1400314003
unsigned int scope;
1400414004

14005-
cpumask_set_cpu(cpu, perf_online_mask);
14006-
1400714005
/*
1400814006
* Early boot stage, the cpumask hasn't been set yet.
1400914007
* The perf_online_<domain>_masks includes the first CPU of each domain.
14010-
* Always uncondifionally set the boot CPU for the perf_online_<domain>_masks.
14008+
* Always unconditionally set the boot CPU for the perf_online_<domain>_masks.
1401114009
*/
14012-
if (!topology_sibling_cpumask(cpu)) {
14010+
if (cpumask_empty(perf_online_mask)) {
1401314011
for (scope = PERF_PMU_SCOPE_NONE + 1; scope < PERF_PMU_MAX_SCOPE; scope++) {
1401414012
pmu_cpumask = perf_scope_cpumask(scope);
1401514013
if (WARN_ON_ONCE(!pmu_cpumask))
1401614014
continue;
1401714015
cpumask_set_cpu(cpu, pmu_cpumask);
1401814016
}
14019-
return;
14017+
goto end;
1402014018
}
1402114019

1402214020
for (scope = PERF_PMU_SCOPE_NONE + 1; scope < PERF_PMU_MAX_SCOPE; scope++) {
@@ -14031,6 +14029,8 @@ static void perf_event_setup_cpumask(unsigned int cpu)
1403114029
cpumask_any_and(pmu_cpumask, cpumask) >= nr_cpu_ids)
1403214030
cpumask_set_cpu(cpu, pmu_cpumask);
1403314031
}
14032+
end:
14033+
cpumask_set_cpu(cpu, perf_online_mask);
1403414034
}
1403514035

1403614036
int perf_event_init_cpu(unsigned int cpu)

0 commit comments

Comments
 (0)