linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf pmu: Fix parser error for uncore event alias
@ 2019-03-15 18:00 kan.liang
  2019-03-18  8:53 ` Jiri Olsa
  2019-03-29 20:43 ` [tip:perf/urgent] " tip-bot for Kan Liang
  0 siblings, 2 replies; 5+ messages in thread
From: kan.liang @ 2019-03-15 18:00 UTC (permalink / raw)
  To: acme, mingo, linux-kernel; +Cc: jolsa, ak, Kan Liang, Thomas Richter, stable

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

Perf fails to parse uncore event alias, for example:

  #perf stat -e unc_m_clockticks -a --no-merge sleep 1
  event syntax error: 'unc_m_clockticks'
                       \___ parser error

Current code assumes that the event alias is from one specific PMU.
To find the PMU, perf strcmp the pmu name of event alias with the
real pmu name on the system.
However, the uncore event alias may be from multiple PMUs with common
prefix. The pmu name of uncore event alias is the common prefix.
For example, UNC_M_CLOCKTICKS is clock event for iMC, which include
6 PMUs with the same prefix "uncore_imc" on a skylake server.
The real pmu names on the system for iMC are uncore_imc_0 ...
uncore_imc_5.
The strncmp is used to only check the common prefix for uncore
event alias.

With the patch,
  #perf stat -e unc_m_clockticks -a --no-merge sleep 1
  Performance counter stats for 'system wide':

       723,594,722      unc_m_clockticks [uncore_imc_5]
       724,001,954      unc_m_clockticks [uncore_imc_3]
       724,042,655      unc_m_clockticks [uncore_imc_1]
       724,161,001      unc_m_clockticks [uncore_imc_4]
       724,293,713      unc_m_clockticks [uncore_imc_2]
       724,340,901      unc_m_clockticks [uncore_imc_0]

       1.002090060 seconds time elapsed

Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Cc: Thomas Richter <tmricht@linux.ibm.com>
Cc: stable@vger.kernel.org
Fixes: ea1fa48c055f ("perf stat: Handle different PMU names with common prefix")
---
 tools/perf/util/pmu.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 51d437f..395308f 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -732,10 +732,20 @@ static void pmu_add_cpu_aliases(struct list_head *head, struct perf_pmu *pmu)
 
 		if (!is_arm_pmu_core(name)) {
 			pname = pe->pmu ? pe->pmu : "cpu";
+
+			/*
+			 * uncore alias may be from different PMU
+			 * with common prefix
+			 */
+			if (pmu_is_uncore(name) &&
+			    !strncmp(pname, name, strlen(pname)))
+				goto new_alias;
+
 			if (strcmp(pname, name))
 				continue;
 		}
 
+new_alias:
 		/* need type casts to override 'const' */
 		__perf_pmu__new_alias(head, NULL, (char *)pe->name,
 				(char *)pe->desc, (char *)pe->event,
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] perf pmu: Fix parser error for uncore event alias
  2019-03-15 18:00 [PATCH] perf pmu: Fix parser error for uncore event alias kan.liang
@ 2019-03-18  8:53 ` Jiri Olsa
  2019-03-27 19:53   ` Liang, Kan
  2019-03-29 20:43 ` [tip:perf/urgent] " tip-bot for Kan Liang
  1 sibling, 1 reply; 5+ messages in thread
From: Jiri Olsa @ 2019-03-18  8:53 UTC (permalink / raw)
  To: kan.liang; +Cc: acme, mingo, linux-kernel, ak, Thomas Richter, stable

On Fri, Mar 15, 2019 at 11:00:14AM -0700, kan.liang@linux.intel.com wrote:
> From: Kan Liang <kan.liang@linux.intel.com>
> 
> Perf fails to parse uncore event alias, for example:
> 
>   #perf stat -e unc_m_clockticks -a --no-merge sleep 1
>   event syntax error: 'unc_m_clockticks'
>                        \___ parser error
> 
> Current code assumes that the event alias is from one specific PMU.
> To find the PMU, perf strcmp the pmu name of event alias with the
> real pmu name on the system.
> However, the uncore event alias may be from multiple PMUs with common
> prefix. The pmu name of uncore event alias is the common prefix.
> For example, UNC_M_CLOCKTICKS is clock event for iMC, which include
> 6 PMUs with the same prefix "uncore_imc" on a skylake server.
> The real pmu names on the system for iMC are uncore_imc_0 ...
> uncore_imc_5.
> The strncmp is used to only check the common prefix for uncore
> event alias.
> 
> With the patch,
>   #perf stat -e unc_m_clockticks -a --no-merge sleep 1
>   Performance counter stats for 'system wide':
> 
>        723,594,722      unc_m_clockticks [uncore_imc_5]
>        724,001,954      unc_m_clockticks [uncore_imc_3]
>        724,042,655      unc_m_clockticks [uncore_imc_1]
>        724,161,001      unc_m_clockticks [uncore_imc_4]
>        724,293,713      unc_m_clockticks [uncore_imc_2]
>        724,340,901      unc_m_clockticks [uncore_imc_0]
> 
>        1.002090060 seconds time elapsed
> 
> Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
> Cc: Thomas Richter <tmricht@linux.ibm.com>
> Cc: stable@vger.kernel.org
> Fixes: ea1fa48c055f ("perf stat: Handle different PMU names with common prefix")

Acked-by: Jiri Olsa <jolsa@kernel.org>

thanks,
jirka

> ---
>  tools/perf/util/pmu.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
> index 51d437f..395308f 100644
> --- a/tools/perf/util/pmu.c
> +++ b/tools/perf/util/pmu.c
> @@ -732,10 +732,20 @@ static void pmu_add_cpu_aliases(struct list_head *head, struct perf_pmu *pmu)
>  
>  		if (!is_arm_pmu_core(name)) {
>  			pname = pe->pmu ? pe->pmu : "cpu";
> +
> +			/*
> +			 * uncore alias may be from different PMU
> +			 * with common prefix
> +			 */
> +			if (pmu_is_uncore(name) &&
> +			    !strncmp(pname, name, strlen(pname)))
> +				goto new_alias;
> +
>  			if (strcmp(pname, name))
>  				continue;
>  		}
>  
> +new_alias:
>  		/* need type casts to override 'const' */
>  		__perf_pmu__new_alias(head, NULL, (char *)pe->name,
>  				(char *)pe->desc, (char *)pe->event,
> -- 
> 2.7.4
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] perf pmu: Fix parser error for uncore event alias
  2019-03-18  8:53 ` Jiri Olsa
@ 2019-03-27 19:53   ` Liang, Kan
  2019-03-28 14:11     ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 5+ messages in thread
From: Liang, Kan @ 2019-03-27 19:53 UTC (permalink / raw)
  To: acme; +Cc: Jiri Olsa, mingo, linux-kernel, ak, Thomas Richter, stable



On 3/18/2019 4:53 AM, Jiri Olsa wrote:
> On Fri, Mar 15, 2019 at 11:00:14AM -0700, kan.liang@linux.intel.com wrote:
>> From: Kan Liang <kan.liang@linux.intel.com>
>>
>> Perf fails to parse uncore event alias, for example:
>>
>>    #perf stat -e unc_m_clockticks -a --no-merge sleep 1
>>    event syntax error: 'unc_m_clockticks'
>>                         \___ parser error
>>
>> Current code assumes that the event alias is from one specific PMU.
>> To find the PMU, perf strcmp the pmu name of event alias with the
>> real pmu name on the system.
>> However, the uncore event alias may be from multiple PMUs with common
>> prefix. The pmu name of uncore event alias is the common prefix.
>> For example, UNC_M_CLOCKTICKS is clock event for iMC, which include
>> 6 PMUs with the same prefix "uncore_imc" on a skylake server.
>> The real pmu names on the system for iMC are uncore_imc_0 ...
>> uncore_imc_5.
>> The strncmp is used to only check the common prefix for uncore
>> event alias.
>>
>> With the patch,
>>    #perf stat -e unc_m_clockticks -a --no-merge sleep 1
>>    Performance counter stats for 'system wide':
>>
>>         723,594,722      unc_m_clockticks [uncore_imc_5]
>>         724,001,954      unc_m_clockticks [uncore_imc_3]
>>         724,042,655      unc_m_clockticks [uncore_imc_1]
>>         724,161,001      unc_m_clockticks [uncore_imc_4]
>>         724,293,713      unc_m_clockticks [uncore_imc_2]
>>         724,340,901      unc_m_clockticks [uncore_imc_0]
>>
>>         1.002090060 seconds time elapsed
>>
>> Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
>> Cc: Thomas Richter <tmricht@linux.ibm.com>
>> Cc: stable@vger.kernel.org
>> Fixes: ea1fa48c055f ("perf stat: Handle different PMU names with common prefix")
> 
> Acked-by: Jiri Olsa <jolsa@kernel.org>
>

Hi Arnaldo,

Could you please apply the fix?

Thanks,
Kan



> thanks,
> jirka
> 
>> ---
>>   tools/perf/util/pmu.c | 10 ++++++++++
>>   1 file changed, 10 insertions(+)
>>
>> diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
>> index 51d437f..395308f 100644
>> --- a/tools/perf/util/pmu.c
>> +++ b/tools/perf/util/pmu.c
>> @@ -732,10 +732,20 @@ static void pmu_add_cpu_aliases(struct list_head *head, struct perf_pmu *pmu)
>>   
>>   		if (!is_arm_pmu_core(name)) {
>>   			pname = pe->pmu ? pe->pmu : "cpu";
>> +
>> +			/*
>> +			 * uncore alias may be from different PMU
>> +			 * with common prefix
>> +			 */
>> +			if (pmu_is_uncore(name) &&
>> +			    !strncmp(pname, name, strlen(pname)))
>> +				goto new_alias;
>> +
>>   			if (strcmp(pname, name))
>>   				continue;
>>   		}
>>   
>> +new_alias:
>>   		/* need type casts to override 'const' */
>>   		__perf_pmu__new_alias(head, NULL, (char *)pe->name,
>>   				(char *)pe->desc, (char *)pe->event,
>> -- 
>> 2.7.4
>>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] perf pmu: Fix parser error for uncore event alias
  2019-03-27 19:53   ` Liang, Kan
