Commit 827db839 authored by Thomas Gleixner's avatar Thomas Gleixner Committed by Ingo Molnar

perf/x86/intel/cqm: Get rid of the silly for_each_cpu() lookups

CQM is a strict per package facility. Use the proper cpumasks to lookup the
readers.
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Cc: Andi Kleen <andi.kleen@intel.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Harish Chegondi <harish.chegondi@intel.com>
Cc: Jacob Pan <jacob.jun.pan@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Cc: linux-kernel@vger.kernel.org
Link: http://lkml.kernel.org/r/20160222221012.054916179@linutronix.deSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 3712bba1
...@@ -1244,14 +1244,11 @@ static struct pmu intel_cqm_pmu = { ...@@ -1244,14 +1244,11 @@ static struct pmu intel_cqm_pmu = {
static inline void cqm_pick_event_reader(int cpu) static inline void cqm_pick_event_reader(int cpu)
{ {
int phys_id = topology_physical_package_id(cpu); int reader;
int i;
for_each_cpu(i, &cqm_cpumask) {
if (phys_id == topology_physical_package_id(i))
return; /* already got reader for this socket */
}
/* First online cpu in package becomes the reader */
reader = cpumask_any_and(&cqm_cpumask, topology_core_cpumask(cpu));
if (reader >= nr_cpu_ids)
cpumask_set_cpu(cpu, &cqm_cpumask); cpumask_set_cpu(cpu, &cqm_cpumask);
} }
...@@ -1270,24 +1267,17 @@ static void intel_cqm_cpu_starting(unsigned int cpu) ...@@ -1270,24 +1267,17 @@ static void intel_cqm_cpu_starting(unsigned int cpu)
static void intel_cqm_cpu_exit(unsigned int cpu) static void intel_cqm_cpu_exit(unsigned int cpu)
{ {
int phys_id = topology_physical_package_id(cpu); int target;
int i;
/* /* Is @cpu the current cqm reader for this package ? */
* Is @cpu a designated cqm reader?
*/
if (!cpumask_test_and_clear_cpu(cpu, &cqm_cpumask)) if (!cpumask_test_and_clear_cpu(cpu, &cqm_cpumask))
return; return;
for_each_online_cpu(i) { /* Find another online reader in this package */
if (i == cpu) target = cpumask_any_but(topology_core_cpumask(cpu), cpu);
continue;
if (phys_id == topology_physical_package_id(i)) { if (target < nr_cpu_ids)
cpumask_set_cpu(i, &cqm_cpumask); cpumask_set_cpu(target, &cqm_cpumask);
break;
}
}
} }
static int intel_cqm_cpu_notifier(struct notifier_block *nb, static int intel_cqm_cpu_notifier(struct notifier_block *nb,
......
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