All of lore.kernel.org
 help / color / mirror / Atom feed
From: Taeung Song <treeze.taeung@gmail.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	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 RESEND 1/3] tracing/syscalls: Rename variable 'nr' to 'syscall_nr'
Date: Fri, 26 Feb 2016 01:53:47 +0900	[thread overview]
Message-ID: <56CF319B.8060806@gmail.com> (raw)
In-Reply-To: <20160225104741.2cd3bf14@gandalf.local.home>

Hi, Steven

On 02/26/2016 12:47 AM, Steven Rostedt wrote:
> On Fri, 26 Feb 2016 00:24:18 +0900
> Taeung Song <treeze.taeung@gmail.com> wrote:
>
>> There is a problem about duplicated variable name
>> for system call number and a argument of some
>> system call. I found this problem when I tested
>> perf-script with python script as below.
>>
>>      # 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
>>
>> As above, problems about duplicated argument occurred
>> when processing sys_enter_io_getevent() and sys_enter_io_submit().
>> Because the two system calls have a argument 'nr' as below.
>>
>>      int io_getevents(aio_context_t ctx_id, long min_nr, long nr,
>>                       struct io_event *events, struct timespec *timeout);
>>
>>      int io_submit(aio_context_t ctx_id, long nr, struct iocb **iocbpp);
>>
>> So rename a variable 'nr' to 'syscall_nr' for system call number
>> in print_syscall_enter().
>
> WTF, how does changing the kernel fix a user space python generation
> bug?
>

The underlying cause of this problem is not because of
the python script. This problem have relevance to tracing/syscalls
as below.

# 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 you see, there are duplicated variable name among fields.
So I renamed the variable name 'nr' to 'syscall_nr' to avoid this
duplication. As you know 'nr' in print_syscall_enter() mean
system call number so, I changed 'nr' to 'syscall_nr'(IMHO).


Thanks,
Taeung

>>
>> Cc: Thomas Gleixner <tglx@linutronix.de>
>> Cc: Lai Jiangshan <jiangshanlai@gmail.com>
>> Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
>> ---
>>   kernel/trace/trace.h          |  4 ++--
>>   kernel/trace/trace_syscalls.c | 16 ++++++++--------
>>   2 files changed, 10 insertions(+), 10 deletions(-)
>>
>> diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
>> index 8414fa4..beddeb1 100644
>> --- a/kernel/trace/trace.h
>> +++ b/kernel/trace/trace.h
>> @@ -88,13 +88,13 @@ enum trace_type {
>>    */
>>   struct syscall_trace_enter {
>>   	struct trace_entry	ent;
>> -	int			nr;
>> +	int			syscall_nr;
>>   	unsigned long		args[];
>>   };
>>
>>   struct syscall_trace_exit {
>>   	struct trace_entry	ent;
>> -	int			nr;
>> +	int			syscall_nr;
>>   	long			ret;
>>   };
>>
>> diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
>> index 0655afb..956209f 100644
>> --- a/kernel/trace/trace_syscalls.c
>> +++ b/kernel/trace/trace_syscalls.c
>> @@ -118,7 +118,7 @@ print_syscall_enter(struct trace_iterator *iter, int flags,
>>   	int i, syscall;
>>
>>   	trace = (typeof(trace))ent;
>> -	syscall = trace->nr;
>> +	syscall = trace->syscall_nr;
>>   	entry = syscall_nr_to_meta(syscall);
>>
>>   	if (!entry)
>> @@ -164,7 +164,7 @@ print_syscall_exit(struct trace_iterator *iter, int flags,
>>   	struct syscall_metadata *entry;
>>
>>   	trace = (typeof(trace))ent;
>> -	syscall = trace->nr;
>> +	syscall = trace->syscall_nr;
>>   	entry = syscall_nr_to_meta(syscall);
>>
>>   	if (!entry) {
>> @@ -261,7 +261,7 @@ static int __init syscall_enter_define_fields(struct trace_event_call *call)
>>   	int i;
>>   	int offset = offsetof(typeof(trace), args);
>>
>> -	ret = trace_define_field(call, SYSCALL_FIELD(int, nr), FILTER_OTHER);
>> +	ret = trace_define_field(call, SYSCALL_FIELD(int, syscall_nr), FILTER_OTHER);
>>   	if (ret)
>>   		return ret;
>>
>> @@ -281,7 +281,7 @@ static int __init syscall_exit_define_fields(struct trace_event_call *call)
>>   	struct syscall_trace_exit trace;
>>   	int ret;
>>
>> -	ret = trace_define_field(call, SYSCALL_FIELD(int, nr), FILTER_OTHER);
>> +	ret = trace_define_field(call, SYSCALL_FIELD(int, syscall_nr), FILTER_OTHER);
>>   	if (ret)
>>   		return ret;
>>
>> @@ -332,7 +332,7 @@ static void ftrace_syscall_enter(void *data, struct pt_regs *regs, long id)
>>   		return;
>>
>>   	entry = ring_buffer_event_data(event);
>> -	entry->nr = syscall_nr;
>> +	entry->syscall_nr = syscall_nr;
>>   	syscall_get_arguments(current, regs, 0, sys_data->nb_args, entry->args);
>>
>>   	event_trigger_unlock_commit(trace_file, buffer, event, entry,
>> @@ -378,7 +378,7 @@ static void ftrace_syscall_exit(void *data, struct pt_regs *regs, long ret)
>>   		return;
>>
>>   	entry = ring_buffer_event_data(event);
>> -	entry->nr = syscall_nr;
>> +	entry->syscall_nr = syscall_nr;
>>   	entry->ret = syscall_get_return_value(current, regs);
>>
>>   	event_trigger_unlock_commit(trace_file, buffer, event, entry,
>> @@ -579,7 +579,7 @@ static void perf_syscall_enter(void *ignore, struct pt_regs *regs, long id)
>>   	if (!rec)
>>   		return;
>>
>> -	rec->nr = syscall_nr;
>> +	rec->syscall_nr = syscall_nr;
>>   	syscall_get_arguments(current, regs, 0, sys_data->nb_args,
>>   			       (unsigned long *)&rec->args);
>>   	perf_trace_buf_submit(rec, size, rctx, 0, 1, regs, head, NULL);
>> @@ -652,7 +652,7 @@ static void perf_syscall_exit(void *ignore, struct pt_regs *regs, long ret)
>>   	if (!rec)
>>   		return;
>>
>> -	rec->nr = syscall_nr;
>> +	rec->syscall_nr = syscall_nr;
>>   	rec->ret = syscall_get_return_value(current, regs);
>>   	perf_trace_buf_submit(rec, size, rctx, 0, 1, regs, head, NULL);
>>   }
>

  reply	other threads:[~2016-02-25 16:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-25 15:24 [PATCH RESEND 1/3] tracing/syscalls: Rename variable 'nr' to 'syscall_nr' Taeung Song
2016-02-25 15:47 ` Steven Rostedt
2016-02-25 16:53   ` Taeung Song [this message]
2016-02-25 17:05     ` Steven Rostedt
2016-02-25 17:09       ` Steven Rostedt
2016-02-25 17:26         ` Taeung Song

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=56CF319B.8060806@gmail.com \
    --to=treeze.taeung@gmail.com \
    --cc=acme@kernel.org \
    --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 \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.