All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next v3 0/5] sleepable uprobe support
@ 2022-05-13  1:22 Delyan Kratunov
  2022-05-13  1:22 ` [PATCH bpf-next v3 3/5] bpf: allow sleepable uprobe programs to attach Delyan Kratunov
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Delyan Kratunov @ 2022-05-13  1:22 UTC (permalink / raw)
  To: daniel, ast, andrii, bpf

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-like
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/

v2 -> v3:
 * Inline uprobe_call_bpf into trace_uprobe.c, it's just a bpf_prog_run_array_sleepable call now.
 * Do not disable preemption for uprobe non-sleepable programs.
 * Add acks.

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 gps
  bpf: allow sleepable uprobe programs to attach
  libbpf: add support for sleepable uprobe programs
  selftests/bpf: add tests for sleepable (uk)probes

 include/linux/bpf.h                           | 89 +++++++++++++++++++
 include/linux/filter.h                        | 34 -------
 kernel/bpf/core.c                             | 15 ++++
 kernel/bpf/verifier.c                         |  4 +-
 kernel/events/core.c                          | 16 ++--
 kernel/trace/bpf_trace.c                      |  4 +-
 kernel/trace/trace_uprobe.c                   |  5 +-
 tools/lib/bpf/libbpf.c                        |  5 +-
 .../selftests/bpf/prog_tests/attach_probe.c   | 49 +++++++++-
 .../selftests/bpf/progs/test_attach_probe.c   | 60 +++++++++++++
 10 files changed, 232 insertions(+), 49 deletions(-)

--
2.35.3

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-05-13 17:05 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-13  1:22 [PATCH bpf-next v3 0/5] sleepable uprobe support Delyan Kratunov
2022-05-13  1:22 ` [PATCH bpf-next v3 3/5] bpf: allow sleepable uprobe programs to attach Delyan Kratunov
2022-05-13  1:22 ` [PATCH bpf-next v3 1/5] bpf: move bpf_prog to bpf.h Delyan Kratunov
2022-05-13  1:22 ` [PATCH bpf-next v3 4/5] libbpf: add support for sleepable uprobe programs Delyan Kratunov
2022-05-13  1:22 ` [PATCH bpf-next v3 2/5] bpf: implement sleepable uprobes by chaining gps Delyan Kratunov
2022-05-13 16:00   ` Daniel Borkmann
2022-05-13 17:05     ` Delyan Kratunov
2022-05-13  1:22 ` [PATCH bpf-next v3 5/5] selftests/bpf: add tests for sleepable (uk)probes Delyan Kratunov

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.