aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMatt Fleming <matt.fleming@intel.com>2015-01-23 13:45:41 -0500
committerIngo Molnar <mingo@kernel.org>2015-02-25 07:53:29 -0500
commiteacd3ecc34472ce3751eedfc94e44c7cc6eb6305 (patch)
tree6a250e7e1c4b58cebeefc9be767479991d75ac9e /include
parent39bed6cbb842d8edf5a26b01122b391d36775b5e (diff)
perf: Add ->count() function to read per-package counters
For PMU drivers that record per-package counters, the ->count variable cannot be used to record an accurate aggregated value, since it's not possible to perform SMP cross-calls to cpus on other packages from the context in which we update ->count. Introduce a new optional ->count() accessor function that can be used to customize how values are collected. If a PMU driver doesn't provide a ->count() function, we fallback to the existing code. There is necessarily a window of staleness with this approach because the task that generated the counter value may not have been scheduled by the cpu recently. An alternative and more complex approach would be to use a hrtimer to periodically refresh the values from a more permissive scheduling context. So, we're trading off complexity for accuracy. Signed-off-by: Matt Fleming <matt.fleming@intel.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Arnaldo Carvalho de Melo <acme@kernel.org> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Kanaka Juvva <kanaka.d.juvva@intel.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Vikas Shivappa <vikas.shivappa@linux.intel.com> Link: http://lkml.kernel.org/r/1422038748-21397-3-git-send-email-matt@codeblueprint.co.uk Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/perf_event.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index cae4a9481777..9fc9b0d31442 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -272,6 +272,11 @@ struct pmu {
272 */ 272 */
273 size_t task_ctx_size; 273 size_t task_ctx_size;
274 274
275
276 /*
277 * Return the count value for a counter.
278 */
279 u64 (*count) (struct perf_event *event); /*optional*/
275}; 280};
276 281
277/** 282/**
@@ -770,6 +775,11 @@ static inline void perf_event_task_sched_out(struct task_struct *prev,
770 __perf_event_task_sched_out(prev, next); 775 __perf_event_task_sched_out(prev, next);
771} 776}
772 777
778static inline u64 __perf_event_count(struct perf_event *event)
779{
780 return local64_read(&event->count) + atomic64_read(&event->child_count);
781}
782
773extern void perf_event_mmap(struct vm_area_struct *vma); 783extern void perf_event_mmap(struct vm_area_struct *vma);
774extern struct perf_guest_info_callbacks *perf_guest_cbs; 784extern struct perf_guest_info_callbacks *perf_guest_cbs;
775extern int perf_register_guest_info_callbacks(struct perf_guest_info_callbacks *callbacks); 785extern int perf_register_guest_info_callbacks(struct perf_guest_info_callbacks *callbacks);