Skip to content
  1. Jan 16, 2021
    • Al Grant's avatar
      perf inject: Correct event attribute sizes · 648b054a
      Al Grant authored
      
      
      When 'perf inject' reads a perf.data file from an older version of perf,
      it writes event attributes into the output with the original size field,
      but lays them out as if they had the size currently used. Readers see a
      corrupt file. Update the size field to match the layout.
      
      Signed-off-by: default avatarAl Grant <al.grant@foss.arm.com>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20201124195818.30603-1-al.grant@arm.com
      
      
      Signed-off-by: default avatarDenis Nikitin <denik@chromium.org>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      648b054a
    • Adrian Hunter's avatar
      perf intel-pt: Fix 'CPU too large' error · 5501e922
      Adrian Hunter authored
      In some cases, the number of cpus (nr_cpus_online) is confused with the
      maximum cpu number (nr_cpus_avail), which results in the error in the
      example below:
      
      Example on system with 8 cpus:
      
       Before:
         # echo 0 > /sys/devices/system/cpu/cpu2/online
         # ./perf record --kcore -e intel_pt// taskset --cpu-list 7 uname
         Linux
         [ perf record: Woken up 1 times to write data ]
         [ perf record: Captured and wrote 0.147 MB perf.data ]
         # ./perf script --itrace=e
         Requested CPU 7 too large. Consider raising MAX_NR_CPUS
         0x25908 [0x8]: failed to process type: 68 [Invalid argument]
      
       After:
         # ./perf script --itrace=e
         #
      
      Fixes: 8c727469 ("perf machine: Replace MAX_NR_CPUS with perf_env::nr_cpus_online")
      Fixes: 7df4e36a
      
       ("perf session: Replace MAX_NR_CPUS with perf_env::nr_cpus_online")
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Tested-by: default avatarKan Liang <kan.liang@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: stable@vger.kernel.org
      Link: http://lore.kernel.org/lkml/20210107174159.24897-1-adrian.hunter@intel.com
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5501e922
    • Namhyung Kim's avatar
      perf stat: Take cgroups into account for shadow stats · a1bf2305
      Namhyung Kim authored
      
      
      As of now it doesn't consider cgroups when collecting shadow stats and
      metrics so counter values from different cgroups will be saved in a same
      slot.  This resulted in incorrect numbers when those cgroups have
      different workloads.
      
      For example, let's look at the scenario below: cgroups A and C runs same
      workload which burns a cpu while cgroup B runs a light workload.
      
        $ perf stat -a -e cycles,instructions --for-each-cgroup A,B,C  sleep 1
      
         Performance counter stats for 'system wide':
      
           3,958,116,522      cycles                A
           6,722,650,929      instructions          A #    2.53  insn per cycle
               1,132,741      cycles                B
                 571,743      instructions          B #    0.00  insn per cycle
           4,007,799,935      cycles                C
           6,793,181,523      instructions          C #    2.56  insn per cycle
      
             1.001050869 seconds time elapsed
      
      When I run 'perf stat' with single workload, it usually shows IPC around
      1.7.  We can verify it (6,722,650,929.0 / 3,958,116,522 = 1.698) for cgroup A.
      
      But in this case, since cgroups are ignored, cycles are averaged so it
      used the lower value for IPC calculation and resulted in around 2.5.
      
        avg cycle: (3958116522 + 1132741 + 4007799935) / 3 = 2655683066
        IPC (A)  :  6722650929 / 2655683066 = 2.531
        IPC (B)  :      571743 / 2655683066 = 0.0002
        IPC (C)  :  6793181523 / 2655683066 = 2.557
      
      We can simply compare cgroup pointers in the evsel and it'll be NULL
      when cgroups are not specified.  With this patch, I can see correct
      numbers like below:
      
        $ perf stat -a -e cycles,instructions --for-each-cgroup A,B,C  sleep 1
      
        Performance counter stats for 'system wide':
      
           4,171,051,687      cycles                A
           7,219,793,922      instructions          A #    1.73  insn per cycle
               1,051,189      cycles                B
                 583,102      instructions          B #    0.55  insn per cycle
           4,171,124,710      cycles                C
           7,192,944,580      instructions          C #    1.72  insn per cycle
      
             1.007909814 seconds time elapsed
      
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20210115071139.257042-2-namhyung@kernel.org
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a1bf2305
    • Namhyung Kim's avatar
      perf stat: Introduce struct runtime_stat_data · 3ff1e718
      Namhyung Kim authored
      
      
      To pass more info to the saved_value in the runtime_stat, add a new
      struct runtime_stat_data.  Currently it only has 'ctx' field but later
      patch will add more.
      
      Note that we intentionally pass 0 as ctx to clock-related events for
      compatibility.  It was already there in a few places.  So move the code
      into the saved_value_lookup() explicitly and add a comment.
      
      Suggested-by: default avatarAndi Kleen <ak@linux.intel.com>
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20210115071139.257042-1-namhyung@kernel.org
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      3ff1e718
    • Ian Rogers's avatar
      libperf tests: Fail when failing to get a tracepoint id · 66dd86b2
      Ian Rogers authored
      
      
      Permissions are necessary to get a tracepoint id. Fail the test when the
      read fails.
      
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.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/20210114180250.3853825-2-irogers@google.com
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      66dd86b2
    • Ian Rogers's avatar
      libperf tests: If a test fails return non-zero · bba2ea17
      Ian Rogers authored
      
      
      If a test fails return -1 rather than 0. This is consistent with the
      return value in test-cpumap.c
      
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.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/20210114180250.3853825-1-irogers@google.com
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      bba2ea17
    • Ian Rogers's avatar
      libperf tests: Avoid uninitialized variable warning · be82fddc
      Ian Rogers authored
      
      
      The variable 'bf' is read (for a write call) without being initialized
      triggering a memory sanitizer warning. Use 'bf' in the read and switch
      the write to reading from a string.
      
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20210114212304.4018119-1-irogers@google.com
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      be82fddc
    • Namhyung Kim's avatar
      perf test: Fix shadow stat test for non-bash shells · a042a82d
      Namhyung Kim authored
      
      
      It was using some bash-specific features and failed to parse when
      running with a different shell like below:
      
        root@kbl-ppc:~/kbl-ws/perf-dev/lck-9077/acme.tmp/tools/perf# ./perf test 83 -vv
        83: perf stat metrics (shadow stat) test                            :
        --- start ---
        test child forked, pid 3922
        ./tests/shell/stat+shadow_stat.sh: 19: ./tests/shell/stat+shadow_stat.sh: [[: not found
        ./tests/shell/stat+shadow_stat.sh: 24: ./tests/shell/stat+shadow_stat.sh: [[: not found
        ./tests/shell/stat+shadow_stat.sh: 30: ./tests/shell/stat+shadow_stat.sh: [[: not found
        (standard_in) 2: syntax error
        ./tests/shell/stat+shadow_stat.sh: 36: ./tests/shell/stat+shadow_stat.sh: [[: not found
        ./tests/shell/stat+shadow_stat.sh: 19: ./tests/shell/stat+shadow_stat.sh: [[: not found
        ./tests/shell/stat+shadow_stat.sh: 24: ./tests/shell/stat+shadow_stat.sh: [[: not found
        ./tests/shell/stat+shadow_stat.sh: 30: ./tests/shell/stat+shadow_stat.sh: [[: not found
        (standard_in) 2: syntax error
        ./tests/shell/stat+shadow_stat.sh: 36: ./tests/shell/stat+shadow_stat.sh: [[: not found
        ./tests/shell/stat+shadow_stat.sh: 45: ./tests/shell/stat+shadow_stat.sh: declare: not found
        test child finished with -1
        ---- end ----
        perf stat metrics (shadow stat) test: FAILED!
      
      Reported-by: default avatarJin Yao <yao.jin@linux.intel.com>
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: David Laight <david.laight@aculab.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20210114050609.1258820-1-namhyung@kernel.org
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a042a82d
    • Arnaldo Carvalho de Melo's avatar
      tools headers: Syncronize linux/build_bug.h with the kernel sources · addbdff2
      Arnaldo Carvalho de Melo authored
      To pick up the changes in:
      
        3a176b94
      
       ("Revert "kbuild: avoid static_assert for genksyms"")
      
      And silence this perf build warning:
      
        Warning: Kernel ABI header at 'tools/include/linux/build_bug.h' differs from latest version at 'include/linux/build_bug.h'
        diff -u tools/include/linux/build_bug.h include/linux/build_bug.h
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Masahiro Yamada <masahiroy@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      addbdff2
    • Arnaldo Carvalho de Melo's avatar
      tools headers UAPI: Sync kvm.h headers with the kernel sources · 38c53947
      Arnaldo Carvalho de Melo authored
      To pick the changes in:
      
        647daca2
      
       ("KVM: SVM: Add support for booting APs in an SEV-ES guest")
      
      That don't cause any tooling change, just silences this perf build
      warning:
      
        Warning: Kernel ABI header at 'tools/include/uapi/linux/kvm.h' differs from latest version at 'include/uapi/linux/kvm.h'
        diff -u tools/include/uapi/linux/kvm.h include/uapi/linux/kvm.h
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Tom Lendacky <thomas.lendacky@amd.com>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      38c53947
    • Arnaldo Carvalho de Melo's avatar
      perf bpf examples: Fix bpf.h header include directive in 5sec.c example · 301f0203
      Arnaldo Carvalho de Melo authored
      
      
      It was looking at bpf/bpf.h, which caused this problem:
      
        # perf trace -e tools/perf/examples/bpf/5sec.c
        /home/acme/git/perf/tools/perf/examples/bpf/5sec.c:42:10: fatal error: 'bpf/bpf.h' file not found
        #include <bpf/bpf.h>
                 ^~~~~~~~~~~
        1 error generated.
        ERROR:	unable to compile tools/perf/examples/bpf/5sec.c
        Hint:	Check error message shown above.
        Hint:	You can also pre-compile it into .o using:
             		clang -target bpf -O2 -c tools/perf/examples/bpf/5sec.c
             	with proper -I and -D options.
        event syntax error: 'tools/perf/examples/bpf/5sec.c'
                             \___ Failed to load tools/perf/examples/bpf/5sec.c from source: Error when compiling BPF scriptlet
        #
      
      Change that to plain bpf.h, to make it work again:
      
        # perf trace -e tools/perf/examples/bpf/5sec.c sleep 5s
             0.000 perf_bpf_probe:hrtimer_nanosleep(__probe_ip: -1776891872, rqtp: 5000000000)
        # perf trace -e tools/perf/examples/bpf/5sec.c/max-stack=16/ sleep 5s
             0.000 perf_bpf_probe:hrtimer_nanosleep(__probe_ip: -1776891872, rqtp: 5000000000)
                                               hrtimer_nanosleep ([kernel.kallsyms])
                                               common_nsleep ([kernel.kallsyms])
                                               __x64_sys_clock_nanosleep ([kernel.kallsyms])
                                               do_syscall_64 ([kernel.kallsyms])
                                               entry_SYSCALL_64_after_hwframe ([kernel.kallsyms])
                                               __clock_nanosleep_2 (/usr/lib64/libc-2.32.so)
        # perf trace -e tools/perf/examples/bpf/5sec.c sleep 4s
        #
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      301f0203
    • Linus Torvalds's avatar
      Merge tag 'acpi-5.11-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm · f4e087c6
      Linus Torvalds authored
      Pull ACPI fixes from Rafael Wysocki:
       "These address a device ID bounds check error in the device enumeration
        code and fix a mistake in the documentation.
      
        Specifics:
      
         - Harden the ACPI device enumeration code against device ID length
           overflows to address a Linux VM cash on Hyper-V (Dexuan Cui).
      
         - Fix a mistake in the documentation of error type values for PCIe
           errors (Qiuxu Zhuo)"
      
      * tag 'acpi-5.11-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
        Documentation: ACPI: EINJ: Fix error type values for PCIe errors
        ACPI: scan: Harden acpi_device_add() against device ID overflows
      f4e087c6
    • Linus Torvalds's avatar
      Merge tag 'for-linus-5.11-rc4-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip · dcda487c
      Linus Torvalds authored
      Pull xen fixes from Juergen Gross:
      
       - A series to fix a regression when running as a fully virtualized
         guest on an old Xen hypervisor not supporting PV interrupt callbacks
         for HVM guests.
      
       - A patch to add support to query Xen resource sizes (setting was
         possible already) from user mode.
      
      * tag 'for-linus-5.11-rc4-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip:
        x86/xen: Fix xen_hvm_smp_init() when vector callback not available
        x86/xen: Don't register Xen IPIs when they aren't going to be used
        x86/xen: Add xen_no_vector_callback option to test PCI INTX delivery
        xen: Set platform PCI device INTX affinity to CPU0
        xen: Fix event channel callback via INTX/GSI
        xen/privcmd: allow fetching resource sizes
      dcda487c
    • Linus Torvalds's avatar
      Merge tag 'iommu-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux · 7aec71cd
      Linus Torvalds authored
      Pull iommu fixes from Will Deacon:
       "Three IOMMU fixes for -rc4.
      
        The main one is a change to the Intel IOMMU driver to fix the handling
        of unaligned addresses when invalidating the TLB.
      
        The fix itself is a bit ugly (the caller does a bunch of shifting
        which is then effectively undone later in the callchain), but Lu has
        patches to clean all of this up in 5.12.
      
        Summary:
      
         - Fix address alignment handling for VT-D TLB invalidation
      
         - Enable workarounds for buggy Qualcomm firmware on two more SoCs
      
         - Drop duplicate #include"
      
      * tag 'iommu-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux:
        iommu/vt-d: Fix duplicate included linux/dma-map-ops.h
        iommu: arm-smmu-qcom: Add sdm630/msm8998 compatibles for qcom quirks
        iommu/vt-d: Fix unaligned addresses for intel_flush_svm_range_dev()
      7aec71cd
    • Linus Torvalds's avatar
      Merge tag 'topic/nouveau-ampere-modeset-2021-01-15' of git://anongit.freedesktop.org/drm/drm · 02c06dc3
      Linus Torvalds authored
      Pull drm nouveau ampere display support from Dave Airlie:
       "Ben has requested if we can include Ampere modesetting support under
        fixes, it's for new GPUs and shouldn't affect existing hardware.
      
        It's a bit bigger than just adding a PCI ID, but It has no effect on
        older GPUs"
      
      * tag 'topic/nouveau-ampere-modeset-2021-01-15' of git://anongit.freedesktop.org/drm/drm:
        drm/nouveau/disp/ga10[24]: initial support
        drm/nouveau/dmaobj/ga10[24]: initial support
        drm/nouveau/i2c/ga10[024]: initial support
        drm/nouveau/gpio/ga10[024]: initial support
        drm/nouveau/bar/ga10[024]: initial support
        drm/nouveau/mmu/ga10[024]: initial support
        drm/nouveau/timer/ga10[024]: initial support
        drm/nouveau/fb/ga10[024]: initial support
        drm/nouveau/imem/ga10[024]: initial support
        drm/nouveau/privring/ga10[024]: initial support
        drm/nouveau/mc/ga10[024]: initial support
        drm/nouveau/devinit/ga10[024]: initial support
        drm/nouveau/bios/ga10[024]: initial support
        drm/nouveau/pci/ga10[024]: initial support
        drm/nouveau/core: recognise GA10[024]
      02c06dc3
    • Rafael J. Wysocki's avatar
      Merge branch 'acpi-docs' · 179892ad
      Rafael J. Wysocki authored
      * acpi-docs:
        Documentation: ACPI: EINJ: Fix error type values for PCIe errors
      179892ad
  2. Jan 15, 2021