linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: tip-bot for Zhou Chengming <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: zhouchengming1@huawei.com, linux-kernel@vger.kernel.org,
	hpa@zytor.com, qiaonuohan@huawei.com, tglx@linutronix.de,
	mingo@kernel.org
Subject: [tip:perf/urgent] perf/x86/intel: Handle exclusive threadid correctly on CPU hotplug
Date: Tue, 17 Jan 2017 02:12:57 -0800	[thread overview]
Message-ID: <tip-4e71de7986386d5fd3765458f27d612931f27f5e@git.kernel.org> (raw)
In-Reply-To: <1484536871-3131-1-git-send-email-zhouchengming1@huawei.com>

Commit-ID:  4e71de7986386d5fd3765458f27d612931f27f5e
Gitweb:     http://git.kernel.org/tip/4e71de7986386d5fd3765458f27d612931f27f5e
Author:     Zhou Chengming <zhouchengming1@huawei.com>
AuthorDate: Mon, 16 Jan 2017 11:21:11 +0800
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Tue, 17 Jan 2017 11:08:36 +0100

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

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: Zhou Chengming <zhouchengming1@huawei.com>
Cc: NuoHan Qiao <qiaonuohan@huawei.com>
Cc: ak@linux.intel.com
Cc: peterz@infradead.org
Cc: kan.liang@intel.com
Cc: dave.hansen@linux.intel.com
Cc: eranian@google.com
Cc: qiaonuohan@huawei.com
Cc: davidcc@google.com
Cc: guohanjun@huawei.com
Link: http://lkml.kernel.org/r/1484536871-3131-1-git-send-email-zhouchengming1@huawei.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---					---
 arch/x86/events/intel/core.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

---
 arch/x86/events/intel/core.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
index d611cab..eb1484c 100644
--- a/arch/x86/events/intel/core.c
+++ b/arch/x86/events/intel/core.c
@@ -3176,13 +3176,16 @@ static void intel_pmu_cpu_starting(int cpu)
 
 	if (x86_pmu.flags & PMU_FL_EXCL_CNTRS) {
 		for_each_cpu(i, topology_sibling_cpumask(cpu)) {
+			struct cpu_hw_events *sibling;
 			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) {
 				cpuc->kfree_on_online[1] = cpuc->excl_cntrs;
 				cpuc->excl_cntrs = c;
-				cpuc->excl_thread_id = 1;
+				if (!sibling->excl_thread_id)
+					cpuc->excl_thread_id = 1;
 				break;
 			}
 		}

      parent reply	other threads:[~2017-01-17 10:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-16  3:21 [PATCH] fix race caused by hyperthreads when online an offline cpu Zhou Chengming
2017-01-16  9:05 ` Thomas Gleixner
2017-01-16  9:53   ` zhouchengming
2017-01-16 18:36     ` Stephane Eranian
2017-01-17 10:05       ` Thomas Gleixner
2017-01-17 10:12 ` tip-bot for Zhou Chengming [this message]

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=tip-4e71de7986386d5fd3765458f27d612931f27f5e@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=qiaonuohan@huawei.com \
    --cc=tglx@linutronix.de \
    --cc=zhouchengming1@huawei.com \
    /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;
as well as URLs for NNTP newsgroup(s).