Commit fded17be authored by Zhou Chengming's avatar Zhou Chengming Committed by Greg Kroah-Hartman
Browse files

perf/x86/intel: Handle exclusive threadid correctly on CPU hotplug

[ Upstream commit 4e71de79


The CPU hotplug function intel_pmu_cpu_starting() sets
cpu_hw_events.excl_thread_id unconditionally to 1 when the shared exclusive
counters data structure is already availabe for the sibling thread.

This works during the boot process because the first sibling gets threadid
0 assigned and the second sibling which shares the data structure gets 1.

But when the first thread of the core is offlined and onlined again it
shares the data structure with the second thread and gets exclusive thread
id 1 assigned as well.

Prevent this by checking the threadid of the already online thread.

[ tglx: Rewrote changelog ]
Signed-off-by: default avatarZhou Chengming <>
Cc: NuoHan Qiao <>

Signed-off-by: default avatarThomas Gleixner <>
Signed-off-by: default avatarSasha Levin <>
Signed-off-by: default avatarGreg Kroah-Hartman <>
parent 3eeb3459
...@@ -3164,12 +3164,15 @@ static void intel_pmu_cpu_starting(int cpu) ...@@ -3164,12 +3164,15 @@ static void intel_pmu_cpu_starting(int cpu)
if (x86_pmu.flags & PMU_FL_EXCL_CNTRS) { if (x86_pmu.flags & PMU_FL_EXCL_CNTRS) {
for_each_cpu(i, topology_sibling_cpumask(cpu)) { for_each_cpu(i, topology_sibling_cpumask(cpu)) {
struct cpu_hw_events *sibling;
struct intel_excl_cntrs *c; struct intel_excl_cntrs *c;
c = per_cpu(cpu_hw_events, i).excl_cntrs; sibling = &per_cpu(cpu_hw_events, i);
c = sibling->excl_cntrs;
if (c && c->core_id == core_id) { if (c && c->core_id == core_id) {
cpuc->kfree_on_online[1] = cpuc->excl_cntrs; cpuc->kfree_on_online[1] = cpuc->excl_cntrs;
cpuc->excl_cntrs = c; cpuc->excl_cntrs = c;
if (!sibling->excl_thread_id)
cpuc->excl_thread_id = 1; cpuc->excl_thread_id = 1;
break; break;
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment