bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@kernel.org>
To: Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>
Cc: bpf@vger.kernel.org, Martin KaFai Lau <kafai@fb.com>,
	Song Liu <songliubraving@fb.com>, Yonghong Song <yhs@fb.com>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@chromium.org>,
	Stanislav Fomichev <sdf@google.com>, Hao Luo <haoluo@google.com>
Subject: [PATCHv4 bpf-next 13/28] libbpf: Add bpf_link_create support for multi uprobes
Date: Thu, 20 Jul 2023 13:35:35 +0200	[thread overview]
Message-ID: <20230720113550.369257-14-jolsa@kernel.org> (raw)
In-Reply-To: <20230720113550.369257-1-jolsa@kernel.org>

Adding new uprobe_multi struct to bpf_link_create_opts object
to pass multiple uprobe data to link_create attr uapi.

Acked-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/lib/bpf/bpf.c | 11 +++++++++++
 tools/lib/bpf/bpf.h | 11 ++++++++++-
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c
index 3b0da19715e1..3a2da530bf5f 100644
--- a/tools/lib/bpf/bpf.c
+++ b/tools/lib/bpf/bpf.c
@@ -733,6 +733,17 @@ int bpf_link_create(int prog_fd, int target_fd,
 		if (!OPTS_ZEROED(opts, kprobe_multi))
 			return libbpf_err(-EINVAL);
 		break;
+	case BPF_TRACE_UPROBE_MULTI:
+		attr.link_create.uprobe_multi.flags = OPTS_GET(opts, uprobe_multi.flags, 0);
+		attr.link_create.uprobe_multi.cnt = OPTS_GET(opts, uprobe_multi.cnt, 0);
+		attr.link_create.uprobe_multi.path = ptr_to_u64(OPTS_GET(opts, uprobe_multi.path, 0));
+		attr.link_create.uprobe_multi.offsets = ptr_to_u64(OPTS_GET(opts, uprobe_multi.offsets, 0));
+		attr.link_create.uprobe_multi.ref_ctr_offsets = ptr_to_u64(OPTS_GET(opts, uprobe_multi.ref_ctr_offsets, 0));
+		attr.link_create.uprobe_multi.cookies = ptr_to_u64(OPTS_GET(opts, uprobe_multi.cookies, 0));
+		attr.link_create.uprobe_multi.pid = OPTS_GET(opts, uprobe_multi.pid, 0);
+		if (!OPTS_ZEROED(opts, uprobe_multi))
+			return libbpf_err(-EINVAL);
+		break;
 	case BPF_TRACE_FENTRY:
 	case BPF_TRACE_FEXIT:
 	case BPF_MODIFY_RETURN:
diff --git a/tools/lib/bpf/bpf.h b/tools/lib/bpf/bpf.h
index c676295ab9bf..4d5c439c0765 100644
--- a/tools/lib/bpf/bpf.h
+++ b/tools/lib/bpf/bpf.h
@@ -346,6 +346,15 @@ struct bpf_link_create_opts {
 			const unsigned long *addrs;
 			const __u64 *cookies;
 		} kprobe_multi;
+		struct {
+			__u32 flags;
+			__u32 cnt;
+			const char *path;
+			const unsigned long *offsets;
+			const unsigned long *ref_ctr_offsets;
+			const __u64 *cookies;
+			__u32 pid;
+		} uprobe_multi;
 		struct {
 			__u64 cookie;
 		} tracing;
@@ -358,7 +367,7 @@ struct bpf_link_create_opts {
 	};
 	size_t :0;
 };
