BPF List
 help / color / mirror / Atom feed
From: sdf@google.com
To: Andrii Nakryiko <andrii@kernel.org>
Cc: bpf@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net,
	kernel-team@fb.com
Subject: Re: [PATCH v2 bpf-next 0/5] Add SEC("ksyscall") support
Date: Thu, 14 Jul 2022 11:31:53 -0700	[thread overview]
Message-ID: <YtBhGSRqFckLewHQ@google.com> (raw)
In-Reply-To: <20220714070755.3235561-1-andrii@kernel.org>

On 07/14, Andrii Nakryiko wrote:
> Add SEC("ksyscall")/SEC("kretsyscall") sections and corresponding
> bpf_program__attach_ksyscall() API that simplifies tracing kernel syscalls
> through kprobe mechanism. Kprobing syscalls isn't trivial due to varying
> syscall handler names in the kernel and various ways syscall argument are
> passed, depending on kernel architecture and configuration.  
> SEC("ksyscall")
> allows user to not care about such details and just get access to syscall
> input arguments, while libbpf takes care of necessary feature detection  
> logic.

> There are still more quirks that are not straightforward to hide  
> completely
> (see comments about mmap(), clone() and compat syscalls), so in such more
> advanced scenarios user might need to fall back to plain SEC("kprobe")
> approach, but for absolute majority of users SEC("ksyscall") is a big
> improvement.

> As part of this patch set libbpf adds two more virtual __kconfig externs,  
> in
> addition to existing LINUX_KERNEL_VERSION: LINUX_HAS_BPF_COOKIE and
> LINUX_HAS_SYSCALL_WRAPPER, which let's libbpf-provided BPF-side code  
> minimize
> external dependencies and assumptions and let's user-space part of libbpf  
> to
> perform all the feature detection logic. This benefits USDT support code,
> which now doesn't depend on BPF CO-RE for its functionality.

> v1->v2:
>    - normalize extern variable-related warn and debug message formats  
> (Alan);

For the series:

Reviewed-by: Stanislav Fomichev <sdf@google.com>

> rfc->v1:
>    - drop dependency on kallsyms and speed up SYSCALL_WRAPPER detection  
> (Alexei);
>    - drop dependency on /proc/config.gz in bpf_tracing.h (Yaniv);
>    - add doc comment and ephasize mmap(), clone() and compat quirks that  
> are
>      not supported (Ilya);
>    - use mechanism similar to LINUX_KERNEL_VERSION to also improve USDT  
> code.

> Andrii Nakryiko (5):
>    libbpf: generalize virtual __kconfig externs and use it for USDT
>    selftests/bpf: add test of __weak unknown virtual __kconfig extern
>    libbpf: improve BPF_KPROBE_SYSCALL macro and rename it to BPF_KSYSCALL
>    libbpf: add ksyscall/kretsyscall sections support for syscall kprobes
>    selftests/bpf: use BPF_KSYSCALL and SEC("ksyscall") in selftests

>   tools/lib/bpf/bpf_tracing.h                   |  51 +++--
>   tools/lib/bpf/libbpf.c                        | 214 ++++++++++++++----
>   tools/lib/bpf/libbpf.h                        |  46 ++++
>   tools/lib/bpf/libbpf.map                      |   1 +
>   tools/lib/bpf/libbpf_internal.h               |   2 +
>   tools/lib/bpf/usdt.bpf.h                      |  16 +-
>   .../selftests/bpf/prog_tests/core_extern.c    |  17 +-
>   .../selftests/bpf/progs/bpf_syscall_macro.c   |   6 +-
>   .../selftests/bpf/progs/test_attach_probe.c   |  15 +-
>   .../selftests/bpf/progs/test_core_extern.c    |   3 +
>   .../selftests/bpf/progs/test_probe_user.c     |  27 +--
>   11 files changed, 289 insertions(+), 109 deletions(-)

> --
> 2.30.2


  parent reply	other threads:[~2022-07-14 18:31 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-14  7:07 [PATCH v2 bpf-next 0/5] Add SEC("ksyscall") support Andrii Nakryiko
2022-07-14  7:07 ` [PATCH v2 bpf-next 1/5] libbpf: generalize virtual __kconfig externs and use it for USDT Andrii Nakryiko
2022-07-14  7:07 ` [PATCH v2 bpf-next 2/5] selftests/bpf: add test of __weak unknown virtual __kconfig extern Andrii Nakryiko
2022-07-14  7:07 ` [PATCH v2 bpf-next 3/5] libbpf: improve BPF_KPROBE_SYSCALL macro and rename it to BPF_KSYSCALL Andrii Nakryiko
2022-07-14  7:07 ` [PATCH v2 bpf-next 4/5] libbpf: add ksyscall/kretsyscall sections support for syscall kprobes Andrii Nakryiko
2022-07-14  7:07 ` [PATCH v2 bpf-next 5/5] selftests/bpf: use BPF_KSYSCALL and SEC("ksyscall") in selftests Andrii Nakryiko
2022-07-15 23:28   ` Ilya Leoshkevich
2022-07-15 23:54     ` Ilya Leoshkevich
2022-07-14 18:31 ` sdf [this message]
2022-07-19 16:50 ` [PATCH v2 bpf-next 0/5] Add SEC("ksyscall") support patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YtBhGSRqFckLewHQ@google.com \
    --to=sdf@google.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox