perf trace --no-syscalls -e rcu:* -- garbage in output

From: Tommi Rantala
Date: Tue Jun 26 2018 - 08:26:02 EST


Hi,

There some garbage in perf trace output, when tracing some rcu tracepoints (kernel is configured with CONFIG_RCU_TRACE=y).

For example in rcu:rcu_callback, instead of getting proper rcuname in the first "%s" here, there's garbage:

$ tail -1 /sys/kernel/debug/tracing/events/rcu/rcu_callback/format
print fmt: "%s rhp=%p func=%pf %ld/%ld", REC->rcuname, REC->rhp, REC->func, REC->qlen_lazy, REC->qlen

$ ./perf trace --no-syscalls -e 'rcu:*' -- sleep 1 2>&1 | od -t c

0000000 0 . 0 0 0 r c u : r
0000020 c u _ c a l l b a c k : 200 351 345 215
0000040 377 377 377 377 r h p = 0 x f f f f 8
0000060 d 5 5 8 f 5 b 0 1 0 0 f u n c
0000100 = f i l e _ f r e e _ r c u 0
0000120 / 1 \n 0 . 0 0 8 r c
0000140 u : r c u _ d y n t i c k : 373 217
0000160 276 215 377 377 377 377 4 0 0 0 0 0 0 0 0
0000200 0 0 0 0 0 0 0 4 0 0 0 0 0 0 0
0000220 0 0 0 0 0 0 0 2 0 x 1 d 2 \n
0000240 0 . 0 2 3 r c u : r c
0000260 u _ d y n t i c k : 023 220 276 215 377 377
0000300 377 377 4 0 0 0 0 0 0 0 0 0 0 0 0
0000320 0 0 2 4 0 0 0 0 0 0 0 0 0 0 0
0000340 0 0 0 0 0 x 1 d 2 \n
0000360 0 . 0 2 8 r c u : r c u _ d y
0000400 n t i c k : 373 217 276 215 377 377 377 377 4
0000420 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0000440 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2
0000460 0 x 1 d 2 \n 0 . 0 3
[...]


If I got it right, "pevent" in print_str_arg() is zero-initialized (pevent->long_size is zero...), causing "%s" format to produce garbage bytes instead of the proper string.

-Tommi