Skip to content
  1. Apr 05, 2022
    • Andrii Nakryiko's avatar
      libbpf: Add BPF-side of USDT support · d72e2968
      Andrii Nakryiko authored
      
      
      Add BPF-side implementation of libbpf-provided USDT support. This
      consists of single header library, usdt.bpf.h, which is meant to be used
      from user's BPF-side source code. This header is added to the list of
      installed libbpf header, along bpf_helpers.h and others.
      
      BPF-side implementation consists of two BPF maps:
        - spec map, which contains "a USDT spec" which encodes information
          necessary to be able to fetch USDT arguments and other information
          (argument count, user-provided cookie value, etc) at runtime;
        - IP-to-spec-ID map, which is only used on kernels that don't support
          BPF cookie feature. It allows to lookup spec ID based on the place
          in user application that triggers USDT program.
      
      These maps have default sizes, 256 and 1024, which are chosen
      conservatively to not waste a lot of space, but handling a lot of common
      cases. But there could be cases when user application needs to either
      trace a lot of different USDTs, or USDTs are heavily inlined and their
      arguments are located in a lot of differing locations. For such cases it
      might be necessary to size those maps up, which libbpf allows to do by
      overriding BPF_USDT_MAX_SPEC_CNT and BPF_USDT_MAX_IP_CNT macros.
      
      It is an important aspect to keep in mind. Single USDT (user-space
      equivalent of kernel tracepoint) can have multiple USDT "call sites".
      That is, single logical USDT is triggered from multiple places in user
      application. This can happen due to function inlining. Each such inlined
      instance of USDT invocation can have its own unique USDT argument
      specification (instructions about the location of the value of each of
      USDT arguments). So while USDT looks very similar to usual uprobe or
      kernel tracepoint, under the hood it's actually a collection of uprobes,
      each potentially needing different spec to know how to fetch arguments.
      
      User-visible API consists of three helper functions:
        - bpf_usdt_arg_cnt(), which returns number of arguments of current USDT;
        - bpf_usdt_arg(), which reads value of specified USDT argument (by
          it's zero-indexed position) and returns it as 64-bit value;
        - bpf_usdt_cookie(), which functions like BPF cookie for USDT
          programs; this is necessary as libbpf doesn't allow specifying actual
          BPF cookie and utilizes it internally for USDT support implementation.
      
      Each bpf_usdt_xxx() APIs expect struct pt_regs * context, passed into
      BPF program. On kernels that don't support BPF cookie it is used to
      fetch absolute IP address of the underlying uprobe.
      
      usdt.bpf.h also provides BPF_USDT() macro, which functions like
      BPF_PROG() and BPF_KPROBE() and allows much more user-friendly way to
      get access to USDT arguments, if USDT definition is static and known to
      the user. It is expected that majority of use cases won't have to use
      bpf_usdt_arg_cnt() and bpf_usdt_arg() directly and BPF_USDT() will cover
      all their needs.
      
      Last, usdt.bpf.h is utilizing BPF CO-RE for one single purpose: to
      detect kernel support for BPF cookie. If BPF CO-RE dependency is
      undesirable, user application can redefine BPF_USDT_HAS_BPF_COOKIE to
      either a boolean constant (or equivalently zero and non-zero), or even
      point it to its own .rodata variable that can be specified from user's
      application user-space code. It is important that
      BPF_USDT_HAS_BPF_COOKIE is known to BPF verifier as static value (thus
      .rodata and not just .data), as otherwise BPF code will still contain
      bpf_get_attach_cookie() BPF helper call and will fail validation at
      runtime, if not dead-code eliminated.
      
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Reviewed-by: default avatarAlan Maguire <alan.maguire@oracle.com>
      Link: https://lore.kernel.org/bpf/20220404234202.331384-2-andrii@kernel.org
      d72e2968
  2. Apr 04, 2022
  3. Apr 03, 2022
  4. Apr 01, 2022
  5. Mar 31, 2022
  6. Mar 29, 2022
  7. Mar 28, 2022
  8. Mar 26, 2022
    • Jakub Kicinski's avatar
      selftests: tls: skip cmsg_to_pipe tests with TLS=n · 5c7e49be
      Jakub Kicinski authored
      
      
      These are negative tests, testing TLS code rejects certain
      operations. They won't pass without TLS enabled, pure TCP
      accepts those operations.
      
      Reported-by: default avatarLinux Kernel Functional Testing <lkft@linaro.org>
      Fixes: d87d67fd ("selftests: tls: test splicing cmsgs")
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Reviewed-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      5c7e49be
    • Kim Phillips's avatar
      perf evsel: Improve AMD IBS (Instruction-Based Sampling) error handling messages · ab0809af
      Kim Phillips authored
      
      
      Improve the error message returned on failed perf_event_open() on AMD
      systems when using IBS (Instruction-Based Sampling).
      
      Output of executing 'perf record -e ibs_op// true' as a non root user
      BEFORE this patch (perf will add the 'u' modifier at the end to exclude
      kernel/hypervisor sampling):
      
        The sys_perf_event_open() syscall returned with 22 (Invalid argument)for event (ibs_op//u).
        /bin/dmesg | grep -i perf may provide additional information.
      
      Output after:
      
        AMD IBS can't exclude kernel events.  Try running at a higher privilege level.
      
      Output of executing 'sudo perf record -e ibs_op// true' BEFORE this patch:
      
        Error:
        The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (ibs_op//).
        /bin/dmesg | grep -i perf may provide additional information.
      
      Output after:
      
        Error:
        Invalid event (ibs_op//) in per-thread mode, enable system wide with '-a'.
      
      Folowing the suggestion:
      
        $ sudo perf record -a -e ibs_op// true
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 1.664 MB perf.data (194 samples) ]
        $
      
      Signed-off-by: default avatarKim Phillips <kim.phillips@amd.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: João Martins <joao.m.martins@oracle.com>
      Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.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>
      Cc: Rafael J. Wysocki <rafael@kernel.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Robert Richter <robert.richter@amd.com>
      Cc: Sandipan Das <sandipan.das@amd.com>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20220322221517.2510440-12-eranian@google.com
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ab0809af
    • Arnaldo Carvalho de Melo's avatar
      perf python: Add perf_env stubs that will be needed in evsel__open_strerror() · b58230de
      Arnaldo Carvalho de Melo authored
      
      
      The AMD IBS error message enhancements will use these, but we're not
      using evsel__open_strerror() in the python binding so far.
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b58230de
    • Wei Li's avatar
      perf tools: Enhance the matching of sub-commands abbreviations · ae0f4eb3
      Wei Li authored
      
      
      We support short command 'rec*' for 'record' and 'rep*' for 'report' in
      lots of sub-commands, but the matching is not quite strict currnetly.
      
      It may be puzzling sometime, like we mis-type a 'recport' to report but
      it will perform 'record' in fact without any message.
      
      To fix this, add a check to ensure that the short cmd is valid prefix
      of the real command.
      
      Committer testing:
      
        [root@quaco ~]# perf c2c re sleep 1
      
         Usage: perf c2c {record|report}
      
            -v, --verbose         be more verbose (show counter open errors, etc)
      
        # perf c2c rec sleep 1
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.038 MB perf.data (16 samples) ]
        # perf c2c recport sleep 1
      
         Usage: perf c2c {record|report}
      
            -v, --verbose         be more verbose (show counter open errors, etc)
      
        # perf c2c record sleep 1
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.038 MB perf.data (15 samples) ]
        # perf c2c records sleep 1
      
         Usage: perf c2c {record|report}
      
            -v, --verbose         be more verbose (show counter open errors, etc)
      
        #
      
      Signed-off-by: default avatarWei Li <liwei391@huawei.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Hanjun Guo <guohanjun@huawei.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Rui Xiang <rui.xiang@huawei.com>
      Link: http://lore.kernel.org/lkml/20220325092032.2956161-1-liwei391@huawei.com
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ae0f4eb3
    • Shunsuke Nakamura's avatar
      libperf tests: Fix typo in perf_evlist__open() failure error messages · c2eeac98
      Shunsuke Nakamura authored
      
      
      This patch corrects typos in error messages. I should be "evlist", not
      "evsel" as the function that fails is perf_evlist__open().
      
      Fixes: 3ce311af ("libperf: Move to tools/lib/perf")
      Fixes: a7f3713f ("libperf tests: Add test_stat_multiplexing test")
      Signed-off-by: default avatarShunsuke Nakamura <nakamura.shun@fujitsu.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.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: http://lore.kernel.org/lkml/20220325043829.224045-2-nakamura.shun@fujitsu.com
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c2eeac98
    • Ali Saidi's avatar
      tools arm64: Import cputype.h · 1314376d
      Ali Saidi authored
      
      
      Bring-in the kernel's arch/arm64/include/asm/cputype.h into tools/
      for arm64 to make use of all the core-type definitions in perf.
      
      Replace sysreg.h with the version already imported into tools/.
      
      Committer notes:
      
      Added an entry to tools/perf/check-headers.sh, so that we get notified
      when the original file in the kernel sources gets modified.
      
      Tester notes:
      
      LGTM. I did the testing on both my x86 and Arm64 platforms, thanks for
      the fixing up.
      
      Signed-off-by: default avatarAli Saidi <alisaidi@amazon.com>
      Tested-by: default avatarLeo Yan <leo.yan@linaro.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andrew Kilroy <andrew.kilroy@arm.com>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Li Huafei <lihuafei1@huawei.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nick.Forrington@arm.com
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20220324183323.31414-2-alisaidi@amazon.com
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1314376d
    • Ido Schimmel's avatar
      selftests: test_vxlan_under_vrf: Fix broken test case · b50d3b46
      Ido Schimmel authored
      
      
      The purpose of the last test case is to test VXLAN encapsulation and
      decapsulation when the underlay lookup takes place in a non-default VRF.
      This is achieved by enslaving the physical device of the tunnel to a
      VRF.
      
      The binding of the VXLAN UDP socket to the VRF happens when the VXLAN
      device itself is opened, not when its physical device is opened. This
      was also mentioned in the cited commit ("tests that moving the underlay
      from a VRF to another works when down/up the VXLAN interface"), but the
      test did something else.
      
      Fix it by reopening the VXLAN device instead of its physical device.
      
      Before:
      
       # ./test_vxlan_under_vrf.sh
       Checking HV connectivity                                           [ OK ]
       Check VM connectivity through VXLAN (underlay in the default VRF)  [ OK ]
       Check VM connectivity through VXLAN (underlay in a VRF)            [FAIL]
      
      After:
      
       # ./test_vxlan_under_vrf.sh
       Checking HV connectivity                                           [ OK ]
       Check VM connectivity through VXLAN (underlay in the default VRF)  [ OK ]
       Check VM connectivity through VXLAN (underlay in a VRF)            [ OK ]
      
      Fixes: 03f1c26b ("test/net: Add script for VXLAN underlay in a VRF")
      Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
      Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
      Link: https://lore.kernel.org/r/20220324200514.1638326-1-idosch@nvidia.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      b50d3b46
  9. Mar 25, 2022
Loading