Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754343AbcCUJ4N (ORCPT ); Mon, 21 Mar 2016 05:56:13 -0400 Received: from [198.137.202.10] ([198.137.202.10]:45558 "EHLO terminus.zytor.com" rhost-flags-FAIL-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1754204AbcCUJz6 (ORCPT ); Mon, 21 Mar 2016 05:55:58 -0400 Date: Mon, 21 Mar 2016 02:51:29 -0700 From: tip-bot for Vikas Shivappa Message-ID: Cc: mingo@kernel.org, luto@amacapital.net, acme@redhat.com, dsahern@gmail.com, jolsa@redhat.com, dvlasenk@redhat.com, vikas.shivappa@linux.intel.com, tglx@linutronix.de, peterz@infradead.org, bp@alien8.de, brgerst@gmail.com, eranian@google.com, linux-kernel@vger.kernel.org, tony.luck@intel.com, hpa@zytor.com, alexander.shishkin@linux.intel.com, vincent.weaver@maine.edu, matt@codeblueprint.co.uk, namhyung@kernel.org, torvalds@linux-foundation.org Reply-To: hpa@zytor.com, eranian@google.com, linux-kernel@vger.kernel.org, tony.luck@intel.com, brgerst@gmail.com, peterz@infradead.org, bp@alien8.de, tglx@linutronix.de, vikas.shivappa@linux.intel.com, dsahern@gmail.com, dvlasenk@redhat.com, jolsa@redhat.com, luto@amacapital.net, mingo@kernel.org, acme@redhat.com, torvalds@linux-foundation.org, namhyung@kernel.org, matt@codeblueprint.co.uk, vincent.weaver@maine.edu, alexander.shishkin@linux.intel.com In-Reply-To: <1457652732-4499-2-git-send-email-vikas.shivappa@linux.intel.com> References: <1457652732-4499-2-git-send-email-vikas.shivappa@linux.intel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/urgent] perf/x86/cqm: Fix CQM handling of grouping events into a cache_group Git-Commit-ID: a223c1c7ab4cc64537dc4b911f760d851683768a 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: 4174 Lines: 108 Commit-ID: a223c1c7ab4cc64537dc4b911f760d851683768a Gitweb: http://git.kernel.org/tip/a223c1c7ab4cc64537dc4b911f760d851683768a Author: Vikas Shivappa AuthorDate: Thu, 10 Mar 2016 15:32:07 -0800 Committer: Ingo Molnar CommitDate: Mon, 21 Mar 2016 09:08:18 +0100 perf/x86/cqm: Fix CQM handling of grouping events into a cache_group Currently CQM (cache quality of service monitoring) is grouping all events belonging to same PID to use one RMID. However its not counting all of these different events. Hence we end up with a count of zero for all events other than the group leader. The patch tries to address the issue by keeping a flag in the perf_event.hw which has other CQM related fields. The field is updated at event creation and during grouping. Signed-off-by: Vikas Shivappa [peterz: Changed hw_perf_event::is_group_event to an int] 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-2-git-send-email-vikas.shivappa@linux.intel.com Signed-off-by: Ingo Molnar --- arch/x86/events/intel/cqm.c | 13 ++++++++++--- include/linux/perf_event.h | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/arch/x86/events/intel/cqm.c b/arch/x86/events/intel/cqm.c index 93cb412..b0226f1 100644 --- a/arch/x86/events/intel/cqm.c +++ b/arch/x86/events/intel/cqm.c @@ -281,9 +281,13 @@ static bool __match_event(struct perf_event *a, struct perf_event *b) /* * Events that target same task are placed into the same cache group. + * Mark it as a multi event group, so that we update ->count + * for every event rather than just the group leader later. */ - if (a->hw.target == b->hw.target) + if (a->hw.target == b->hw.target) { + b->hw.is_group_event = true; return true; + } /* * Are we an inherited event? @@ -849,6 +853,7 @@ static void intel_cqm_setup_event(struct perf_event *event, bool conflict = false; u32 rmid; + event->hw.is_group_event = false; list_for_each_entry(iter, &cache_groups, hw.cqm_groups_entry) { rmid = iter->hw.cqm_rmid; @@ -940,7 +945,9 @@ static u64 intel_cqm_event_count(struct perf_event *event) return __perf_event_count(event); /* - * Only the group leader gets to report values. This stops us + * Only the group leader gets to report values except in case of + * multiple events in the same group, we still need to read the + * other events.This stops us * reporting duplicate values to userspace, and gives us a clear * rule for which task gets to report the values. * @@ -948,7 +955,7 @@ static u64 intel_cqm_event_count(struct perf_event *event) * specific packages - we forfeit that ability when we create * task events. */ - if (!cqm_group_leader(event)) + if (!cqm_group_leader(event) && !event->hw.is_group_event) return 0; /* diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index 79ec7bb..7bb315b 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h @@ -121,6 +121,7 @@ struct hw_perf_event { struct { /* intel_cqm */ int cqm_state; u32 cqm_rmid; + int is_group_event; struct list_head cqm_events_entry; struct list_head cqm_groups_entry; struct list_head cqm_group_entry;