linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Richter <tmricht@linux.ibm.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>,
	Ian Rogers <irogers@google.com>
Cc: "linux-perf-use." <linux-perf-users@vger.kernel.org>,
	Sumanth Korikkar <sumanthk@linux.ibm.com>,
	James Clark <james.clark@arm.com>, Leo Yan <leo.yan@linaro.org>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	Mike Leach <mike.leach@linaro.org>,
	Mark Rutland <mark.rutland@arm.com>,
	John Garry <john.g.garry@oracle.com>,
	Will Deacon <will@kernel.org>
Subject: Re: Hybrid PMU issues on aarch64. was: Re: perf test failures in linux-next on s390
Date: Mon, 19 Jun 2023 12:04:00 +0200	[thread overview]
Message-ID: <cacce572-cab1-7938-a3e5-304b397861c9@linux.ibm.com> (raw)
In-Reply-To: <ZIxza13x+AwApbQb@kernel.org>

On 6/16/23 16:36, Arnaldo Carvalho de Melo wrote:
> Em Fri, Jun 16, 2023 at 07:23:30AM -0700, Ian Rogers escreveu:
>> On Thu, Jun 15, 2023 at 7:35 AM Arnaldo Carvalho de Melo <acme@kernel.org> wrote:
>>> Ccing the ARM people too:
>>> Em Thu, Jun 15, 2023 at 11:39:16AM +0200, Thomas Richter escreveu:
>>>> On 6/14/23 16:57, Ian Rogers wrote:
>>>>> On Wed, Jun 14, 2023 at 1:32 AM Thomas Richter <tmricht@linux.ibm.com> wrote:
>>>>> bool is_pmu_core(const char *name)
>>>>> {
>>>>> return !strcmp(name, "cpu") || is_sysfs_pmu_core(name);
>>>>> }
> 
>>>> Maybe we should scan the directory
> 
>>>> [linux-next]# ll /sys/bus/event_source/devices
>>>> total 0
>>>> lrwxrwxrwx 1 root root 0 Jun  2 15:11 cpum_cf -> ../../../devices/cpum_cf
>>>> lrwxrwxrwx 1 root root 0 Jun  2 15:11 cpum_cf_diag -> ../../../devices/cpum_cf_diag
>>>> lrwxrwxrwx 1 root root 0 Jun  2 15:11 cpum_sf -> ../../../devices/cpum_sf
>>>> lrwxrwxrwx 1 root root 0 Jun  2 15:11 kprobe -> ../../../devices/kprobe
>>>> lrwxrwxrwx 1 root root 0 Jun  2 15:11 software -> ../../../devices/software
>>>> lrwxrwxrwx 1 root root 0 Jun  2 15:11 tracepoint -> ../../../devices/tracepoint
>>>> lrwxrwxrwx 1 root root 0 Jun  2 15:11 uprobe -> ../../../devices/uprobe
>>>> [linux-next]#
> 
>>>> This directory lists the PMUs available on s390, maybe this is true for
>>>> other platform...
> 
>>> I noticed this on an arm64 board:
> 
>>> acme@roc-rk3399-pc:~/git/perf-tools-next$ perf stat -e cycles:u,instructions:u ls
>>> COPYING  CREDITS  Documentation  Kbuild  Kconfig  LICENSES  MAINTAINERS  Makefile  README  arch  block  certs  crypto  drivers  fs  include  init  io_uring  ipc  kernel  lib  mm  net  perf.data  rust  samples  scripts  security  sound  tools  usr  virt
> 
>>>  Performance counter stats for 'ls':
> 
>>>    <not supported>      armv8_cortex_a72/cycles:u/
>>>    <not supported>      armv8_cortex_a53/cycles:u/
>>>    <not supported>      armv8_cortex_a72/instructions:u/
>>>    <not supported>      armv8_cortex_a53/instructions:u/
> 
>> I tested on a raspberry pi and perf-tools-next is working there. I
>> suspect the issue here is the heterogeneous PMU. The cycles event is
>> converted into a perf_event_attr with type 0 and config 0. When there
>> are heterogeneous PMUs then we try to use the extended type to say we
>> want armv8_cortex_a72 and armv8_cortex_a53 cycles events. Let's say
>> the type number of armv8_cortex_a72 and armv8_cortex_a53 PMUs are 9
>> and 10 respectively. With heterogeneous encodings the type in the
> 
> The numbers are 8 and 7, PERF_TYPE_HW (thus zero, thus not printed):
> 
> root@roc-rk3399-pc:~# perf stat -vv -e cycles sleep 1
> Using CPUID 0x00000000410fd080
> Control descriptor is not initialized
> ------------------------------------------------------------
> perf_event_attr:
>   size                             136
>   config                           0x800000000
>   sample_type                      IDENTIFIER
>   read_format                      TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING
>   disabled                         1
>   inherit                          1
>   enable_on_exec                   1
>   exclude_guest                    1
> ------------------------------------------------------------
> sys_perf_event_open: pid 13885  cpu -1  group_fd -1  flags 0x8
> sys_perf_event_open failed, error -2
> Warning:

