All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ganapatrao Kulkarni <gklkml16@gmail.com>
Cc: "Jin, Yao" <yao.jin@linux.intel.com>,
	Ganapatrao Kulkarni <ganapatrao.kulkarni@cavium.com>,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	Will Deacon <Will.Deacon@arm.com>,
	catalin.marinas@arm.com, mark.rutland@arm.com,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	jnair@caviumnetworks.com,
	Zhangshaokun <zhangshaokun@hisilicon.com>,
	Jonathan.Cameron@huawei.com,
	Robert Richter <Robert.Richter@cavium.com>,
	"Jin, Yao" <yao.jin@intel.com>
Subject: Re: [PATCH v9 3/5] perf utils: use pmu->is_uncore to detect PMU UNCORE devices
Date: Tue, 5 Dec 2017 10:58:35 -0300	[thread overview]
Message-ID: <20171205135835.GD28405@kernel.org> (raw)
In-Reply-To: <CAKTKpr7oM4h_gxj1P=r_J_T5L_Mmtqqj_Uvji-fARKnQRnCP1w@mail.gmail.com>

Em Tue, Dec 05, 2017 at 12:42:30PM +0530, Ganapatrao Kulkarni escreveu:
> thanks Jin Yao for point this out.
> 
> looks like logic of leveraging uncore device type(which i have changed
> in v9) does not go well
> with some json events of x86.
> can you please try below diff(logic used till v8), which keeps the
> original logic of identifying core/cpu PMUs.

This seems space mangled :-\

- Arnaldo
 
