Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754503AbcCUJ50 (ORCPT ); Mon, 21 Mar 2016 05:57:26 -0400 Received: from [198.137.202.10] ([198.137.202.10]:45706 "EHLO terminus.zytor.com" rhost-flags-FAIL-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1752002AbcCUJ5N (ORCPT ); Mon, 21 Mar 2016 05:57:13 -0400 Date: Mon, 21 Mar 2016 02:53:04 -0700 From: tip-bot for Vikas Shivappa Message-ID: Cc: torvalds@linux-foundation.org, vincent.weaver@maine.edu, eranian@google.com, tony.luck@intel.com, vikas.shivappa@linux.intel.com, dsahern@gmail.com, namhyung@kernel.org, mingo@kernel.org, dvlasenk@redhat.com, bp@alien8.de, brgerst@gmail.com, peterz@infradead.org, luto@amacapital.net, hpa@zytor.com, jolsa@redhat.com, matt@codeblueprint.co.uk, acme@redhat.com, tglx@linutronix.de, alexander.shishkin@linux.intel.com, linux-kernel@vger.kernel.org Reply-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, matt@codeblueprint.co.uk, jolsa@redhat.com, acme@redhat.com In-Reply-To: <1457652732-4499-6-git-send-email-vikas.shivappa@linux.intel.com> References: <1457652732-4499-6-git-send-email-vikas.shivappa@linux.intel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/urgent] perf/x86/mbm: Implement RMID recycling Git-Commit-ID: 2d4de8376ff1d94a5070cfa9092c59bfdc4e693e X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4124 Lines: 117 Commit-ID: 2d4de8376ff1d94a5070cfa9092c59bfdc4e693e Gitweb: http://git.kernel.org/tip/2d4de8376ff1d94a5070cfa9092c59bfdc4e693e Author: Vikas Shivappa AuthorDate: Thu, 10 Mar 2016 15:32:11 -0800 Committer: Ingo Molnar CommitDate: Mon, 21 Mar 2016 09:08:20 +0100 perf/x86/mbm: Implement RMID recycling RMID could be allocated or deallocated as part of RMID recycling. When an RMID is allocated for MBM event, the MBM counter needs to be initialized because next time we read the counter we need the previous value to account for total bytes that went to the memory controller. Similarly, when RMID is deallocated we need to update the ->count variable. Signed-off-by: Vikas Shivappa Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Tony Luck Acked-by: Thomas Gleixner Cc: Alexander Shishkin Cc: Andy Lutomirski Cc: Arnaldo Carvalho de Melo Cc: Borislav Petkov Cc: Brian Gerst Cc: David Ahern Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Jiri Olsa Cc: Linus Torvalds Cc: Matt Fleming Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Stephane Eranian Cc: Vince Weaver Cc: fenghua.yu@intel.com Cc: h.peter.anvin@intel.com Cc: ravi.v.shankar@intel.com Cc: vikas.shivappa@intel.com Link: http://lkml.kernel.org/r/1457652732-4499-6-git-send-email-vikas.shivappa@linux.intel.com Signed-off-by: Ingo Molnar --- arch/x86/events/intel/cqm.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/arch/x86/events/intel/cqm.c b/arch/x86/events/intel/cqm.c index 610bd8a..a98f472 100644 --- a/arch/x86/events/intel/cqm.c +++ b/arch/x86/events/intel/cqm.c @@ -450,6 +450,7 @@ struct rmid_read { static void __intel_cqm_event_count(void *info); static void init_mbm_sample(u32 rmid, u32 evt_type); +static void __intel_mbm_event_count(void *info); static bool is_mbm_event(int e) { @@ -476,8 +477,14 @@ static u32 intel_cqm_xchg_rmid(struct perf_event *group, u32 rmid) .rmid = old_rmid, }; - on_each_cpu_mask(&cqm_cpumask, __intel_cqm_event_count, - &rr, 1); + if (is_mbm_event(group->attr.config)) { + rr.evt_type = group->attr.config; + on_each_cpu_mask(&cqm_cpumask, __intel_mbm_event_count, + &rr, 1); + } else { + on_each_cpu_mask(&cqm_cpumask, __intel_cqm_event_count, + &rr, 1); + } local64_set(&group->count, atomic64_read(&rr.value)); } @@ -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; } @@ -978,7 +1001,7 @@ static void intel_cqm_setup_event(struct perf_event *event, /* All tasks in a group share an RMID */ event->hw.cqm_rmid = rmid; *group = iter; - if (is_mbm_event(event->attr.config)) + if (is_mbm_event(event->attr.config) && __rmid_valid(rmid)) init_mbm_sample(rmid, event->attr.config); return; } @@ -996,7 +1019,7 @@ static void intel_cqm_setup_event(struct perf_event *event, else rmid = __get_rmid(); - if (is_mbm_event(event->attr.config)) + if (is_mbm_event(event->attr.config) && __rmid_valid(rmid)) init_mbm_sample(rmid, event->attr.config); event->hw.cqm_rmid = rmid;