-#define bpf_link_create_opts__last_field kprobe_multi.cookies
+#define bpf_link_create_opts__last_field uprobe_multi.pid
 
 LIBBPF_API int bpf_link_create(int prog_fd, int target_fd,
 			       enum bpf_attach_type attach_type,
-- 
2.41.0


  parent reply	other threads:[~2023-07-20 11:38 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-20 11:35 [PATCHv4 bpf-next 00/28] bpf: Add multi uprobe link Jiri Olsa
2023-07-20 11:35 ` [PATCHv4 bpf-next 01/28] bpf: Switch BPF_F_KPROBE_MULTI_RETURN macro to enum Jiri Olsa
2023-07-20 11:35 ` [PATCHv4 bpf-next 02/28] bpf: Add attach_type checks under bpf_prog_attach_check_attach_type Jiri Olsa
2023-07-20 11:35 ` [PATCHv4 bpf-next 03/28] bpf: Add multi uprobe link Jiri Olsa
2023-07-20 11:35 ` [PATCHv4 bpf-next 04/28] bpf: Add cookies support for uprobe_multi link Jiri Olsa
2023-07-21  2:18   ` Yafang Shao
2023-07-21  7:39     ` Jiri Olsa
2023-07-20 11:35 ` [PATCHv4 bpf-next 05/28] bpf: Add pid filter " Jiri Olsa
2023-07-21  2:55   ` Yafang Shao
2023-07-21  8:31     ` Oleg Nesterov
2023-07-21  8:54       ` Oleg Nesterov
2023-07-21  9:05         ` Yafang Shao
2023-07-21 10:41           ` Jiri Olsa
2023-07-20 11:35 ` [PATCHv4 bpf-next 06/28] bpf: Add bpf_get_func_ip helper support for uprobe link Jiri Olsa
2023-07-20 11:35 ` [PATCHv4 bpf-next 07/28] libbpf: Add uprobe_multi attach type and link names Jiri Olsa
2023-07-20 11:35 ` [PATCHv4 bpf-next 08/28] libbpf: Move elf_find_func_offset* functions to elf object Jiri Olsa
2023-07-20 11:35 ` [PATCHv4 bpf-next 09/28] libbpf: Add elf_open/elf_close functions Jiri Olsa
2023-07-20 11:35 ` [PATCHv4 bpf-next 10/28] libbpf: Add elf symbol iterator Jiri Olsa
2023-07-20 11:35 ` [PATCHv4 bpf-next 11/28] libbpf: Add elf_resolve_syms_offsets function Jiri Olsa
2023-07-20 11:35 ` [PATCHv4 bpf-next 12/28] libbpf: Add elf_resolve_pattern_offsets function Jiri Olsa
2023-07-20 11:35 ` Jiri Olsa [this message]
2023-07-20 11:35 ` [PATCHv4 bpf-next 14/28] libbpf: Add bpf_program__attach_uprobe_multi function Jiri Olsa
2023-07-20 11:35 ` [PATCHv4 bpf-next 15/28] libbpf: Add support for u[ret]probe.multi[.s] program sections Jiri Olsa
2023-07-20 11:35 ` [PATCHv4 bpf-next 16/28] libbpf: Add uprobe multi link detection Jiri Olsa
2023-07-20 11:35 ` [PATCHv4 bpf-next 17/28] libbpf: Add uprobe multi link support to bpf_program__attach_usdt Jiri Olsa
2023-07-20 11:35 ` [PATCHv4 bpf-next 18/28] selftests/bpf: Move get_time_ns to testing_helpers.h Jiri Olsa
2023-07-20 11:35 ` [PATCHv4 bpf-next 19/28] selftests/bpf: Add uprobe_multi skel test Jiri Olsa
2023-07-20 11:35 ` [PATCHv4 bpf-next 20/28] selftests/bpf: Add uprobe_multi api test Jiri Olsa
2023-07-20 11:35 ` [PATCHv4 bpf-next 21/28] selftests/bpf: Add uprobe_multi link test Jiri Olsa
2023-07-20 11:35 ` [PATCHv4 bpf-next 22/28] selftests/bpf: Add uprobe_multi test program Jiri Olsa
2023-07-20 11:35 ` [PATCHv4 bpf-next 23/28] selftests/bpf: Add uprobe_multi bench test Jiri Olsa
2023-07-20 11:35 ` [PATCHv4 bpf-next 24/28] selftests/bpf: Add uprobe_multi usdt test code Jiri Olsa
2023-07-20 11:35 ` [PATCHv4 bpf-next 25/28] selftests/bpf: Add uprobe_multi usdt bench test Jiri Olsa
2023-07-20 11:35 ` [PATCHv4 bpf-next 26/28] selftests/bpf: Add uprobe_multi cookie test Jiri Olsa
2023-07-20 11:35 ` [PATCHv4 bpf-next 27/28] selftests/bpf: Add uprobe_multi pid filter tests Jiri Olsa
2023-07-20 11:35 ` [PATCHv4 bpf-next 28/28] selftests/bpf: Add extra link to uprobe_multi tests Jiri Olsa

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=20230720113550.369257-14-jolsa@kernel.org \
    --to=jolsa@kernel.org \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=kafai@fb.com \
    --cc=kpsingh@chromium.org \
    --cc=sdf@google.com \
    --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).