Messages in this thread | | | Date | Fri, 27 Mar 2015 11:11:01 -0600 | From | David Ahern <> | Subject | Re: [PATCH] perf, record: Add clockid parameter |
| |
On 3/27/15 8:32 AM, Peter Zijlstra wrote: > On Fri, Mar 27, 2015 at 04:48:08AM -0700, tip-bot for Peter Zijlstra wrote: >> perf: Add per event clockid support > > And here the accompanying userspace; which I'd totally forgotten about. > > XXX: do we want to store the clockid in the data file as well, such that > we can verify at perf-inject time the clocks match with our > expectations? > > --- > Subject: perf, record: Add clockid parameter > > Teach perf-record about the new perf_event_attr::{use_clockid, clockid} > fields. Add a simple parameter to set the clock (if any) to be used for > the events to be recorded into the data file. > > Cc: Arnaldo Carvalho de Melo <acme@kernel.org> > Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> > --- > 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
> > diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c > index 18aad239b401..9d4ed884b1c8 100644 > --- a/tools/perf/builtin-record.c > +++ b/tools/perf/builtin-record.c > @@ -739,6 +739,7 @@ static struct record record = { > .uses_mmap = true, > .default_per_cpu = true, > }, > + .clockid = -1, > }, > .tool = { > .sample = process_sample_event, > @@ -842,6 +843,8 @@ struct option __record_options[] = { > "Sample machine registers on interrupt"), > OPT_BOOLEAN(0, "running-time", &record.opts.running_time, > "Record running/enabled time of read (:S) events"), > + OPT_INTEGER('k', "clockid", &record.opts.clockid, > + "clockid to use for events"), > OPT_END() > }; > > diff --git a/tools/perf/perf.h b/tools/perf/perf.h > index c38a085a5571..275c0c58fbbe 100644 > --- a/tools/perf/perf.h > +++ b/tools/perf/perf.h > @@ -62,6 +62,7 @@ struct record_opts { > u64 user_interval; > bool sample_transaction; > unsigned initial_delay; > + clockid_t clockid; > }; > > struct option; > diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c > index 358e5954baa8..309208b16632 100644 > --- a/tools/perf/util/evsel.c > +++ 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.
Also, if the intent is to allow clock selection per event should there be an event modifier as well (see get_event_modifier())?
| |