mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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 1/5] tracing: Don't show dynamic string internals in synthetic event description
Date: Sun, 11 Oct 2020 00:03:44 +0900	[thread overview]
Message-ID: <20201011000344.4056fd1b0e8a7e48f2677ac0@kernel.org> (raw)
In-Reply-To: <b3b7baf7813298a5ede4ff02e2e837b91c05a724.1602255803.git.zanussi@kernel.org>

Hi Tom,

On Fri,  9 Oct 2020 10:17:07 -0500
Tom Zanussi <zanussi@kernel.org> wrote:

> For synthetic event dynamic fields, the type contains "__data_loc",
> which is basically an internal part of the type which is only meant to
> be displayed in the format, not in the event description itself, which
> is confusing to users since they can't use __data_loc on the
> command-line to define an event field, which printing it would lead
> them to believe.
> 
> So filter it out from the description, while leaving it in the type.
> 

OK, I confirmed this removes __data_loc from synth_events interface.
However, I also found another issue.

  /sys/kernel/debug/tracing # echo "myevent char str[]; int v" >> synthetic_events  
  /sys/kernel/debug/tracing # cat synthetic_events 
  myevent	char[]; str; int v

It seems that the type "char[]" includes ";" as a type, this results


  /sys/kernel/debug/tracing # cat events/synthetic/myevent/format 
  name: myevent
  ID: 1220
  format:
	field:unsigned short common_type;	offset:0;	size:2;	signed:0;
	field:unsigned char common_flags;	offset:2;	size:1;	signed:0;
	field:unsigned char common_preempt_count;	offset:3;	size:1;	signed:0;
	field:int common_pid;	offset:4;	size:4;	signed:1;

	field:__data_loc char[]; str;	offset:8;	size:8;	signed:1;
	field:int v;	offset:16;	size:4;	signed:1;

  print fmt: "str=%.*s, v=%d", __get_str(str), REC->v


As you can see, the field type has ";" in format file too. This will prevent
parsing event information correctly.
I also try to remove ";" as below, it seems to work correctly.

  /sys/kernel/debug/tracing # echo "myevent char[] str; int v" >> synthetic_events 
  /sys/kernel/debug/tracing # cat events/synthetic/myevent/format 
  name: myevent
  ID: 1221
  format:
	field:unsigned short common_type;	offset:0;	size:2;	signed:0;
	field:unsigned char common_flags;	offset:2;	size:1;	signed:0;
	field:unsigned char common_preempt_count;	offset:3;	size:1;	signed:0;
	field:int common_pid;	offset:4;	size:4;	signed:1;

	field:__data_loc char[] str;	offset:8;	size:8;	signed:1;
	field:int v;	offset:16;	size:4;	signed:1;

  print fmt: "str=%.*s, v=%d", __get_str(str), REC->v


Thank you,

> Reported-by: Masami Hiramatsu <mhiramat@kernel.org>
> Signed-off-by: Tom Zanussi <zanussi@kernel.org>
> ---
>  kernel/trace/trace_events_synth.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/trace/trace_events_synth.c b/kernel/trace/trace_events_synth.c
> index 3b2dcc42b8ee..b19e2f4159ab 100644
> --- a/kernel/trace/trace_events_synth.c
> +++ b/kernel/trace/trace_events_synth.c
> @@ -1867,14 +1867,22 @@ static int __synth_event_show(struct seq_file *m, struct synth_event *event)
>  {
>  	struct synth_field *field;
>  	unsigned int i;
> +	char *type, *t;
>  
>  	seq_printf(m, "%s\t", event->name);
>  
>  	for (i = 0; i < event->n_fields; i++) {
>  		field = event->fields[i];
>  
> +		type = field->type;
> +		t = strstr(type, "__data_loc");
> +		if (t) { /* __data_loc belongs in format but not event desc */
> +			t += sizeof("__data_loc");
> +			type = t;
> +		}
> +
>  		/* parameter values */
> -		seq_printf(m, "%s %s%s", field->type, field->name,
> +		seq_printf(m, "%s %s%s", type, field->name,
>  			   i == event->n_fields - 1 ? "" : "; ");
>  	}
>  
> -- 
> 2.17.1
> 


-- 
Masami Hiramatsu <mhiramat@kernel.org>

  reply	other threads:[~2020-10-10 23:03 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-09 15:17 [PATCH 0/5] tracing: Synthetic event dynamic string fixes Tom Zanussi
2020-10-09 15:17 ` [PATCH 1/5] tracing: Don't show dynamic string internals in synthetic event description Tom Zanussi
2020-10-10 15:03   ` Masami Hiramatsu [this message]
2020-10-12 15:37     ` Tom Zanussi
2020-10-09 15:17 ` [PATCH 2/5] tracing: Move is_good_name() from trace_probe.h to trace.h Tom Zanussi
2020-10-10 14:39   ` Masami Hiramatsu
2020-10-09 15:17 ` [PATCH 3/5] tracing: Check that the synthetic event and field names are legal Tom Zanussi
2020-10-10 14:41   ` Masami Hiramatsu
2020-10-09 15:17 ` [PATCH 4/5] tracing: Add synthetic event error logging Tom Zanussi
2020-10-10 14:57   ` Masami Hiramatsu
2020-10-12 15:34     ` Tom Zanussi
2020-10-09 15:17 ` [PATCH 5/5] selftests/ftrace: Change synthetic event name for inter-event-combined test Tom Zanussi
2020-10-10 14:43   ` Masami Hiramatsu
2020-10-09 20:35 ` [PATCH 0/5] tracing: Synthetic event dynamic string fixes Axel Rasmussen
2020-10-09 21:10   ` Tom Zanussi
2020-10-12 15:13 ` Steven Rostedt
2020-10-12 15:38   ` 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=20201011000344.4056fd1b0e8a7e48f2677ac0@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

Powered by JetHome