bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH bpf-next 0/2] Priorities for bpf progs attached to the same tracepoint
@ 2022-04-03 16:07 Dmitrii Dolgov
  2022-04-03 16:07 ` [RFC PATCH bpf-next 1/2] bpf: tracing: Introduce prio field for bpf_prog Dmitrii Dolgov
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Dmitrii Dolgov @ 2022-04-03 16:07 UTC (permalink / raw)
  To: bpf, ast, andrii, yhs, songliubraving; +Cc: Dmitrii Dolgov

With growing number of various products and tools using BPF it could
easily happen that multiple BPF programs from different processes will
be attached to the same tracepoint. It seems that in such case there is
no way to specify a custom order in which those programs may want to be
executed -- it will depend on the order in which they were attached.

Consider an example when the BPF program A is attached to tracepoint T,
the BFP program B needs to be attached to the T as well and start
before/end after the A (e.g. to monitor the whole process of A +
tracepoint in some way).  If the program A could not be changed and is
attached before B, the order specified above will not be possible.

One way to address this in a limited, but less invasive way is to
utilize link options structure to pass the desired priority to
perf_event_set_bpf_prog, and add new bpf_prog into the bpf_prog_array
based on its value. This will allow to specify the priority value via
bpf_tracepoint_opts when attaching a new prog.

Does this make sense? There maybe a better way to achieve this, I would
be glad to hear any feedback on it.

Dmitrii Dolgov (2):
  bpf: tracing: Introduce prio field for bpf_prog
  libbpf: Allow setting bpf_prog priority

 drivers/media/rc/bpf-lirc.c    |  4 ++--
 include/linux/bpf.h            |  3 ++-
 include/linux/trace_events.h   |  7 ++++---
 include/uapi/linux/bpf.h       |  1 +
 kernel/bpf/core.c              | 19 +++++++++++++++++--
 kernel/bpf/syscall.c           |  3 ++-
 kernel/events/core.c           |  8 ++++----
 kernel/trace/bpf_trace.c       |  8 +++++---
 tools/include/uapi/linux/bpf.h |  1 +
 tools/lib/bpf/bpf.c            |  1 +
 tools/lib/bpf/bpf.h            |  1 +
 tools/lib/bpf/libbpf.c         |  4 +++-
 tools/lib/bpf/libbpf.h         |  6 ++++--
 13 files changed, 47 insertions(+), 19 deletions(-)

-- 
2.32.0


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

end of thread, other threads:[~2022-04-06 12:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-03 16:07 [RFC PATCH bpf-next 0/2] Priorities for bpf progs attached to the same tracepoint Dmitrii Dolgov
2022-04-03 16:07 ` [RFC PATCH bpf-next 1/2] bpf: tracing: Introduce prio field for bpf_prog Dmitrii Dolgov
2022-04-03 16:07 ` [RFC PATCH bpf-next 2/2] libbpf: Allow setting bpf_prog priority Dmitrii Dolgov
2022-04-04  0:17 ` [RFC PATCH bpf-next 0/2] Priorities for bpf progs attached to the same tracepoint Andrii Nakryiko
2022-04-04 15:29   ` Dmitry Dolgov
2022-04-05 17:20     ` Alexei Starovoitov
2022-04-06  8:12       ` Dmitry Dolgov

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).