On s390 with above patch applied and latest git pull of linux-next this morning
I get this result:

# ./perf test -F 6
  6: Parse event definition strings                                  :
  6.1: Test event parsing                                            : Ok
  6.2: Parsing of all PMU events from sysfs                          : Ok
  6.3: Parsing of given PMU events from sysfs                        : Ok
  6.4: Parsing of aliased events from sysfs                          : Skip (no aliases in sysfs)
  6.5: Parsing of aliased events                                     : Ok
  6.6: Parsing of terms (event modifiers)                            : Ok
#

However the config member in perf_event_attr::config member does not change
as can be seen in this trace:
# ./perf stat -e cycles -vv true
Control descriptor is not initialized
------------------------------------------------------------
perf_event_attr:
  size                             136
  sample_type                      IDENTIFIER
  read_format                      TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING
  disabled                         1
  inherit                          1
  enable_on_exec                   1
  exclude_guest                    1
------------------------------------------------------------
sys_perf_event_open: pid 6510  cpu -1  group_fd -1  flags 0x8 = 3
cycles: -1: 2646065 510719 510719
cycles: 2646065 510719 510719

 Performance counter stats for 'true':

         2,646,065      cycles                                                                

       0.002084266 seconds time elapsed

       0.000052000 seconds user
       0.002107000 seconds sys


#

Thanks for fixing this...

-- 
Thomas Richter, Dept 3303, IBM s390 Linux Development, Boeblingen, Germany
--
Vorsitzender des Aufsichtsrats: Gregor Pillen
Geschäftsführung: David Faller
Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294


      parent reply	other threads:[~2023-06-19 10:04 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-13 12:54 perf test failures in linux-next on s390 Thomas Richter
2023-06-13 14:32 ` Ian Rogers
2023-06-14  8:31   ` Thomas Richter
2023-06-14 14:57     ` Ian Rogers
2023-06-15  8:57       ` Thomas Richter
2023-06-15  9:39       ` Thomas Richter
2023-06-15 14:34         ` Arnaldo Carvalho de Melo
2023-06-16 14:23           ` Ian Rogers
2023-06-16 14:36             ` Hybrid PMU issues on aarch64. was: " Arnaldo Carvalho de Melo
2023-06-16 14:44               ` Arnaldo Carvalho de Melo
2023-06-16 16:28                 ` Ian Rogers
2023-06-16 16:53                   ` Arnaldo Carvalho de Melo
2023-06-16 21:47                     ` Arnaldo Carvalho de Melo
2023-06-16 22:09                       ` Ian Rogers
2023-06-19 10:04               ` Thomas Richter [this message]

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=cacce572-cab1-7938-a3e5-304b397861c9@linux.ibm.com \
    --to=tmricht@linux.ibm.com \
    --cc=acme@kernel.org \
    --cc=irogers@google.com \
    --cc=james.clark@arm.com \
    --cc=john.g.garry@oracle.com \
    --cc=leo.yan@linaro.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mike.leach@linaro.org \
    --cc=sumanthk@linux.ibm.com \
    --cc=suzuki.poulose@arm.com \
    --cc=will@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).