Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932206AbcCUTt3 (ORCPT ); Mon, 21 Mar 2016 15:49:29 -0400 Received: from mga01.intel.com ([192.55.52.88]:13021 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757895AbcCUTt2 (ORCPT ); Mon, 21 Mar 2016 15:49:28 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,373,1455004800"; d="scan'208";a="942005746" Date: Mon, 21 Mar 2016 11:27:55 -0700 (PDT) From: Vikas Shivappa X-X-Sender: vikas@vshiva-Udesk To: Matt Fleming cc: 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, linux-tip-commits@vger.kernel.org Subject: Re: [tip:perf/urgent] perf/x86/mbm: Implement RMID recycling In-Reply-To: <20160321150905.GD11676@codeblueprint.co.uk> Message-ID: References: <1457652732-4499-6-git-send-email-vikas.shivappa@linux.intel.com> <20160321150905.GD11676@codeblueprint.co.uk> User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1342 Lines: 45 On Mon, 21 Mar 2016, Matt Fleming wrote: > 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? The init_mbm_sample calls the update_sample to read the MSR in IPI .. Since the count is also in IPI , they should not trash each other ? Basically all the MSR read/writes are in high irql , except for the mbm overflow timer and read calls which holds an irqsave spinlock. Thanks, Vikas >