From: Masami Hiramatsu <mhiramat@kernel.org>
To: Tom Zanussi <zanussi@kernel.org>
Cc: rostedt@goodmis.org, axelrasmussen@google.com,
mhiramat@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/4] tracing/dynevent: Delegate parsing to create function
Date: Sat, 24 Oct 2020 17:50:40 +0900 [thread overview]
Message-ID: <20201024175040.3c7a69dcff5f110e713350be@kernel.org> (raw)
In-Reply-To: <af206cdc069b1de4670c0a27458eb98263eaf84e.1603484117.git.zanussi@kernel.org>
Hi Tom,
Thanks for the update!
On Fri, 23 Oct 2020 15:33:52 -0500
Tom Zanussi <zanussi@kernel.org> wrote:
> From: Masami Hiramatsu <mhiramat@kernel.org>
>
> Delegate command parsing to each create function so that the
> command syntax can be customized.
>
> Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
> [ zanussi@kernel.org: added synthetic event modifications ]
Since you've customized the synth_event parser, could you update
the patch description? (Or split this into 2 patches)
> Signed-off-by: Tom Zanussi <zanussi@kernel.org>
> ---
> kernel/trace/trace.c | 23 +---
> kernel/trace/trace.h | 3 +-
> kernel/trace/trace_dynevent.c | 35 +++---
> kernel/trace/trace_dynevent.h | 4 +-
> kernel/trace/trace_events_synth.c | 186 ++++++++++++++++--------------
> kernel/trace/trace_kprobe.c | 33 +++---
> kernel/trace/trace_probe.c | 17 +++
> kernel/trace/trace_probe.h | 1 +
> kernel/trace/trace_uprobe.c | 17 ++-
> 9 files changed, 174 insertions(+), 145 deletions(-)
[..]
> @@ -1223,26 +1176,43 @@ static int __create_synth_event(int argc, const char *name, const char **argv)
> goto out;
> }
>
> - for (i = 0; i < argc - 1; i++) {
> - if (strcmp(argv[i], ";") == 0)
> - continue;
> + tmp_fields = saved_fields = kstrdup(raw_fields, GFP_KERNEL);
> + if (!tmp_fields) {
> + ret = -ENOMEM;
> + goto out;
> + }
> +
> + while ((field_str = strsep(&tmp_fields, ";")) != NULL) {
> if (n_fields == SYNTH_FIELDS_MAX) {
> synth_err(SYNTH_ERR_TOO_MANY_FIELDS, 0);
> ret = -EINVAL;
> goto err;
> }
>
> - field = parse_synth_field(argc - i, &argv[i], &consumed);
> + argv = argv_split(GFP_KERNEL, field_str, &argc);
> + if (!argv) {
> + ret = -ENOMEM;
> + goto err;
> + }
> +
> + if (!argc)
> + continue;
> +
> + field = parse_synth_field(argc, argv);
> if (IS_ERR(field)) {
> + argv_free(argv);
> ret = PTR_ERR(field);
> goto err;
> }
> +
> + argv_free(argv);
> +
> fields[n_fields++] = field;
> i += consumed - 1;
You may not need this line (and "consumed") anymore?
> }
>
> - if (i < argc && strcmp(argv[i], ";") != 0) {
> - synth_err(SYNTH_ERR_INVALID_FIELD, errpos(argv[i]));
> + if (n_fields == 0) {
> + synth_err(SYNTH_ERR_CMD_INCOMPLETE, 0);
> ret = -EINVAL;
> goto err;
> }
> @@ -1261,6 +1231,8 @@ static int __create_synth_event(int argc, const char *name, const char **argv)
> out:
> mutex_unlock(&event_mutex);
>
> + kfree(saved_fields);
> +
> return ret;
> err:
> for (i = 0; i < n_fields; i++)
> @@ -1378,18 +1350,35 @@ int synth_event_delete(const char *event_name)
> }
> EXPORT_SYMBOL_GPL(synth_event_delete);
>
> -static int create_or_delete_synth_event(int argc, char **argv)
> +static int create_or_delete_synth_event(const char *raw_command)
> {
> - const char *name = argv[0];
> - int ret;
> + char **argv, *name = NULL, *fields;
> + int argc = 0, ret = 0;
> +
> + last_cmd_set(raw_command);
> +
> + argv = argv_split(GFP_KERNEL, raw_command, &argc);
> + if (!argv)
> + return -ENOMEM;
If you are sure the first argument is the name, you don't need
to use argv_split, but just strpbrk(raw_command, " \t"), something
like this.
raw_command = skip_spaces(raw_command);
p = strpbrk(raw_command, " \t");
if (!p)
return -EINVAL;
name = kmemdup_nul(raw_command, p - raw_command, GFP_KERNEL);
field = skip_spaces(p);
...
ret = __create_synth_event(name, fields);
free:
kfree(name);
(BTW, we should have find_spaces() instead of slow strpbrk().)
Thank you,
--
Masami Hiramatsu <mhiramat@kernel.org>
next prev parent reply other threads:[~2020-10-24 8:50 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-23 20:33 [PATCH v2 0/4] tracing: More synthetic event error fixes Tom Zanussi
2020-10-23 20:33 ` [PATCH v2 1/4] tracing/dynevent: Delegate parsing to create function Tom Zanussi
2020-10-23 23:03 ` kernel test robot
2020-10-24 8:50 ` Masami Hiramatsu [this message]
2020-10-23 20:33 ` [PATCH v2 2/4] tracing: Update synth command errors Tom Zanussi
2020-10-23 20:33 ` [PATCH v2 3/4] selftests/ftrace: Add synthetic event field separators Tom Zanussi
2020-10-23 20:33 ` [PATCH v2 4/4] selftests/ftrace: Update synthetic event syntax errors Tom Zanussi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201024175040.3c7a69dcff5f110e713350be@kernel.org \
--to=mhiramat@kernel.org \
--cc=axelrasmussen@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=zanussi@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox