Re: [RFC PATCH 1/4] tracing: add __print_sym() to replace __print_symbolic()

From: Johannes Berg
Date: Thu Sep 21 2023 - 13:24:38 EST


On Thu, 2023-09-21 at 08:51 +0000, Johannes Berg wrote:
>
> - Is it correct that we can assume RCU critical section when in
> the lookup function? The SKB code currently does, but I may
> not ever have actually run this code yet.

Well, I could easily answer that myself, and no, it's incorrect.

It'd be really useful though for these lookups to be able to do them
under RCU, so I think I'll fold this?

--- a/include/linux/tracepoint.h
+++ b/include/linux/tracepoint.h
@@ -34,7 +34,7 @@ struct trace_eval_map {
struct trace_sym_def {
const char *system;
const char *symbol_id;
- /* may return NULL */
+ /* may return NULL, called under rcu_read_lock() */
const char * (*lookup)(unsigned long long);
/*
* Must print the list: ', { val, "name"}, ...'
--- a/kernel/trace/trace_output.c
+++ b/kernel/trace/trace_output.c
@@ -155,11 +155,13 @@ trace_print_sym_seq(struct trace_seq *p, unsigned
long long val,
const char *ret = trace_seq_buffer_ptr(p);
const char *name;

+ rcu_read_lock();
name = lookup(val);
if (name)
trace_seq_puts(p, name);
else
trace_seq_printf(p, "0x%llx", val);
+ rcu_read_unlock();

trace_seq_putc(p, 0);



johannes