netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: John Fastabend <john.fastabend@gmail.com>
To: Andrii Nakryiko <andriin@fb.com>,
	bpf@vger.kernel.org, netdev@vger.kernel.org, ast@fb.com,
	daniel@iogearbox.net
Cc: andrii.nakryiko@gmail.com, kernel-team@fb.com,
	Andrii Nakryiko <andriin@fb.com>
Subject: RE: [PATCH bpf-next 3/3] selftest/bpf: add BPF triggring benchmark
Date: Fri, 08 May 2020 09:02:00 -0700	[thread overview]
Message-ID: <5eb58278bae41_2a992ad50b5cc5b430@john-XPS-13-9370.notmuch> (raw)
In-Reply-To: <20200508070548.2358701-4-andriin@fb.com>

Andrii Nakryiko wrote:
> It is sometimes desirable to be able to trigger BPF program from user-space
> with minimal overhead. sys_enter would seem to be a good candidate, yet in
> a lot of cases there will be a lot of noise from syscalls triggered by other
> processes on the system. So while searching for low-overhead alternative, I've
> stumbled upon getpgid() syscall, which seems to be specific enough to not
> suffer from accidental syscall by other apps.
> 
> This set of benchmarks compares tp, raw_tp w/ filtering by syscall ID, kprobe,
> fentry and fmod_ret with returning error (so that syscall would not be
> executed), to determine the lowest-overhead way. Here are results on my
> machine:
> 
> $ for i in base tp rawtp kprobe fentry fmodret; \
> do \
>     summary=$(sudo ./bench -w2 -d5 -a trig-$i | \
>               tail -n1 | cut -d'(' -f1 | cut -d' ' -f3- ) && \
>     printf "%-10s: %s\n" $i "$summary"; \
> done
> 
> base      :    9.200 ± 0.319M/s
> tp        :    6.690 ± 0.125M/s
> rawtp     :    8.571 ± 0.214M/s
> kprobe    :    6.431 ± 0.048M/s
> fentry    :    8.955 ± 0.241M/s
> fmodret   :    8.903 ± 0.135M/s
> 
> So it seems like fmodret doesn't give much benefit for such lightweight
> syscall. Raw tracepoint is pretty decent despite additional filtering logic,
> but it will be called for any other syscall in the system, which rules it out.
> Fentry, though, seems to be adding the least amoung of overhead and achieves
> 97.3% of performance of baseline no-BPF-attached syscall.
> 
> Using getpgid() seems to be preferable to set_task_comm() approach from
> test_overhead, as it's about 2.35x faster in a baseline performance.
> 
> Signed-off-by: Andrii Nakryiko <andriin@fb.com>
> ---

Nice.

Acked-by: John Fastabend <john.fastabend@gmail.com>

  reply	other threads:[~2020-05-08 16:02 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-08  7:05 [PATCH bpf-next 0/3] Add benchmark runner and few benchmarks Andrii Nakryiko
2020-05-08  7:05 ` [PATCH bpf-next 1/3] selftests/bpf: add benchmark runner infrastructure Andrii Nakryiko
2020-05-08 15:49   ` John Fastabend
2020-05-08 17:59     ` Andrii Nakryiko
2020-05-08  7:05 ` [PATCH bpf-next 2/3] selftest/bpf: fmod_ret prog and implement test_overhead as part of bench Andrii Nakryiko
2020-05-08 15:57   ` John Fastabend
2020-05-08 18:01     ` Andrii Nakryiko
2020-05-08  7:05 ` [PATCH bpf-next 3/3] selftest/bpf: add BPF triggring benchmark Andrii Nakryiko
2020-05-08 16:02   ` John Fastabend [this message]
2020-05-08 16:40   ` Alexei Starovoitov
2020-05-08 17:50     ` Andrii Nakryiko

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=5eb58278bae41_2a992ad50b5cc5b430@john-XPS-13-9370.notmuch \
    --to=john.fastabend@gmail.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=andriin@fb.com \
    --cc=ast@fb.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@fb.com \
    --cc=netdev@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).