From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796214838; b=lOhO1eCx/4lJYaEKlZ0KXOnJYL6IcHarvQ2oZ75JYsFPLJSuSVm/jyTmG3WozTh3Hx2p gR1Lz7pjr3cOerXdUG4mJ3bClJLvZuRCG6DOYyV+ck5Tofl6Bq1cKr6auVxTWxXBBuhF4 T/GPVd8uvOODCrLXngdwyDMQdiPLeb4P0U1oKH2CZh6n7U7sSx9f5zBk8cGwCYVN1af89 3NM4OfvuDY+bSTtN5m0xnzNgvTXe2K254P+NefespMmLjPI8OR7vA2bOAw69E+Pv6U/B+ k2Z9xa+XeZownpfh58A/MYRNDJyk6xZtHhc1JIEFv9Qxr+pV52nv2L+Qj3/XapmBfcQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796214838; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=bCNdm7uRKvqWGCysDAZNkde/HQXDiSIQsgbsShahRsw=; b=OAb384xWIAWj9cx1P1MND8Pw7grtAawl+uDNPQ2hpM9nbR1XiY82gnFX1b/rvqcyPpCG AtUEo8LOvZ1NJqhLc5BT13Nb7Gn/VyVEr8ge7FRTzNwewlXcSTE8gOdvzB5DDf3Imx86K rQRP2kAmi66KXSg61PZfIFH+LaEzac2miTgogx8PTNx4ojDTuJ6B+D102ITfqkhRxggik nFfgWYqScho2mEgzxJa7nJBCVyX97E+YD/T8FIF4A+klCFuXawtXg3+cmYRiNpPKhbS8x S+fg0IbHFysHqgz+vighK9gHWFpBcnNIJW93KBCrlFb0seOqTv24O0bX7b+JUXXV0Bg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=bO1dFdeF; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BB49C606A323; Wed, 2 Dec 2026 12:33:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=bO1dFdeF Received: by smtp.kernel.org (Postfix) with ESMTPSA id 884CE1F00893; Wed, 2 Dec 2026 12:33:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796214838; bh=bCNdm7uRKvqWGCysDAZNkde/HQXDiSIQsgbsShahRsw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=bO1dFdeFL/u+SQvzYtkIBDiuR18ywtZt6dgROXUxX8BINdcMcgV9AODNRUT6SrVUs j/+5uYIbNS6Tfoins0hSPMrYkA58HDcG1YnX5cpuMzjkuct/dIKjVWICY5w7mEao5E +Yr/+xBba/piTJ5fCf0qvxX5JD5lpHb8KUeUUFPb/KT0JLIQ9+GX1PAkjxk2LAycmk KgTxzsJ7VcuKTOxICt9Sm01hkdvVqCF/22ChoyzWdWHt2l4YwNRjUgpMDomHNT/i0Q v4xms3itdGDNogoMSSbiO7dKkn9gTzym6bROeMUO/RjaSzhJ+19MSDtrfdauQQMtOY iY2QbHxfPfTOw== From: Jiri Olsa To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Masami Hiramatsu Cc: bpf@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org, Song Liu , Yonghong Song , Quentin Monnet , Alan Maguire Subject: [PATCH RFC bpf-next 19/31] libbpf: Add inline options to bpf_kprobe_multi_opts Date: Wed, 2 Dec 2026 13:30:23 +0100 Message-ID: <20261202123035.10335-20-jolsa@kernel.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261202123035.10335-1-jolsa@kernel.org> References: <20261202123035.10335-1-jolsa@kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add inlined and inlined_strict options to struct bpf_kprobe_multi_opts to attach the link with BPF_F_KPROBE_MULTI_INLINE[_STRICT] flags. The inlined instances are resolved by kernel from function names, so the options work only with syms array or with pattern without wildcards. Signed-off-by: Jiri Olsa --- tools/lib/bpf/libbpf.c | 18 +++++++++++++++++- tools/lib/bpf/libbpf.h | 6 +++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index 61a388868373..885383def114 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c @@ -13159,7 +13159,7 @@ bpf_program__attach_kprobe_multi_opts(const struct bpf_program *prog, struct bpf_link *link = NULL; const unsigned long *addrs; int err, link_fd, prog_fd; - bool retprobe, session, unique_match; + bool retprobe, session, unique_match, inlined, inlined_strict; const __u64 *cookies; const char **syms; size_t cnt; @@ -13179,6 +13179,8 @@ bpf_program__attach_kprobe_multi_opts(const struct bpf_program *prog, cnt = OPTS_GET(opts, cnt, false); cookies = OPTS_GET(opts, cookies, false); unique_match = OPTS_GET(opts, unique_match, false); + inlined = OPTS_GET(opts, inlined, false); + inlined_strict = OPTS_GET(opts, inlined_strict, false); if (!pattern && !addrs && !syms) return libbpf_err_ptr(-EINVAL); @@ -13190,6 +13192,14 @@ bpf_program__attach_kprobe_multi_opts(const struct bpf_program *prog, return libbpf_err_ptr(-EINVAL); if (addrs && syms) return libbpf_err_ptr(-EINVAL); + /* + * Inlined instances are resolved by kernel from function names, + * so we can't use addresses or pattern resolved to addresses. + */ + if (inlined && (addrs || unique_match || (pattern && strpbrk(pattern, "*?")))) + return libbpf_err_ptr(-EINVAL); + if (inlined_strict && !inlined) + return libbpf_err_ptr(-EINVAL); /* * Exact function name (no wildcards) without unique_match: @@ -13224,6 +13234,8 @@ bpf_program__attach_kprobe_multi_opts(const struct bpf_program *prog, if (retprobe && session) return libbpf_err_ptr(-EINVAL); + if (inlined && (retprobe || session)) + return libbpf_err_ptr(-EINVAL); attach_type = session ? BPF_TRACE_KPROBE_SESSION : BPF_TRACE_KPROBE_MULTI; @@ -13232,6 +13244,10 @@ bpf_program__attach_kprobe_multi_opts(const struct bpf_program *prog, lopts.kprobe_multi.cookies = cookies; lopts.kprobe_multi.cnt = cnt; lopts.kprobe_multi.flags = retprobe ? BPF_F_KPROBE_MULTI_RETURN : 0; + if (inlined) + lopts.kprobe_multi.flags |= BPF_F_KPROBE_MULTI_INLINE; + if (inlined_strict) + lopts.kprobe_multi.flags |= BPF_F_KPROBE_MULTI_INLINE_STRICT; link = calloc(1, sizeof(*link)); if (!link) { diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h index 56300be81016..286512037a68 100644 --- a/tools/lib/bpf/libbpf.h +++ b/tools/lib/bpf/libbpf.h @@ -648,10 +648,14 @@ struct bpf_kprobe_multi_opts { bool session; /* enforce unique match */ bool unique_match; + /* attach also to inlined instances of functions */ + bool inlined; + /* fail if any inlined instance can't be attached, needs inlined */ + bool inlined_strict; size_t :0; }; -#define bpf_kprobe_multi_opts__last_field unique_match +#define bpf_kprobe_multi_opts__last_field inlined_strict LIBBPF_API struct bpf_link * bpf_program__attach_kprobe_multi_opts(const struct bpf_program *prog, -- 2.56.1