Skip to content

Commit

Permalink
tracing: Add "uptime" trace clock that uses jiffies
Browse files Browse the repository at this point in the history
Add a simple trace clock called "uptime" for those that are
interested in the uptime of the trace. It uses jiffies as that's
the safest method, as other uptime clocks grab seq locks, which could
cause a deadlock if taken from an event or function tracer.

Requested-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
  • Loading branch information
Steven Rostedt (Red Hat) committed Mar 15, 2013
1 parent 328df47 commit 8aacf01
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/linux/trace_clock.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

extern u64 notrace trace_clock_local(void);
extern u64 notrace trace_clock(void);
extern u64 notrace trace_clock_jiffies(void);
extern u64 notrace trace_clock_global(void);
extern u64 notrace trace_clock_counter(void);

Expand Down
1 change: 1 addition & 0 deletions kernel/trace/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,7 @@ static struct {
{ trace_clock_local, "local", 1 },
{ trace_clock_global, "global", 1 },
{ trace_clock_counter, "counter", 0 },
{ trace_clock_jiffies, "uptime", 1 },
ARCH_TRACE_CLOCKS
};

Expand Down
10 changes: 10 additions & 0 deletions kernel/trace/trace_clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ u64 notrace trace_clock(void)
return local_clock();
}

/*
* trace_jiffy_clock(): Simply use jiffies as a clock counter.
*/
u64 notrace trace_clock_jiffies(void)
{
u64 jiffy = jiffies - INITIAL_JIFFIES;

/* Return nsecs */
return (u64)jiffies_to_usecs(jiffy) * 1000ULL;
}

/*
* trace_clock_global(): special globally coherent trace clock
Expand Down

0 comments on commit 8aacf01

Please sign in to comment.