All of lore.kernel.org
 help / color / mirror / Atom feed
From: Delyan Kratunov <delyank@fb.com>
To: "daniel@iogearbox.net" <daniel@iogearbox.net>,
	"ast@kernel.org" <ast@kernel.org>,
	"andrii@kernel.org" <andrii@kernel.org>,
	"bpf@vger.kernel.org" <bpf@vger.kernel.org>
Subject: [PATCH bpf-next v2 0/5] sleepable uprobe support
Date: Mon, 2 May 2022 23:09:36 +0000	[thread overview]
Message-ID: <cover.1651532419.git.delyank@fb.com> (raw)

This series implements support for sleepable uprobe programs.
Key work is in patches 2 and 3, the rest is plumbing and tests.

The main observation is that the only obstacle in the way of sleepable uprobe
programs is not the uprobe infrastructure, which already runs in a user context,
but the rcu usage around bpf_prog_array.

Details are in patch 2 but the tl;dr is that we chain trace_tasks and normal rcu
grace periods when releasing to array to accommodate users of either rcu type.
This introduces latency for non-sleepable users (kprobe, tp) but that's deemed
acceptable, given recent benchmarks by Andrii [1]. We're a couple of orders of
magnitude under the rate of bpf_prog_array churn that would raise flags (~1MM/s per Paul).

  [1]: https://lore.kernel.org/bpf/CAEf4BzbpjN6ca7D9KOTiFPOoBYkciYvTz0UJNp5c-_3ptm=Mrg@mail.gmail.com/

v1 -> v2:
 * Fix lockdep annotations in bpf_prog_run_array_sleepable
 * Chain rcu grace periods only for perf_event-attached programs. This limits
   the additional latency on the free path to use cases where we know it won't
   be a problem.
 * Add tests calling helpers only available in sleepable programs.
 * Remove kprobe.s support from libbpf.

Delyan Kratunov (5):
  bpf: move bpf_prog to bpf.h
  bpf: implement sleepable uprobes by chaining tasks_trace and normal
    rcu
  bpf: allow sleepable uprobe programs to attach
  libbpf: add support for sleepable kprobe and uprobe programs
  selftests/bpf: add tests for sleepable kprobes and uprobes

 include/linux/bpf.h                           | 93 +++++++++++++++++++
 include/linux/filter.h                        | 34 -------
 include/linux/trace_events.h                  |  1 +
 kernel/bpf/core.c                             | 15 +++
 kernel/bpf/verifier.c                         |  4 +-
 kernel/events/core.c                          | 16 ++--
 kernel/trace/bpf_trace.c                      | 27 +++++-
 kernel/trace/trace_uprobe.c                   |  4 +-
 tools/lib/bpf/libbpf.c                        |  6 +-
 .../selftests/bpf/prog_tests/attach_probe.c   | 51 +++++++++-
 .../selftests/bpf/progs/test_attach_probe.c   | 58 ++++++++++++
 11 files changed, 260 insertions(+), 49 deletions(-)

--
2.35.1

             reply	other threads:[~2022-05-02 23:09 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-02 23:09 Delyan Kratunov [this message]
2022-05-02 23:09 ` [PATCH bpf-next v2 3/5] bpf: allow sleepable uprobe programs to attach Delyan Kratunov
2022-05-09 23:52   ` Andrii Nakryiko
2022-05-02 23:09 ` [PATCH bpf-next v2 5/5] selftests/bpf: add tests for sleepable kprobes and uprobes Delyan Kratunov
2022-05-09 23:57   ` Andrii Nakryiko
2022-05-02 23:09 ` [PATCH bpf-next v2 4/5] libbpf: add support for sleepable kprobe and uprobe programs Delyan Kratunov
2022-05-09 23:53   ` Andrii Nakryiko
2022-05-02 23:09 ` [PATCH bpf-next v2 2/5] bpf: implement sleepable uprobes by chaining tasks_trace and normal rcu Delyan Kratunov
2022-05-03  6:30   ` kernel test robot
2022-05-03 17:20     ` Delyan Kratunov
2022-05-03 17:20       ` Delyan Kratunov
2022-05-09 23:58       ` Andrii Nakryiko
2022-05-09 23:58         ` Andrii Nakryiko
2022-05-10  2:54       ` Alexei Starovoitov
2022-05-10  2:54         ` Alexei Starovoitov
2022-05-03  8:48   ` kernel test robot
2022-05-10  3:02   ` Alexei Starovoitov
2022-05-02 23:09 ` [PATCH bpf-next v2 1/5] bpf: move bpf_prog to bpf.h Delyan Kratunov
2022-05-10  3:04   ` Alexei Starovoitov
2022-05-13  1:22     ` Delyan Kratunov

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=cover.1651532419.git.delyank@fb.com \
    --to=delyank@fb.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.