From: Thomas Gleixner <tglx@linutronix.de>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
x86@kernel.org, Stephane Eranian <eranian@google.com>,
Matt Fleming <matt@codeblueprint.co.uk>,
Vikas Shivappa <vikas.shivappa@intel.com>
Subject: Re: [PATCH] x86/perf/intel/cqm: Get rid of the silly for_each_cpu lookups
Date: Wed, 17 Feb 2016 17:08:57 +0100 (CET) [thread overview]
Message-ID: <alpine.DEB.2.11.1602171706540.19512@nanos> (raw)
In-Reply-To: <alpine.DEB.2.11.1602171643460.19512@nanos>
On Wed, 17 Feb 2016, Thomas Gleixner wrote:
> CQM is a strict per package facility. Use the proper cpumasks to lookup the
> readers.
Sorry for the noise. PEBKAC: quilt refresh missing. Correct version below.
Thanks,
tglx
8<----------
Subject: x86/perf/cqm: Get rid of the silly for_each_cpu lookups
From: Thomas Gleixner <tglx@linutronix.de>
Date: Sun, 14 Feb 2016 23:09:06 +0100
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;
- 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), &cqm_cpumask);
+ 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;
- /*
- * 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, &cqm_cpumask);
}
static int intel_cqm_cpu_notifier(struct notifier_block *nb,
next prev parent reply other threads:[~2016-02-17 16:10 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-17 15:47 Thomas Gleixner
2016-02-17 16:08 ` Thomas Gleixner [this message]
2016-02-17 16:28 ` Matt Fleming
2016-02-17 18:27 ` Vikas Shivappa
2016-02-17 18:31 ` Thomas Gleixner
2016-02-17 18:35 ` Thomas Gleixner
2016-02-17 18:48 ` Vikas Shivappa
2016-02-17 19:09 ` Thomas Gleixner
2016-02-18 20:15 ` Thomas Gleixner
2016-02-18 23:12 ` Vikas Shivappa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.DEB.2.11.1602171706540.19512@nanos \
--to=tglx@linutronix.de \
--cc=eranian@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=matt@codeblueprint.co.uk \
--cc=peterz@infradead.org \
--cc=vikas.shivappa@intel.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®