linux-api.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC 0/2] Yet another take at user/kernel time correlation problem
@ 2014-09-12 11:48 Pawel Moll
  2014-09-12 11:48 ` [RFC 1/2] perf: Add sampling of the raw monotonic clock Pawel Moll
       [not found] ` <1410522513-1045-1-git-send-email-pawel.moll-5wv7dgnIgG8@public.gmane.org>
  0 siblings, 2 replies; 19+ messages in thread
From: Pawel Moll @ 2014-09-12 11:48 UTC (permalink / raw)
  To: Richard Cochran, Steven Rostedt, Ingo Molnar, Peter Zijlstra,
	Paul Mackerras, Arnaldo Carvalho de Melo, John Stultz
  Cc: linux-kernel, linux-api, Pawel Moll

Greetings,

Here comes yet another take at the problem of correlating perf
samples, timestamped in kernel (with - de-facto - sched_clock values),
with performance-related events (be it debug information from JIT
engines or energy sensor data obtained via USB or hwmon) generated
in user space.

The first patch adds an additional timestamp field in the perf
sample data, which can be requested for any perf event along
with normal PERF_SAMPLE_TIME. Events with both values appearing
periodically in the perf data allow user code to translate
raw monotonic time (obtained via POSIX clock API) to sched_clock
domain. Although any perf event can be used, the natural choice
would be a sched_switch trace event (for processes with root
permissions) or a hrtimer-based PERF_COUNT_SW_CPU_CLOCK.

One question I haven't found answer to is: could it be even more
generic? As in: would it be possible to request a time value from
any of the available time sources? It doesn't make sense, I
believe, to have a PERF_SAMPLE_* for each possibility. An extra
flags in perf_event_attrs maybe? (we still have 39 spare bits there)

The second patch, functionally orthogonal but complementing
the first one, replicates the "trace_maker" idea from ftrace
in the perf world. Instead of a sysfs file, there is an ioctl
command, which simply injects a new type of software event into
the buffer. The argument can point at a zero-terminated string
of PAGE_SIZE max lenght. If provided, it will be copied to
the "raw" part of a sample. Of course the event can sample
a monotonic clock as well, if used with the above, so one
gets means of both synchronisation and time stamp approximation.

One doubt I have here is the ioctl argument. It takes
a strong now, like trace_marker does. But maybe a simple
integer value would suffice? After all the ioctl can be
only generated by the "owner" of the perf stream (unlike
in trace_marker case, where "anyone" can write to it), so
we could rely on him to have a dictionary of events of
some sort.

On another note, I proposed this subject for the tracing
microconference on Plumbers next month. Hope to have some good
discussion there. Maybe even a conclusion? (I wish... ;-)

Thanks!

Pawel


Pawel Moll (2):
  perf: Add sampling of the raw monotonic clock
  perf: Marker software event and ioctl

 include/linux/perf_event.h      |  2 ++
 include/uapi/linux/perf_event.h |  6 ++++-
 kernel/events/core.c            | 55 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 62 insertions(+), 1 deletion(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2014-09-16 17:58 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-12 11:48 [RFC 0/2] Yet another take at user/kernel time correlation problem Pawel Moll
2014-09-12 11:48 ` [RFC 1/2] perf: Add sampling of the raw monotonic clock Pawel Moll
     [not found] ` <1410522513-1045-1-git-send-email-pawel.moll-5wv7dgnIgG8@public.gmane.org>
2014-09-12 11:48   ` [RFC 2/2] perf: Marker software event and ioctl Pawel Moll
     [not found]     ` <1410522513-1045-3-git-send-email-pawel.moll-5wv7dgnIgG8@public.gmane.org>
2014-09-12 12:43       ` Christopher Covington
     [not found]         ` <5412EA7A.9020807-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2014-09-12 12:57           ` Pawel Moll
2014-09-12 13:49             ` Arnaldo Carvalho de Melo
     [not found]               ` <20140912134910.GG1801-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2014-09-12 13:58                 ` Pawel Moll
2014-09-12 16:19                   ` Arnaldo Carvalho de Melo
     [not found]                     ` <20140912161934.GJ1801-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2014-09-15 17:27                       ` Pawel Moll
2014-09-15 18:31                         ` Arnaldo Carvalho de Melo
     [not found]                           ` <20140915183101.GE11199-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2014-09-16 16:33                             ` Pawel Moll
2014-09-12 14:00             ` Christopher Covington
2014-09-12 17:37       ` David Ahern
     [not found]         ` <54132F63.1010401-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-09-12 20:44           ` Arnaldo Carvalho de Melo
2014-09-14 15:43             ` David Ahern
     [not found]               ` <5415B790.5010607-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-09-15 17:18                 ` Pawel Moll
2014-09-16  7:44                 ` Ingo Molnar
     [not found]                   ` <20140916074421.GA21295-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-09-16 16:37                     ` Pawel Moll
2014-09-16 17:58                       ` Ingo Molnar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).