LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] tracing / histogram: Give calculation hist_fields a size
@ 2021-07-30 21:19 Steven Rostedt
0 siblings, 0 replies; only message in thread
From: Steven Rostedt @ 2021-07-30 21:19 UTC (permalink / raw)
Cc: Tom Zanussi, Masami Hiramatsu, Namhyung Kim, Ingo Molnar, Andrew Morton
From: "Steven Rostedt (VMware)" <firstname.lastname@example.org>
When working on my user space applications, I found a bug in the synthetic
event code where the automated synthetic event field was not matching the
event field calculation it was attached to. Looking deeper into it, it was
because the calculation hist_field was not given a size.
The synthetic event fields are matched to their hist_fields either by
having the field have an identical string type, or if that does not match,
then the size and signed values are used to match the fields.
The problem arose when I tried to match a calculation where the fields
were "unsigned int". My tool created a synthetic event of type "u32". But
it failed to match. The string was:
Adding debugging into the kernel, I found that the size of "diff" was 0.
And since it was given "unsigned int" as a type, the histogram fallback
code used size and signed. The signed matched, but the size of u32 (4) did
not match zero, and the event failed to be created.
This can be worse if the field you want to match is not one of the
acceptable fields for a synthetic event. As event fields can have any type
that is supported in Linux, this can cause an issue. For example, if a
type is an enum. Then there's no way to use that with any calculations.
Have the calculation field simply take on the size of what it is
Fixes: 100719dcef447 ("tracing: Add simple expression support to hist triggers")
Signed-off-by: Steven Rostedt (VMware) <email@example.com>
kernel/trace/trace_events_hist.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
index 34325f41ebc0..362db9b81b8d 100644
@@ -2287,6 +2287,10 @@ static struct hist_field *parse_expr(struct hist_trigger_data *hist_data,
expr->operands = operand1;
expr->operands = operand2;
+ /* The operand sizes should be the same, so just pick one */
+ expr->size = operand1->size;
expr->operator = field_op;
expr->name = expr_str(expr, 0);
expr->type = kstrdup(operand1->type, GFP_KERNEL);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-07-30 21:19 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-30 21:19 [PATCH] tracing / histogram: Give calculation hist_fields a size Steven Rostedt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).