Commit 2d4de837 authored by Vikas Shivappa's avatar Vikas Shivappa Committed by Ingo Molnar

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: default avatarVikas Shivappa <vikas.shivappa@linux.intel.com>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: default avatarTony Luck <tony.luck@intel.com>
Acked-by: default avatarThomas Gleixner <tglx@linutronix.de>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Vince Weaver <vincent.weaver@maine.edu>
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.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 87f01cc2
...@@ -450,6 +450,7 @@ struct rmid_read { ...@@ -450,6 +450,7 @@ struct rmid_read {
static void __intel_cqm_event_count(void *info); static void __intel_cqm_event_count(void *info);
static void init_mbm_sample(u32 rmid, u32 evt_type); 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) static bool is_mbm_event(int e)
{ {
...@@ -476,8 +477,14 @@ static u32 intel_cqm_xchg_rmid(struct perf_event *group, u32 rmid) ...@@ -476,8 +477,14 @@ static u32 intel_cqm_xchg_rmid(struct perf_event *group, u32 rmid)
.rmid = old_rmid, .rmid = old_rmid,
}; };
on_each_cpu_mask(&cqm_cpumask, __intel_cqm_event_count, if (is_mbm_event(group->attr.config)) {
&rr, 1); 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)); local64_set(&group->count, atomic64_read(&rr.value));
} }
...@@ -489,6 +496,22 @@ static u32 intel_cqm_xchg_rmid(struct perf_event *group, u32 rmid) ...@@ -489,6 +496,22 @@ static u32 intel_cqm_xchg_rmid(struct perf_event *group, u32 rmid)
raw_spin_unlock_irq(&cache_lock); 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; return old_rmid;
} }
...@@ -978,7 +1001,7 @@ static void intel_cqm_setup_event(struct perf_event *event, ...@@ -978,7 +1001,7 @@ static void intel_cqm_setup_event(struct perf_event *event,
/* All tasks in a group share an RMID */ /* All tasks in a group share an RMID */
event->hw.cqm_rmid = rmid; event->hw.cqm_rmid = rmid;
*group = iter; *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); init_mbm_sample(rmid, event->attr.config);
return; return;
} }
...@@ -996,7 +1019,7 @@ static void intel_cqm_setup_event(struct perf_event *event, ...@@ -996,7 +1019,7 @@ static void intel_cqm_setup_event(struct perf_event *event,
else else
rmid = __get_rmid(); 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); init_mbm_sample(rmid, event->attr.config);
event->hw.cqm_rmid = rmid; event->hw.cqm_rmid = rmid;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment