1. 10 Aug, 2022 9 commits
    • Ian Rogers's avatar
      perf jevents: Simplify generation of C-string · 46acb311
      Ian Rogers authored
      Previous implementation wanted variable order and '(null)' string output
      to match the C implementation. The '(null)' string output was a
      quirk/bug and so there is no need to carry it forward.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lore.kernel.org/lkml/20220804221816.1802790-3-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      46acb311
    • Ian Rogers's avatar
      perf jevents: Clean up pytype warnings · e1e19d05
      Ian Rogers authored
      Improve type hints to clean up pytype warnings.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lore.kernel.org/lkml/20220804221816.1802790-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e1e19d05
    • Roberto Sassu's avatar
      tools build: Switch to new openssl API for test-libcrypto · 5b245985
      Roberto Sassu authored
      Switch to new EVP API for detecting libcrypto, as Fedora 36 returns an
      error when it encounters the deprecated function MD5_Init() and the others.
      
      The error would be interpreted as missing libcrypto, while in reality it is
      not.
      
      Fixes: 6e8ccb4f ("tools/bpf: properly account for libbfd variations")
      Signed-off-by: default avatarRoberto Sassu <roberto.sassu@huawei.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Andrii Nakryiko <andrii@kernel.org>
      Cc: bpf@vger.kernel.org
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: John Fastabend <john.fastabend@gmail.com>
      Cc: KP Singh <kpsingh@kernel.org>
      Cc: llvm@lists.linux.dev
      Cc: Martin KaFai Lau <martin.lau@linux.dev>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Nick Terrell <terrelln@fb.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Quentin Monnet <quentin@isovalent.com>
      Cc: Song Liu <song@kernel.org>
      Cc: Stanislav Fomichev <sdf@google.com>
      Link: https://lore.kernel.org/r/20220719170555.2576993-4-roberto.sassu@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5b245985
    • Arnaldo Carvalho de Melo's avatar
      Revert "perf build: Suppress openssl v3 deprecation warnings in libcrypto feature test" · 73f8ec59
      Arnaldo Carvalho de Melo authored
      This reverts commit 10fef869.
      
      Because a proper fix was submitted.
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      73f8ec59
    • Roberto Sassu's avatar
      perf build: Remove FEATURE_CHECK_LDFLAGS-disassembler-{four-args,init-styled} setting · dd6775f9
      Roberto Sassu authored
      As the building mechanism is now able to retry detection with different
      combinations of linking flags, setting
      FEATURE_CHECK_LDFLAGS-disassembler-four-args and
      FEATURE_CHECK_LDFLAGS-disassembler-init-styled is not necessary anymore,
      so remove it.
      
      Committer notes:
      
      Use the same technique to find the set of bfd-related libraries to link as in:
      
        3308ffc5016e6136 ("tools, build: Retry detection of bfd-related features")
      Signed-off-by: default avatarRoberto Sassu <roberto.sassu@huawei.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Andres Freund <andres@anarazel.de>
      Cc: Andrii Nakryiko <andrii@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: John Fastabend <john.fastabend@gmail.com>
      Cc: KP Singh <kpsingh@kernel.org>
      Cc: Martin KaFai Lau <martin.lau@linux.dev>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Nick Terrell <terrelln@fb.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Quentin Monnet <quentin@isovalent.com>
      Cc: Song Liu <song@kernel.org>
      Cc: Stanislav Fomichev <sdf@google.com>
      Cc: bpf@vger.kernel.org
      Cc: llvm@lists.linux.dev
      Link: https://lore.kernel.org/r/20220719170555.2576993-3-roberto.sassu@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      dd6775f9
    • Roberto Sassu's avatar
      bpftool: Complete libbfd feature detection · 13e6f53a
      Roberto Sassu authored
      Commit 6e8ccb4f ("tools/bpf: properly account for libbfd variations")
      sets the linking flags depending on which flavor of the libbfd feature was
      detected.
      
      However, the flavors except libbfd cannot be detected, as they are not in
      the feature list.
      
      Complete the list of features to detect by adding libbfd-liberty and
      libbfd-liberty-z.
      
      Committer notes:
      
      Adjust conflict with with:
      
        1e1613f6 ("tools bpftool: Don't display disassembler-four-args feature test")
        600b7b26 ("tools bpftool: Fix compilation error with new binutils")
      
      Fixes: 6e8ccb4f ("tools/bpf: properly account for libbfd variations")
      Signed-off-by: default avatarRoberto Sassu <roberto.sassu@huawei.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Andres Freund <andres@anarazel.de>
      Cc: Andrii Nakryiko <andrii@kernel.org>
      Cc: bpf@vger.kernel.org
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: John Fastabend <john.fastabend@gmail.com>
      Cc: KP Singh <kpsingh@kernel.org>
      Cc: llvm@lists.linux.dev
      Cc: Martin KaFai Lau <martin.lau@linux.dev>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Nick Terrell <terrelln@fb.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Quentin Monnet <quentin@isovalent.com>
      Cc: Song Liu <song@kernel.org>
      Cc: Stanislav Fomichev <sdf@google.com>
      Link: https://lore.kernel.org/r/20220719170555.2576993-2-roberto.sassu@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      13e6f53a
    • Roberto Sassu's avatar
      tools, build: Retry detection of bfd-related features · 629b98e2
      Roberto Sassu authored
      While separate features have been defined to determine which linking flags
      are required to use libbfd depending on the distribution (libbfd,
      libbfd-liberty and libbfd-liberty-z), the same has not been done for other
      features requiring linking to libbfd.
      
      For example, disassembler-four-args requires linking to libbfd too, but it
      should use the right linking flags. If not all the required ones are
      specified, e.g. -liberty, detection will always fail even if the feature is
      available.
      
      Instead of creating new features, similarly to libbfd, simply retry
      detection with the different set of flags until detection succeeds (or
      fails, if the libraries are missing). In this way, feature detection is
      transparent for the users of this building mechanism (e.g. perf), and those
      users don't have for example to set an appropriate value for the
      FEATURE_CHECK_LDFLAGS-disassembler-four-args variable.
      
      The number of retries and features for which the retry mechanism is
      implemented is low enough to make the increase in the complexity of
      Makefile negligible.
      
      Tested with perf and bpftool on Ubuntu 20.04.4 LTS, Fedora 36 and openSUSE
      Tumbleweed.
      
      Committer notes:
      
      Do the retry for disassembler-init-styled as well.
      Signed-off-by: default avatarRoberto Sassu <roberto.sassu@huawei.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Andres Freund <andres@anarazel.de>
      Cc: Andrii Nakryiko <andrii@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: John Fastabend <john.fastabend@gmail.com>
      Cc: KP Singh <kpsingh@kernel.org>
      Cc: Martin KaFai Lau <martin.lau@linux.dev>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Nick Terrell <terrelln@fb.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Quentin Monnet <quentin@isovalent.com>
      Cc: Song Liu <song@kernel.org>
      Cc: Stanislav Fomichev <sdf@google.com>
      Cc: bpf@vger.kernel.org
      Cc: llvm@lists.linux.dev
      Link: https://lore.kernel.org/r/20220719170555.2576993-1-roberto.sassu@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      629b98e2
    • Claire Jensen's avatar
      perf test: JSON format checking · 0c343af2
      Claire Jensen authored
      Add field checking tests for perf stat JSON output.
      
      Sanity checks the expected number of fields are present, that the
      expected keys are present and they have the correct values.
      
      Committer notes:
      
      Had to fix this:
      
        -               $(INSTALL) tests/shell/lib/*.sh '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/lib' \
        +               $(INSTALL) tests/shell/lib/*.sh '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell/lib'; \
      
      Committer testing:
      
        [root@quaco ~]# perf test json
         90: perf stat JSON output linter                                    : Ok
        [root@quaco ~]# set -o vi
        [root@quaco ~]# perf test -v json
         90: perf stat JSON output linter                                    :
        --- start ---
        test child forked, pid 560794
        Checking json output: no args [Success]
        Checking json output: system wide [Success]
        Checking json output: system wide Checking json output: system wide no aggregation [Success]
        Checking json output: interval [Success]
        Checking json output: event [Success]
        Checking json output: per core [Success]
        Checking json output: per thread [Success]
        Checking json output: per die [Success]
        Checking json output: per node [Success]
        Checking json output: per socket [Success]
        test child finished with 0
        ---- end ----
        perf stat JSON output linter: Ok
        [root@quaco ~]#
      Signed-off-by: default avatarClaire Jensen <cjense@google.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alyssa Ross <hi@alyssa.is>
      Cc: Claire Jensen <clairej735@gmail.com>
      Cc: Florian Fischer <florian.fischer@muhq.space>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Like Xu <likexu@tencent.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sandipan Das <sandipan.das@amd.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Link: https://lore.kernel.org/r/20220805200105.2020995-3-irogers@google.comSigned-off-by: default avatarIan Rogers <irogers@google.com>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0c343af2
    • Claire Jensen's avatar
      perf stat: Add JSON output option · df936cad
      Claire Jensen authored
      CSV output is tricky to format and column layout changes are susceptible
      to breaking parsers. New JSON-formatted output has variable names to
      identify fields that are consistent and informative, making the output
      parseable.
      
      CSV output example:
      
        1.20,msec,task-clock:u,1204272,100.00,0.697,CPUs utilized
        0,,context-switches:u,1204272,100.00,0.000,/sec
        0,,cpu-migrations:u,1204272,100.00,0.000,/sec
        70,,page-faults:u,1204272,100.00,58.126,K/sec
      
      JSON output example:
      
        {"counter-value" : "3805.723968", "unit" : "msec", "event" :
        "cpu-clock", "event-runtime" : 3805731510100.00, "pcnt-running"
        : 100.00, "metric-value" : 4.007571, "metric-unit" : "CPUs utilized"}
        {"counter-value" : "6166.000000", "unit" : "", "event" :
        "context-switches", "event-runtime" : 3805723045100.00, "pcnt-running"
        : 100.00, "metric-value" : 1.620191, "metric-unit" : "K/sec"}
        {"counter-value" : "466.000000", "unit" : "", "event" :
        "cpu-migrations", "event-runtime" : 3805727613100.00, "pcnt-running"
        : 100.00, "metric-value" : 122.447136, "metric-unit" : "/sec"}
        {"counter-value" : "208.000000", "unit" : "", "event" :
        "page-faults", "event-runtime" : 3805726799100.00, "pcnt-running"
        : 100.00, "metric-value" : 54.654516, "metric-unit" : "/sec"}
      
      Also added documentation for JSON option.
      
      There is some tidy up of CSV code including a potential memory over run
      in the os.nfields set up. To facilitate this an AGGR_MAX value is added.
      
      Committer notes:
      
      Fixed up using PRIu64 to format u64 values, not %lu.
      
      Committer testing:
      
        ⬢[acme@toolbox perf]$ perf stat -j sleep 1
        {"counter-value" : "0.731750", "unit" : "msec", "event" : "task-clock:u", "event-runtime" : 731750, "pcnt-running" : 100.00, "metric-value" : 0.000731, "metric-unit" : "CPUs utilized"}
        {"counter-value" : "0.000000", "unit" : "", "event" : "context-switches:u", "event-runtime" : 731750, "pcnt-running" : 100.00, "metric-value" : 0.000000, "metric-unit" : "/sec"}
        {"counter-value" : "0.000000", "unit" : "", "event" : "cpu-migrations:u", "event-runtime" : 731750, "pcnt-running" : 100.00, "metric-value" : 0.000000, "metric-unit" : "/sec"}
        {"counter-value" : "75.000000", "unit" : "", "event" : "page-faults:u", "event-runtime" : 731750, "pcnt-running" : 100.00, "metric-value" : 102.494021, "metric-unit" : "K/sec"}
        {"counter-value" : "578765.000000", "unit" : "", "event" : "cycles:u", "event-runtime" : 379366, "pcnt-running" : 49.00, "metric-value" : 0.790933, "metric-unit" : "GHz"}
        {"counter-value" : "1298.000000", "unit" : "", "event" : "stalled-cycles-frontend:u", "event-runtime" : 768020, "pcnt-running" : 100.00, "metric-value" : 0.224271, "metric-unit" : "frontend cycles idle"}
        {"counter-value" : "21984.000000", "unit" : "", "event" : "stalled-cycles-backend:u", "event-runtime" : 768020, "pcnt-running" : 100.00, "metric-value" : 3.798433, "metric-unit" : "backend cycles idle"}
        {"counter-value" : "468197.000000", "unit" : "", "event" : "instructions:u", "event-runtime" : 768020, "pcnt-running" : 100.00, "metric-value" : 0.808959, "metric-unit" : "insn per cycle"}
        {"metric-value" : 0.046955, "metric-unit" : "stalled cycles per insn"}
        {"counter-value" : "103335.000000", "unit" : "", "event" : "branches:u", "event-runtime" : 768020, "pcnt-running" : 100.00, "metric-value" : 141.216262, "metric-unit" : "M/sec"}
        {"counter-value" : "2381.000000", "unit" : "", "event" : "branch-misses:u", "event-runtime" : 388654, "pcnt-running" : 50.00, "metric-value" : 2.304156, "metric-unit" : "of all branches"}
        ⬢[acme@toolbox perf]$
      Signed-off-by: default avatarClaire Jensen <cjense@google.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alyssa Ross <hi@alyssa.is>
      Cc: Claire Jensen <clairej735@gmail.com>
      Cc: Florian Fischer <florian.fischer@muhq.space>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Like Xu <likexu@tencent.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sandipan Das <sandipan.das@amd.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Link: https://lore.kernel.org/r/20220805200105.2020995-2-irogers@google.comSigned-off-by: default avatarIan Rogers <irogers@google.com>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      df936cad
  2. 09 Aug, 2022 31 commits