@ 2019-03-28 14:11     ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 5+ messages in thread
From: Arnaldo Carvalho de Melo @ 2019-03-28 14:11 UTC (permalink / raw)
  To: Liang, Kan; +Cc: Jiri Olsa, mingo, linux-kernel, ak, Thomas Richter, stable

Em Wed, Mar 27, 2019 at 03:53:30PM -0400, Liang, Kan escreveu:
> On 3/18/2019 4:53 AM, Jiri Olsa wrote:
> > On Fri, Mar 15, 2019 at 11:00:14AM -0700, kan.liang@linux.intel.com wrote:
> > > From: Kan Liang <kan.liang@linux.intel.com>
> > > Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
> > > Cc: Thomas Richter <tmricht@linux.ibm.com>
> > > Cc: stable@vger.kernel.org
> > > Fixes: ea1fa48c055f ("perf stat: Handle different PMU names with common prefix")

> > Acked-by: Jiri Olsa <jolsa@kernel.org>
 
> Could you please apply the fix?

yeah, applied.

- Arnaldo

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [tip:perf/urgent] perf pmu: Fix parser error for uncore event alias
  2019-03-15 18:00 [PATCH] perf pmu: Fix parser error for uncore event alias kan.liang
  2019-03-18  8:53 ` Jiri Olsa
@ 2019-03-29 20:43 ` tip-bot for Kan Liang
  1 sibling, 0 replies; 5+ messages in thread
From: tip-bot for Kan Liang @ 2019-03-29 20:43 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: hpa, kan.liang, acme, linux-kernel, ak, jolsa, tglx, tmricht, mingo

Commit-ID:  e94d6b7f615e6dfbaf9fba7db6011db561461d0c
Gitweb:     https://git.kernel.org/tip/e94d6b7f615e6dfbaf9fba7db6011db561461d0c
Author:     Kan Liang <kan.liang@linux.intel.com>
AuthorDate: Fri, 15 Mar 2019 11:00:14 -0700
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 28 Mar 2019 15:53:27 -0300

perf pmu: Fix parser error for uncore event alias

Perf fails to parse uncore event alias, for example:

  # perf stat -e unc_m_clockticks -a --no-merge sleep 1
  event syntax error: 'unc_m_clockticks'
                       \___ parser error

Current code assumes that the event alias is from one specific PMU.

To find the PMU, perf strcmps the PMU name of event alias with the real
PMU name on the system.

However, the uncore event alias may be from multiple PMUs with common
prefix. The PMU name of uncore event alias is the common prefix.

For example, UNC_M_CLOCKTICKS is clock event for iMC, which include 6
PMUs with the same prefix "uncore_imc" on a skylake server.

The real PMU names on the system for iMC are uncore_imc_0 ...
uncore_imc_5.

The strncmp is used to only check the common prefix for uncore event
alias.

With the patch:

  # perf stat -e unc_m_clockticks -a --no-merge sleep 1
  Performance counter stats for 'system wide':

       723,594,722      unc_m_clockticks [uncore_imc_5]
       724,001,954      unc_m_clockticks [uncore_imc_3]
       724,042,655      unc_m_clockticks [uncore_imc_1]
       724,161,001      unc_m_clockticks [uncore_imc_4]
       724,293,713      unc_m_clockticks [uncore_imc_2]
       724,340,901      unc_m_clockticks [uncore_imc_0]

       1.002090060 seconds time elapsed

Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Thomas Richter <tmricht@linux.ibm.com>
Cc: stable@vger.kernel.org
Fixes: ea1fa48c055f ("perf stat: Handle different PMU names with common prefix")
Link: http://lkml.kernel.org/r/1552672814-156173-1-git-send-email-kan.liang@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/pmu.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 6199a3174ab9..e0429f4ef335 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -732,10 +732,20 @@ static void pmu_add_cpu_aliases(struct list_head *head, struct perf_pmu *pmu)
 
 		if (!is_arm_pmu_core(name)) {
 			pname = pe->pmu ? pe->pmu : "cpu";
+
+			/*
+			 * uncore alias may be from different PMU
+			 * with common prefix
+			 */
+			if (pmu_is_uncore(name) &&
+			    !strncmp(pname, name, strlen(pname)))
+				goto new_alias;
+
 			if (strcmp(pname, name))
 				continue;
 		}
 
+new_alias:
 		/* need type casts to override 'const' */
 		__perf_pmu__new_alias(head, NULL, (char *)pe->name,
 				(char *)pe->desc, (char *)pe->event,

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-03-29 20:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-15 18:00 [PATCH] perf pmu: Fix parser error for uncore event alias kan.liang
2019-03-18  8:53 ` Jiri Olsa
2019-03-27 19:53   ` Liang, Kan
2019-03-28 14:11     ` Arnaldo Carvalho de Melo
2019-03-29 20:43 ` [tip:perf/urgent] " tip-bot for Kan Liang

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).