aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorPeter Zijlstra <peterz@infradead.org>2015-02-20 08:05:38 -0500
committerIngo Molnar <mingo@kernel.org>2015-03-27 05:13:22 -0400
commit34f439278cef7b1177f8ce24f9fc81dfc6221d3b (patch)
tree8bd86bf3d73aff36e8bee13c0102c7ae7e44e40c /include
parentb381e63b48a0b6befc7b4e55408c39012a0dcf8c (diff)
perf: Add per event clockid support
While thinking on the whole clock discussion it occurred to me we have two distinct uses of time: 1) the tracking of event/ctx/cgroup enabled/running/stopped times which includes the self-monitoring support in struct perf_event_mmap_page. 2) the actual timestamps visible in the data records. And we've been conflating them. The first is all about tracking time deltas, nobody should really care in what time base that happens, its all relative information, as long as its internally consistent it works. The second however is what people are worried about when having to merge their data with external sources. And here we have the discussion on MONOTONIC vs MONOTONIC_RAW etc.. Where MONOTONIC is good for correlating between machines (static offset), MONOTNIC_RAW is required for correlating against a fixed rate hardware clock. This means configurability; now 1) makes that hard because it needs to be internally consistent across groups of unrelated events; which is why we had to have a global perf_clock(). However, for 2) it doesn't really matter, perf itself doesn't care what it writes into the buffer. The below patch makes the distinction between these two cases by adding perf_event_clock() which is used for the second case. It further makes this configurable on a per-event basis, but adds a few sanity checks such that we cannot combine events with different clocks in confusing ways. And since we then have per-event configurability we might as well retain the 'legacy' behaviour as a default. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: John Stultz <john.stultz@linaro.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Cc: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/perf_event.h2
-rw-r--r--include/uapi/linux/perf_event.h6
2 files changed, 5 insertions, 3 deletions
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index b16eac5f54ce..401554074de9 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -173,6 +173,7 @@ struct perf_event;
173 * pmu::capabilities flags 173 * pmu::capabilities flags
174 */ 174 */
175#define PERF_PMU_CAP_NO_INTERRUPT 0x01 175#define PERF_PMU_CAP_NO_INTERRUPT 0x01
176#define PERF_PMU_CAP_NO_NMI 0x02
176 177
177/** 178/**
178 * struct pmu - generic performance monitoring unit 179 * struct pmu - generic performance monitoring unit
@@ -457,6 +458,7 @@ struct perf_event {
457 struct pid_namespace *ns; 458 struct pid_namespace *ns;
458 u64 id; 459 u64 id;
459 460
461 u64 (*clock)(void);
460 perf_overflow_handler_t overflow_handler; 462 perf_overflow_handler_t overflow_handler;
461 void *overflow_handler_context; 463 void *overflow_handler_context;
462 464
diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h
index 1e3cd07cf76e..3bb40ddadbe5 100644
--- a/include/uapi/linux/perf_event.h
+++ b/include/uapi/linux/perf_event.h
@@ -326,7 +326,8 @@ struct perf_event_attr {
326 exclude_callchain_user : 1, /* exclude user callchains */ 326 exclude_callchain_user : 1, /* exclude user callchains */
327 mmap2 : 1, /* include mmap with inode data */ 327 mmap2 : 1, /* include mmap with inode data */
328 comm_exec : 1, /* flag comm events that are due to an exec */ 328 comm_exec : 1, /* flag comm events that are due to an exec */
329 __reserved_1 : 39; 329 use_clockid : 1, /* use @clockid for time fields */
330 __reserved_1 : 38;
330 331
331 union { 332 union {
332 __u32 wakeup_events; /* wakeup every n events */ 333 __u32 wakeup_events; /* wakeup every n events */
@@ -355,8 +356,7 @@ struct perf_event_attr {
355 */ 356 */
356 __u32 sample_stack_user; 357 __u32 sample_stack_user;
357 358
358 /* Align to u64. */ 359 __s32 clockid;
359 __u32 __reserved_2;
360 /* 360 /*
361 * Defines set of regs to dump for each sample 361 * Defines set of regs to dump for each sample
362 * state captured on: 362 * state captured on: