tracing: Updates for 5.19
Subsystems (4)
Steven Rostedt
maintainerPATCH 5/8 tracing: Remove usage of list iterator after the loop body
In reply to Steven RostedtFrom: Jakob Koschel <[email protected]>
In preparation to limit the scope of the list iterator variable to the traversal loop, use a dedicated pointer to point to the found element [1].
Before, the code implicitly used the head when no element was found when using &pos->list. Since the new variable is only set if an element was found, the head needs to be used explicitly if the variable is NULL.
--- kernel/trace/trace_output.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
kernel/trace/trace_output.c +9 -4
@@ -692,7 +692,7 @@ static LIST_HEAD(ftrace_event_list);static int trace_search_list (struct list_head **list) { -struct trace_event *e; +struct trace_event *e =NULL , *iter;int next = __TRACE_LAST_TYPE;if (list_empty (&ftrace_event_list)) {
@@ -704,9 +704,11 @@ static int trace_search_list(struct list_head **list)* We used up all possible max events, * lets see if somebody freed one. */ -list_for_each_entry (e, &ftrace_event_list, list) { -if (e->type != next) +list_for_each_entry (iter, &ftrace_event_list, list) { +if (iter->type != next) { + e = iter;break ; + } next++; }
@@ -714,7 +716,10 @@ static int trace_search_list(struct list_head **list)if (next >TRACE_EVENT_TYPE_MAX )return 0 ; - *list = &e->list; +if (e) + *list = &e->list; +else + *list = &ftrace_event_list;return next; }
Signature · 1 line
2.35.1
Steven Rostedt
maintainerPATCH 2/8 ring-buffer: Have 32 bit time stamps use all 64 bits
In reply to Steven RostedtFrom: "Steven Rostedt (Google)" <[email protected]>
When the new logic was made to handle deltas of events from interrupts that interrupted other events, it required 64 bit local atomics. Unfortunately, 64 bit local atomics are expensive on 32 bit architectures. Thus, commit 10464b4aa605e ("ring-buffer: Add rb_time_t 64 bit operations for speeding up 32 bit") created a type of seq lock timer for 32 bits. It used two 32 bit local atomics, but required 2 bits from them each for synchronization, making it only 60 bits.
Add a new "msb" field to hold the extra 4 bits that are cut off.
--- kernel/trace/ring_buffer.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-)
kernel/trace/ring_buffer.c +18 -10
@@ -476,6 +476,7 @@ struct rb_time_struct {local_t cnt;local_t top;local_t bottom; + local_t msb; };#else #include <asm/local64.h>
@@ -577,7 +578,6 @@ struct ring_buffer_iter {* For the ring buffer, 64 bit required operations for the time is * the following: * -* - Only need 59 bits (uses 60 to make it even). * - Reads may fail if it interrupted a modification of the time stamp. * It will succeed if it did not interrupt another write even if * the read itself is interrupted by a write.
@@ -602,6 +602,7 @@ struct ring_buffer_iter {*/ #define RB_TIME_SHIFT 30#define RB_TIME_VAL_MASK ((1 << RB_TIME_SHIFT) - 1) +#define RB_TIME_MSB_SHIFT 60static inline int rb_time_cnt (unsigned long val) {
@@ -621,7 +622,7 @@ static inline u64 rb_time_val(unsigned long top, unsigned long bottom)static inline bool __rb_time_read (rb_time_t *t,u64 *ret,unsigned long *cnt) { -unsigned long top, bottom; +unsigned long top, bottom, msb;unsigned long c;/*
@@ -633,6 +634,7 @@ static inline bool __rb_time_read(rb_time_t *t, u64 *ret, unsigned long *cnt) c =local_read (&t->cnt); top =local_read (&t->top); bottom =local_read (&t->bottom); + msb =local_read (&t->msb); }while (c !=local_read (&t->cnt)); *cnt =rb_time_cnt (top);
@@ -641,7 +643,8 @@ static inline bool __rb_time_read(rb_time_t *t, u64 *ret, unsigned long *cnt)if (*cnt !=rb_time_cnt (bottom))return false; - *ret =rb_time_val (top, bottom); +/* The shift to msb will lose its cnt bits */ + *ret =rb_time_val (top, bottom) | ((u64 )msb <<RB_TIME_MSB_SHIFT );return true; }
@@ -657,10 +660,12 @@ static inline unsigned long rb_time_val_cnt(unsigned long val, unsigned long cntreturn (val &RB_TIME_VAL_MASK ) | ((cnt &3 ) <<RB_TIME_SHIFT ); } -static inline void rb_time_split (u64 val,unsigned long *top,unsigned long *bottom) +static inline void rb_time_split (u64 val,unsigned long *top,unsigned long *bottom, +unsigned long *msb) { *top = (unsigned long )((val >>RB_TIME_SHIFT ) &RB_TIME_VAL_MASK ); *bottom = (unsigned long )(val &RB_TIME_VAL_MASK ); + *msb = (unsigned long )(val >>RB_TIME_MSB_SHIFT ); }static inline void rb_time_val_set (local_t *t,unsigned long val,unsigned long cnt)
@@ -671,15 +676,16 @@ static inline void rb_time_val_set(local_t *t, unsigned long val, unsigned longstatic void rb_time_set (rb_time_t *t,u64 val) { -unsigned long cnt, top, bottom; +unsigned long cnt, top, bottom, msb; -rb_time_split (val, &top, &bottom); +rb_time_split (val, &top, &bottom, &msb);/* Writes always succeed with a valid number even if it gets interrupted. */ do { cnt =local_inc_return (&t->cnt);rb_time_val_set (&t->top, top, cnt);rb_time_val_set (&t->bottom, bottom, cnt); +rb_time_val_set (&t->msb, val >>RB_TIME_MSB_SHIFT , cnt); }while (cnt !=local_read (&t->cnt)); }
@@ -694,8 +700,8 @@ rb_time_read_cmpxchg(local_t *l, unsigned long expect, unsigned long set)static int rb_time_cmpxchg (rb_time_t *t,u64 expect,u64 set) { -unsigned long cnt, top, bottom; -unsigned long cnt2, top2, bottom2; +unsigned long cnt, top, bottom, msb; +unsigned long cnt2, top2, bottom2, msb2;u64 val;/* The cmpxchg always fails if it interrupted an update */
@@ -711,16 +717,18 @@ static int rb_time_cmpxchg(rb_time_t *t, u64 expect, u64 set) cnt2 = cnt +1 ; -rb_time_split (val, &top, &bottom); +rb_time_split (val, &top, &bottom, &msb); top =rb_time_val_cnt (top, cnt); bottom =rb_time_val_cnt (bottom, cnt); -rb_time_split (set, &top2, &bottom2); +rb_time_split (set, &top2, &bottom2, &msb2); top2 =rb_time_val_cnt (top2, cnt2); bottom2 =rb_time_val_cnt (bottom2, cnt2);if (!rb_time_read_cmpxchg (&t->cnt, cnt, cnt2))return false; +if (!rb_time_read_cmpxchg (&t->msb, msb, msb2)) +return false;if (!rb_time_read_cmpxchg (&t->top, top, top2))return false;if (!rb_time_read_cmpxchg (&t->bottom, bottom, bottom2))
Signature · 1 line
2.35.1
Steven Rostedt
maintainerPATCH 3/8 tracing: Introduce trace clock tai
In reply to Steven RostedtFrom: Kurt Kanzenbach <[email protected]>
A fast/NMI safe accessor for CLOCK_TAI has been introduced. Use it for adding the additional trace clock "tai".
--- kernel/trace/trace.c | 1 + 1 file changed, 1 insertion(+)
kernel/trace/trace.c +1 -0
@@ -1542,6 +1542,7 @@ static struct { { ktime_get_mono_fast_ns, "mono", 1 }, { ktime_get_raw_fast_ns, "mono_raw", 1 }, { ktime_get_boot_fast_ns, "boot", 1 }, + { ktime_get_tai_fast_ns, "tai", 1 },ARCH_TRACE_CLOCKS };
Signature · 1 line
2.35.1
Steven Rostedt
maintainerPATCH 8/8 tracing: Remove check of list iterator against head past the loop body
In reply to Steven RostedtFrom: Jakob Koschel <[email protected]>
When list_for_each_entry() completes the iteration over the whole list without breaking the loop, the iterator value will be a bogus pointer computed based on the head element.
While it is safe to use the pointer to determine if it was computed based on the head element, either with list_entry_is_head() or &pos->member == head, using the iterator variable after the loop should be avoided.
In preparation to limit the scope of a list iterator to the list traversal loop, use a dedicated pointer to point to the found element [1].
--- kernel/trace/ftrace.c | 20 ++++++++++++-------- kernel/trace/trace_eprobe.c | 14 ++++++++------ kernel/trace/trace_events.c | 12 ++++++------ 3 files changed, 26 insertions(+), 20 deletions(-)
kernel/trace/ftrace.c +12 -8
@@ -4560,8 +4560,8 @@ register_ftrace_function_probe(char *glob, struct trace_array *tr,struct ftrace_probe_ops *probe_ops, void *data) { + struct ftrace_func_probe *probe = NULL, *iter;struct ftrace_func_entry *entry; -struct ftrace_func_probe *probe;struct ftrace_hash **orig_hash;struct ftrace_hash *old_hash;struct ftrace_hash *hash;
@@ -4580,11 +4580,13 @@ register_ftrace_function_probe(char *glob, struct trace_array *tr,mutex_lock (&ftrace_lock);/* Check if the probe_ops is already registered */ -list_for_each_entry (probe, &tr->func_probes, list) { -if (probe->probe_ops == probe_ops) +list_for_each_entry (iter, &tr->func_probes, list) { +if (iter->probe_ops == probe_ops) { + probe = iter;break ; + } } -if (&probe->list == &tr->func_probes) { +if (!probe) { probe =kzalloc (sizeof (*probe),GFP_KERNEL );if (!probe) {mutex_unlock (&ftrace_lock);
@@ -4702,9 +4704,9 @@ int unregister_ftrace_function_probe_func(char *glob, struct trace_array *tr, struct ftrace_probe_ops *probe_ops) { +struct ftrace_func_probe *probe =NULL , *iter;struct ftrace_ops_hash old_hash_ops;struct ftrace_func_entry *entry; -struct ftrace_func_probe *probe;struct ftrace_glob func_g;struct ftrace_hash **orig_hash;struct ftrace_hash *old_hash;
@@ -4732,11 +4734,13 @@ unregister_ftrace_function_probe_func(char *glob, struct trace_array *tr,mutex_lock (&ftrace_lock);/* Check if the probe_ops is already registered */ -list_for_each_entry (probe, &tr->func_probes, list) { -if (probe->probe_ops == probe_ops) +list_for_each_entry (iter, &tr->func_probes, list) { +if (iter->probe_ops == probe_ops) { + probe = iter;break ; + } } -if (&probe->list == &tr->func_probes) +if (!probe) goto err_unlock_ftrace; ret = -EINVAL ;
kernel/trace/trace_eprobe.c +8 -6
@@ -648,7 +648,7 @@ static struct trace_event_functions eprobe_funcs = {static int disable_eprobe (struct trace_eprobe *ep,struct trace_array *tr) { -struct event_trigger_data *trigger; +struct event_trigger_data *trigger =NULL , *iter;struct trace_event_file *file;struct eprobe_data *edata;
@@ -656,14 +656,16 @@ static int disable_eprobe(struct trace_eprobe *ep,if (!file)return -ENOENT ; -list_for_each_entry (trigger, &file->triggers, list) { -if (!(trigger->flags &EVENT_TRIGGER_FL_PROBE )) +list_for_each_entry (iter, &file->triggers, list) { +if (!(iter->flags &EVENT_TRIGGER_FL_PROBE ))continue ; - edata = trigger->private_data; -if (edata->ep == ep) + edata = iter->private_data; +if (edata->ep == ep) { + trigger = iter;break ; + } } -if (list_entry_is_head (trigger, &file->triggers, list)) +if (!trigger)return -ENODEV ;list_del_rcu (&trigger->list);
kernel/trace/trace_events.c +6 -6
@@ -2279,8 +2279,8 @@ static struct dentry * event_subsystem_dir(struct trace_array *tr, const char *name, struct trace_event_file *file, struct dentry *parent) { + struct event_subsystem *system, *iter;struct trace_subsystem_dir *dir; -struct event_subsystem *system;struct dentry *entry;/* First see if we did not already create this dir */
@@ -2294,13 +2294,13 @@ event_subsystem_dir(struct trace_array *tr, const char *name, }/* Now see if the system itself exists. */ -list_for_each_entry (system, &event_subsystems, list) { -if (strcmp (system->name, name) ==0 ) + system =NULL ; +list_for_each_entry (iter, &event_subsystems, list) { +if (strcmp (iter->name, name) ==0 ) { + system = iter;break ; + } } -/* Reset system variable when not found */ -if (&system->list == &event_subsystems) - system =NULL ; dir =kmalloc (sizeof (*dir),GFP_KERNEL );if (!dir)
Signature · 1 line
2.35.1
Steven Rostedt
maintainerPATCH 7/8 tracing: Replace usage of found with dedicated list iterator variable
In reply to Steven RostedtFrom: Jakob Koschel <[email protected]>
To move the list iterator variable into the list_for_each_entry_*() macro in the future it should be avoided to use the list iterator variable after the loop body.
To *never* use the list iterator variable after the loop it was concluded to use a separate iterator variable instead of a found boolean [1].
This removes the need to use a found variable and simply checking if the variable was set, can determine if the break/goto was hit.
--- kernel/trace/trace_events_hist.c | 15 +++++++-------- kernel/trace/trace_events_trigger.c | 24 +++++++++++------------- 2 files changed, 18 insertions(+), 21 deletions(-)
kernel/trace/trace_events_hist.c +7 -8
@@ -6117,20 +6117,19 @@ static void hist_unregister_trigger(char *glob,struct event_trigger_data *data, struct trace_event_file *file) { + struct event_trigger_data *test = NULL, *iter, *named_data = NULL;struct hist_trigger_data *hist_data = data->private_data; -struct event_trigger_data *test, *named_data =NULL ; -bool unregistered = false;lockdep_assert_held (&event_mutex);if (hist_data->attrs->name) named_data =find_named_trigger (hist_data->attrs->name); -list_for_each_entry (test, &file->triggers, list) { -if (test->cmd_ops->trigger_type ==ETT_EVENT_HIST ) { -if (!hist_trigger_match (data, test, named_data, false)) +list_for_each_entry (iter, &file->triggers, list) { +if (iter->cmd_ops->trigger_type ==ETT_EVENT_HIST ) { +if (!hist_trigger_match (data, iter, named_data, false))continue ; - unregistered = true; + test = iter;list_del_rcu (&test->list);trace_event_trigger_enable_disable (file,0 );update_cond_flag (file);
@@ -6138,11 +6137,11 @@ static void hist_unregister_trigger(char *glob, } } -if (unregistered && test->ops->free) +if (test && test->ops->free) test->ops->free (test);if (hist_data->enable_timestamps) { -if (!hist_data->remove || unregistered) +if (!hist_data->remove || test)tracing_set_filter_buffering (file->tr, false); } }
kernel/trace/trace_events_trigger.c +11 -13
@@ -609,14 +609,13 @@ static void unregister_trigger(char *glob,struct event_trigger_data *test, struct trace_event_file *file) { - struct event_trigger_data *data; -bool unregistered = false; + struct event_trigger_data *data = NULL, *iter;lockdep_assert_held (&event_mutex); -list_for_each_entry (data, &file->triggers, list) { -if (data->cmd_ops->trigger_type == test->cmd_ops->trigger_type) { - unregistered = true; +list_for_each_entry (iter, &file->triggers, list) { +if (iter->cmd_ops->trigger_type == test->cmd_ops->trigger_type) { + data = iter;list_del_rcu (&data->list);trace_event_trigger_enable_disable (file,0 );update_cond_flag (file);
@@ -624,7 +623,7 @@ static void unregister_trigger(char *glob, } } -if (unregistered && data->ops->free) +if (data && data->ops->free) data->ops->free (data); }
@@ -1870,19 +1869,18 @@ void event_enable_unregister_trigger(char *glob, struct trace_event_file *file) {struct enable_trigger_data *test_enable_data = test->private_data; +struct event_trigger_data *data =NULL , *iter;struct enable_trigger_data *enable_data; -struct event_trigger_data *data; -bool unregistered = false;lockdep_assert_held (&event_mutex); -list_for_each_entry (data, &file->triggers, list) { - enable_data = data->private_data; +list_for_each_entry (iter, &file->triggers, list) { + enable_data = iter->private_data;if (enable_data && - (data->cmd_ops->trigger_type == + (iter->cmd_ops->trigger_type == test->cmd_ops->trigger_type) && (enable_data->file == test_enable_data->file)) { - unregistered = true; + data = iter;list_del_rcu (&data->list);trace_event_trigger_enable_disable (file,0 );update_cond_flag (file);
@@ -1890,7 +1888,7 @@ void event_enable_unregister_trigger(char *glob, } } -if (unregistered && data->ops->free) +if (data && data->ops->free) data->ops->free (data); }
Signature · 1 line
2.35.1
Steven Rostedt
maintainerPATCH 6/8 tracing: Remove usage of list iterator variable after the loop
In reply to Steven RostedtFrom: Jakob Koschel <[email protected]>
In preparation to limit the scope of a list iterator to the list traversal loop, use a dedicated pointer to point to the found element [1].
--- kernel/trace/trace_events.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
kernel/trace/trace_events.c +7 -8
@@ -1723,9 +1723,9 @@ static LIST_HEAD(event_subsystems);static int subsystem_open (struct inode *inode,struct file *filp) { +struct trace_subsystem_dir *dir =NULL , *iter_dir; +struct trace_array *tr =NULL , *iter_tr;struct event_subsystem *system =NULL ; -struct trace_subsystem_dir *dir =NULL ;/* Initialize for gcc */ -struct trace_array *tr;int ret;if (tracing_is_disabled ())
@@ -1734,10 +1734,12 @@ static int subsystem_open(struct inode *inode, struct file *filp)/* Make sure the system still exists */ mutex_lock (&event_mutex);mutex_lock (&trace_types_lock); -list_for_each_entry (tr, &ftrace_trace_arrays, list) { -list_for_each_entry (dir, &tr->systems, list) { -if (dir == inode->i_private) { +list_for_each_entry (iter_tr, &ftrace_trace_arrays, list) { +list_for_each_entry (iter_dir, &iter_tr->systems, list) { +if (iter_dir == inode->i_private) {/* Don't open systems with no events */ + tr = iter_tr; + dir = iter_dir;if (dir->nr_events) {__get_system_dir (dir); system = dir->subsystem;
@@ -1753,9 +1755,6 @@ static int subsystem_open(struct inode *inode, struct file *filp)if (!system)return -ENODEV ; -/* Some versions of gcc think dir can be uninitialized here */ -WARN_ON (!dir); -/* Still need to increment the ref count of the system */ if (trace_array_get (tr) <0 ) {put_system (dir);
Signature · 1 line
2.35.1
Steven Rostedt
maintainercover tracing: Updates for 5.19
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
for-next-core
Head SHA1: ba27d8555867b0e02e15709f4ddb79aec5cf2efc
Jakob Koschel (4):
tracing: Remove usage of list iterator after the loop body
tracing: Remove usage of list iterator variable after the loop
tracing: Replace usage of found with dedicated list iterator variable
tracing: Remove check of list iterator against head past the loop body
Kurt Kanzenbach (2):
tracing: Introduce trace clock tai
tracing: Add documentation for trace clock tai
Steven Rostedt (Google) (2):
ring-buffer: Have absolute time stamps handle large numbers
ring-buffer: Have 32 bit time stamps use all 64 bits
----
Documentation/trace/ftrace.rst | 12 ++++++ kernel/trace/ftrace.c | 20 ++++++---- kernel/trace/ring_buffer.c | 77 +++++++++++++++++++++++++++++-------- kernel/trace/trace.c | 1 + kernel/trace/trace_eprobe.c | 14 ++++--- kernel/trace/trace_events.c | 27 +++++++------ kernel/trace/trace_events_hist.c | 15 ++++---- kernel/trace/trace_events_trigger.c | 24 ++++++------ kernel/trace/trace_output.c | 13 +++++-- 9 files changed, 135 insertions(+), 68 deletions(-)
Steven Rostedt
maintainerPATCH 1/8 ring-buffer: Have absolute time stamps handle large numbers
From: "Steven Rostedt (Google)" <[email protected]>
There's an absolute timestamp event in the ring buffer, but this only saves 59 bits of the timestamp, as the 5 MSB is used for meta data (stating it is an absolute time stamp). This was never an issue as all the clocks currently in use never used those 5 MSB. But now there's a new clock (TAI) that does.
To handle this case, when reading an absolute timestamp, a previous full timestamp is passed in, and the 5 MSB of that timestamp is OR'd to the absolute timestamp (if any of the 5 MSB are set), and then to test for overflow, if the new result is smaller than the passed in previous timestamp, then 1 << 59 is added to it.
All the extra processing is done on the reader "slow" path, with the exception of the "too big delta" check, and the reading of timestamps for histograms.
Note, libtraceevent will need to be updated to handle this case as well. But this is not a user space regression, as user space was never able to handle any timestamps that used more than 59 bits.
--- kernel/trace/ring_buffer.c | 49 ++++++++++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 5 deletions(-)
kernel/trace/ring_buffer.c +44 -5
@@ -29,6 +29,14 @@#include <asm/local.h> +/* +* The "absolute" timestamp in the buffer is only 59 bits. +* If a clock has the 5 MSBs set, it needs to be saved and +* reinserted. +*/ +#define TS_MSB (0xf8ULL << 56) +#define ABS_TS_MASK (~TS_MSB) +static void update_pages_handler (struct work_struct *work);/*
@@ -783,6 +791,24 @@ static inline void verify_event(struct ring_buffer_per_cpu *cpu_buffer, }#endif +/* +* The absolute time stamp drops the 5 MSBs and some clocks may +* require them. The rb_fix_abs_ts() will take a previous full +* time stamp, and add the 5 MSB of that time stamp on to the +* saved absolute time stamp. Then they are compared in case of +* the unlikely event that the latest time stamp incremented +* the 5 MSB. +*/ +static inline u64 rb_fix_abs_ts (u64 abs,u64 save_ts) +{ +if (save_ts &TS_MSB ) { + abs |= save_ts &TS_MSB ; +/* Check for overflow */ +if (unlikely (abs < save_ts)) + abs +=1ULL <<59 ; + } +return abs; +}static inline u64 rb_time_stamp (struct trace_buffer *buffer);
@@ -811,8 +837,10 @@ u64 ring_buffer_event_time_stamp(struct trace_buffer *buffer,u64 ts;/* If the event includes an absolute time, then just use that */ -if (event->type_len ==RINGBUF_TYPE_TIME_STAMP ) -return rb_event_time_stamp (event); +if (event->type_len ==RINGBUF_TYPE_TIME_STAMP ) { + ts =rb_event_time_stamp (event); +return rb_fix_abs_ts (ts, cpu_buffer->tail_page->page->time_stamp); + } nest =local_read (&cpu_buffer->committing);verify_event (cpu_buffer, event);
@@ -2754,8 +2782,15 @@ static void rb_add_timestamp(struct ring_buffer_per_cpu *cpu_buffer, (RB_ADD_STAMP_FORCE |RB_ADD_STAMP_ABSOLUTE );if (unlikely (info->delta > (1ULL <<59 ))) { +/* +* Some timers can use more than 59 bits, and when a timestamp +* is added to the buffer, it will lose those bits. +*/ +if (abs && (info->ts &TS_MSB )) { + info->delta &=ABS_TS_MASK ; +/* did the clock go backwards */ -if (info->before == info->after && info->before > info->ts) { + }else if (info->before == info->after && info->before > info->ts) {/* not interrupted */ static int once;
@@ -3304,7 +3339,7 @@ static void dump_buffer_page(struct buffer_data_page *bpage,case RINGBUF_TYPE_TIME_STAMP : delta =rb_event_time_stamp (event); - ts = delta; + ts =rb_fix_abs_ts (delta, ts);pr_warn (" [%lld] absolute:%lld TIME STAMP\n" , ts, delta);break ;
@@ -3380,7 +3415,7 @@ static void check_buffer(struct ring_buffer_per_cpu *cpu_buffer,case RINGBUF_TYPE_TIME_STAMP : delta =rb_event_time_stamp (event); - ts = delta; + ts =rb_fix_abs_ts (delta, ts);break ;case RINGBUF_TYPE_PADDING :
@@ -4367,6 +4402,7 @@ rb_update_read_stamp(struct ring_buffer_per_cpu *cpu_buffer,case RINGBUF_TYPE_TIME_STAMP : delta =rb_event_time_stamp (event); + delta =rb_fix_abs_ts (delta, cpu_buffer->read_stamp); cpu_buffer->read_stamp = delta;return ;
@@ -4397,6 +4433,7 @@ rb_update_iter_read_stamp(struct ring_buffer_iter *iter,case RINGBUF_TYPE_TIME_STAMP : delta =rb_event_time_stamp (event); + delta =rb_fix_abs_ts (delta, iter->read_stamp); iter->read_stamp = delta;return ;
@@ -4650,6 +4687,7 @@ rb_buffer_peek(struct ring_buffer_per_cpu *cpu_buffer, u64 *ts,case RINGBUF_TYPE_TIME_STAMP :if (ts) { *ts =rb_event_time_stamp (event); + *ts =rb_fix_abs_ts (*ts, reader->page->time_stamp);ring_buffer_normalize_time_stamp (cpu_buffer->buffer, cpu_buffer->cpu, ts); }
@@ -4741,6 +4779,7 @@ rb_iter_peek(struct ring_buffer_iter *iter, u64 *ts)case RINGBUF_TYPE_TIME_STAMP :if (ts) { *ts =rb_event_time_stamp (event); + *ts =rb_fix_abs_ts (*ts, iter->head_page->page->time_stamp);ring_buffer_normalize_time_stamp (cpu_buffer->buffer, cpu_buffer->cpu, ts); }
Signature · 1 line
2.35.1
Steven Rostedt
maintainerPATCH 4/8 tracing: Add documentation for trace clock tai
In reply to Steven RostedtFrom: Kurt Kanzenbach <[email protected]>
Add documentation for newly introduced trace clock "tai". This clock corresponds to CLOCK_TAI.
--- Documentation/trace/ftrace.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+)
Documentation/trace/ftrace.rst +12 -0
@@ -517,6 +517,18 @@ of ftrace. Here is a list of some of the key files: processing should be able to handle them. See comments in the ktime_get_boot_fast_ns() function for more information. + tai: + This is the tai clock (CLOCK_TAI) and is derived from the wall- + clock time. However, this clock does not experience + discontinuities and backwards jumps caused by NTP inserting leap + seconds. Since the clock access is designed for use in tracing, + side effects are possible. The clock access may yield wrong + readouts in case the internal TAI offset is updated e.g., caused + by setting the system time or using adjtimex() with an offset. + These effects are rare and post processing should be able to + handle them. See comments in the ktime_get_tai_fast_ns() + function for more information. + To set a clock, simply echo the clock name into this file:: # echo global > trace_clock
Signature · 1 line
2.35.1