LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: Clark Williams <williams@redhat.com>,
	linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
	Kan Liang <kan.liang@linux.intel.com>,
	Agustin Vega-Frias <agustinv@codeaurora.org>,
	Andi Kleen <ak@linux.intel.com>,
	Ganapatrao Kulkarni <ganapatrao.kulkarni@cavium.com>,
	Jin Yao <yao.jin@linux.intel.com>, Jiri Olsa <jolsa@redhat.com>,
	Namhyung Kim <namhyung@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Shaokun Zhang <zhangshaokun@hisilicon.com>,
	Will Deacon <will.deacon@arm.com>,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 12/12] perf stat: Fix duplicate PMU name for interval print
Date: Wed, 25 Apr 2018 13:00:08 -0300	[thread overview]
Message-ID: <20180425160008.3407-13-acme@kernel.org> (raw)
In-Reply-To: <20180425160008.3407-1-acme@kernel.org>

From: Kan Liang <kan.liang@linux.intel.com>

PMU name is printed repeatedly for interval print, for example:

  perf stat --no-merge -e 'unc_m_clockticks' -a -I 1000
  #           time             counts unit events
     1.001053069        243,702,144      unc_m_clockticks [uncore_imc_4]
     1.001053069        244,268,304      unc_m_clockticks [uncore_imc_2]
     1.001053069        244,427,386      unc_m_clockticks [uncore_imc_0]
     1.001053069        244,583,760      unc_m_clockticks [uncore_imc_5]
     1.001053069        244,738,971      unc_m_clockticks [uncore_imc_3]
     1.001053069        244,880,309      unc_m_clockticks [uncore_imc_1]
     2.002024821        240,818,200      unc_m_clockticks [uncore_imc_4] [uncore_imc_4]
     2.002024821        240,767,812      unc_m_clockticks [uncore_imc_2] [uncore_imc_2]
     2.002024821        240,764,215      unc_m_clockticks [uncore_imc_0] [uncore_imc_0]
     2.002024821        240,759,504      unc_m_clockticks [uncore_imc_5] [uncore_imc_5]
     2.002024821        240,755,992      unc_m_clockticks [uncore_imc_3] [uncore_imc_3]
     2.002024821        240,750,403      unc_m_clockticks [uncore_imc_1] [uncore_imc_1]

For each print, the PMU name is unconditionally appended to the
counter->name.

Need to check the counter->name first. If the PMU name is already
appended, do nothing.

Committer notes:

Add and use perf_evsel->uniquified_name bool instead of doing the more
expensive strstr(event->name, pmu->name).

Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Agustin Vega-Frias <agustinv@codeaurora.org>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ganapatrao Kulkarni <ganapatrao.kulkarni@cavium.com>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Shaokun Zhang <zhangshaokun@hisilicon.com>
Cc: Will Deacon <will.deacon@arm.com>
Fixes: 8c5421c016a4 ("perf pmu: Display pmu name when printing unmerged events in stat")
Link: http://lkml.kernel.org/r/1524594014-79243-5-git-send-email-kan.liang@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-stat.c | 5 ++++-
 tools/perf/util/evsel.h   | 1 +
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 30e6b374e095..f17dc601b0f3 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -1284,7 +1284,8 @@ static void uniquify_event_name(struct perf_evsel *counter)
 	char *new_name;
 	char *config;
 
-	if (!counter->pmu_name || !strncmp(counter->name, counter->pmu_name,
+	if (counter->uniquified_name ||
+	    !counter->pmu_name || !strncmp(counter->name, counter->pmu_name,
 					   strlen(counter->pmu_name)))
 		return;
 
@@ -1302,6 +1303,8 @@ static void uniquify_event_name(struct perf_evsel *counter)
 			counter->name = new_name;
 		}
 	}
