Skip to content

Add walltime support for ring-buffer

Zhaolei lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 18 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3Add walltime support for ring-bufferdrivers/oprofile/cpu_buffer.c include/linux/ring_buffer.h kernel/trace/ring_buffer.c +4 more+161 -350 replies
1/3ftrace: Move setting of clock-source out of optionskernel/trace/trace.c kernel/trace/trace.h+79 -202 replies
2/3Apply walltime-supporting functions to trace systeminclude/linux/ftrace_event.h kernel/trace/trace.c kernel/trace/trace.h +1 more+19 -120 replies
2/3ftrace: add tracepoint for xtimeinclude/trace/events/xtime.h kernel/time/ntp.c kernel/time/timekeeping.c+48 -07 replies
3/3Make ftrace display walltime in outputkernel/trace/trace.c kernel/trace/trace.h kernel/trace/trace_output.c+30 -60 replies
3/3ftrace: Add timer-source of walltime for ftraceinclude/linux/trace_clock.h kernel/trace/trace.c kernel/trace/trace.h +2 more+91 -111 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/3] Add walltime support for ring-buffer

Hello, Steven

It is a prototype code to make ftrace display walltime of events.

It need to applys on my patch of:
[PATCH v3 1/2] Add function to convert between calendar time and broken-down time for universal use

This code can run but need to be fixed, it only for demostrate what is result looks like.

I think display walltime is valuable for ftrace, it can provide more recognizable information to system manager that he can known "when" event happened.
And it is also helpful for flight-recorder we are doing now, we can get walltime of events after panic for analyse.

We can get following result on this patch:

 # cd /mnt/debugfs/tracing/
 # echo sched_switch > current_tracer
 # cat trace
 # tracer: sched_switch
 #
 #           TASK-PID    CPU#    TIMESTAMP  FUNCTION
 #              | |       |          |         |
             bash-2457  [000]   214.895446:   2457:120:S   + [000]  2457:120:S bash
             bash-2457  [000]   214.898298:   2457:120:R   + [000]     5:115:S events/0
             bash-2457  [000]   214.898684:   2457:120:R ==> [000]     5:115:R events/0
         events/0-5     [000]   214.899458:      5:115:R   + [000]  2455:120:S sshd
         events/0-5     [000]   214.899495:      5:115:S ==> [000]  2455:120:R sshd
 ...
 # echo 1 > options/walltime
 # cat trace
 # tracer: sched_switch
 #
 #           TASK-PID    CPU#                  TIMESTAMP  FUNCTION
 #              | |       |                        |         |
           <idle>-0     [000] 2009-07-25 18:01:00.848468:      0:140:R ==> [000]     5:115:R events/0
         events/0-5     [000] 2009-07-25 18:01:00.848523:      5:115:S ==> [000]     0:140:R <idle>
           <idle>-0     [000] 2009-07-25 18:01:01.613479:      0:140:R   + [000]  2455:120:S sshd
           <idle>-0     [000] 2009-07-25 18:01:01.613678:      0:140:R ==> [000]  2455:120:R sshd
             sshd-2455  [000] 2009-07-25 18:01:01.614015:   2455:120:S   + [000]  2455:120:S sshd
 ...

This patch is prototype because we have following things to do:
1: function to get walltime is not near rb_time_stamp()
So walltime is not absolutely synchronize with trace time.
But if we place code to get walltime near rb_time_stamp(), it will be called on every reserve-event and will make system slow.
2: We can't call getnstimeofday() freely in ring-buffer's code, because
it is possibility already hold xtime_lock. Prototype code used a ugly way to get gid of this problem, maybe we need to ftrace_disable_cpu() before every write_seqlock() instead.
3: People maybe change walltime when tracing, but current ring-buffer page's
walltime can not reflect this change. We need to add tracepoints to watch this change, and add a walltime-change event(already reserved in ring-buffer.c) to record this change.

I'll continue to finish remain steps, what is your opinion on it?

Thanks
Zhaolei