Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756415AbbFRSsY (ORCPT ); Thu, 18 Jun 2015 14:48:24 -0400 Received: from mga11.intel.com ([192.55.52.93]:13990 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754641AbbFRSsR (ORCPT ); Thu, 18 Jun 2015 14:48:17 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,640,1427785200"; d="scan'208";a="713466988" From: Kanaka Juvva To: kanaka.d.juvva@intel.com, glenn.p.williamson@intel.com, matt.fleming@intel.com, will.auld@intel.com, andi@firstfloor.org, ananth.s.narayan@intel.com, linux-kernel@vger.kernel.org, andrew.j.herdrich@intel.com, tony.luck@intel.com, peterz@infradead.org, tglx@linutronix.de, x86@kernel.org, mingo@redhat.com, hpa@zytor.com, luto@amacapital.net, dvlasenk@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, peter.p.waskiewicz.jr@intel.com, imammedo@redhat.com, bp@suse.de, ross.zwisler@linux.intel.com, jacob.w.shin@gmail.com, dirk.j.brandewie@intel.com, vikas.shivappa@intel.com, edwin.verplanke@intel.com, tomasz.kantecki@intel.com Subject: [PATCH v1 2/2] x86, perf,cqm: handle CPU hotplug Date: Thu, 18 Jun 2015 11:49:29 -0700 Message-Id: <1434653369-5162-1-git-send-email-kanaka.d.juvva@linux.intel.com> X-Mailer: git-send-email 2.1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1399 Lines: 41 Added lock in event reader function. The cqm_pick_event_reader() function accesses cqm_cpumask and it is critical section between this and cqm_stable(). This situation is true when a CPU is hotplugged. Mutex is used to protect the critical section. Signed-off-by: Kanaka Juvva --- arch/x86/kernel/cpu/perf_event_intel_cqm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/perf_event_intel_cqm.c b/arch/x86/kernel/cpu/perf_event_intel_cqm.c index 1880761..e17e37f 100644 --- a/arch/x86/kernel/cpu/perf_event_intel_cqm.c +++ b/arch/x86/kernel/cpu/perf_event_intel_cqm.c @@ -1239,12 +1239,15 @@ static inline void cqm_pick_event_reader(int cpu) int phys_id = topology_physical_package_id(cpu); int i; + mutex_lock(&cache_mutex); for_each_cpu(i, &cqm_cpumask) { if (phys_id == topology_physical_package_id(i)) - return; /* already got reader for this socket */ + goto out; /* already got reader for this socket */ } cpumask_set_cpu(cpu, &cqm_cpumask); +out: + mutex_unlock(&cache_mutex); } static void intel_cqm_cpu_prepare(unsigned int cpu) -- 2.1.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/