Skip to content

Commit ec835f8

Browse files
committed
Merge tag 'trace-v4.15-rc4-3' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace
Pull tracing fixes from Steven Rostedt: "Two more small fixes - The conversion of enums into their actual numbers to display in the event format file had an off-by-one bug, that could cause an enum not to be converted, and break user space parsing tools. - A fix to a previous fix to bring back the context recursion checks. The interrupt case checks for NMI, IRQ and softirq, but the softirq returned the same number regardless if it was set or not, although the logic would force it to be set if it were hit" * tag 'trace-v4.15-rc4-3' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: tracing: Fix converting enum's from the map in trace_event_eval_update() ring-buffer: Fix duplicate results in mapping context to bits in recursive lock
2 parents 672bb0f + 1ebe1ea commit ec835f8

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

kernel/trace/ring_buffer.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2579,8 +2579,7 @@ trace_recursive_lock(struct ring_buffer_per_cpu *cpu_buffer)
25792579
bit = RB_CTX_NORMAL;
25802580
else
25812581
bit = pc & NMI_MASK ? RB_CTX_NMI :
2582-
pc & HARDIRQ_MASK ? RB_CTX_IRQ :
2583-
pc & SOFTIRQ_OFFSET ? 2 : RB_CTX_SOFTIRQ;
2582+
pc & HARDIRQ_MASK ? RB_CTX_IRQ : RB_CTX_SOFTIRQ;
25842583

25852584
if (unlikely(val & (1 << bit)))
25862585
return 1;

kernel/trace/trace_events.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2213,22 +2213,36 @@ void trace_event_eval_update(struct trace_eval_map **map, int len)
22132213
{
22142214
struct trace_event_call *call, *p;
22152215
const char *last_system = NULL;
2216+
bool first = false;
22162217
int last_i;
22172218
int i;
22182219

22192220
down_write(&trace_event_sem);
22202221
list_for_each_entry_safe(call, p, &ftrace_events, list) {
22212222
/* events are usually grouped together with systems */
22222223
if (!last_system || call->class->system != last_system) {
2224+
first = true;
22232225
last_i = 0;
22242226
last_system = call->class->system;
22252227
}
22262228

2229+
/*
2230+
* Since calls are grouped by systems, the likelyhood that the
2231+
* next call in the iteration belongs to the same system as the
2232+
* previous call is high. As an optimization, we skip seaching
2233+
* for a map[] that matches the call's system if the last call
2234+
* was from the same system. That's what last_i is for. If the
2235+
* call has the same system as the previous call, then last_i
2236+
* will be the index of the first map[] that has a matching
2237+
* system.
2238+
*/
22272239
for (i = last_i; i < len; i++) {
22282240
if (call->class->system == map[i]->system) {
22292241
/* Save the first system if need be */
2230-
if (!last_i)
2242+
if (first) {
22312243
last_i = i;
2244+
first = false;
2245+
}
22322246
update_event_printk(call, map[i]);
22332247
}
22342248
}

0 commit comments

Comments
 (0)