[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20170608144144.19253-1-jolsa@kernel.org>
Date: Thu, 8 Jun 2017 16:41:44 +0200
From: Jiri Olsa <jolsa@...nel.org>
To: Thomas Gleixner <tglx@...utronix.de>
Cc: Peter Zijlstra <a.p.zijlstra@...llo.nl>,
Peter Zijlstra <peterz@...radead.org>,
Vikas Shivappa <vikas.shivappa@...ux.intel.com>,
Tony Luck <tony.luck@...el.com>,
lkml <linux-kernel@...r.kernel.org>,
Ingo Molnar <mingo@...nel.org>
Subject: [PATCH] perf/x86/intel/cqm: Start MBM timers only for MBM events
Currently start MBM timers for the first event
of any kind, though they are not needed for
occupancy event.
Adding check to ensure the MBM timers are started
only for MBM events.
Cc: Peter Zijlstra <a.p.zijlstra@...llo.nl>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Vikas Shivappa <vikas.shivappa@...ux.intel.com>
Cc: Tony Luck <tony.luck@...el.com>
Signed-off-by: Jiri Olsa <jolsa@...nel.org>
---
arch/x86/events/intel/cqm.c | 39 +++++++++++++++++++++++++++++++--------
1 file changed, 31 insertions(+), 8 deletions(-)
diff --git a/arch/x86/events/intel/cqm.c b/arch/x86/events/intel/cqm.c
index 2521f771f2f5..2f7253358c17 100644
--- a/arch/x86/events/intel/cqm.c
+++ b/arch/x86/events/intel/cqm.c
@@ -1286,6 +1286,35 @@ static int intel_cqm_event_add(struct perf_event *event, int mode)
return 0;
}
+/* Guarded with cache_mutex. */
+static int mbm_events;
+
+/*
+ * Start the mbm overflow timers when the first MBM event is created.
+ */
+static bool should_start_mbm_timers(struct perf_event *event)
+{
+ if (mbm_enabled && is_mbm_event(event->attr.config)) {
+ mbm_events++;
+ return mbm_events == 1;
+ }
+
+ return false;
+}
+
+/*
+ * Stop the mbm overflow timers when the last MBM event is destroyed.
+ */
+static bool should_stop_mbm_timers(struct perf_event *event)
+{
+ if (mbm_enabled && is_mbm_event(event->attr.config)) {
+ mbm_events--;
+ return mbm_events == 0;
+ }
+
+ return false;
+}
+
static void intel_cqm_event_destroy(struct perf_event *event)
{
struct perf_event *group_other = NULL;
@@ -1330,10 +1359,7 @@ static void intel_cqm_event_destroy(struct perf_event *event)
raw_spin_unlock_irqrestore(&cache_lock, flags);
- /*
- * Stop the mbm overflow timers when the last event is destroyed.
- */
- if (mbm_enabled && list_empty(&cache_groups))
+ if (should_stop_mbm_timers(event))
mbm_stop_timers();
mutex_unlock(&cache_mutex);
@@ -1373,10 +1399,7 @@ static int intel_cqm_event_init(struct perf_event *event)
mutex_lock(&cache_mutex);
- /*
- * Start the mbm overflow timers when the first event is created.
- */
- if (mbm_enabled && list_empty(&cache_groups))
+ if (should_start_mbm_timers(event))
mbm_start_timers();
/* Will also set rmid */
--
2.9.4
Powered by blists - more mailing lists