Skip to contentSkip to conversation

tracing/histograms: Fix parsing of "sym-offset" modifier

PATCH In review Steven Rostedt 2 participants 2 messages Jul 7, 2021 Tracing

lore
Share & tools
lore

Steven Rostedt

author maintainer
#0 lore raw

PATCH 1/1 tracing/histograms: Fix parsing of "sym-offset" modifier

From: "Steven Rostedt (VMware)" <[email protected]>

With the addition of simple mathematical operations (plus and minus), the parsing of the "sym-offset" modifier broke, as it took the '-' part of the "sym-offset" as a minus, and tried to break it up into a mathematical operation of "field.sym - offset", in which case it failed to parse (unless the event had a field called "offset").

Both .sym and .sym-offset modifiers should not be entered into mathematical calculations anyway. If ".sym-offset" is found in the modifier, then simply make it not an operation that can be calculated on.

Fixes 100719dcef447 ("tracing: Add simple expression support to hist triggers")
---
 kernel/trace/trace_events_hist.c | 7 +++++++
 1 file changed, 7 insertions(+)
kernel/trace/trace_events_hist.c +7 -0
index ba03b7d84fc2..0207aeed31e6 100644
@@ -1555,6 +1555,13 @@ static int contains_operator(char *str)
 
 	switch (*op) {
 	case '-':
+		/*
+		 * Unfortunately, the modifier ".sym-offset"
+		 * can confuse things.
+		 */
+		if (op - str >= 4 && !strncmp(op - 4, ".sym-offset", 11))
+			return FIELD_OP_NONE;
+
 		if (*str == '-')
 			field_op = FIELD_OP_UNARY_MINUS;
 		else
Signature · 1 line
2.31.1
Reviewed-by on v1 1/1
#1 lore raw

Hi Steve,

Quoted 29 lines · Steven Rostedt

From: "Steven Rostedt (VMware)" <[email protected]>

With the addition of simple mathematical operations (plus and minus), the
parsing of the "sym-offset" modifier broke, as it took the '-' part of the
"sym-offset" as a minus, and tried to break it up into a mathematical operation of "field.sym - offset", in which case it failed to parse (unless the event had a field called "offset").

Both .sym and .sym-offset modifiers should not be entered into mathematical calculations anyway. If ".sym-offset" is found in the modifier, then simply make it not an operation that can be calculated on.

Fixes 100719dcef447 ("tracing: Add simple expression support to hist

triggers")

---
 kernel/trace/trace_events_hist.c | 7 +++++++
 1 file changed, 7 insertions(+)
kernel/trace/trace_events_hist.c +0 -0
index ba03b7d84fc2..0207aeed31e6 100644

kernel/trace/trace_events_hist.c static int contains_operator(char *str) · line 1561

Quoted 7 lines
kernel/trace/trace_events_hist.c +4 -0
@@ -1555,6 +1555,13 @@ static int contains_operator(char *str)
 
 	switch (*op) {
 	case '-':
+		/*
+		 * Unfortunately, the modifier ".sym-offset"
+		 * can confuse things.
+		 */

Good catch.

Quoted 7 lines
kernel/trace/trace_events_hist.c +3 -0
+		if (op - str >= 4 && !strncmp(op - 4, ".sym-offset",
 11))
+			return FIELD_OP_NONE;
+
 		if (*str == '-')
 			field_op = FIELD_OP_UNARY_MINUS;

else