Skip to content

Commit d8279bf

Browse files
committed
tracing: Add tracing_event_time_stamp() API
Add a tracing_event_time_stamp() API that checks if the event passed in is not on the ring buffer but a pointer to the per CPU trace_buffered_event which does not have its time stamp set yet. If it is a pointer to the trace_buffered_event, then just return the current time stamp that the ring buffer would produce. Otherwise, return the time stamp from the event. Link: https://lkml.kernel.org/r/[email protected] Reviewed-by: Tom Zanussi <[email protected]> Signed-off-by: Steven Rostedt (VMware) <[email protected]>
1 parent a948c69 commit d8279bf

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

kernel/trace/trace.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6972,6 +6972,14 @@ static int tracing_time_stamp_mode_open(struct inode *inode, struct file *file)
69726972
return ret;
69736973
}
69746974

6975+
u64 tracing_event_time_stamp(struct trace_buffer *buffer, struct ring_buffer_event *rbe)
6976+
{
6977+
if (rbe == this_cpu_read(trace_buffered_event))
6978+
return ring_buffer_time_stamp(buffer, smp_processor_id());
6979+
6980+
return ring_buffer_event_time_stamp(buffer, rbe);
6981+
}
6982+
69756983
/*
69766984
* Set or disable using the per CPU trace_buffer_event when possible.
69776985
*/

kernel/trace/trace.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ extern int tracing_check_open_get_tr(struct trace_array *tr);
372372
extern struct trace_array *trace_array_find(const char *instance);
373373
extern struct trace_array *trace_array_find_get(const char *instance);
374374

375+
extern u64 tracing_event_time_stamp(struct trace_buffer *buffer, struct ring_buffer_event *rbe);
375376
extern int tracing_set_filter_buffering(struct trace_array *tr, bool set);
376377
extern int tracing_set_clock(struct trace_array *tr, const char *clockstr);
377378

0 commit comments

Comments
 (0)