bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitrii Dolgov <9erthalion6@gmail.com>
To: bpf@vger.kernel.org, ast@kernel.org, andrii@kernel.org,
	yhs@fb.com, songliubraving@fb.com
Cc: Dmitrii Dolgov <9erthalion6@gmail.com>
Subject: [RFC PATCH bpf-next 0/2] Priorities for bpf progs attached to the same tracepoint
Date: Sun,  3 Apr 2022 18:07:16 +0200	[thread overview]
Message-ID: <20220403160718.13730-1-9erthalion6@gmail.com> (raw)

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


             reply	other threads:[~2022-04-03 16:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-03 16:07 Dmitrii Dolgov [this message]
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

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=20220403160718.13730-1-9erthalion6@gmail.com \
    --to=9erthalion6@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=songliubraving@fb.com \
    --cc=yhs@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;
as well as URLs for NNTP newsgroup(s).