All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ian Rogers <irogers@google.com>
Cc: Weilin Wang <weilin.wang@intel.com>,
	Perry Taylor <perry.taylor@intel.com>,
	Caleb Biggers <caleb.biggers@intel.com>,
	Leo Yan <leo.yan@linaro.org>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>,
	Sandipan Das <sandipan.das@amd.com>,
	Kajol Jain <kjain@linux.ibm.com>,
	Zhengjun Xing <zhengjun.xing@linux.intel.com>,
	Kan Liang <kan.liang@linux.intel.com>,
	Ravi Bangoria <ravi.bangoria@amd.com>,
	Xin Gao <gaoxin@cdjrlc.com>, Rob Herring <robh@kernel.org>,
	linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
	Stephane Eranian <eranian@google.com>
Subject: Re: [PATCH v3 10/10] perf list: Add json output option
Date: Thu, 17 Nov 2022 13:31:53 -0300	[thread overview]
Message-ID: <Y3Zh+XTXbhrOXAla@kernel.org> (raw)
In-Reply-To: <CAP-5=fU-tJPdxosVFfbbKtrswom7bnY6Ei3JczRJaQYyOnjcAA@mail.gmail.com>

Em Wed, Nov 16, 2022 at 11:52:39AM -0800, Ian Rogers escreveu:
> On Wed, Nov 16, 2022 at 7:21 AM Arnaldo Carvalho de Melo
> <acme@kernel.org> wrote:
> >
> > Em Wed, Nov 16, 2022 at 10:10:53AM -0300, Arnaldo Carvalho de Melo escreveu:
> > > Em Wed, Nov 16, 2022 at 09:41:43AM -0300, Arnaldo Carvalho de Melo escreveu:
> > > > But then:
> > >
> > > > [root@five ~]# perf list syscalls:sys_enter_open* |& grep syscalls:
> > > >   syscalls:sys_enter_open                            [Tracepoint event]
> > > >   syscalls:sys_enter_open_by_handle_at               [Tracepoint event]
> > > >   syscalls:sys_enter_open_tree                       [Tracepoint event]
> > > >   syscalls:sys_enter_openat                          [Tracepoint event]
> > > >   syscalls:sys_enter_openat2                         [Tracepoint event]
> > > > [root@five ~]#
> > > >
> > > > This stops working, looking into it.
> > >
> > > Sidetracked with other stuff, please find what I have patched at
> > > perf/perf-list-json-output in my tree.
> > >
> > > I removed the last two patches and I'm testing so that I can push
> > > perf/core with your series modulo the last two + Namhyung's 'perf list'
> > > kit.
> >
> > I just saw you sent a patch on top of the previous one, will try and
> > combine stuff to remove failures from the bisect history.
> >
> > - Arnaldo
> 
> So the failing test was skipping for me due to a lack of kernel
> symbols, sorry for not spotting it. I find that the issue is resolved
> with your fixes and:
> 
> ```
> diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c
> index 30937e1dd82c..ad6cb5d2e1cc 100644
> --- a/tools/perf/builtin-list.c
> +++ b/tools/perf/builtin-list.c
> @@ -107,7 +107,7 @@ static void default_print_event(void *ps, const
> char *pmu_name, const char *topi
>        if (deprecated && !print_state->deprecated)
>                return;
> 
> -       if (print_state->pmu_glob && !strglobmatch(pmu_name,
> print_state->pmu_glob))
> +       if (print_state->pmu_glob && pmu_name &&
> !strglobmatch(pmu_name, print_state->pmu_glob))
>                return;
> 
>        if (print_state->event_glob &&
> @@ -534,24 +534,18 @@ int cmd_list(int argc, const char **argv)
>                        default_ps.metrics = false;
>                        metricgroup__print(&print_cb, ps);
>                } else if ((sep = strchr(argv[i], ':')) != NULL) {
> -                       int sep_idx;
> -
> -                       sep_idx = sep - argv[i];
> -                       s = strdup(argv[i]);
> -                       if (s == NULL) {
> +                       default_ps.event_glob = strdup(argv[i]);
> +                       if (!default_ps.event_glob) {
>                                ret = -1;
>                                goto out;
>                        }
> -
> -                       s[sep_idx] = '\0';
> -                       default_ps.pmu_glob = s;
> -                       default_ps.event_glob = s + sep_idx + 1;
>                        print_tracepoint_events(&print_cb, ps);
>                        print_sdt_events(&print_cb, ps);
>                        default_ps.metrics = true;
>                        default_ps.metricgroups = true;
>                        metricgroup__print(&print_cb, ps);
> -                       free(s);
> +                       free(default_ps.event_glob);
> +                       default_ps.event_glob = NULL;
> ```
> I think this should be squashed into "perf list: Reorganize to use
> callbacks". Some explanation, in porting the : glob case I'd assumed
> the before the colon would be the PMU and the after the event. Doing
> things caused tracepoint output to differ too much and so for
> tracepoints the : is kept in the event name. So we can simplify the
> matching to not be pmu and event, just use the event glob.

