1. 04 Jan, 2022 26 commits
  2. 03 Jan, 2022 5 commits
  3. 07 Dec, 2021 9 commits
    • Linus Torvalds's avatar
      Merge tag 'perf-tools-fixes-for-v5.16-2021-12-07' of... · 2a987e65
      Linus Torvalds authored
      Merge tag 'perf-tools-fixes-for-v5.16-2021-12-07' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux
      
      Pull perf tools fixes from Arnaldo Carvalho de Melo:
      
       - Fix SMT detection fast read path on sysfs.
      
       - Fix memory leaks when processing feature headers in perf.data files.
      
       - Fix 'Simple expression parser' 'perf test' on arch without CPU die
         topology info, such as s/390.
      
       - Fix building perf with BUILD_BPF_SKEL=1.
      
       - Fix 'perf bench' by reverting "perf bench: Fix two memory leaks
         detected with ASan".
      
       - Fix itrace space allowed for new attributes in 'perf script'.
      
       - Fix the build feature detection fast path, that was always failing on
         systems with python3 development packages, speeding up the build.
      
       - Reset shadow counts before loading, fixing metrics using
         duration_time.
      
       - Sync more kernel headers changed by the new futex_waitv syscall: s390
         and powerpc.
      
      * tag 'perf-tools-fixes-for-v5.16-2021-12-07' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux:
        perf bpf_skel: Do not use typedef to avoid error on old clang
        perf bpf: Fix building perf with BUILD_BPF_SKEL=1 by default in more distros
        perf header: Fix memory leaks when processing feature headers
        perf test: Reset shadow counts before loading
        perf test: Fix 'Simple expression parser' test on arch without CPU die topology info
        tools build: Remove needless libpython-version feature check that breaks test-all fast path
        perf tools: Fix SMT detection fast read path
        tools headers UAPI: Sync powerpc syscall table file changed by new futex_waitv syscall
        perf inject: Fix itrace space allowed for new attributes
        tools headers UAPI: Sync s390 syscall table file changed by new futex_waitv syscall
        Revert "perf bench: Fix two memory leaks detected with ASan"
      2a987e65
    • Linus Torvalds's avatar
      Merge tag 'platform-drivers-x86-v5.16-3' of... · 95723243
      Linus Torvalds authored
      Merge tag 'platform-drivers-x86-v5.16-3' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86
      
      Pull x86 platform driver fixes from Hans de Goede:
       "Various bug-fixes and hardware-id additions"
      
      * tag 'platform-drivers-x86-v5.16-3' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86:
        platform/x86/intel: hid: add quirk to support Surface Go 3
        platform/x86: amd-pmc: Fix s2idle failures on certain AMD laptops
        platform/x86: touchscreen_dmi: Add TrekStor SurfTab duo W1 touchscreen info
        platform/x86: lg-laptop: Recognize more models
        platform/x86: thinkpad_acpi: Add lid_logo_dot to the list of safe LEDs
        platform/x86: thinkpad_acpi: Restore missing hotkey_tablet_mode and hotkey_radio_sw sysfs-attr
      95723243
    • Song Liu's avatar
      perf bpf_skel: Do not use typedef to avoid error on old clang · 5a897531
      Song Liu authored
      When building bpf_skel with clang-10, typedef causes confusions like:
      
        libbpf: map 'prev_readings': unexpected def kind var.
      
      Fix this by removing the typedef.
      
      Fixes: 7fac83aa ("perf stat: Introduce 'bperf' to share hardware PMCs with BPF")
      Reported-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSong Liu <songliubraving@fb.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: http://lore.kernel.org/lkml/BEF5C312-4331-4A60-AEC0-AD7617CB2BC4@fb.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5a897531
    • Song Liu's avatar
      perf bpf: Fix building perf with BUILD_BPF_SKEL=1 by default in more distros · f7c4e85b
      Song Liu authored
      Arnaldo reported that building all his containers with BUILD_BPF_SKEL=1
      to then make this the default he found problems in some distros where
      the system linux/bpf.h file was being used and lacked this:
      
         util/bpf_skel/bperf_leader.bpf.c:13:20: error: use of undeclared identifier 'BPF_F_PRESERVE_ELEMS'
                 __uint(map_flags, BPF_F_PRESERVE_ELEMS);
      
      So use instead the vmlinux.h file generated by bpftool from BTF info.
      
      This fixed these as well, getting the build back working on debian:11,
      debian:experimental and ubuntu:21.10:
      
        In file included from In file included from util/bpf_skel/bperf_leader.bpf.cutil/bpf_skel/bpf_prog_profiler.bpf.c::33:
        :
        In file included from In file included from /usr/include/linux/bpf.h/usr/include/linux/bpf.h::1111:
        :
        /usr/include/linux/types.h/usr/include/linux/types.h::55::1010:: In file included from  util/bpf_skel/bperf_follower.bpf.c:3fatal errorfatal error:
        : : In file included from /usr/include/linux/bpf.h:'asm/types.h' file not found11'asm/types.h' file not found:
      
        /usr/include/linux/types.h:5:10: fatal error: 'asm/types.h' file not found
        #include <asm/types.h>#include <asm/types.h>
      
                 ^~~~~~~~~~~~~         ^~~~~~~~~~~~~
      
        #include <asm/types.h>
                 ^~~~~~~~~~~~~
        1 error generated.
      Reported-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSong Liu <song@kernel.org>
      Tested-by: default avatarAthira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: http://lore.kernel.org/lkml/CF175681-8101-43D1-ABDB-449E644BE986@fb.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f7c4e85b
    • Ian Rogers's avatar
      perf header: Fix memory leaks when processing feature headers · 47473950
      Ian Rogers authored
      These leaks were found with leak sanitizer running "perf pipe recording
      and injection test".
      
      In pipe mode feat_fd may hold onto an events struct that needs freeing.
      
      When string features are processed they may overwrite an already created
      string, so free this before the overwrite.
      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/20211118201730.2302927-1-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      47473950
    • Ian Rogers's avatar
      perf test: Reset shadow counts before loading · 1aa79e57
      Ian Rogers authored
      Otherwise load counting is an average. Without this change
      duration_time in test_memory_bandwidth will alter its value if an
      earlier test contains duration_time.
      
      This patch fixes an issue that's introduced in the proposed patch:
      https://lore.kernel.org/lkml/20211124015226.3317994-1-irogers@google.com/
      in perf test "Parse and process metrics".
      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: Andi Kleen <ak@linux.intel.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20211128085810.4027314-1-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1aa79e57
    • Thomas Richter's avatar
      perf test: Fix 'Simple expression parser' test on arch without CPU die topology info · 6c481031
      Thomas Richter authored
      Some platforms do not have CPU die support, for example s390.
      
      Commit
      Cc: Ian Rogers <irogers@google.com>
      Fixes: fdf1e29b ("perf expr: Add metric literals for topology.")
      fails on s390:
      
        # perf test -Fv 7
          ...
        # FAILED tests/expr.c:173 #num_dies >= #num_packages
          ---- end ----
          Simple expression parser: FAILED!
        #
      
      Investigating this issue leads to these functions:
      
       build_cpu_topology()
         +--> has_die_topology(void)
              {
                 struct utsname uts;
      
                 if (uname(&uts) < 0)
                        return false;
                 if (strncmp(uts.machine, "x86_64", 6))
                        return false;
                 ....
              }
      
      which always returns false on s390. The caller build_cpu_topology()
      checks has_die_topology() return value. On false the the struct
      cpu_topology::die_cpu_list is not contructed and has zero entries. This
      leads to the failing comparison: #num_dies >= #num_packages.  s390 of
      course has a positive number of packages.
      
      Fix this and check if the function build_cpu_topology() did build up
      a die_cpus_list. The number of entries in this list should be larger
      than 0. If the number of list element is zero, the die_cpus_list has
      not been created and the check in function test__expr():
      
          TEST_ASSERT_VAL("#num_dies >= #num_packages", \
      		    num_dies >= num_packages)
      
      always fails.
      
      Output after:
      
        # perf test -Fv 7
         7: Simple expression parser                                        :
         --- start ---
         division by zero
         syntax error
         ---- end ----
         Simple expression parser: Ok
        #
      
      Fixes: fdf1e29b ("perf expr: Add metric literals for topology.")
      Signed-off-by: default avatarThomas Richter <tmricht@linux.ibm.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
      Cc: Sven Schnelle <svens@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Link: http://lore.kernel.org/lkml/20211129112339.3003036-1-tmricht@linux.ibm.com
      [ Added comment in the added 'if (num_dies)' line about architectures not having die topology ]
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6c481031
    • Arnaldo Carvalho de Melo's avatar
      tools build: Remove needless libpython-version feature check that breaks test-all fast path · 3d1d57de
      Arnaldo Carvalho de Melo authored
      Since 66dfdff0 ("perf tools: Add Python 3 support") we don't use
      the tools/build/feature/test-libpython-version.c version in any Makefile
      feature check:
      
        $ find tools/ -type f | xargs grep feature-libpython-version
        $
      
      The only place where this was used was removed in 66dfdff0:
      
        -        ifneq ($(feature-libpython-version), 1)
        -          $(warning Python 3 is not yet supported; please set)
        -          $(warning PYTHON and/or PYTHON_CONFIG appropriately.)
        -          $(warning If you also have Python 2 installed, then)
        -          $(warning try something like:)
        -          $(warning $(and ,))
        -          $(warning $(and ,)  make PYTHON=python2)
        -          $(warning $(and ,))
        -          $(warning Otherwise, disable Python support entirely:)
        -          $(warning $(and ,))
        -          $(warning $(and ,)  make NO_LIBPYTHON=1)
        -          $(warning $(and ,))
        -          $(error   $(and ,))
        -        else
        -          LDFLAGS += $(PYTHON_EMBED_LDFLAGS)
        -          EXTLIBS += $(PYTHON_EMBED_LIBADD)
        -          LANG_BINDINGS += $(obj-perf)python/perf.so
        -          $(call detected,CONFIG_LIBPYTHON)
        -        endif
      
      And nowadays we either build with PYTHON=python3 or just install the
      python3 devel packages and perf will build against it.
      
      But the leftover feature-libpython-version check made the fast path
      feature detection to break in all cases except when python2 devel files
      were installed:
      
        $ rpm -qa | grep python.*devel
        python3-devel-3.9.7-1.fc34.x86_64
        $ rm -rf /tmp/build/perf ; mkdir -p /tmp/build/perf ;
        $ make -C tools/perf O=/tmp/build/perf install-bin
        make: Entering directory '/var/home/acme/git/perf/tools/perf'
          BUILD:   Doing 'make -j32' parallel build
          HOSTCC  /tmp/build/perf/fixdep.o
        <SNIP>
        $ cat /tmp/build/perf/feature/test-all.make.output
        In file included from test-all.c:18:
        test-libpython-version.c:5:10: error: #error
            5 |         #error
              |          ^~~~~
        $ ldd ~/bin/perf | grep python
      	libpython3.9.so.1.0 => /lib64/libpython3.9.so.1.0 (0x00007fda6dbcf000)
        $
      
      As python3 is the norm these days, fix this by just removing the unused
      feature-libpython-version feature check, making the test-all fast path
      to work with the common case.
      
      With this:
      
        $ rm -rf /tmp/build/perf ; mkdir -p /tmp/build/perf ;
        $ make -C tools/perf O=/tmp/build/perf install-bin |& head
        make: Entering directory '/var/home/acme/git/perf/tools/perf'
          BUILD:   Doing 'make -j32' parallel build
          HOSTCC  /tmp/build/perf/fixdep.o
          HOSTLD  /tmp/build/perf/fixdep-in.o
          LINK    /tmp/build/perf/fixdep
      
        Auto-detecting system features:
        ...                         dwarf: [ on  ]
        ...            dwarf_getlocations: [ on  ]
        ...                         glibc: [ on  ]
        $ ldd ~/bin/perf | grep python
      	libpython3.9.so.1.0 => /lib64/libpython3.9.so.1.0 (0x00007f58800b0000)
        $ cat /tmp/build/perf/feature/test-all.make.output
        $
      Reviewed-by: default avatarJames Clark <james.clark@arm.com>
      Fixes: 66dfdff0 ("perf tools: Add Python 3 support")
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jaroslav Škarvada <jskarvad@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/lkml/YaYmeeC6CS2b8OSz@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      3d1d57de
    • Ian Rogers's avatar
      perf tools: Fix SMT detection fast read path · 4ffbe87e
      Ian Rogers authored
      sysfs__read_int() returns 0 on success, and so the fast read path was
      always failing.
      
      Fixes: bb629484 ("perf tools: Simplify checking if SMT is active.")
      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: Jiri Olsa <jolsa@redhat.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Konstantin Khlebnikov <koct9i@gmail.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20211124001231.3277836-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      4ffbe87e