2017-07-09 11:42:39 +00:00
|
|
|
From: Tom Zanussi <tom.zanussi@linux.intel.com>
|
2017-12-20 18:53:59 +00:00
|
|
|
Date: Wed, 6 Dec 2017 16:38:09 -0600
|
2017-11-29 23:05:39 +00:00
|
|
|
Subject: [PATCH 28/37] tracing: Allow whitespace to surround hist trigger
|
2017-07-09 11:42:39 +00:00
|
|
|
filter
|
2017-12-20 18:53:59 +00:00
|
|
|
Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.6-rt7.tar.xz
|
2017-07-09 11:42:39 +00:00
|
|
|
|
|
|
|
The existing code only allows for one space before and after the 'if'
|
|
|
|
specifying the filter for a hist trigger. Add code to make that more
|
2017-11-20 14:16:49 +00:00
|
|
|
permissive as far as whitespace goes. Specifically, we want to allow
|
|
|
|
spaces in the trigger itself now that we have additional syntax
|
|
|
|
(onmatch/onmax) where spaces are more natural e.g. spaces after commas
|
|
|
|
in param lists.
|
2017-07-09 11:42:39 +00:00
|
|
|
|
|
|
|
Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>
|
|
|
|
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
|
|
|
|
---
|
2017-11-29 23:05:39 +00:00
|
|
|
kernel/trace/trace_events_hist.c | 37 ++++++++++++++++++++++++++++++++-----
|
|
|
|
1 file changed, 32 insertions(+), 5 deletions(-)
|
2017-07-09 11:42:39 +00:00
|
|
|
|
|
|
|
--- a/kernel/trace/trace_events_hist.c
|
|
|
|
+++ b/kernel/trace/trace_events_hist.c
|
2017-12-20 18:53:59 +00:00
|
|
|
@@ -5177,7 +5177,7 @@ static int event_hist_trigger_func(struc
|
2017-11-20 14:16:49 +00:00
|
|
|
struct synth_event *se;
|
|
|
|
const char *se_name;
|
2017-07-09 11:42:39 +00:00
|
|
|
bool remove = false;
|
|
|
|
- char *trigger;
|
|
|
|
+ char *trigger, *p;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
if (!param)
|
2017-12-20 18:53:59 +00:00
|
|
|
@@ -5186,10 +5186,37 @@ static int event_hist_trigger_func(struc
|
2017-11-20 14:16:49 +00:00
|
|
|
if (glob[0] == '!')
|
2017-07-09 11:42:39 +00:00
|
|
|
remove = true;
|
|
|
|
|
2017-11-20 14:16:49 +00:00
|
|
|
- /* separate the trigger from the filter (k:v [if filter]) */
|
2017-07-09 11:42:39 +00:00
|
|
|
- trigger = strsep(¶m, " \t");
|
|
|
|
- if (!trigger)
|
|
|
|
- return -EINVAL;
|
2017-11-20 14:16:49 +00:00
|
|
|
+ /*
|
|
|
|
+ * separate the trigger from the filter (k:v [if filter])
|
|
|
|
+ * allowing for whitespace in the trigger
|
|
|
|
+ */
|
2017-11-29 23:05:39 +00:00
|
|
|
+ p = trigger = param;
|
|
|
|
+ do {
|
|
|
|
+ p = strstr(p, "if");
|
|
|
|
+ if (!p)
|
|
|
|
+ break;
|
|
|
|
+ if (p == param)
|
2017-07-09 11:42:39 +00:00
|
|
|
+ return -EINVAL;
|
2017-11-29 23:05:39 +00:00
|
|
|
+ if (*(p - 1) != ' ' && *(p - 1) != '\t') {
|
|
|
|
+ p++;
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ if (p >= param + strlen(param) - strlen("if") - 1)
|
|
|
|
+ return -EINVAL;
|
|
|
|
+ if (*(p + strlen("if")) != ' ' && *(p + strlen("if")) != '\t') {
|
|
|
|
+ p++;
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ } while (p);
|
|
|
|
+
|
|
|
|
+ if (!p)
|
2017-07-09 11:42:39 +00:00
|
|
|
+ param = NULL;
|
2017-11-29 23:05:39 +00:00
|
|
|
+ else {
|
|
|
|
+ *(p - 1) = '\0';
|
|
|
|
+ param = strstrip(p);
|
|
|
|
+ trigger = strstrip(trigger);
|
|
|
|
+ }
|
2017-07-09 11:42:39 +00:00
|
|
|
|
|
|
|
attrs = parse_hist_trigger_attrs(trigger);
|
|
|
|
if (IS_ERR(attrs))
|