public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Taeung Song <treeze.taeung@gmail.com>
Cc: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ingo Molnar <mingo@redhat.com>, Jiri Olsa <jolsa@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	linux-kernel@vger.kernel.org,
	Thomas Gleixner <tglx@linutronix.de>,
	Lai Jiangshan <jiangshanlai@gmail.com>
Subject: Re: [PATCH v2 1/3] tracing/syscalls: Rename variable 'nr' to 'syscall_nr'
Date: Fri, 26 Feb 2016 10:46:25 -0300	[thread overview]
Message-ID: <20160226134625.GT8720@kernel.org> (raw)
In-Reply-To: <56D0440E.1000605@gmail.com>

Em Fri, Feb 26, 2016 at 09:24:46PM +0900, Taeung Song escreveu:
> Hi, Arnaldo
> 
> On 02/26/2016 03:42 AM, Arnaldo Carvalho de Melo wrote:
> >Em Fri, Feb 26, 2016 at 03:31:19AM +0900, Taeung Song escreveu:
> >>Hi, Arnaldo
> >>
> >>On 02/26/2016 02:57 AM, Arnaldo Carvalho de Melo wrote:
> >>>Em Fri, Feb 26, 2016 at 02:38:57AM +0900, Taeung Song escreveu:
> >>>>There is a problem about duplicated variable name i.e.
> >>>>     # cat /sys/kernel/debug/tracing/events/syscalls/sys_enter_io_getevents/format
> >>>>     name: sys_enter_io_getevents
> >>>>     ID: 739
> >>>>     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:int nr;                     offset:8;  size:4; signed:1;
> >>>>             field:aio_context_t ctx_id;       offset:16; size:8; signed:0;
> >>>>             field:long min_nr;                offset:24; size:8; signed:0;
> >>>>             field:long nr;                    offset:32; size:8; signed:0;
> >>>>             field:struct io_event * events;   offset:40; size:8; signed:0;
> >>>>             field:struct timespec * timeout;  offset:48; size:8; signed:0;
> >>>>
> >>>>             print fmt: "ctx_id: 0x%08lx, min_nr: 0x%08lx, nr: 0x%08lx,
> >>>>                         events: 0x%08lx, timeout: 0x%08lx", ((unsigned long)(REC->ctx_id)),
> >>>>                         ((unsigned long)(REC->min_nr)), ((unsigned long)(REC->nr)),
> >>>>                         ((unsigned long)(REC->events)), ((unsigned long)(REC->timeout))
> >>>>
> >>>>As above 'int nr;' and 'long nr;' variables have
> >>>>duplicated name so problems are occurred in perf-script i.e.
> >>>>
> >>>>     # perf record -e syscalls:*
> >>>>     # perf script -g python
> >>>>     # perf script -s perf-script.py
> >>>>       File "perf-script.py", line 8694
> >>>>         def syscalls__sys_enter_io_getevents(event_name, context, common_cpu,
> >>>>     SyntaxError: duplicate argument 'nr' in function definition
> >>>>     Error running python script perf-script.py
> >>>
> >>>Please test this with 'perf trace', which this patch breaks, this patch
> >>>should make it understand this 3rd variation of the non common list of
> >>>fields in syscall tracepoints:
> >>
> >>OK, I will test it.
> >>But IMHO, I think the bottom change has a problem.
> >>Because sys_enter_io_getevent() has a argument 'long nr'.
> >
> >It doesn't matter
> >
> >>So this if statement must not have strcmp(sc->args->name, "nr") == 0.
> >
> >This is checking for the first variable, if that has that name, it
> >should be discarded, as in the past it wasn't there, so for the tool to
> >work on kernels with "nr" as the first (for the syscall number) variable
> >and for kernels without it, we must check and discard.
> >
> >Now we must check and discard the first "nr" (for kernels with this
> >meaning the syscall number) and also if it is called "syscall_nr").
> >The other fields are taken as the syscall arguments, in the order that
> >they come, that is what what we will match with what is in the
> >raw_syscalls:sys_enter args array:
> >
> >[root@jouet ~]# cat
> >/sys/kernel/debug/tracing/events/raw_syscalls/sys_enter/format
> >name: sys_enter
> >ID: 17
> >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:long id;	offset:8;	size:8;	signed:1;
> >	field:unsigned long args[6];	offset:16;	size:48; signed:0;
> >
> >print fmt: "NR %ld (%lx, %lx, %lx, %lx, %lx, %lx)", REC->id,
> >REC->args[0], REC->args[1], REC->args[2], REC->args[3], REC->args[4],
> >REC->args[5]
> >[root@jouet ~]#
> >
> >>+ if (sc->args && strcmp(sc->args->name, "syscall_nr") == 0) {
> >>
> >>I think the above instance seem better than the bottom.
> >>
> >>+	if (sc->args && (strcmp(sc->args->name, "syscall_nr") ||
> >>strcmp(sc->args->name, "nr")) == 0) {
> >
> >Right in this 'if' body we do:
> >
> >		sc->args = sc->args->next;
> >		sc->nr_args--;
> >
> >something like that.
> >
> >- Arnaldo
> >
> >>But I'll test again with perf-trace.
> >
> >Right, look at the output of 'perf trace' before and after, so that you
> >can check if, say, we're using that syscall_nr value as the fd for the
> >'write' syscall ('fd' comes right after 'nr'/'syscall_nr').
> >
> 
> Sorry, I'm late.
> 
> I tested perf-trace with the bottom change.
> (does not rename it to '__syscall_nr' on kernel)

"With this change:"

> 
> +        if (sc->args && (strcmp(sc->args->name, "__syscall_nr") ||
> strcmp(sc->args->name, "nr")) == 0) {
>                  sc->args = sc->args->next;
>                  --sc->nr_args;
>          }
> 
> But there are some problems as below.

Right, there is a silly error, we have to test both strcmp(), checking
if one of them is equal to zero, i.e. if there was a match.

- Arnaldo
 
> 0.322 ( 0.012 ms): a.out/27045 write(nr: 3, fd: 4196046, buf: 0x4, count:
> 2140 ) = 4
> 
> So, I modified the above change. (I'll send it as new patch)
> And then I tested again as below
> 
> 0.345 ( 0.016 ms): a.out/27695 write(fd: 3, buf: 0x4006ce, count: 4 ) = 4
> 
> And I tested perf-trace with renamed '__syscall_nr' on modified kernel.
> Everything is ok for aught I know.
> 
> 0.345 ( 0.016 ms): a.out/27695 write(fd: 3, buf: 0x4006ce, count: 4 ) = 4
> 
> I'm writing another patchset. I'll send it soon.
> 
> Thanks,
> Taeung

  parent reply	other threads:[~2016-02-26 13:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-25 17:38 [PATCH v2 1/3] tracing/syscalls: Rename variable 'nr' to 'syscall_nr' Taeung Song
2016-02-25 17:57 ` Arnaldo Carvalho de Melo
2016-02-25 18:31   ` Taeung Song
2016-02-25 18:42     ` Arnaldo Carvalho de Melo
2016-02-26 12:24       ` Taeung Song
2016-02-26 13:01         ` Taeung Song
2016-02-26 13:46         ` Arnaldo Carvalho de Melo [this message]
2016-02-26 14:13           ` Taeung Song
2016-02-25 19:00     ` Steven Rostedt

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=20160226134625.GT8720@kernel.org \
    --to=acme@kernel.org \
    --cc=arnaldo.melo@gmail.com \
    --cc=jiangshanlai@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=treeze.taeung@gmail.com \
    /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