BPF List
 help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii@kernel.org>
To: <bpf@vger.kernel.org>, <ast@kernel.org>, <daniel@iogearbox.net>,
	<martin.lau@kernel.org>
Cc: <andrii@kernel.org>, <kernel-team@meta.com>
Subject: [PATCH bpf-next 2/6] libbpf: report vmlinux vs module name when dealing with ksyms
Date: Mon, 17 Apr 2023 17:21:44 -0700	[thread overview]
Message-ID: <20230418002148.3255690-3-andrii@kernel.org> (raw)
In-Reply-To: <20230418002148.3255690-1-andrii@kernel.org>

Currently libbpf always reports "kernel" as a source of ksym BTF type,
which is ambiguous given ksym's BTF can come from either vmlinux or
kernel module BTFs. Make this explicit and log module name, if used BTF
is from kernel module.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
---
 tools/lib/bpf/libbpf.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index a382ed3586bd..0a11563067b3 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -7538,8 +7538,9 @@ static int bpf_object__resolve_ksym_func_btf_id(struct bpf_object *obj,
 	ret = bpf_core_types_are_compat(obj->btf, local_func_proto_id,
 					kern_btf, kfunc_proto_id);
 	if (ret <= 0) {
-		pr_warn("extern (func ksym) '%s': func_proto [%d] incompatible with kernel [%d]\n",
-			ext->name, local_func_proto_id, kfunc_proto_id);
+		pr_warn("extern (func ksym) '%s': func_proto [%d] incompatible with %s [%d]\n",
+			ext->name, local_func_proto_id,
+			mod_btf ? mod_btf->name : "vmlinux", kfunc_proto_id);
 		return -EINVAL;
 	}
 
@@ -7573,8 +7574,8 @@ static int bpf_object__resolve_ksym_func_btf_id(struct bpf_object *obj,
 	 * {kernel_btf_id, kernel_btf_obj_fd} -> fixup ld_imm64.
 	 */
 	ext->ksym.kernel_btf_obj_fd = mod_btf ? mod_btf->fd : 0;
-	pr_debug("extern (func ksym) '%s': resolved to kernel [%d]\n",
-		 ext->name, kfunc_id);
+	pr_debug("extern (func ksym) '%s': resolved to %s [%d]\n",
+		 ext->name, mod_btf ? mod_btf->name : "vmlinux", kfunc_id);
 
 	return 0;
 }
-- 
2.34.1


  parent reply	other threads:[~2023-04-18  0:22 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-18  0:21 [PATCH bpf-next 0/6] Provide bpf_for() and bpf_for_each() by libbpf Andrii Nakryiko
2023-04-18  0:21 ` [PATCH bpf-next 1/6] libbpf: misc internal libbpf clean ups around log fixup Andrii Nakryiko
2023-04-18  0:21 ` Andrii Nakryiko [this message]
2023-04-18  0:21 ` [PATCH bpf-next 3/6] libbpf: improve handling of unresolved kfuncs Andrii Nakryiko
2023-04-18  1:10   ` Alexei Starovoitov
2023-04-18 18:10     ` Andrii Nakryiko
2023-04-18 18:14       ` Alexei Starovoitov
2023-04-18 18:45         ` Andrii Nakryiko
2023-04-18  0:21 ` [PATCH bpf-next 4/6] selftests/bpf: add missing __weak kfunc log fixup test Andrii Nakryiko
2023-04-18  0:21 ` [PATCH bpf-next 5/6] libbpf: move bpf_for(), bpf_for_each(), and bpf_repeat() into bpf_helpers.h Andrii Nakryiko
2023-04-18  0:21 ` [PATCH bpf-next 6/6] libbpf: mark bpf_iter_num_{new,next,destroy} as __weak Andrii Nakryiko
2023-04-18 20:00 ` [PATCH bpf-next 0/6] Provide bpf_for() and bpf_for_each() by libbpf patchwork-bot+netdevbpf

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=20230418002148.3255690-3-andrii@kernel.org \
    --to=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@meta.com \
    --cc=martin.lau@kernel.org \
    /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