Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1727022 > unrolled thread
| Started by | Tom Zanussi <tom.zanussi@linux.intel.com> |
|---|---|
| First post | 2017-09-06 00:10 +0200 |
| Last post | 2017-09-08 21:10 +0200 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH v2 31/40] tracing: Allow whitespace to surround hist trigger filter Tom Zanussi <tom.zanussi@linux.intel.com> - 2017-09-06 00:10 +0200
Re: [PATCH v2 31/40] tracing: Allow whitespace to surround hist trigger filter Steven Rostedt <rostedt@goodmis.org> - 2017-09-08 21:00 +0200
Re: [PATCH v2 31/40] tracing: Allow whitespace to surround hist trigger filter Tom Zanussi <tom.zanussi@linux.intel.com> - 2017-09-08 21:10 +0200
| From | Tom Zanussi <tom.zanussi@linux.intel.com> |
|---|---|
| Date | 2017-09-06 00:10 +0200 |
| Subject | [PATCH v2 31/40] tracing: Allow whitespace to surround hist trigger filter |
| Message-ID | <umucF-oz-3@gated-at.bofh.it> |
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
permissive as far as whitespace goes.
Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>
---
kernel/trace/trace_events_hist.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
index 0a398f3..4f66f2e 100644
--- a/kernel/trace/trace_events_hist.c
+++ b/kernel/trace/trace_events_hist.c
@@ -4819,7 +4819,7 @@ static int event_hist_trigger_func(struct event_command *cmd_ops,
struct synth_event *se;
const char *se_name;
bool remove = false;
- char *trigger;
+ char *trigger, *p;
int ret = 0;
if (!param)
@@ -4829,9 +4829,19 @@ static int event_hist_trigger_func(struct event_command *cmd_ops,
remove = true;
/* separate the trigger from the filter (k:v [if filter]) */
- trigger = strsep(¶m, " \t");
- if (!trigger)
- return -EINVAL;
+ trigger = param;
+ p = strstr(param, " if");
+ if (!p)
+ p = strstr(param, "\tif");
+ if (p) {
+ if (p == trigger)
+ return -EINVAL;
+ param = p + 1;
+ param = strstrip(param);
+ *p = '\0';
+ trigger = strstrip(trigger);
+ } else
+ param = NULL;
attrs = parse_hist_trigger_attrs(trigger);
if (IS_ERR(attrs))
@@ -4889,6 +4899,7 @@ static int event_hist_trigger_func(struct event_command *cmd_ops,
}
ret = cmd_ops->reg(glob, trigger_ops, trigger_data, file);
+
/*
* The above returns on success the # of triggers registered,
* but if it didn't register any it returns zero. Consider no
--
1.9.3
[toc] | [next] | [standalone]
| From | Steven Rostedt <rostedt@goodmis.org> |
|---|---|
| Date | 2017-09-08 21:00 +0200 |
| Subject | Re: [PATCH v2 31/40] tracing: Allow whitespace to surround hist trigger filter |
| Message-ID | <unwFr-2mq-7@gated-at.bofh.it> |
| In reply to | #1727022 |
On Tue, 5 Sep 2017 16:57:43 -0500
Tom Zanussi <tom.zanussi@linux.intel.com> wrote:
> 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
> permissive as far as whitespace goes.
>
> Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>
> ---
> kernel/trace/trace_events_hist.c | 19 +++++++++++++++----
> 1 file changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
> index 0a398f3..4f66f2e 100644
> --- a/kernel/trace/trace_events_hist.c
> +++ b/kernel/trace/trace_events_hist.c
> @@ -4819,7 +4819,7 @@ static int event_hist_trigger_func(struct event_command *cmd_ops,
> struct synth_event *se;
> const char *se_name;
> bool remove = false;
> - char *trigger;
> + char *trigger, *p;
> int ret = 0;
>
> if (!param)
> @@ -4829,9 +4829,19 @@ static int event_hist_trigger_func(struct event_command *cmd_ops,
> remove = true;
>
> /* separate the trigger from the filter (k:v [if filter]) */
> - trigger = strsep(¶m, " \t");
> - if (!trigger)
> - return -EINVAL;
> + trigger = param;
> + p = strstr(param, " if");
> + if (!p)
> + p = strstr(param, "\tif");
> + if (p) {
> + if (p == trigger)
> + return -EINVAL;
> + param = p + 1;
> + param = strstrip(param);
> + *p = '\0';
> + trigger = strstrip(trigger);
> + } else
> + param = NULL;
This seems rather complex. Wouldn't the following work?
param = skip_spaces(param);
trigger = strsep(¶m, " \t");
if (param)
param = strstrip(param);
-- Steve
>
> attrs = parse_hist_trigger_attrs(trigger);
> if (IS_ERR(attrs))
> @@ -4889,6 +4899,7 @@ static int event_hist_trigger_func(struct event_command *cmd_ops,
> }
>
> ret = cmd_ops->reg(glob, trigger_ops, trigger_data, file);
> +
> /*
> * The above returns on success the # of triggers registered,
> * but if it didn't register any it returns zero. Consider no
[toc] | [prev] | [next] | [standalone]
| From | Tom Zanussi <tom.zanussi@linux.intel.com> |
|---|---|
| Date | 2017-09-08 21:10 +0200 |
| Subject | Re: [PATCH v2 31/40] tracing: Allow whitespace to surround hist trigger filter |
| Message-ID | <unwP8-2If-21@gated-at.bofh.it> |
| In reply to | #1729204 |
On Fri, 2017-09-08 at 14:50 -0400, Steven Rostedt wrote:
> On Tue, 5 Sep 2017 16:57:43 -0500
> Tom Zanussi <tom.zanussi@linux.intel.com> wrote:
>
> > 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
> > permissive as far as whitespace goes.
> >
> > Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>
> > ---
> > kernel/trace/trace_events_hist.c | 19 +++++++++++++++----
> > 1 file changed, 15 insertions(+), 4 deletions(-)
> >
> > diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
> > index 0a398f3..4f66f2e 100644
> > --- a/kernel/trace/trace_events_hist.c
> > +++ b/kernel/trace/trace_events_hist.c
> > @@ -4819,7 +4819,7 @@ static int event_hist_trigger_func(struct event_command *cmd_ops,
> > struct synth_event *se;
> > const char *se_name;
> > bool remove = false;
> > - char *trigger;
> > + char *trigger, *p;
> > int ret = 0;
> >
> > if (!param)
> > @@ -4829,9 +4829,19 @@ static int event_hist_trigger_func(struct event_command *cmd_ops,
> > remove = true;
> >
> > /* separate the trigger from the filter (k:v [if filter]) */
> > - trigger = strsep(¶m, " \t");
> > - if (!trigger)
> > - return -EINVAL;
> > + trigger = param;
> > + p = strstr(param, " if");
> > + if (!p)
> > + p = strstr(param, "\tif");
> > + if (p) {
> > + if (p == trigger)
> > + return -EINVAL;
> > + param = p + 1;
> > + param = strstrip(param);
> > + *p = '\0';
> > + trigger = strstrip(trigger);
> > + } else
> > + param = NULL;
>
> This seems rather complex. Wouldn't the following work?
>
> param = skip_spaces(param);
> trigger = strsep(¶m, " \t");
> if (param)
> param = strstrip(param);
>
Yes, much better ;-)
Tom
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web