Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1336529

[PATCH] x86/perf/intel/cqm: Get rid of the silly for_each_cpu lookups

From Thomas Gleixner <tglx@linutronix.de>
Newsgroups linux.kernel
Subject [PATCH] x86/perf/intel/cqm: Get rid of the silly for_each_cpu lookups
Date 2016-02-17 16:50 +0100
Message-ID <r3cwx-8pl-7@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


CQM is a strict per package facility. Use the proper cpumasks to lookup the
readers.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/x86/kernel/cpu/perf_event_intel_cqm.c |   34 ++++++++++-------------------
 1 file changed, 12 insertions(+), 22 deletions(-)

--- a/arch/x86/kernel/cpu/perf_event_intel_cqm.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_cqm.c
@@ -1244,15 +1244,12 @@ static struct pmu intel_cqm_pmu = {
 
 static inline void cqm_pick_event_reader(int cpu)
 {
-	int phys_id = topology_physical_package_id(cpu);
-	int i;
+	int reader, pkg = topology_physical_package_id(cpu);
 
-	for_each_cpu(i, &cqm_cpumask) {
-		if (phys_id == topology_physical_package_id(i))
-			return;	/* already got reader for this socket */
-	}
-
-	cpumask_set_cpu(cpu, &cqm_cpumask);
+	/* First online cpu in package becomes the reader */
+	reader = cpumask_any_and(topology_core_cpumask(cpu), &uncore_cpu_mask);
+	if (reader >= nr_cpu_ids)
+		cpumask_set_cpu(cpu, &cqm_cpumask);
 }
 
 static void intel_cqm_cpu_starting(unsigned int cpu)
@@ -1270,24 +1267,17 @@ static void intel_cqm_cpu_starting(unsig
 
 static void intel_cqm_cpu_exit(unsigned int cpu)
 {
-	int phys_id = topology_physical_package_id(cpu);
-	int i;
+	int target, pkg = topology_physical_package_id(cpu);
 
-	/*
-	 * Is @cpu a designated cqm reader?
-	 */
+	/* Is @cpu the current cqm reader for this package ? */
 	if (!cpumask_test_and_clear_cpu(cpu, &cqm_cpumask))
 		return;
 
-	for_each_online_cpu(i) {
-		if (i == cpu)
-			continue;
-
-		if (phys_id == topology_physical_package_id(i)) {
-			cpumask_set_cpu(i, &cqm_cpumask);
-			break;
-		}
-	}
+	/* Find another online reader in this package */
+	target = cpumask_any_but(topology_core_cpumask(cpu), cpu);
+
+	if (target < nr_cpu_ids)
+		cpumask_set_cpu(target, &uncore_cpu_mask);
 }
 
 static int intel_cqm_cpu_notifier(struct notifier_block *nb,

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH] x86/perf/intel/cqm: Get rid of the silly for_each_cpu  lookups Thomas Gleixner <tglx@linutronix.de> - 2016-02-17 16:50 +0100
  Re: [PATCH] x86/perf/intel/cqm: Get rid of the silly for_each_cpu  lookups Thomas Gleixner <tglx@linutronix.de> - 2016-02-17 17:20 +0100
    Re: [PATCH] x86/perf/intel/cqm: Get rid of the silly for_each_cpu  lookups Matt Fleming <matt@codeblueprint.co.uk> - 2016-02-17 17:30 +0100
    Re: [PATCH] x86/perf/intel/cqm: Get rid of the silly for_each_cpu  lookups Vikas Shivappa <vikas.shivappa@intel.com> - 2016-02-17 19:30 +0100
      Re: [PATCH] x86/perf/intel/cqm: Get rid of the silly for_each_cpu  lookups Thomas Gleixner <tglx@linutronix.de> - 2016-02-17 19:40 +0100
      Re: [PATCH] x86/perf/intel/cqm: Get rid of the silly for_each_cpu  lookups Thomas Gleixner <tglx@linutronix.de> - 2016-02-17 19:40 +0100
        Re: [PATCH] x86/perf/intel/cqm: Get rid of the silly for_each_cpu  lookups Vikas Shivappa <vikas.shivappa@intel.com> - 2016-02-17 19:50 +0100
          Re: [PATCH] x86/perf/intel/cqm: Get rid of the silly for_each_cpu  lookups Thomas Gleixner <tglx@linutronix.de> - 2016-02-17 20:20 +0100
            Re: [PATCH] x86/perf/intel/cqm: Get rid of the silly for_each_cpu  lookups Thomas Gleixner <tglx@linutronix.de> - 2016-02-18 21:20 +0100
              Re: [PATCH] x86/perf/intel/cqm: Get rid of the silly for_each_cpu  lookups Vikas Shivappa <vikas.shivappa@intel.com> - 2016-02-19 00:20 +0100

csiph-web