From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754266AbcB2LKW (ORCPT ); Mon, 29 Feb 2016 06:10:22 -0500 Received: from torg.zytor.com ([198.137.202.12]:53774 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753081AbcB2LKS (ORCPT ); Mon, 29 Feb 2016 06:10:18 -0500 Date: Mon, 29 Feb 2016 03:09:16 -0800 From: tip-bot for Thomas Gleixner Message-ID: Cc: hpa@zytor.com, acme@redhat.com, tglx@linutronix.de, linux-kernel@vger.kernel.org, peterz@infradead.org, bp@alien8.de, jolsa@redhat.com, harish.chegondi@intel.com, eranian@google.com, kan.liang@intel.com, andi.kleen@intel.com, torvalds@linux-foundation.org, jacob.jun.pan@linux.intel.com, mingo@kernel.org, vincent.weaver@maine.edu Reply-To: vincent.weaver@maine.edu, torvalds@linux-foundation.org, jacob.jun.pan@linux.intel.com, mingo@kernel.org, harish.chegondi@intel.com, kan.liang@intel.com, andi.kleen@intel.com, eranian@google.com, acme@redhat.com, tglx@linutronix.de, hpa@zytor.com, peterz@infradead.org, linux-kernel@vger.kernel.org, bp@alien8.de, jolsa@redhat.com In-Reply-To: <20160222221012.054916179@linutronix.de> References: <20160222221012.054916179@linutronix.de> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf/x86/intel/cqm: Get rid of the silly for_each_cpu() lookups Git-Commit-ID: 827db839cd051cfde5a618fb4427e86dc91bc9aa X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 827db839cd051cfde5a618fb4427e86dc91bc9aa Gitweb: http://git.kernel.org/tip/827db839cd051cfde5a618fb4427e86dc91bc9aa Author: Thomas Gleixner AuthorDate: Mon, 22 Feb 2016 22:19:20 +0000 Committer: Ingo Molnar CommitDate: Mon, 29 Feb 2016 09:35:21 +0100 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: Thomas Gleixner Signed-off-by: Peter Zijlstra (Intel) Cc: Andi Kleen Cc: Arnaldo Carvalho de Melo Cc: Borislav Petkov Cc: Harish Chegondi Cc: Jacob Pan Cc: Jiri Olsa Cc: Kan Liang Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Stephane Eranian Cc: Vince Weaver Cc: linux-kernel@vger.kernel.org Link: http://lkml.kernel.org/r/20160222221012.054916179@linutronix.de Signed-off-by: Ingo Molnar --- arch/x86/events/intel/cqm.c | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/arch/x86/events/intel/cqm.c b/arch/x86/events/intel/cqm.c index 1b064c4..93cb412 100644 --- a/arch/x86/events/intel/cqm.c +++ b/arch/x86/events/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; - 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(&cqm_cpumask, topology_core_cpumask(cpu)); + 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(unsigned int cpu) static void intel_cqm_cpu_exit(unsigned int cpu) { - int phys_id = topology_physical_package_id(cpu); - int i; + int target; - /* - * 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; + /* Find another online reader in this package */ + target = cpumask_any_but(topology_core_cpumask(cpu), cpu); - if (phys_id == topology_physical_package_id(i)) { - cpumask_set_cpu(i, &cqm_cpumask); - break; - } - } + if (target < nr_cpu_ids) + cpumask_set_cpu(target, &cqm_cpumask); } static int intel_cqm_cpu_notifier(struct notifier_block *nb,