Skip to content

Commit c071a4f

Browse files
committed
Merge tag 'trace-latency-v7.2' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace
Pull tracing latency updates from Steven Rostedt: - Dump the stack to the buffer on timerlat uret threashold event Record the stack trace in the buffer for THREAD_URET as well as THREAD_CONTEXT when the threshold is hit. Otherwise, if the threshold was not hit at task wakeup, but was at task return, it will not produce a stack trace making it harder to debug. - Have osnoise trace prints print to all buffers The osnoise tracer is allowed to print to the main buffer. Add a osnoise_print() helper function and use trace_array_vprintk() to print osnoise output. * tag 'trace-latency-v7.2' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace: tracing/osnoise: Array printk init and cleanup tracing/osnoise: Dump stack on timerlat uret threshold event
2 parents 18ecdd4 + 9cb99c5 commit c071a4f

1 file changed

Lines changed: 29 additions & 17 deletions

File tree

kernel/trace/trace_osnoise.c

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,22 @@ struct osnoise_instance {
8383

8484
static struct list_head osnoise_instances;
8585

86+
static void osnoise_print(const char *fmt, ...)
87+
{
88+
struct osnoise_instance *inst;
89+
struct trace_array *tr;
90+
va_list ap;
91+
92+
rcu_read_lock();
93+
list_for_each_entry_rcu(inst, &osnoise_instances, list) {
94+
tr = inst->tr;
95+
va_start(ap, fmt);
96+
trace_array_vprintk(tr, _RET_IP_, fmt, ap);
97+
va_end(ap);
98+
}
99+
rcu_read_unlock();
100+
}
101+
86102
static bool osnoise_has_registered_instances(void)
87103
{
88104
return !!list_first_or_null_rcu(&osnoise_instances,
@@ -123,6 +139,7 @@ static int osnoise_register_instance(struct trace_array *tr)
123139
* trace_types_lock.
124140
*/
125141
lockdep_assert_held(&trace_types_lock);
142+
trace_array_init_printk(tr);
126143

127144
inst = kmalloc_obj(*inst);
128145
if (!inst)
@@ -471,15 +488,7 @@ static void print_osnoise_headers(struct seq_file *s)
471488
* osnoise_taint - report an osnoise error.
472489
*/
473490
#define osnoise_taint(msg) ({ \
474-
struct osnoise_instance *inst; \
475-
struct trace_buffer *buffer; \
476-
\
477-
rcu_read_lock(); \
478-
list_for_each_entry_rcu(inst, &osnoise_instances, list) { \
479-
buffer = inst->tr->array_buffer.buffer; \
480-
trace_array_printk_buf(buffer, _THIS_IP_, msg); \
481-
} \
482-
rcu_read_unlock(); \
491+
osnoise_print(msg); \
483492
osnoise_data.tainted = true; \
484493
})
485494

@@ -1189,10 +1198,10 @@ static __always_inline void osnoise_stop_exception(char *msg, int cpu)
11891198
rcu_read_lock();
11901199
list_for_each_entry_rcu(inst, &osnoise_instances, list) {
11911200
tr = inst->tr;
1192-
trace_array_printk_buf(tr->array_buffer.buffer, _THIS_IP_,
1193-
"stop tracing hit on cpu %d due to exception: %s\n",
1194-
smp_processor_id(),
1195-
msg);
1201+
trace_array_printk(tr, _THIS_IP_,
1202+
"stop tracing hit on cpu %d due to exception: %s\n",
1203+
smp_processor_id(),
1204+
msg);
11961205

11971206
if (test_bit(OSN_PANIC_ON_STOP, &osnoise_options))
11981207
panic("tracer hit on cpu %d due to exception: %s\n",
@@ -1362,8 +1371,8 @@ static __always_inline void osnoise_stop_tracing(void)
13621371
rcu_read_lock();
13631372
list_for_each_entry_rcu(inst, &osnoise_instances, list) {
13641373
tr = inst->tr;
1365-
trace_array_printk_buf(tr->array_buffer.buffer, _THIS_IP_,
1366-
"stop tracing hit on cpu %d\n", smp_processor_id());
1374+
trace_array_printk(tr, _THIS_IP_,
1375+
"stop tracing hit on cpu %d\n", smp_processor_id());
13671376

13681377
if (test_bit(OSN_PANIC_ON_STOP, &osnoise_options))
13691378
panic("tracer hit stop condition on CPU %d\n", smp_processor_id());
@@ -2544,9 +2553,12 @@ timerlat_fd_read(struct file *file, char __user *ubuf, size_t count,
25442553
notify_new_max_latency(diff);
25452554

25462555
tlat->tracing_thread = false;
2547-
if (osnoise_data.stop_tracing_total)
2548-
if (time_to_us(diff) >= osnoise_data.stop_tracing_total)
2556+
if (osnoise_data.stop_tracing_total) {
2557+
if (time_to_us(diff) >= osnoise_data.stop_tracing_total) {
2558+
timerlat_dump_stack(time_to_us(diff));
25492559
osnoise_stop_tracing();
2560+
}
2561+
}
25502562
} else {
25512563
tlat->tracing_thread = false;
25522564
tlat->kthread = current;

0 commit comments

Comments
 (0)