public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: kan.liang@linux.intel.com
Cc: mingo@redhat.com, peterz@infradead.org,
	linux-kernel@vger.kernel.org, jolsa@redhat.com,
	namhyung@kernel.org, ganapatrao.kulkarni@cavium.com,
	zhangshaokun@hisilicon.com, yao.jin@linux.intel.com,
	will.deacon@arm.com, ak@linux.intel.com, agustinv@codeaurora.org
Subject: Re: [PATCH 5/5] perf stat: Fix duplicate PMU name for interval print
Date: Tue, 24 Apr 2018 15:53:34 -0300	[thread overview]
Message-ID: <20180424185334.GA4427@kernel.org> (raw)
In-Reply-To: <1524594014-79243-5-git-send-email-kan.liang@linux.intel.com>

Em Tue, Apr 24, 2018 at 11:20:14AM -0700, kan.liang@linux.intel.com escreveu:
> 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.
> 
> Fixes: 8c5421c016a4 ("perf pmu: Display pmu name when printing unmerged events in stat")
> +++ b/tools/perf/builtin-stat.c
> @@ -1296,6 +1296,8 @@ static void uniquify_event_name(struct perf_evsel *counter)
>  			counter->name = new_name;
>  		}
>  	} else {
> +		if (strstr(counter->name, counter->pmu_name))
> +			return;
>  		if (asprintf(&new_name,
>  			     "%s [%s]", counter->name, counter->pmu_name) > 0) {
>  			free(counter->name);

Humm, do you have any problem with the patch below instead?

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 2137c7d11767..8518342c5466 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -1261,7 +1261,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;
 
@@ -1279,6 +1280,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;

  reply	other threads:[~2018-04-24 18:53 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-24 18:20 [PATCH 1/5] perf pmu: Fix core PMU alias list for X86 platform kan.liang
2018-04-24 18:20 ` [PATCH 2/5] perf stat: Print out hint for mixed PMU group error kan.liang
2018-04-26  5:56   ` [tip:perf/urgent] " tip-bot for Kan Liang
2018-04-24 18:20 ` [PATCH 3/5] perf evsel: Only fall back group read for leader kan.liang
2018-04-26  5:57   ` [tip:perf/urgent] " tip-bot for Kan Liang
2018-04-24 18:20 ` [PATCH 4/5] perf parse-events: Specially handle uncore event alias in small groups kan.liang
2018-04-24 19:17   ` Arnaldo Carvalho de Melo
2018-04-24 19:23     ` Liang, Kan
2018-04-24 19:29       ` Arnaldo Carvalho de Melo
2018-04-25 12:27         ` Liang, Kan
2018-04-25 12:59           ` Arnaldo Carvalho de Melo
2018-04-25 13:39             ` Liang, Kan
2018-04-24 18:20 ` [PATCH 5/5] perf stat: Fix duplicate PMU name for interval print kan.liang
2018-04-24 18:53   ` Arnaldo Carvalho de Melo [this message]
2018-04-24 19:18     ` Liang, Kan
2018-04-24 19:29       ` Arnaldo Carvalho de Melo
2018-04-26  5:57   ` [tip:perf/urgent] " tip-bot for Kan Liang
2018-04-26  5:56 ` [tip:perf/urgent] perf pmu: Fix core PMU alias list for X86 platform tip-bot for Kan Liang

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=20180424185334.GA4427@kernel.org \
    --to=acme@kernel.org \
    --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=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=will.deacon@arm.com \
    --cc=yao.jin@linux.intel.com \
    --cc=zhangshaokun@hisilicon.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox