From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964783AbbC0RLF (ORCPT ); Fri, 27 Mar 2015 13:11:05 -0400 Received: from mail-ig0-f169.google.com ([209.85.213.169]:36226 "EHLO mail-ig0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964786AbbC0RLD (ORCPT ); Fri, 27 Mar 2015 13:11:03 -0400 Message-ID: <55158F25.9040100@gmail.com> Date: Fri, 27 Mar 2015 11:11:01 -0600 From: David Ahern User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Peter Zijlstra , tglx@linutronix.de, acme@redhat.com, jolsa@redhat.com, eranian@google.com, torvalds@linux-foundation.org, linux-kernel@vger.kernel.org, john.stultz@linaro.org, hpa@zytor.com, akpm@linux-foundation.org, mingo@kernel.org Subject: Re: [PATCH] perf, record: Add clockid parameter References: <20150327143201.GG21418@twins.programming.kicks-ass.net> In-Reply-To: <20150327143201.GG21418@twins.programming.kicks-ass.net> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > Signed-off-by: Peter Zijlstra (Intel) > --- > 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())?