[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87y4s6cak7.fsf@sejong.aot.lge.com>
Date: Fri, 24 Oct 2014 14:15:52 +0900
From: Namhyung Kim <namhyung@...nel.org>
To: Adrian Hunter <adrian.hunter@...el.com>
Cc: Arnaldo Carvalho de Melo <acme@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
linux-kernel@...r.kernel.org, David Ahern <dsahern@...il.com>,
Frederic Weisbecker <fweisbec@...il.com>,
Jiri Olsa <jolsa@...hat.com>,
Paul Mackerras <paulus@...ba.org>,
Stephane Eranian <eranian@...gle.com>
Subject: Re: [PATCH 02/16] perf pmu: Let pmu's with no events show up on perf list
On Thu, 23 Oct 2014 13:45:10 +0300, Adrian Hunter wrote:
> perf list only lists PMUs with events. Add a
> flag to cause a PMU to be also listed separately.
>
> Signed-off-by: Adrian Hunter <adrian.hunter@...el.com>
> ---
> tools/perf/util/pmu.c | 13 +++++++++++--
> tools/perf/util/pmu.h | 1 +
> 2 files changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
> index e243ad9..91dca60 100644
> --- a/tools/perf/util/pmu.c
> +++ b/tools/perf/util/pmu.c
> @@ -747,15 +747,18 @@ void print_pmu_events(const char *event_glob, bool name_only)
>
> pmu = NULL;
> len = 0;
> - while ((pmu = perf_pmu__scan(pmu)) != NULL)
> + while ((pmu = perf_pmu__scan(pmu)) != NULL) {
> list_for_each_entry(alias, &pmu->aliases, list)
> len++;
> + if (pmu->selectable)
> + len++;
> + }
> aliases = malloc(sizeof(char *) * len);
> if (!aliases)
> return;
> pmu = NULL;
> j = 0;
> - while ((pmu = perf_pmu__scan(pmu)) != NULL)
> + while ((pmu = perf_pmu__scan(pmu)) != NULL) {
> list_for_each_entry(alias, &pmu->aliases, list) {
> char *name = format_alias(buf, sizeof(buf), pmu, alias);
> bool is_cpu = !strcmp(pmu->name, "cpu");
> @@ -772,6 +775,12 @@ void print_pmu_events(const char *event_glob, bool name_only)
> aliases[j] = strdup(aliases[j]);
> j++;
> }
> + if (pmu->selectable) {
> + scnprintf(buf, sizeof(buf), "%s//", pmu->name);
> + aliases[j] = strdup(buf);
You need to check the return value here (and above too).
> + j++;
> + }
> + }
> len = j;
> qsort(aliases, len, sizeof(char *), cmp_string);
> for (j = 0; j < len; j++) {
> diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h
> index fe9dfbe..8092de7 100644
> --- a/tools/perf/util/pmu.h
> +++ b/tools/perf/util/pmu.h
> @@ -18,6 +18,7 @@ struct perf_event_attr;
> struct perf_pmu {
> char *name;
> __u32 type;
> + bool selectable;
I think it's a bit confusing. IIUC this 'selectable' means that this
PMU doesn't contain any events but wants to be listed. So the normal
PMUs which contain events are not selectable, right?
Thanks,
Namhyung
> struct perf_event_attr *default_config;
> struct cpu_map *cpus;
> struct list_head format; /* HEAD struct perf_pmu_format -> list */
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists