Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756129AbcCUPJM (ORCPT ); Mon, 21 Mar 2016 11:09:12 -0400 Received: from mail-wm0-f53.google.com ([74.125.82.53]:35386 "EHLO mail-wm0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755784AbcCUPJJ (ORCPT ); Mon, 21 Mar 2016 11:09:09 -0400 Date: Mon, 21 Mar 2016 15:09:05 +0000 From: Matt Fleming To: vikas.shivappa@linux.intel.com, dsahern@gmail.com, namhyung@kernel.org, mingo@kernel.org, peterz@infradead.org, brgerst@gmail.com, bp@alien8.de, dvlasenk@redhat.com, vincent.weaver@maine.edu, torvalds@linux-foundation.org, eranian@google.com, tony.luck@intel.com, tglx@linutronix.de, alexander.shishkin@linux.intel.com, linux-kernel@vger.kernel.org, luto@amacapital.net, hpa@zytor.com, jolsa@redhat.com, acme@redhat.com Cc: linux-tip-commits@vger.kernel.org Subject: Re: [tip:perf/urgent] perf/x86/mbm: Implement RMID recycling Message-ID: <20160321150905.GD11676@codeblueprint.co.uk> References: <1457652732-4499-6-git-send-email-vikas.shivappa@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24+41 (02bc14ed1569) (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 974 Lines: 29 On Mon, 21 Mar, at 02:53:04AM, tip-bot for Vikas Shivappa wrote: > @@ -489,6 +496,22 @@ static u32 intel_cqm_xchg_rmid(struct perf_event *group, u32 rmid) > > raw_spin_unlock_irq(&cache_lock); > > + /* > + * If the allocation is for mbm, init the mbm stats. > + * Need to check if each event in the group is mbm event > + * because there could be multiple type of events in the same group. > + */ > + if (__rmid_valid(rmid)) { > + event = group; > + if (is_mbm_event(event->attr.config)) > + init_mbm_sample(rmid, event->attr.config); > + > + list_for_each_entry(event, head, hw.cqm_group_entry) { > + if (is_mbm_event(event->attr.config)) > + init_mbm_sample(rmid, event->attr.config); > + } > + } > + > return old_rmid; > } > You're calling init_mbm_sample() without holding cache_lock. Won't this potentially trash the existing value in MSR_IA32_QM_EVTSEL, if say, we're reading the counter at the same time as the recycling worker is running?