tracing: Fix config dependency and trigger parser
Masami Hiramatsu
maintainercover tracing: Fix config dependency and trigger parser
Hi,
These are some fixes which I found recentry on ftrace.
- Since the boot-time tracing synthetic event feature is decoupled from trigger recenty, it should use CONFIG_SYNTH_EVENT.
- The parser of event trigger seems rejecting some redundant spaces. But it is hard users to find the wrong point. Such spaces should be accepted.
BTW, I also found the trigger parser accepts some inputs which may not correctly formatted, e.g.
# echo "traceon 1" > events/ftrace/print/trigger
(from the document, it must be "traceon:1")
But I think this does not decrease the usability.
Thank you,
---
Masami Hiramatsu (2):
tracing/boot: Fix config dependency for synthedic event
tracing: Fix event trigger to accept redundant spaces
kernel/trace/trace_boot.c | 2 +- kernel/trace/trace_events_trigger.c | 21 +++++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-)
--
Masami Hiramatsu (Linaro) <[email protected]>
Masami Hiramatsu
maintainerPATCH 1/2 tracing/boot: Fix config dependency for synthedic event
Since commit 726721a51838 ("tracing: Move synthetic events to a separate file") decoupled synthetic event from histogram, boot-time tracing also has to check CONFIG_SYNTH_EVENT instead of CONFIG_HIST_TRIGGERS.
--- kernel/trace/trace_boot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_boot.c +1 -1
@@ -120,7 +120,7 @@ trace_boot_add_kprobe_event(struct xbc_node *node, const char *event) }#endif -#ifdef CONFIG_HIST_TRIGGERS +#ifdef CONFIG_SYNTH_EVENTS static int __init trace_boot_add_synth_event (struct xbc_node *node,const char *event) {
Masami Hiramatsu
maintainerPATCH 2/2 tracing: Fix event trigger to accept redundant spaces
In reply to Masami HiramatsuFix the event trigger to accept redundant spaces in the trigger input.
For example, these return -EINVAL
echo " traceon" > events/ftrace/print/trigger
echo "traceon if common_pid == 0" > events/ftrace/print/trigger echo "disable_event:kmem:kmalloc " > events/ftrace/print/trigger
But these are hard to find what is wrong.
To fix this issue, use skip_spaces() to remove spaces in front of actual tokens, and set NULL if there is no token.
--- kernel/trace/trace_events_trigger.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-)
kernel/trace/trace_events_trigger.c +19 -2
@@ -216,11 +216,17 @@ static int event_trigger_regex_open(struct inode *inode, struct file *file)int trigger_process_regex (struct trace_event_file *file,char *buff) { -char *command, *next = buff; +char *command, *next;struct event_command *p;int ret = -EINVAL ; + next = buff =skip_spaces (buff); command =strsep (&next,": \t" ); +if (next) { + next =skip_spaces (next); +if (!*next) + next =NULL ; + } command = (command[0 ] !='!' ) ? command : command +1 ;mutex_lock (&trigger_cmd_mutex);
@@ -630,8 +636,14 @@ event_trigger_callback(struct event_command *cmd_ops,int ret;/* separate the trigger from the filter (t:n [if filter]) */ -if (param &&isdigit (param[0 ])) +if (param &&isdigit (param[0 ])) { trigger =strsep (¶m," \t" ); +if (param) { + param =skip_spaces (param); +if (!*param) + param =NULL ; + } + } trigger_ops = cmd_ops->get_trigger_ops (cmd, trigger);
@@ -1368,6 +1380,11 @@ int event_enable_trigger_func(struct event_command *cmd_ops, trigger =strsep (¶m," \t" );if (!trigger)return -EINVAL ; +if (param) { + param =skip_spaces (param); +if (!*param) + param =NULL ; + } system =strsep (&trigger,":" );if (!trigger)
Hi Masami,
Quoted 6 lines · Masami Hiramatsu
Hi,
These are some fixes which I found recentry on ftrace.
- Since the boot-time tracing synthetic event feature is decoupled from trigger recenty, it should use
CONFIG_SYNTH_EVENT.
Oops, yeah, I missed this one in the update, thanks for finding it.
Quoted 4 lines
- The parser of event trigger seems rejecting some redundant spaces. But it is hard users to find the wrong point. Such spaces should be accepted.
Agreed, your patch makes things much better, thanks.
You can add my reviewed-by for both patches.
Thanks,
Tom
Quoted 23 lines
BTW, I also found the trigger parser accepts some inputs which may not correctly formatted, e.g.
# echo "traceon 1" > events/ftrace/print/trigger(from the document, it must be "traceon:1")
But I think this does not decrease the usability.Thank you,
---
Masami Hiramatsu (2):
tracing/boot: Fix config dependency for synthedic event
tracing: Fix event trigger to accept redundant spaceskernel/trace/trace_boot.c | 2 +- kernel/trace/trace_events_trigger.c | 21 +++++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-)--
Masami Hiramatsu (Linaro) <[email protected]>