> 
> diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
> index 5ad8a18..57e38fd 100644
> --- a/tools/perf/util/pmu.c
> +++ b/tools/perf/util/pmu.c
> @@ -538,6 +538,34 @@ static bool pmu_is_uncore(const char *name)
>  }
> 
>  /*
> + *  PMU CORE devices have different name other than cpu in sysfs on some
> + *  platforms. looking for possible sysfs files to identify as core device.
> + */
> +static int is_pmu_core(const char *name)
> +{
> + struct stat st;
> + char path[PATH_MAX];
> + const char *sysfs = sysfs__mountpoint();
> +
> + if (!sysfs)
> + return 0;
> +
> + /* Look for cpu sysfs (x86 and others) */
> + scnprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu", sysfs);
> + if ((stat(path, &st) == 0) &&
> + (strncmp(name, "cpu", strlen("cpu")) == 0))
> + return 1;
> +
> + /* Look for cpu sysfs (specific to arm) */
> + scnprintf(path, PATH_MAX, "%s/bus/event_source/devices/%s/cpus",
> + sysfs, name);
> + if (stat(path, &st) == 0)
> + return 1;
> +
> + return 0;
> +}
> +
> +/*
>   * Return the CPU id as a raw string.
>   *
>   * Each architecture should provide a more precise id string that
> @@ -641,7 +669,7 @@ static void pmu_add_cpu_aliases(struct list_head
> *head, struct perf_pmu *pmu)
>   break;
>   }
> 
> - if (pmu->is_uncore) {
> + if (!is_pmu_core(name)) {
>   /* check for uncore devices */
>   if (pe->pmu == NULL)
>   continue;
> 
> i have tried this diff on my x86 PC(haswell) and looks to be ok.
> please confirm your testing on skylake.
> 
> gkulkarni@gkFc25>perf>> ./perf stat --per-thread -p 12663 -M CPI,IPC sleep 1
> 
>  Performance counter stats for process id '12663':
> 
>             bash-12663               278,886      inst_retired.any:u
>             bash-12663               482,284      cycles:u
>             bash-12663               278,886      inst_retired.any:u
>             bash-12663               483,597
> cpu_clk_unhalted.thread:u
> 
>        1.000923760 seconds time elapsed
> 
> 
> On Tue, Dec 5, 2017 at 7:42 AM, Jin, Yao <yao.jin@linux.intel.com> wrote:
> > Hi Kulkarni, Arnaldo,
> >
> > This patch has been merged in perf/core branch today.
> >
> > But I see a regression issue when I run the 'perf stat'.
> >
> > With bisect checking, I locate to this patch.
> >
> > commit ad8737a08973f5dca632bdd63cf2abc99670e540
> > Author: Ganapatrao Kulkarni <ganapatrao.kulkarni@cavium.com>
> > Date:   Tue Oct 17 00:02:20 2017 +0530
> >
> >     perf pmu: Use pmu->is_uncore to detect UNCORE devices
> >
> > For example (on Intel skylake desktop),
> >
> > 1. The correct output should be (without this patch):
> >
> > root@skl:/tmp# perf stat --per-thread -p 1754 -M CPI,IPC
> > ^C
> >  Performance counter stats for process id '1754':
> >
> >           vmstat-1754              1,882,798      inst_retired.any     #
> > 0.8 CPI
> >           vmstat-1754              1,589,720      cycles
> >           vmstat-1754              1,882,798      inst_retired.any     #
> > 1.2 IPC
> >           vmstat-1754              1,589,720      cpu_clk_unhalted.thread
> >
> >        2.647443167 seconds time elapsed
> >
> > 2. With this patch, the output will be:
> >
> > root@skl:/tmp# perf stat --per-thread -p 1754 -M CPI,IPC
> > ^C
> >  Performance counter stats for process id '1754':
> >
> >           vmstat-1754              1,945,589      inst_retired.any
> >           vmstat-1754        <not supported>      inst_retired.any
> >           vmstat-1754              1,609,892      cycles
> >           vmstat-1754              1,945,589      inst_retired.any
> >           vmstat-1754        <not supported>      inst_retired.any
> >           vmstat-1754              1,609,892      cpu_clk_unhalted.thread
> >           vmstat-1754        <not supported>      cpu_clk_unhalted.thread
> >
> >        3.051274166 seconds time elapsed
> >
> > Could you please help to take a look?
> >
> > Thanks
> > Jin Yao
> >
> >
> > On 10/17/2017 2:32 AM, Ganapatrao Kulkarni wrote:
> >>
> >> PMU CORE devices are identified using sysfs filename cpu, however
> >> on some platforms(like arm/arm64), PMU CORE sysfs name is not cpu.
> >> Hence cpu cannot be used to differentiate PMU CORE/UNCORE devices.
> >>
> >> commit:
> >>   66ec1191 ("perf pmu: Unbreak perf record for arm/arm64 with events with
> >> explicit PMU")
> >>
> >> has introduced pmu->is_uncore, which is set to PMU UNCORE devices only.
> >> Adding changes to use pmu->is_uncore to identify UNCORE devices.
> >>
> >> Acked-by: Will Deacon <will.deacon@arm.com>
> >> Tested-by: Shaokun Zhang <zhangshaokun@hisilicon.com>
> >> Signed-off-by: Ganapatrao Kulkarni <ganapatrao.kulkarni@cavium.com>
> >> ---
> >>   tools/perf/util/pmu.c | 11 +++++++----
> >>   1 file changed, 7 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
> >> index 8b17db5..9110718 100644
> >> --- a/tools/perf/util/pmu.c
> >> +++ b/tools/perf/util/pmu.c
> >> @@ -603,7 +603,6 @@ static void pmu_add_cpu_aliases(struct list_head
> >> *head, struct perf_pmu *pmu)
> >>          */
> >>         i = 0;
> >>         while (1) {
> >> -               const char *pname;
> >>                 pe = &map->table[i++];
> >>                 if (!pe->name) {
> >> @@ -612,9 +611,13 @@ static void pmu_add_cpu_aliases(struct list_head
> >> *head, struct perf_pmu *pmu)
> >>                         break;
> >>                 }
> >>   -             pname = pe->pmu ? pe->pmu : "cpu";
> >> -               if (strncmp(pname, name, strlen(pname)))
> >> -                       continue;
> >> +               if (pmu->is_uncore) {
> >> +                       /* check for uncore devices */
> >> +                       if (pe->pmu == NULL)
> >> +                               continue;
> >> +                       if (strncmp(pe->pmu, name, strlen(pe->pmu)))
> >> +                               continue;
> >> +               }
> >>                 /* need type casts to override 'const' */
> >>                 __perf_pmu__new_alias(head, NULL, (char *)pe->name,
> >>
> >
> 
> thanks
> Ganapat

WARNING: multiple messages have this Message-ID (diff)
From: acme@kernel.org (Arnaldo Carvalho de Melo)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v9 3/5] perf utils: use pmu->is_uncore to detect PMU UNCORE devices
Date: Tue, 5 Dec 2017 10:58:35 -0300	[thread overview]
Message-ID: <20171205135835.GD28405@kernel.org> (raw)
In-Reply-To: <CAKTKpr7oM4h_gxj1P=r_J_T5L_Mmtqqj_Uvji-fARKnQRnCP1w@mail.gmail.com>

Em Tue, Dec 05, 2017 at 12:42:30PM +0530, Ganapatrao Kulkarni escreveu:
> thanks Jin Yao for point this out.
> 
> looks like logic of leveraging uncore device type(which i have changed
> in v9) does not go well
> with some json events of x86.
> can you please try below diff(logic used till v8), which keeps the
> original logic of identifying core/cpu PMUs.

This seems space mangled :-\

- Arnaldo
 
> 
> diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
> index 5ad8a18..57e38fd 100644
> --- a/tools/perf/util/pmu.c
> +++ b/tools/perf/util/pmu.c
> @@ -538,6 +538,34 @@ static bool pmu_is_uncore(const char *name)
>  }
> 
>  /*
> + *  PMU CORE devices have different name other than cpu in sysfs on some
> + *  platforms. looking for possible sysfs files to identify as core device.
> + */
> +static int is_pmu_core(const char *name)
> +{
> + struct stat st;
> + char path[PATH_MAX];
> + const char *sysfs = sysfs__mountpoint();
> +
> + if (!sysfs)
> + return 0;
> +
> + /* Look for cpu sysfs (x86 and others) */
> + scnprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu", sysfs);
> + if ((stat(path, &st) == 0) &&
> + (strncmp(name, "cpu", strlen("cpu")) == 0))
> + return 1;
> +
> + /* Look for cpu sysfs (specific to arm) */
> + scnprintf(path, PATH_MAX, "%s/bus/event_source/devices/%s/cpus",
> + sysfs, name);
> + if (stat(path, &st) == 0)
> + return 1;
> +
> + return 0;
> +}
> +
> +/*
>   * Return the CPU id as a raw string.
>   *
>   * Each architecture should provide a more precise id string that
> @@ -641,7 +669,7 @@ static void pmu_add_cpu_aliases(struct list_head
> *head, struct perf_pmu *pmu)
>   break;
>   }
> 
> - if (pmu->is_uncore) {
> + if (!is_pmu_core(name)) {
>   /* check for uncore devices */
>   if (pe->pmu == NULL)
>   continue;
> 
> i have tried this diff on my x86 PC(haswell) and looks to be ok.
> please confirm your testing on skylake.
> 
> gkulkarni at gkFc25>perf>> ./perf stat --per-thread -p 12663 -M CPI,IPC sleep 1
> 
>  Performance counter stats for process id '12663':
> 
>             bash-12663               278,886      inst_retired.any:u
>             bash-12663               482,284      cycles:u
>             bash-12663               278,886      inst_retired.any:u
>             bash-12663               483,597
> cpu_clk_unhalted.thread:u
> 
>        1.000923760 seconds time elapsed
> 
> 
> On Tue, Dec 5, 2017 at 7:42 AM, Jin, Yao <yao.jin@linux.intel.com> wrote:
> > Hi Kulkarni, Arnaldo,
> >
> > This patch has been merged in perf/core branch today.
> >
> > But I see a regression issue when I run the 'perf stat'.
> >
> > With bisect checking, I locate to this patch.
> >
> > commit ad8737a08973f5dca632bdd63cf2abc99670e540
> > Author: Ganapatrao Kulkarni <ganapatrao.kulkarni@cavium.com>
> > Date:   Tue Oct 17 00:02:20 2017 +0530
> >
> >     perf pmu: Use pmu->is_uncore to detect UNCORE devices
> >
> > For example (on Intel skylake desktop),
> >
> > 1. The correct output should be (without this patch):
> >
> > root at skl:/tmp# perf stat --per-thread -p 1754 -M CPI,IPC
> > ^C
> >  Performance counter stats for process id '1754':
> >
> >           vmstat-1754              1,882,798      inst_retired.any     #
> > 0.8 CPI
> >           vmstat-1754              1,589,720      cycles
> >           vmstat-1754              1,882,798      inst_retired.any     #
> > 1.2 IPC
> >           vmstat-1754              1,589,720      cpu_clk_unhalted.thread
> >
> >        2.647443167 seconds time elapsed
> >
> > 2. With this patch, the output will be:
> >
> > root at skl:/tmp# perf stat --per-thread -p 1754 -M CPI,IPC
> > ^C
> >  Performance counter stats for process id '1754':
> >
> >           vmstat-1754              1,945,589      inst_retired.any
> >           vmstat-1754        <not supported>      inst_retired.any
> >           vmstat-1754              1,609,892      cycles
> >           vmstat-1754              1,945,589      inst_retired.any
> >           vmstat-1754        <not supported>      inst_retired.any
> >           vmstat-1754              1,609,892      cpu_clk_unhalted.thread
> >           vmstat-1754        <not supported>      cpu_clk_unhalted.thread
> >
> >        3.051274166 seconds time elapsed
> >
> > Could you please help to take a look?
> >
> > Thanks
> > Jin Yao
> >
> >
> > On 10/17/2017 2:32 AM, Ganapatrao Kulkarni wrote:
> >>
> >> PMU CORE devices are identified using sysfs filename cpu, however
> >> on some platforms(like arm/arm64), PMU CORE sysfs name is not cpu.
> >> Hence cpu cannot be used to differentiate PMU CORE/UNCORE devices.
> >>
> >> commit:
> >>   66ec1191 ("perf pmu: Unbreak perf record for arm/arm64 with events with
> >> explicit PMU")
> >>
> >> has introduced pmu->is_uncore, which is set to PMU UNCORE devices only.
> >> Adding changes to use pmu->is_uncore to identify UNCORE devices.
> >>
> >> Acked-by: Will Deacon <will.deacon@arm.com>
> >> Tested-by: Shaokun Zhang <zhangshaokun@hisilicon.com>
> >> Signed-off-by: Ganapatrao Kulkarni <ganapatrao.kulkarni@cavium.com>
> >> ---
> >>   tools/perf/util/pmu.c | 11 +++++++----
> >>   1 file changed, 7 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
> >> index 8b17db5..9110718 100644
> >> --- a/tools/perf/util/pmu.c
> >> +++ b/tools/perf/util/pmu.c
> >> @@ -603,7 +603,6 @@ static void pmu_add_cpu_aliases(struct list_head
> >> *head, struct perf_pmu *pmu)
> >>          */
> >>         i = 0;
> >>         while (1) {
> >> -               const char *pname;
> >>                 pe = &map->table[i++];
> >>                 if (!pe->name) {
> >> @@ -612,9 +611,13 @@ static void pmu_add_cpu_aliases(struct list_head
> >> *head, struct perf_pmu *pmu)
> >>                         break;
> >>                 }
> >>   -             pname = pe->pmu ? pe->pmu : "cpu";
> >> -               if (strncmp(pname, name, strlen(pname)))
> >> -                       continue;
> >> +               if (pmu->is_uncore) {
> >> +                       /* check for uncore devices */
> >> +                       if (pe->pmu == NULL)
> >> +                               continue;
> >> +                       if (strncmp(pe->pmu, name, strlen(pe->pmu)))
> >> +                               continue;
> >> +               }
> >>                 /* need type casts to override 'const' */
> >>                 __perf_pmu__new_alias(head, NULL, (char *)pe->name,
> >>
> >
> 
> thanks
> Ganapat

  parent reply	other threads:[~2017-12-05 13:58 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-16 18:32 [PATCH v9 0/5] Add support for ThunderX2 pmu events using json files Ganapatrao Kulkarni
2017-10-16 18:32 ` Ganapatrao Kulkarni
2017-10-16 18:32 ` [PATCH v9 1/5] perf utils: passing pmu as a parameter to function get_cpuid_str Ganapatrao Kulkarni
2017-10-16 18:32   ` Ganapatrao Kulkarni
2017-12-06 16:38   ` [tip:perf/core] perf pmu: Pass pmu as a parameter to get_cpuid_str() tip-bot for Ganapatrao Kulkarni
2017-10-16 18:32 ` [PATCH v9 2/5] perf tools arm64: Add support for get_cpuid_str function Ganapatrao Kulkarni
2017-10-16 18:32   ` Ganapatrao Kulkarni
2017-12-06 16:39   ` [tip:perf/core] " tip-bot for Ganapatrao Kulkarni
2017-10-16 18:32 ` [PATCH v9 3/5] perf utils: use pmu->is_uncore to detect PMU UNCORE devices Ganapatrao Kulkarni
2017-10-16 18:32   ` Ganapatrao Kulkarni
2017-12-05  2:12   ` Jin, Yao
2017-12-05  2:12     ` Jin, Yao
2017-12-05  7:12     ` Ganapatrao Kulkarni
2017-12-05  7:12       ` Ganapatrao Kulkarni
2017-12-05  7:23       ` Jin, Yao
2017-12-05  7:23         ` Jin, Yao
2017-12-05 12:35         ` Jin, Yao
2017-12-05 12:35           ` Jin, Yao
2017-12-05 13:56           ` Arnaldo Carvalho de Melo
2017-12-05 13:56             ` Arnaldo Carvalho de Melo
2017-12-05 14:02             ` Ganapatrao Kulkarni
2017-12-05 14:02               ` Ganapatrao Kulkarni
2017-12-05 18:42           ` Arnaldo Carvalho de Melo
2017-12-05 18:42             ` Arnaldo Carvalho de Melo
2017-12-06  0:30             ` Jin, Yao
2017-12-06  0:30               ` Jin, Yao
2017-12-06 13:47               ` Arnaldo Carvalho de Melo
2017-12-06 13:47                 ` Arnaldo Carvalho de Melo
2017-12-07  0:49                 ` Jin, Yao
2017-12-07  0:49                   ` Jin, Yao
2017-12-05 13:58       ` Arnaldo Carvalho de Melo [this message]
2017-12-05 13:58         ` Arnaldo Carvalho de Melo
2017-10-16 18:32 ` [PATCH v9 4/5] perf vendor events arm64: Add ThunderX2 implementation defined pmu core events Ganapatrao Kulkarni
2017-10-16 18:32   ` Ganapatrao Kulkarni
2017-12-06 16:39   ` [tip:perf/core] " tip-bot for Ganapatrao Kulkarni
2017-10-16 18:32 ` [PATCH v9 5/5] perf utils: add check for valid cpuid in function perf_pmu__find_map Ganapatrao Kulkarni
2017-10-16 18:32   ` Ganapatrao Kulkarni
2017-12-06 16:40   ` [tip:perf/core] perf pmu: Add check for valid cpuid in perf_pmu__find_map() tip-bot for Ganapatrao Kulkarni
2017-10-18 17:49 ` [PATCH v9 0/5] Add support for ThunderX2 pmu events using json files Ganapatrao Kulkarni
2017-10-18 17:49   ` Ganapatrao Kulkarni
2017-11-06  9:01   ` John Garry
2017-11-06  9:01     ` John Garry
2017-11-07  1:23 ` Will Deacon
2017-11-07  1:23   ` Will Deacon
2017-11-27 10:04   ` John Garry
2017-11-27 10:04     ` John Garry
2017-12-04  4:41     ` Ganapatrao Kulkarni
2017-12-04  4:41       ` Ganapatrao Kulkarni
2017-12-04 15:09       ` Arnaldo Carvalho de Melo
2017-12-04 15:09         ` Arnaldo Carvalho de Melo

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=20171205135835.GD28405@kernel.org \
    --to=acme@kernel.org \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=Robert.Richter@cavium.com \
    --cc=Will.Deacon@arm.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=catalin.marinas@arm.com \
    --cc=ganapatrao.kulkarni@cavium.com \
    --cc=gklkml16@gmail.com \
    --cc=jnair@caviumnetworks.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=yao.jin@intel.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 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.