Skip to content

Commit

Permalink
tracing: Fix endianness bug in histogram trigger
Browse files Browse the repository at this point in the history
At least on PA-RISC and s390 synthetic histogram triggers are failing
selftests because trace_event_raw_event_synth() always writes a 64 bit
values, but the reader expects a field->size sized value. On little endian
machines this doesn't hurt, but on big endian this makes the reader always
read zero values.

Link: http://lore.kernel.org/linux-trace-devel/[email protected]

Cc: [email protected]
Fixes: 4b14793 ("tracing: Add support for 'synthetic' events")
Acked-by: Tom Zanussi <[email protected]>
Signed-off-by: Sven Schnelle <[email protected]>
Signed-off-by: Steven Rostedt (VMware) <[email protected]>
  • Loading branch information
svens-s390 authored and rostedt committed Dec 21, 2019
1 parent 01f36a5 commit fe6e096
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion kernel/trace/trace_events_hist.c
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,26 @@ static notrace void trace_event_raw_event_synth(void *__data,
strscpy(str_field, str_val, STR_VAR_LEN_MAX);
n_u64 += STR_VAR_LEN_MAX / sizeof(u64);
} else {
entry->fields[n_u64] = var_ref_vals[var_ref_idx + i];
struct synth_field *field = event->fields[i];
u64 val = var_ref_vals[var_ref_idx + i];

switch (field->size) {
case 1:
*(u8 *)&entry->fields[n_u64] = (u8)val;
break;

case 2:
*(u16 *)&entry->fields[n_u64] = (u16)val;
break;

case 4:
*(u32 *)&entry->fields[n_u64] = (u32)val;
break;

default:
entry->fields[n_u64] = val;
break;
}
n_u64++;
}
}
Expand Down

0 comments on commit fe6e096

Please sign in to comment.