[lkml]   [2019]   [Nov]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH] tracing: Fix printing ptrs in preempt/irq enable/disable events
This tracing event class is the only instance in kernel that logs
in the trace buffer the instruction pointer as offset to _stext,
instead of logging the full pointer.
This looks like a nice optimization for 64 bits platforms, where a
32 bit offset can take less space than a full 64 bits pointer. But
the symbol _stext is incorrectly resolved as zero in the expansion
of TP_printk(), which then prints only the hex offset instead of
the name of the caller function. Plus, on arm arch the kernel
modules are loaded at address lower than _stext, causing the u32
offset arithmetics to overflow and wrap at 32 bits.
I did not identified a 64 bit arch where the modules are loaded at
offset from _stext that exceed u32 range, but I also did not
identified any constraint to feel safe with a u32 offset.

Log directly the instruction pointer instead of the offset to

Signed-off-by: Antonio Borneo <>
Fixes: d59158162e03 ("tracing: Add support for preempt and irq enable/disable events")
include/trace/events/preemptirq.h | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/include/trace/events/preemptirq.h b/include/trace/events/preemptirq.h
index 95fba0471e5b..d548a6aafa18 100644
--- a/include/trace/events/preemptirq.h
+++ b/include/trace/events/preemptirq.h
@@ -18,18 +18,18 @@ DECLARE_EVENT_CLASS(preemptirq_template,
TP_ARGS(ip, parent_ip),

- __field(u32, caller_offs)
- __field(u32, parent_offs)
+ __field(unsigned long, caller_ip)
+ __field(unsigned long, parent_ip)

- __entry->caller_offs = (u32)(ip - (unsigned long)_stext);
- __entry->parent_offs = (u32)(parent_ip - (unsigned long)_stext);
+ __entry->caller_ip = ip;
+ __entry->parent_ip = parent_ip;

TP_printk("caller=%pS parent=%pS",
- (void *)((unsigned long)(_stext) + __entry->caller_offs),
- (void *)((unsigned long)(_stext) + __entry->parent_offs))
+ (void *)__entry->caller_ip,
+ (void *)__entry->parent_ip)

 \ /
  Last update: 2019-11-27 16:46    [W:0.074 / U:3.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site