+
+	counter->uniquified_name = true;
 }
 
 static void collect_all_aliases(struct perf_evsel *counter,
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index d3ee3af618ef..92ec009a292d 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -115,6 +115,7 @@ struct perf_evsel {
 	unsigned int		sample_size;
 	int			id_pos;
 	int			is_pos;
+	bool			uniquified_name;
 	bool			snapshot;
 	bool 			supported;
 	bool 			needs_swap;
-- 
2.14.3

  parent reply	other threads:[~2018-04-25 16:01 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-25 15:59 [GIT PULL 00/12] perf/urgent fixes Arnaldo Carvalho de Melo
2018-04-25 15:59 ` [PATCH 01/12] perf machine: Set main kernel end address properly Arnaldo Carvalho de Melo
2018-04-25 15:59 ` [PATCH 02/12] perf list: Remove s390 specific strcmp_cpuid_cmp function Arnaldo Carvalho de Melo
2018-04-25 15:59 ` [PATCH 03/12] perf test: Adapt test case record+probe_libc_inet_pton.sh for s390 Arnaldo Carvalho de Melo
2018-04-25 16:00 ` [PATCH 04/12] perf stat: Keep the / modifier separator in fallback Arnaldo Carvalho de Melo
2018-04-25 16:00 ` [PATCH 05/12] perf pmu: Fix pmu events parsing rule Arnaldo Carvalho de Melo
2018-05-03  8:25   ` Adrian Hunter
2018-05-03 10:37     ` Jiri Olsa
2018-05-03 11:38       ` Adrian Hunter
2018-05-03 11:47         ` Jiri Olsa
2018-05-04 16:02         ` Jiri Olsa
2018-05-06  3:43           ` Andi Kleen
2018-05-06 14:28             ` [PATCH] perf tools: Fix parser for empty pmu terms case Jiri Olsa
2018-05-06 16:34               ` Liang, Kan
2018-05-07  7:21               ` Adrian Hunter
2018-05-07  8:12                 ` Jiri Olsa
2018-05-07 15:04                   ` Arnaldo Carvalho de Melo
2018-05-07 18:37             ` [PATCH 05/12] perf pmu: Fix pmu events parsing rule Arnaldo Carvalho de Melo
2018-05-07 19:16               ` Jiri Olsa
2018-05-07 19:26                 ` Arnaldo Carvalho de Melo
2018-05-07 19:24               ` Arnaldo Carvalho de Melo
2018-05-07 19:42                 ` Jiri Olsa
2018-04-25 16:00 ` [PATCH 06/12] perf evsel: Disable write_backward for leader sampling group events Arnaldo Carvalho de Melo
2018-04-25 16:00 ` [PATCH 07/12] perf mem: Document incorrect and missing options Arnaldo Carvalho de Melo
2018-04-25 16:00 ` [PATCH 08/12] perf record: Fix s390 undefined record__auxtrace_init() return value Arnaldo Carvalho de Melo
2018-04-25 16:00 ` [PATCH 09/12] perf pmu: Fix core PMU alias list for X86 platform Arnaldo Carvalho de Melo
2018-04-25 16:00 ` [PATCH 10/12] perf stat: Print out hint for mixed PMU group error Arnaldo Carvalho de Melo
2018-04-25 16:00 ` [PATCH 11/12] perf evsel: Only fall back group read for leader Arnaldo Carvalho de Melo
2018-04-25 16:00 ` Arnaldo Carvalho de Melo [this message]
2018-04-26  5:33 ` [GIT PULL 00/12] perf/urgent fixes Ingo Molnar

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=20180425160008.3407-13-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=agustinv@codeaurora.org \
    --cc=ak@linux.intel.com \
    --cc=ganapatrao.kulkarni@cavium.com \
    --cc=jolsa@redhat.com \
    --cc=kan.liang@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=will.deacon@arm.com \
    --cc=williams@redhat.com \
    --cc=yao.jin@linux.intel.com \
    --cc=zhangshaokun@hisilicon.com \
    --subject='Re: [PATCH 12/12] perf stat: Fix duplicate PMU name for interval print' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).