1. 10 Aug, 2022 20 commits
    • Adrian Hunter's avatar
      perf machine: Fix missing free of machine->kallsyms_filename · b39c9e1b
      Adrian Hunter authored
      Add missing free of machine->kallsyms_filename to machine__exit().
      
      Fixes: a5367ecb ("perf tools: Automatically use guest kcore_dir if present")
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/r/20220809130758.12800-1-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b39c9e1b
    • Adrian Hunter's avatar
      perf script: Fix reference to perf insert instead of perf inject · 0c39f147
      Adrian Hunter authored
      Amend "perf insert" to "perf inject".
      
      Fixes: e28fb159 ("perf script: Add machine_pid and vcpu")
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/r/20220809123258.9086-1-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0c39f147
    • Yang Jihong's avatar
      perf sched latency: Fix subcommand matching error · 628881ee
      Yang Jihong authored
      perf sched latency use strncmp to match subcommands which matching does not
      meet expectation.
      
      Before:
      
        # perf sched lat1234 >/dev/null
        # echo $?
        0
        #
      
      Solution: Use strstarts to match subcommand.
      
      After:
      
         # perf sched lat1234
      
         Usage: perf sched [<options>] {record|latency|map|replay|script|timehist}
      
            -D, --dump-raw-trace  dump raw trace in ASCII
            -f, --force           don't complain, do it
            -i, --input <file>    input file name
            -v, --verbose         be more verbose (show symbol address, etc)
      
        # echo $?
        129
        #
        # perf sched lat >/dev/null
        # echo $?
        0
        #
      Signed-off-by: default avatarYang Jihong <yangjihong1@huawei.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: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20220808092408.107399-3-yangjihong1@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      628881ee
    • Yang Jihong's avatar
      perf kvm: Fix subcommand matching error · d2f30b79
      Yang Jihong authored
      Currently the 'diff', 'top', 'buildid-list' and 'stat' perf commands use
      strncmp() to match subcommands.  As a result, matching does not meet
      expectation.
      
      For example:
        # perf kvm diff1234
        # Event 'cycles'
        #
        # Baseline  Delta Abs  Shared Object  Symbol
        # ........  .........  .............  ......
        #
      
        # Event 'dummy:HG'
        #
        # Baseline  Delta Abs  Shared Object  Symbol
        # ........  .........  .............  ......
        #
        # echo $?
        0
        #
      
      Invalid information should be returned, but success is actually returned.
      
      Solution: Use strstarts() to match subcommands.
      
      After:
        # perf kvm diff1234
      
         Usage: perf kvm [<options>] {top|record|report|diff|buildid-list|stat}
      
            -i, --input <file>    Input file name
            -o, --output <file>   Output file name
            -v, --verbose         be more verbose (show counter open errors, etc)
                --guest           Collect guest os data
                --guest-code      Guest code can be found in hypervisor process
                --guestkallsyms <file>
                                  file saving guest os /proc/kallsyms
                --guestmodules <file>
                                  file saving guest os /proc/modules
                --guestmount <directory>
                                  guest mount directory under which every guest os instance has a subdir
                --guestvmlinux <file>
                                  file saving guest os vmlinux
                --host            Collect host os data
      
        # echo $?
        129
        #
      Signed-off-by: default avatarYang Jihong <yangjihong1@huawei.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: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20220808092408.107399-2-yangjihong1@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d2f30b79
    • Christophe JAILLET's avatar
      perf probe: Fix an error handling path in 'parse_perf_probe_command()' · 4bf6dcaa
      Christophe JAILLET authored
      If a memory allocation fail, we should branch to the error handling path
      in order to free some resources allocated a few lines above.
      
      Fixes: 15354d54 ("perf probe: Generate event name with line number")
      Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
      Acked-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: kernel-janitors@vger.kernel.org
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/b71bcb01fa0c7b9778647235c3ab490f699ba278.1659797452.git.christophe.jaillet@wanadoo.frSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      4bf6dcaa
    • Brian Robbins's avatar
      perf inject jit: Ignore memfd and anonymous mmap events if jitdump present · 46f7bd5e
      Brian Robbins authored
      Some processes store jitted code in memfd mappings to avoid having rwx
      mappings.  These processes map the code with a writeable mapping and a
      read-execute mapping.  They write the code using the writeable mapping
      and then unmap the writeable mapping.  All subsequent execution is
      through the read-execute mapping.
      
      perf inject --jit ignores //anon* mappings for each process where a
      jitdump is present because it expects to inject mmap events for each
      jitted code range, and said jitted code ranges will overlap with the
      //anon* mappings.
      
      Ignore /memfd: and [anon:* mappings so that jitted code contained in
      /memfd: and [anon:* mappings is treated the same way as jitted code
      contained in //anon* mappings.
      Signed-off-by: default avatarBrian Robbins <brianrob@linux.microsoft.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20220805220645.95855-1-brianrob@linux.microsoft.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      46f7bd5e
    • Thomas Richter's avatar
      perf list: Add PMU pai_crypto event description for IBM z16 · e0b23af8
      Thomas Richter authored
      Add the event description for the IBM z16 pai_crypto PMU released with
      commit 1bf54f32f525 ("s390/pai: Add support for cryptography counters")
      
      The document SA22-7832-13 "z/Architecture Principles of Operation",
      published May, 2022, contains the description of the
      Processor Activity Instrumentation Facility and the cryptography
      counter set., See Pages 5-110 to 5-113.
      
      Patch reworked to fit for the converted jevents processing.
      
      Committer notes:
      
      Couldn't find 1bf54f32f525 ("s390/pai: Add support for cryptography
      counters") in torvalds/master, in what tree is that cset?
      Signed-off-by: default avatarThomas Richter <tmricht@linux.ibm.com>
      Acked-by: default avatarSumanth Korikkar <sumanthk@linux.ibm.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Sven Schnelle <svens@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Link: https://lore.kernel.org/r/20220804075221.1132849-1-tmricht@linux.ibm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e0b23af8
    • Ian Rogers's avatar
      perf vendor events: Remove bad jaketown uncore events · b48ddbbb
      Ian Rogers authored
      The event converter scripts at:
      
        https://github.com/intel/event-converter-for-linux-perf
      
      passes Filter values from data on 01.org that is bogus in a perf command
      line and can cause perf to infinitely recurse in parse events. Remove
      such events or filters using the updated patch:
      
        https://github.com/intel/event-converter-for-linux-perf/pull/15/commits/afd779df99ee41aac646eae1ae5ae651cda3394d
      
      Fixes: 376d8b58 ("perf vendor events: Update Intel jaketown")
      Reviewed-by: default avatarKan Liang <kan.liang@linux.intel.com>
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Caleb Biggers <caleb.biggers@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kshipra Bopardikar <kshipra.bopardikar@intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Perry Taylor <perry.taylor@intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Link: https://lore.kernel.org/r/20220805013856.1842878-4-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b48ddbbb
    • Ian Rogers's avatar
      perf vendor events: Remove bad ivytown uncore events · 22de36ff
      Ian Rogers authored
      The event converter scripts at:
      
        https://github.com/intel/event-converter-for-linux-perf
      
      passes Filter values from data on 01.org that is bogus in a perf command
      line and can cause perf to infinitely recurse in parse events. Remove
      such events or filters using the updated patch:
      
        https://github.com/intel/event-converter-for-linux-perf/pull/15/commits/afd779df99ee41aac646eae1ae5ae651cda3394d
      
      Fixes: 62201368 ("perf vendor events: Update Intel ivytown")
      Reviewed-by: default avatarKan Liang <kan.liang@linux.intel.com>
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Caleb Biggers <caleb.biggers@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kshipra Bopardikar <kshipra.bopardikar@intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Perry Taylor <perry.taylor@intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Link: https://lore.kernel.org/r/20220805013856.1842878-3-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      22de36ff
    • Ian Rogers's avatar
      perf vendor events: Remove bad broadwellde uncore events · 2c98bacf
      Ian Rogers authored
      The event converter scripts at:
      
        https://github.com/intel/event-converter-for-linux-perf
      
      passes Filter values from data on 01.org that is bogus in a perf command
      line and can cause perf to infinitely recurse in parse events. Remove
      such events or filters using the updated patch:
      
        https://github.com/intel/event-converter-for-linux-perf/pull/15/commits/afd779df99ee41aac646eae1ae5ae651cda3394d
      
      Fixes: ef908a19 ("perf vendor events: Update Intel broadwellde")
      Reviewed-by: default avatarKan Liang <kan.liang@linux.intel.com>
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Caleb Biggers <caleb.biggers@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kshipra Bopardikar <kshipra.bopardikar@intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Perry Taylor <perry.taylor@intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Link: https://lore.kernel.org/r/20220805013856.1842878-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      2c98bacf
    • Ian Rogers's avatar
      perf jevents: Add JEVENTS_ARCH make option · b4f04660
      Ian Rogers authored
      Allow the architecture built into pmu-events.c to be set on the make
      command line with JEVENTS_ARCH.
      Reviewed-by: default avatarJohn Garry <john.garry@huawei.com>
      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: 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-4-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b4f04660
    • 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 20 commits