Skip to content
Snippets Groups Projects
  1. Apr 01, 2021
  2. Mar 30, 2021
  3. Mar 26, 2021
    • Leo Yan's avatar
      perf test: Change to use bash for daemon test · 1dc481c0
      Leo Yan authored
      When executing the daemon test on Arm64 and x86 with Debian (Buster)
      distro, both skip the test case with the log:
      
        # ./perf test -v 76
        76: daemon operations                                               :
        --- start ---
        test child forked, pid 11687
        test daemon list
        trap: SIGINT: bad trap
        ./tests/shell/daemon.sh: 173: local: cpu-clock: bad variable name
        test child finished with -2
        ---- end ----
        daemon operations: Skip
      
      So the error happens for the variable expansion when use local variable
      in the shell script.  Since Debian Buster uses dash but not bash as
      non-interactive shell, when execute the daemon testing, it hits a known
      issue for dash which was reported [1].
      
      To resolve this issue, one option is to add double quotes for all local
      variables assignment, so need to change the code from:
      
        local line=`perf daemon --config ${config} -x: | head -2 | tail -1`
      
        ... to:
      
        local line="`perf daemon --config ${config} -x: | head -2 | tail -1`"
      
      But the testing script has bunch of local variables, this leads to big
      changes for whole script.
      
      On the other hand, the testing script asks to use the "local" feature
      which is bash-specific, so this patch explicitly uses "#!/bin/bash" to
      ensure running the script with bash.
      
      After:
      
        # ./perf test -v 76
        76: daemon operations                                               :
        --- start ---
        test child forked, pid 11329
        test daemon list
        test daemon reconfig
        test daemon stop
        test daemon signal
        signal 12 sent to session 'test [11596]'
        signal 12 sent to session 'test [11596]'
        test daemon ping
        test daemon lock
        test child finished with 0
        ---- end ----
        daemon operations: Ok
      
      [1] https://bugs.launchpad.net/ubuntu/+source/dash/+bug/139097
      
      
      
      Fixes: 2291bb91 ("perf tests: Add daemon 'list' command test")
      Signed-off-by: default avatarLeo Yan <leo.yan@linaro.org>
      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: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20210320104554.529213-1-leo.yan@linaro.org
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1dc481c0
  4. Mar 25, 2021
  5. Mar 24, 2021
    • Namhyung Kim's avatar
      perf record: Fix memory leak in vDSO found using ASAN · 41d58541
      Namhyung Kim authored
      
      I got several memory leak reports from Asan with a simple command.  It
      was because VDSO is not released due to the refcount.  Like in
      __dsos_addnew_id(), it should put the refcount after adding to the list.
      
        $ perf record true
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.030 MB perf.data (10 samples) ]
      
        =================================================================
        ==692599==ERROR: LeakSanitizer: detected memory leaks
      
        Direct leak of 439 byte(s) in 1 object(s) allocated from:
          #0 0x7fea52341037 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
          #1 0x559bce4aa8ee in dso__new_id util/dso.c:1256
          #2 0x559bce59245a in __machine__addnew_vdso util/vdso.c:132
          #3 0x559bce59245a in machine__findnew_vdso util/vdso.c:347
          #4 0x559bce50826c in map__new util/map.c:175
          #5 0x559bce503c92 in machine__process_mmap2_event util/machine.c:1787
          #6 0x559bce512f6b in machines__deliver_event util/session.c:1481
          #7 0x559bce515107 in perf_session__deliver_event util/session.c:1551
          #8 0x559bce51d4d2 in do_flush util/ordered-events.c:244
          #9 0x559bce51d4d2 in __ordered_events__flush util/ordered-events.c:323
          #10 0x559bce519bea in __perf_session__process_events util/session.c:2268
          #11 0x559bce519bea in perf_session__process_events util/session.c:2297
          #12 0x559bce2e7a52 in process_buildids /home/namhyung/project/linux/tools/perf/builtin-record.c:1017
          #13 0x559bce2e7a52 in record__finish_output /home/namhyung/project/linux/tools/perf/builtin-record.c:1234
          #14 0x559bce2ed4f6 in __cmd_record /home/namhyung/project/linux/tools/perf/builtin-record.c:2026
          #15 0x559bce2ed4f6 in cmd_record /home/namhyung/project/linux/tools/perf/builtin-record.c:2858
          #16 0x559bce422db4 in run_builtin /home/namhyung/project/linux/tools/perf/perf.c:313
          #17 0x559bce2acac8 in handle_internal_command /home/namhyung/project/linux/tools/perf/perf.c:365
          #18 0x559bce2acac8 in run_argv /home/namhyung/project/linux/tools/perf/perf.c:409
          #19 0x559bce2acac8 in main /home/namhyung/project/linux/tools/perf/perf.c:539
          #20 0x7fea51e76d09 in __libc_start_main ../csu/libc-start.c:308
      
        Indirect leak of 32 byte(s) in 1 object(s) allocated from:
          #0 0x7fea52341037 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
          #1 0x559bce520907 in nsinfo__copy util/namespaces.c:169
          #2 0x559bce50821b in map__new util/map.c:168
          #3 0x559bce503c92 in machine__process_mmap2_event util/machine.c:1787
          #4 0x559bce512f6b in machines__deliver_event util/session.c:1481
          #5 0x559bce515107 in perf_session__deliver_event util/session.c:1551
          #6 0x559bce51d4d2 in do_flush util/ordered-events.c:244
          #7 0x559bce51d4d2 in __ordered_events__flush util/ordered-events.c:323
          #8 0x559bce519bea in __perf_session__process_events util/session.c:2268
          #9 0x559bce519bea in perf_session__process_events util/session.c:2297
          #10 0x559bce2e7a52 in process_buildids /home/namhyung/project/linux/tools/perf/builtin-record.c:1017
          #11 0x559bce2e7a52 in record__finish_output /home/namhyung/project/linux/tools/perf/builtin-record.c:1234
          #12 0x559bce2ed4f6 in __cmd_record /home/namhyung/project/linux/tools/perf/builtin-record.c:2026
          #13 0x559bce2ed4f6 in cmd_record /home/namhyung/project/linux/tools/perf/builtin-record.c:2858
          #14 0x559bce422db4 in run_builtin /home/namhyung/project/linux/tools/perf/perf.c:313
          #15 0x559bce2acac8 in handle_internal_command /home/namhyung/project/linux/tools/perf/perf.c:365
          #16 0x559bce2acac8 in run_argv /home/namhyung/project/linux/tools/perf/perf.c:409
          #17 0x559bce2acac8 in main /home/namhyung/project/linux/tools/perf/perf.c:539
          #18 0x7fea51e76d09 in __libc_start_main ../csu/libc-start.c:308
      
        SUMMARY: AddressSanitizer: 471 byte(s) leaked in 2 allocation(s).
      
      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: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20210315045641.700430-1-namhyung@kernel.org
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      41d58541
    • Thomas Richter's avatar
      perf test: Remove now useless failing sub test "BPF relocation checker" · eb8f998b
      Thomas Richter authored
      
      For some time now the 'perf test 42: BPF filter' returns an error on bpf
      relocation subtest, at least on x86 and s390. This is caused by
      
        d859900c ("bpf, libbpf: support global data/bss/rodata sections")
      
      which introduces support for global variables in eBPF programs.
      
      Perf test 42.4 checks that the eBPF relocation fails when the eBPF program
      contains a global variable. It returns OK when the eBPF program
      could not be loaded and FAILED otherwise.
      
      With above commit the test logic for the eBPF relocation is obsolete.
      The loading of the eBPF now succeeds and the test always shows FAILED.
      
      This patch removes the sub test completely.
      Also a lot of eBPF program testing is done in the eBPF test suite,
      it also contains tests for global variables.
      
      Output before:
       42: BPF filter                          :
       42.1: Basic BPF filtering               : Ok
       42.2: BPF pinning                       : Ok
       42.3: BPF prologue generation           : Ok
       42.4: BPF relocation checker            : Failed
       #
      
      Output after:
       # ./perf test -F 42
       42: BPF filter                          :
       42.1: Basic BPF filtering               : Ok
       42.2: BPF pinning                       : Ok
       42.3: BPF prologue generation           : Ok
       #
      
      Signed-off-by: default avatarThomas Richter <tmricht@linux.ibm.com>
      Suggested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.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/20210324083734.1953123-1-tmricht@linux.ibm.com
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      eb8f998b
    • Jiri Olsa's avatar
      perf daemon: Return from kill functions · 9f177fd8
      Jiri Olsa authored
      
      We should return correctly and warn in both daemon_session__kill() and
      daemon__kill() after we tried everything to kill sessions.  The current
      code will keep on looping and waiting.
      
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.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>
      Link: http://lore.kernel.org/lkml/20210320221013.1619613-2-jolsa@kernel.org
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      9f177fd8
    • Jiri Olsa's avatar
      perf daemon: Force waipid for all session on SIGCHLD delivery · 1833b64f
      Jiri Olsa authored
      
      If we don't process SIGCHLD before another comes, we will see just one
      SIGCHLD as a result. In this case current code will miss exit
      notification for a session and wait forever.
      
      Adding extra waitpid check for all sessions when SIGCHLD is received, to
      make sure we don't miss any session exit.
      
      Also fix close condition for signal_fd.
      
      Reported-by: default avatarIan Rogers <irogers@google.com>
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.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>
      Link: http://lore.kernel.org/lkml/20210320221013.1619613-1-jolsa@kernel.org
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1833b64f
  6. Mar 22, 2021
    • Andre Przywara's avatar
      kselftest/arm64: sve: Do not use non-canonical FFR register value · 7011d725
      Andre Przywara authored
      
      The "First Fault Register" (FFR) is an SVE register that mimics a
      predicate register, but clears bits when a load or store fails to handle
      an element of a vector. The supposed usage scenario is to initialise
      this register (using SETFFR), then *read* it later on to learn about
      elements that failed to load or store. Explicit writes to this register
      using the WRFFR instruction are only supposed to *restore* values
      previously read from the register (for context-switching only).
      As the manual describes, this register holds only certain values, it:
      "... contains a monotonic predicate value, in which starting from bit 0
      there are zero or more 1 bits, followed only by 0 bits in any remaining
      bit positions."
      Any other value is UNPREDICTABLE and is not supposed to be "restored"
      into the register.
      
      The SVE test currently tries to write a signature pattern into the
      register, which is *not* a canonical FFR value. Apparently the existing
      setups treat UNPREDICTABLE as "read-as-written", but a new
      implementation actually only stores canonical values. As a consequence,
      the sve-test fails immediately when comparing the FFR value:
      -----------
       # ./sve-test
      Vector length:  128 bits
      PID:    207
      Mismatch: PID=207, iteration=0, reg=48
              Expected [cf00]
              Got      [0f00]
      Aborted
      -----------
      
      Fix this by only populating the FFR with proper canonical values.
      Effectively the requirement described above limits us to 17 unique
      values over 16 bits worth of FFR, so we condense our signature down to 4
      bits (2 bits from the PID, 2 bits from the generation) and generate the
      canonical pattern from it. Any bits describing elements above the
      minimum 128 bit are set to 0.
      
      This aligns the FFR usage to the architecture and fixes the test on
      microarchitectures implementing FFR in a more restricted way.
      
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      Reviwed-by: default avatarMark Brown <broonie@kernel.org>
      Link: https://lore.kernel.org/r/20210319120128.29452-1-andre.przywara@arm.com
      
      
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      7011d725
  7. Mar 19, 2021
    • Jean-Philippe Brucker's avatar
      selftests/bpf: Add selftest for pointer-to-array-of-struct BTF dump · f118aac6
      Jean-Philippe Brucker authored
      
      Bpftool used to issue forward declarations for a struct used as part of
      a pointer to array, which is invalid. Add a test to check that the
      struct is fully defined in this case:
      
      	@@ -134,9 +134,9 @@
      	 	};
      	 };
      
      	-struct struct_in_array {};
      	+struct struct_in_array;
      
      	-struct struct_in_array_typed {};
      	+struct struct_in_array_typed;
      
      	 typedef struct struct_in_array_typed struct_in_array_t[2];
      
      	@@ -189,3 +189,7 @@
      	 	struct struct_with_embedded_stuff _14;
      	 };
      
      	+struct struct_in_array {};
      	+
      	+struct struct_in_array_typed {};
      	+
      	...
      	#13/1 btf_dump: syntax:FAIL
      
      Suggested-by: default avatarAndrii Nakryiko <andrii.nakryiko@gmail.com>
      Signed-off-by: default avatarJean-Philippe Brucker <jean-philippe@linaro.org>
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/bpf/20210319112554.794552-3-jean-philippe@linaro.org
      f118aac6
    • Jean-Philippe Brucker's avatar
      libbpf: Fix BTF dump of pointer-to-array-of-struct · 901ee1d7
      Jean-Philippe Brucker authored
      
      The vmlinux.h generated from BTF is invalid when building
      drivers/phy/ti/phy-gmii-sel.c with clang:
      
      vmlinux.h:61702:27: error: array type has incomplete element type ‘struct reg_field’
      61702 |  const struct reg_field (*regfields)[3];
            |                           ^~~~~~~~~
      
      bpftool generates a forward declaration for this struct regfield, which
      compilers aren't happy about. Here's a simplified reproducer:
      
      	struct inner {
      		int val;
      	};
      	struct outer {
      		struct inner (*ptr_to_array)[2];
      	} A;
      
      After build with clang -> bpftool btf dump c -> clang/gcc:
      ./def-clang.h:11:23: error: array has incomplete element type 'struct inner'
              struct inner (*ptr_to_array)[2];
      
      Member ptr_to_array of struct outer is a pointer to an array of struct
      inner. In the DWARF generated by clang, struct outer appears before
      struct inner, so when converting BTF of struct outer into C, bpftool
      issues a forward declaration to struct inner. With GCC the DWARF info is
      reversed so struct inner gets fully defined.
      
      That forward declaration is not sufficient when compilers handle an
      array of the struct, even when it's only used through a pointer. Note
      that we can trigger the same issue with an intermediate typedef:
      
      	struct inner {
      	        int val;
      	};
      	typedef struct inner inner2_t[2];
      	struct outer {
      	        inner2_t *ptr_to_array;
      	} A;
      
      Becomes:
      
      	struct inner;
      	typedef struct inner inner2_t[2];
      
      And causes:
      
      ./def-clang.h:10:30: error: array has incomplete element type 'struct inner'
      	typedef struct inner inner2_t[2];
      
      To fix this, clear through_ptr whenever we encounter an intermediate
      array, to make the inner struct part of a strong link and force full
      declaration.
      
      Fixes: 351131b5 ("libbpf: add btf_dump API for BTF-to-C conversion")
      Signed-off-by: default avatarJean-Philippe Brucker <jean-philippe@linaro.org>
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/bpf/20210319112554.794552-2-jean-philippe@linaro.org
      901ee1d7
    • Hangbin Liu's avatar
      selftests: forwarding: vxlan_bridge_1d: Fix vxlan ecn decapsulate value · 5aa3c334
      Hangbin Liu authored
      
      The ECN bit defines ECT(1) = 1, ECT(0) = 2. So inner 0x02 + outer 0x01
      should be inner ECT(0) + outer ECT(1). Based on the description of
      __INET_ECN_decapsulate, the final decapsulate value should be
      ECT(1). So fix the test expect value to 0x01.
      
      Before the fix:
      TEST: VXLAN: ECN decap: 01/02->0x02                                 [FAIL]
              Expected to capture 10 packets, got 0.
      
      After the fix:
      TEST: VXLAN: ECN decap: 01/02->0x01                                 [ OK ]
      
      Fixes: a0b61f3d ("selftests: forwarding: vxlan_bridge_1d: Add an ECN decap test")
      Signed-off-by: default avatarHangbin Liu <liuhangbin@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      5aa3c334
  8. Mar 18, 2021
  9. Mar 17, 2021
  10. Mar 16, 2021
  11. Mar 15, 2021
    • Hangbin Liu's avatar
      selftests/bpf: Set gopt opt_class to 0 if get tunnel opt failed · 31254dc9
      Hangbin Liu authored
      
      When fixing the bpf test_tunnel.sh geneve failure. I only fixed the IPv4
      part but forgot the IPv6 issue. Similar with the IPv4 fixes 557c223b
      ("selftests/bpf: No need to drop the packet when there is no geneve opt"),
      when there is no tunnel option and bpf_skb_get_tunnel_opt() returns error,
      there is no need to drop the packets and break all geneve rx traffic.
      Just set opt_class to 0 and keep returning TC_ACT_OK at the end.
      
      Fixes: 557c223b ("selftests/bpf: No need to drop the packet when there is no geneve opt")
      Fixes: 933a741e ("selftests/bpf: bpf tunnel test.")
      Signed-off-by: default avatarHangbin Liu <liuhangbin@gmail.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarWilliam Tu <u9012063@gmail.com>
      Link: https://lore.kernel.org/bpf/20210309032214.2112438-1-liuhangbin@gmail.com
      31254dc9
    • Jin Yao's avatar
      perf pmu: Validate raw event with sysfs exported format bits · e4064776
      Jin Yao authored
      
      A raw PMU event (eventsel+umask) in the form of rNNN is supported
      by perf but lacks of checking for the validity of raw encoding.
      
      For example, bit 16 and bit 17 are not valid on KBL but perf doesn't
      report warning when encoding with these bits.
      
      Before:
      
        # ./perf stat -e cpu/r031234/ -a -- sleep 1
      
         Performance counter stats for 'system wide':
      
                         0      cpu/r031234/
      
               1.003798924 seconds time elapsed
      
      It may silently measure the wrong event!
      
      The kernel supported bits have been exported through
      /sys/devices/<pmu>/format/. Perf collects the information to
      'struct perf_pmu_format' and links it to 'pmu->format' list.
      
      The 'struct perf_pmu_format' has a bitmap which records the
      valid bits for this format. For example,
      
        root@kbl-ppc:/sys/devices/cpu/format# cat umask
        config:8-15
      
      The valid bits (bit8-bit15) are recorded in bitmap of format 'umask'.
      
      We collect total valid bits of all formats, save to a local variable
      'masks' and reverse it. Now '~masks' represents total invalid bits.
      
      bits = config & ~masks;
      
      The set bits in 'bits' indicate the invalid bits used in config.
      Finally we use bitmap_scnprintf to report the invalid bits.
      
      Some architectures may not export supported bits through sysfs,
      so if masks is 0, perf_pmu__warn_invalid_config directly returns.
      
      After:
      
      Single event without name:
      
        # ./perf stat -e cpu/r031234/ -a -- sleep 1
        WARNING: event 'N/A' not valid (bits 16-17 of config '31234' not supported by kernel)!
      
         Performance counter stats for 'system wide':
      
                         0      cpu/r031234/
      
               1.001597373 seconds time elapsed
      
      Multiple events with names:
      
        # ./perf stat -e cpu/rf01234,name=aaa/,cpu/r031234,name=bbb/ -a -- sleep 1
        WARNING: event 'aaa' not valid (bits 20,22 of config 'f01234' not supported by kernel)!
        WARNING: event 'bbb' not valid (bits 16-17 of config '31234' not supported by kernel)!
      
         Performance counter stats for 'system wide':
      
                         0      aaa
                         0      bbb
      
               1.001573787 seconds time elapsed
      
      Warnings are reported for invalid bits.
      
      Co-developed-by: default avatarJiri Olsa <jolsa@redhat.com>
      Signed-off-by: default avatarJin Yao <yao.jin@linux.intel.com>
      Reviewed-by: default avatarJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jin Yao <yao.jin@intel.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20210310051138.12154-1-yao.jin@linux.intel.com
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e4064776
  12. Mar 13, 2021
  13. Mar 12, 2021
  14. Mar 11, 2021
  15. Mar 10, 2021
  16. Mar 08, 2021
Loading