From mboxrd@z Thu Jan 1 00:00:00 1970 From: Pawel Moll Subject: Re: [PATCH v4 3/3] perf: Sample additional clock value Date: Fri, 23 Jan 2015 17:06:07 +0000 Message-ID: <1422032767.14076.151.camel@arm.com> References: <1415292718-19785-1-git-send-email-pawel.moll@arm.com> <1415292718-19785-4-git-send-email-pawel.moll@arm.com> <20150105134514.GS30905@twins.programming.kicks-ass.net> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20150105134514.GS30905-ndre7Fmf5hadTX5a5knrm8zTDFooKrT+cvkQGrU6aU0@public.gmane.org> Sender: linux-api-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Peter Zijlstra , John Stultz Cc: Richard Cochran , Steven Rostedt , Ingo Molnar , Paul Mackerras , Arnaldo Carvalho de Melo , Masami Hiramatsu , Christopher Covington , Namhyung Kim , David Ahern , Thomas Gleixner , Tomeu Vizoso , "linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" , "linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" List-Id: linux-api@vger.kernel.org On Mon, 2015-01-05 at 13:45 +0000, Peter Zijlstra wrote: > Also, one would expect something like: > > default: { > struct k_clock *kc = clockid_to_kclock(event->attr.clock); > struct timespec ts; > if (kc) { > kc->clock_get(event->attr.clock, &ts); > data->clock = ktime_to_ns(timespec_to_ktime(ts)); > } else { > data->clock = 0; > } > } > > Albeit preferably slightly less horrible -- of course, one would first > need to deal with the NMI issue. I was thinking about it... Maybe the solution is approaching the problem in a completely different way. As far as I understand (John?) POSIX timers can be used on any clockid? So it would be possible to obtain a dynamic clock id, for example for my exotic trace hardware (by any means necessary, like opening a char device) and create a timer firing every 1 ms (in the trace time domain). Than this event would be somehow associated with a perf session (for example, by passing the timerid via perf's ioctl) and then, every when timer fires, a perf record (something like PERF_RECORD_TIMER?) containing the timer/clock's value *and* the normal perf timestamp, would be injected into the circular buffer. No issue with NMI, no issue with passing clockid through perf_event_attr... Does it make any sense to anyone else but me? ;-) Pawel