Skip to content

Commit 9cb99c5

Browse files
crwood-rhrostedt
authored andcommitted
tracing/osnoise: Array printk init and cleanup
None of the calls to trace_array_printk_buf() will do anything if we don't initialize the buffer on instance creation (unless some other tracer called it), so do that. Add an osnoise_print() function to facilitate adding debug prints (without tainting). Use trace_array_printk() instead of trace_array_printk_buf(), as we're only writing to the main buffer (of a non-main instance) anyway -- and trace_array_printk_buf() skips the check to make sure we're not printing to the global instance. Link: https://patch.msgid.link/20260511223035.1475676-1-crwood@redhat.com Signed-off-by: Crystal Wood <crwood@redhat.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
1 parent e11c9c8 commit 9cb99c5

1 file changed

Lines changed: 24 additions & 15 deletions

File tree

kernel/trace/trace_osnoise.c

Lines changed: 24 additions & 15 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());

0 commit comments

Comments
 (0)