From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933527AbcBYSbZ (ORCPT ); Thu, 25 Feb 2016 13:31:25 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:36838 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933340AbcBYSbY (ORCPT ); Thu, 25 Feb 2016 13:31:24 -0500 Subject: Re: [PATCH v2 1/3] tracing/syscalls: Rename variable 'nr' to 'syscall_nr' To: Arnaldo Carvalho de Melo References: <1456421937-16840-1-git-send-email-treeze.taeung@gmail.com> <20160225175710.GP8720@kernel.org> Cc: Steven Rostedt , Ingo Molnar , Jiri Olsa , Namhyung Kim , linux-kernel@vger.kernel.org, Thomas Gleixner , Lai Jiangshan From: Taeung Song Message-ID: <56CF4877.8000107@gmail.com> Date: Fri, 26 Feb 2016 03:31:19 +0900 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <20160225175710.GP8720@kernel.org> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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'. So this if statement must not have strcmp(sc->args->name, "nr") == 0. + 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) { But I'll test again with perf-trace. And then will say the result. > > diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c > index 20916dd77aac..b31eed102a83 100644 > --- a/tools/perf/builtin-trace.c > +++ b/tools/perf/builtin-trace.c > @@ -1724,8 +1724,8 @@ static int trace__read_syscall_info(struct trace *trace, int id) > > sc->args = sc->tp_format->format.fields; > sc->nr_args = sc->tp_format->format.nr_fields; > - /* drop nr field - not relevant here; does not exist on older kernels */ > - if (sc->args && strcmp(sc->args->name, "nr") == 0) { > + /* drop (syscall_)?nr field - not relevant here; does not exist on older kernels */ > + if (sc->args && (strcmp(sc->args->name, "syscall_nr") || strcmp(sc->args->name, "nr")) == 0) { > sc->args = sc->args->next; > --sc->nr_args; > } > > > ---------------------- > > But then I wonder if it wouldn't be better to prefix this with double > underscores, making it "__syscall_nr" :-\ > I so agree. Low probability but the name 'syscall_nr' may also have similar problems. Thanks, Taeung