Re: [PATCH] perf, record: Add clockid parameter

From: Peter Zijlstra
Date: Fri Mar 27 2015 - 13:21:16 EST


On Fri, Mar 27, 2015 at 11:11:01AM -0600, David Ahern wrote:
> > tools/perf/builtin-record.c | 3 +++
> > tools/perf/perf.h | 1 +
> > tools/perf/util/evsel.c | 5 +++++
> > 3 files changed, 9 insertions(+)
>
> missing Documentation/perf-record.txt update

--- a/tools/perf/Documentation/perf-record.txt
+++ b/tools/perf/Documentation/perf-record.txt
@@ -250,6 +250,11 @@ is off by default.
--running-time::
Record running and enabled time for read events (:S)

+-k::
+--clockid::
+Sets the clock id to use for the various time fields in the perf_event_type
+records. See clock_gettime().
+
SEE ALSO
--------
linkperf:perf-stat[1], linkperf:perf-list[1]


> >+++ b/tools/perf/util/evsel.c
> >@@ -761,6 +761,11 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts)
> > attr->disabled = 0;
> > attr->enable_on_exec = 0;
> > }
> >+
> >+ if (opts->clockid >= 0) {
> >+ attr->use_clockid = 1;
> >+ attr->clockid = opts->clockid;
> >+ }
> > }
> >
> > static int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads)
> >
>
> This is a new feature which means use_clockid on older kernels will fail. So
> need to catch that and throw an error -- perhaps yet another probe function.

How does that work? What do I grep to find an example? I figured if the
kernel didn't support the syscall will fail and we'll terminate
someplace.

> Also, if the intent is to allow clock selection per event should there be an
> event modifier as well (see get_event_modifier())?

Nah, its not generally useful to mix clocks in a single recording. That
gets real confused real quick on when which event happened.

The per event configurability is handy to allow different (concurrent)
records different settings.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/