1. 17 Dec, 2020 10 commits
    • John Garry's avatar
      perf pmu: Add pmu_add_sys_aliases() · 4513c719
      John Garry authored
      Add pmu_add_sys_aliases() to add system PMU events aliases.
      
      For adding system PMU events, iterate through all the events for all SoC
      event tables in pmu_sys_event_tables[].
      
      Matches must satisfy both:
      - PMU identifier matches event "compat" value
      - event "Unit" member must match, same as uncore event aliases matched by
        CPUID
      Signed-off-by: default avatarJohn Garry <john.garry@huawei.com>
      Acked-by: default avatarKajol Jain <kjain@linux.ibm.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Joakim Zhang <qiangqing.zhang@nxp.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kim Phillips <kim.phillips@amd.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Shaokun Zhang <zhangshaokun@hisilicon.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linuxarm@huawei.com
      Link: http://lore.kernel.org/lkml/1607080216-36968-5-git-send-email-john.garry@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      4513c719
    • John Garry's avatar
      perf pmu: Add pmu_id() · 51d54847
      John Garry authored
      Add a function to read the PMU id sysfs entry. This is only done for uncore
      PMUs where this would possibly be relevant.
      Signed-off-by: default avatarJohn Garry <john.garry@huawei.com>
      Acked-by: default avatarKajol Jain <kjain@linux.ibm.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Joakim Zhang <qiangqing.zhang@nxp.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kim Phillips <kim.phillips@amd.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Shaokun Zhang <zhangshaokun@hisilicon.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linuxarm@huawei.com
      Link: http://lore.kernel.org/lkml/1607080216-36968-4-git-send-email-john.garry@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      51d54847
    • John Garry's avatar
      perf jevents: Add support for system events tables · 4689f567
      John Garry authored
      Process the JSONs to find support for "system" events, which are not
      tied to a specific CPUID.
      
      A "COMPAT" property is now used to match against the namespace ID from
      the kernel PMU driver.
      
      The generated pmu-events.c will now have 2 tables:
      
      a. CPU events, as before.
      b. New pmu_sys_event_tables[] table, which will have events matched to
         specific SoCs.
      
      It will look like this:
      
      struct pmu_event pme_hisilicon_hip09_sys[] = {
      {
      	.name = "cycles",
      	.compat = "0x00030736",
      	.event = "event=0",
      	.desc = "Clock cycles",
      	.topic = "smmu v3 pmcg",
      	.long_desc = "Clock cycles",
      },
      {
      	.name = "smmuv3_pmcg.l1_tlb",
      	.compat = "0x00030736",
      	.event = "event=0x8a",
      	.desc = "SMMUv3 PMCG l1_tlb. Unit: smmuv3_pmcg ",
      	.topic = "smmu v3 pmcg",
      	.long_desc = "SMMUv3 PMCG l1_tlb",
      	.pmu = "smmuv3_pmcg",
      },
      ...
      };
      
      struct pmu_event pme_arm_cortex_a53[] = {
      {
      	.name = "ext_mem_req",
      	.event = "event=0xc0",
      	.desc = "External memory request",
      	.topic = "memory",
      },
      {
      	.name = "ext_mem_req_nc",
      	.event = "event=0xc1",
      	.desc = "Non-cacheable external memory request",
      	.topic = "memory",
      },
      ...
      };
      
      struct pmu_event pme_hisilicon_hip09_cpu[] = {
      {
      	.name = "l2d_cache_refill_wr",
      	.event = "event=0x53",
      	.desc = "L2D cache refill, write",
      	.topic = "core imp def",
      	.long_desc = "Attributable Level 2 data cache refill, write",
      },
      ...
      };
      
      struct pmu_events_map pmu_events_map[] = {
      {
      	.cpuid = "0x00000000410fd030",
      	.version = "v1",
      	.type = "core",
      	.table = pme_arm_cortex_a53
      },
      {
      	.cpuid = "0x00000000480fd010",
      	.version = "v1",
      	.type = "core",
      	.table = pme_hisilicon_hip09_cpu
      },
      	{
      		.table = 0
      	},
      };
      
      struct pmu_event pme_hisilicon_hip09_cpu[] = {
      {
      	.name = "uncore_hisi_l3c.rd_cpipe",
      	.event = "event=0",
      	.desc = "Total read accesses. Unit: hisi_sccl,l3c ",
      	.topic = "uncore l3c",
      	.long_desc = "Total read accesses",
      	.pmu = "hisi_sccl,l3c",
      },
      {
      	.name = "uncore_hisi_l3c.wr_cpipe",
      	.event = "event=0x1",
      	.desc = "Total write accesses. Unit: hisi_sccl,l3c ",
      	.topic = "uncore l3c",
      	.long_desc = "Total write accesses",
      	.pmu = "hisi_sccl,l3c",
      },
      ...
      };
      
      struct pmu_sys_events pmu_sys_event_tables[] = {
      {
      	.table = pme_hisilicon_hip09_sys,
      },
      ...
      };
      
      Committer notes:
      
      Added the fix for architectures without PMU events, provided by John
      after I reported the build failing in such systems.
      
      Link: https://lore.kernel.org/lkml/650baaf2-36b6-a9e2-ff49-963ef864c1f3@huawei.com/Signed-off-by: default avatarJohn Garry <john.garry@huawei.com>
      Acked-by: default avatarKajol Jain <kjain@linux.ibm.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Joakim Zhang <qiangqing.zhang@nxp.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kim Phillips <kim.phillips@amd.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Shaokun Zhang <zhangshaokun@hisilicon.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linuxarm@huawei.com
      Link: http://lore.kernel.org/lkml/1607080216-36968-3-git-send-email-john.garry@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      4689f567
    • John Garry's avatar
      perf jevents: Add support for an extra directory level · 4853f1ca
      John Garry authored
      Currently only upto a level 2 directory is supported, in form
      vendor/platform.
      
      Add support for a further level, to support vendor/platform
      sub-directories in future, which will be vendor/platform/cpu and
      vendor/platform/sys.
      Signed-off-by: default avatarJohn Garry <john.garry@huawei.com>
      Acked-by: default avatarKajol Jain <kjain@linux.ibm.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Joakim Zhang <qiangqing.zhang@nxp.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kim Phillips <kim.phillips@amd.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Shaokun Zhang <zhangshaokun@hisilicon.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linuxarm@huawei.com
      Link: http://lore.kernel.org/lkml/1607080216-36968-2-git-send-email-john.garry@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      4853f1ca
    • Arnaldo Carvalho de Melo's avatar
      perf evsel: Emit warning about kernel not supporting the data page size sample_type bit · 456ef4c1
      Arnaldo Carvalho de Melo authored
      Before we had this unhelpful message:
      
        $ perf record --data-page-size sleep 1
        Error:
        The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (cycles:u).
        /bin/dmesg | grep -i perf may provide additional information.
        $
      
      Add support to the perf_missing_features variable to remember what
      caused evsel__open() to fail and then use that information in
      evsel__open_strerror().
      
        $ perf record --data-page-size sleep 1
        Error:
        Asking for the data page size isn't supported by this kernel.
        $
      
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Will Deacon <will@kernel.org>
      Link: http://lore.kernel.org/lkml/20201207170759.GB129853@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      456ef4c1
    • Kan Liang's avatar
      perf record: Support new sample type for data page size · 542b88fd
      Kan Liang authored
      Support new sample type PERF_SAMPLE_DATA_PAGE_SIZE for page size.
      
      Add new option --data-page-size to record sample data page size.
      Signed-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Will Deacon <will@kernel.org>
      Link: http://lore.kernel.org/lkml/20201130172803.2676-3-kan.liang@linux.intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      542b88fd
    • Kan Liang's avatar
      tools headers UAPI: Update tools's copy of linux/perf_event.h · 47d98220
      Kan Liang authored
      To get the changes in:
      
         commit 8d97e718 ("perf/core: Add PERF_SAMPLE_DATA_PAGE_SIZE")
         commit 995f088e ("perf/core: Add support for PERF_SAMPLE_CODE_PAGE_SIZE")
      
      This silences this perf tools build warning:
      
        Warning: Kernel ABI header at 'tools/include/uapi/linux/perf_event.h'
      differs from latest version at 'include/uapi/linux/perf_event.h'
        diff -u tools/include/uapi/linux/perf_event.h
      include/uapi/linux/perf_event.h
      Signed-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Will Deacon <will@kernel.org>
      Link: http://lore.kernel.org/lkml/20201130172803.2676-2-kan.liang@linux.intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      47d98220
    • Jan Kratochvil's avatar
      perf unwind: Fix separate debug info files when using elfutils' libdw's unwinder · bf53fc6b
      Jan Kratochvil authored
      elfutils needs to be provided main binary and separate debug info file
      respectively. Providing separate debug info file instead of the main
      binary is not sufficient.
      
      One needs to try both supplied filename and its possible cache by its
      build-id depending on the use case.
      Signed-off-by: default avatarJan Kratochvil <jan.kratochvil@redhat.com>
      Tested-by: default avatarJiri Olsa <jolsa@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      bf53fc6b
    • Zheng Zengkai's avatar
      perf record: Fix memory leak when using '--user-regs=?' to list registers · 2eb5dd41
      Zheng Zengkai authored
      When using 'perf record's option '-I' or '--user-regs=' along with
      argument '?' to list available register names, memory of variable 'os'
      allocated by strdup() needs to be released before __parse_regs()
      returns, otherwise memory leak will occur.
      
      Fixes: bcc84ec6 ("perf record: Add ability to name registers to record")
      Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Li Bin <huawei.libin@huawei.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/r/20200703093344.189450-1-zhengzengkai@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      2eb5dd41
    • Jiri Olsa's avatar
      tools build: Add missing libcap to test-all.bin target · 09d59c2f
      Jiri Olsa authored
      We're missing -lcap in test-all.bin target, so in case it's the only
      library missing (if more are missing test-all.bin fails anyway), we will
      falsely claim that we detected it and fail build, like:
      
        $ make
        ...
        Auto-detecting system features:
        ...                         dwarf: [ on  ]
        ...            dwarf_getlocations: [ on  ]
        ...                         glibc: [ on  ]
        ...                        libbfd: [ on  ]
        ...                libbfd-buildid: [ on  ]
        ...                        libcap: [ on  ]
        ...                        libelf: [ on  ]
        ...                       libnuma: [ on  ]
        ...        numa_num_possible_cpus: [ on  ]
        ...                       libperl: [ on  ]
        ...                     libpython: [ on  ]
        ...                     libcrypto: [ on  ]
        ...                     libunwind: [ on  ]
        ...            libdw-dwarf-unwind: [ on  ]
        ...                          zlib: [ on  ]
        ...                          lzma: [ on  ]
        ...                     get_cpuid: [ on  ]
        ...                           bpf: [ on  ]
        ...                        libaio: [ on  ]
        ...                       libzstd: [ on  ]
        ...        disassembler-four-args: [ on  ]
      
        ...
      
          CC       builtin-ftrace.o
      
        In file included from builtin-ftrace.c:29:
        util/cap.h:11:10: fatal error: sys/capability.h: No such file or directory
           11 | #include <sys/capability.h>
              |          ^~~~~~~~~~~~~~~~~~
        compilation terminated.
      
      Fixes: 74d5f3d0 ("tools build: Add capability-related feature detection")
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Igor Lubashev <ilubashe@akamai.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20201203230836.3751981-1-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      09d59c2f
  2. 15 Dec, 2020 1 commit
    • Kajol Jain's avatar
      perf test: Fix metric parsing test · b2ce5dbc
      Kajol Jain authored
      Commit e1c92a7f ("perf tests: Add another metric parsing test") add
      another test for metric parsing. The test goes through all metrics
      compiled for arch within pmu events and try to parse them.
      
      Right now this test is failing in powerpc machine.
      
      Result in power9 platform:
      
        [command]# ./perf test 10
        10: PMU events                                                      :
        10.1: PMU event table sanity                                        : Ok
        10.2: PMU event map aliases                                         : Ok
        10.3: Parsing of PMU event table metrics                            : Skip (some metrics failed)
        10.4: Parsing of PMU event table metrics with fake PMUs             : FAILED!
      
      Issue is we are passing different runtime parameter value in
      "expr__find_other" and "expr__parse" function which is called from
      function `metric_parse_fake`.  And because of this parsing of hv-24x7
      metrics is failing.
      
        [command]# ./perf test 10 -vv
        .....
        hv_24x7/pm_mcs01_128b_rd_disp_port01,chip=1/ not found
        expr__parse failed
        test child finished with -1
        ---- end ----
        PMU events subtest 4: FAILED!
      
      This patch fix this issue and change runtime parameter value to '0' in
      expr__parse function.
      
      Result in power9 platform after this patch:
      
        [command]# ./perf test 10
        10: PMU events                                                      :
        10.1: PMU event table sanity                                        : Ok
        10.2: PMU event map aliases                                         : Ok
        10.3: Parsing of PMU event table metrics                            : Skip (some metrics failed)
        10.4: Parsing of PMU event table metrics with fake PMUs             : Ok
      
      Fixes: e1c92a7f ("perf tests: Add another metric parsing test")
      Signed-off-by: default avatarKajol Jain <kjain@linux.ibm.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
      Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
      Link: http://lore.kernel.org/lkml/20201119152411.46041-1-kjain@linux.ibm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b2ce5dbc
  3. 30 Nov, 2020 29 commits