Next time please send the patch, I did it manually and before the last
option I get:

[root@quaco ~]# perf list syscalls:sys_enter_open |& grep syscalls
  syscalls:sys_enter_open                            [Tracepoint event]
[root@quaco ~]# perf test 112
112: Check open filename arg using perf trace + vfs_getname          : Ok
[root@quaco ~]#

diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c
index 0c84fdb3ad37c1ad..7b63bc30665a7f56 100644
--- a/tools/perf/builtin-list.c
+++ b/tools/perf/builtin-list.c
@@ -19,6 +19,7 @@
 #include "util/strlist.h"
 #include <subcmd/pager.h>
 #include <subcmd/parse-options.h>
+#include <linux/zalloc.h>
 #include <stdio.h>
 
 /**
@@ -328,25 +329,20 @@ int cmd_list(int argc, const char **argv)
 			ps.metrics = false;
 			metricgroup__print(&print_cb, &ps);
 		} else if ((sep = strchr(argv[i], ':')) != NULL) {
-			int sep_idx;
 			char *old_pmu_glob = ps.pmu_glob;
 
-			sep_idx = sep - argv[i];
-			s = strdup(argv[i]);
-			if (s == NULL) {
+			ps.event_glob = strdup(argv[i]);
+			if (!ps.event_glob) {
 				ret = -1;
 				goto out;
 			}
 
-			s[sep_idx] = '\0';
-			ps.pmu_glob = s;
-			ps.event_glob = s + sep_idx + 1;
 			print_tracepoint_events(&print_cb, &ps);
 			print_sdt_events(&print_cb, &ps);
 			ps.metrics = true;
 			ps.metricgroups = true;
 			metricgroup__print(&print_cb, &ps);
-			free(s);
+			zfree(&ps.event_glob);
 			ps.pmu_glob = old_pmu_glob;
 		} else {
 			if (asprintf(&s, "*%s*", argv[i]) < 0) {

  reply	other threads:[~2022-11-17 16:34 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-14 21:07 [PATCH v3 00/10] Restructure perf list and add json output Ian Rogers
2022-11-14 21:07 ` [PATCH v3 01/10] perf pmu: Remove is_hybrid member Ian Rogers
2022-11-14 21:07 ` [PATCH v3 02/10] perf pmu: Add documentation Ian Rogers
2022-11-14 21:07 ` [PATCH v3 03/10] tools lib api fs tracing_path: Add scandir alphasort Ian Rogers
2022-11-14 21:07 ` [PATCH v3 04/10] perf tracepoint: Sort events in iterator Ian Rogers
2022-11-14 21:07 ` [PATCH v3 05/10] perf list: Generalize limiting to a PMU name Ian Rogers
2022-11-14 21:07 ` [PATCH v3 06/10] perf list: Simplify cache event printing Ian Rogers
2022-11-15 13:33   ` Arnaldo Carvalho de Melo
2022-11-14 21:07 ` [PATCH v3 07/10] perf list: Simplify symbol " Ian Rogers
2022-11-14 21:07 ` [PATCH v3 08/10] perf pmu: Restructure print_pmu_events Ian Rogers
2022-11-14 21:07 ` [PATCH v3 09/10] perf list: Reorganize to use callbacks Ian Rogers
2022-11-15 13:40   ` Arnaldo Carvalho de Melo
2022-11-15 16:53     ` Ian Rogers
2022-11-14 21:07 ` [PATCH v3 10/10] perf list: Add json output option Ian Rogers
2022-11-15 13:44   ` Arnaldo Carvalho de Melo
2022-11-16 11:23     ` Arnaldo Carvalho de Melo
2022-11-16 11:35       ` Arnaldo Carvalho de Melo
2022-11-16 11:51         ` Arnaldo Carvalho de Melo
2022-11-16 12:41           ` Arnaldo Carvalho de Melo
2022-11-16 13:10             ` Arnaldo Carvalho de Melo
2022-11-16 15:21               ` Arnaldo Carvalho de Melo
2022-11-16 19:52                 ` Ian Rogers
2022-11-17 16:31                   ` Arnaldo Carvalho de Melo [this message]
2022-11-17 16:47                     ` Arnaldo Carvalho de Melo
2022-11-18  2:47                       ` Ian Rogers
2022-11-16 23:04     ` Namhyung Kim

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=Y3Zh+XTXbhrOXAla@kernel.org \
    --to=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=caleb.biggers@intel.com \
    --cc=eranian@google.com \
    --cc=gaoxin@cdjrlc.com \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=kan.liang@linux.intel.com \
    --cc=kjain@linux.ibm.com \
    --cc=leo.yan@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=perry.taylor@intel.com \
    --cc=peterz@infradead.org \
    --cc=ravi.bangoria@amd.com \
    --cc=robh@kernel.org \
    --cc=sandipan.das@amd.com \
    --cc=weilin.wang@intel.com \
    --cc=zhengjun.xing@linux.intel.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 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.