All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] libbpf: Support raw btf placed in the default path
@ 2022-09-12 16:43 Tao Chen
  2022-09-20  3:40 ` Yonghong Song
  2022-09-22  0:40 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 4+ messages in thread
From: Tao Chen @ 2022-09-12 16:43 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Yonghong Song, Song Liu, John Fastabend,
	KP Singh
  Cc: netdev, bpf, linux-kernel, Tao Chen

Now only elf btf can be placed in the default path(/boot), raw
btf should also can be there.

Signed-off-by: Tao Chen <chentao.kernel@linux.alibaba.com>
---
v2->v1: Remove the locations[i].raw_btf check
---
 tools/lib/bpf/btf.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
index bb1e06e..46ec244 100644
--- a/tools/lib/bpf/btf.c
+++ b/tools/lib/bpf/btf.c
@@ -4657,11 +4657,10 @@ struct btf *btf__load_vmlinux_btf(void)
 {
 	struct {
 		const char *path_fmt;
-		bool raw_btf;
 	} locations[] = {
 		/* try canonical vmlinux BTF through sysfs first */
-		{ "/sys/kernel/btf/vmlinux", true /* raw BTF */ },
-		/* fall back to trying to find vmlinux ELF on disk otherwise */
+		{ "/sys/kernel/btf/vmlinux" },
+		/* fall back to trying to find vmlinux on disk otherwise */
 		{ "/boot/vmlinux-%1$s" },
 		{ "/lib/modules/%1$s/vmlinux-%1$s" },
 		{ "/lib/modules/%1$s/build/vmlinux" },
@@ -4683,10 +4682,7 @@ struct btf *btf__load_vmlinux_btf(void)
 		if (access(path, R_OK))
 			continue;
 
-		if (locations[i].raw_btf)
-			btf = btf__parse_raw(path);
-		else
-			btf = btf__parse_elf(path, NULL);
+		btf = btf__parse(path, NULL);
 		err = libbpf_get_error(btf);
 		pr_debug("loading kernel BTF '%s': %d\n", path, err);
 		if (err)
-- 
2.2.1


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

* Re: [PATCH v2] libbpf: Support raw btf placed in the default path
  2022-09-12 16:43 [PATCH v2] libbpf: Support raw btf placed in the default path Tao Chen
@ 2022-09-20  3:40 ` Yonghong Song
  2022-09-22  0:29   ` Andrii Nakryiko
  2022-09-22  0:40 ` patchwork-bot+netdevbpf
  1 sibling, 1 reply; 4+ messages in thread
From: Yonghong Song @ 2022-09-20  3:40 UTC (permalink / raw)
  To: Tao Chen, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Song Liu, John Fastabend, KP Singh
  Cc: netdev, bpf, linux-kernel



On 9/12/22 9:43 AM, Tao Chen wrote:
> Now only elf btf can be placed in the default path(/boot), raw
> btf should also can be there.

There are more default paths than just /boot. Also some grammer
issues in the above like 'should also can be'.

Maybe the commit message can be changed like below.

Currently, the default vmlinux files at '/boot/vmlinux-*',
'/lib/modules/*/vmlinux-*' etc. are parsed with 'btf__parse_elf'
to extract BTF. It is possible that these files are actually
raw BTF files similar to /sys/kernel/btf/vmlinux. So parse
these files with 'btf__parse' which tries both raw format and
ELF format.

It would be great if you can add more information on why
'/boot/vmlinux-*' or '/lib/modules/*/vmlinux-*' might be
a raw BTF file in your system.

> 
> Signed-off-by: Tao Chen <chentao.kernel@linux.alibaba.com>

Ack with some commit message changes in the above.

Acked-by: Yonghong Song <yhs@fb.com>

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

* Re: [PATCH v2] libbpf: Support raw btf placed in the default path
  2022-09-20  3:40 ` Yonghong Song
@ 2022-09-22  0:29   ` Andrii Nakryiko
  0 siblings, 0 replies; 4+ messages in thread
From: Andrii Nakryiko @ 2022-09-22  0:29 UTC (permalink / raw)
  To: Yonghong Song
  Cc: Tao Chen, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Song Liu, John Fastabend, KP Singh, netdev,
	bpf, linux-kernel

On Mon, Sep 19, 2022 at 8:40 PM Yonghong Song <yhs@fb.com> wrote:
>
>
>
> On 9/12/22 9:43 AM, Tao Chen wrote:
> > Now only elf btf can be placed in the default path(/boot), raw
> > btf should also can be there.
>
> There are more default paths than just /boot. Also some grammer
> issues in the above like 'should also can be'.
>
> Maybe the commit message can be changed like below.
>
> Currently, the default vmlinux files at '/boot/vmlinux-*',
> '/lib/modules/*/vmlinux-*' etc. are parsed with 'btf__parse_elf'
> to extract BTF. It is possible that these files are actually
> raw BTF files similar to /sys/kernel/btf/vmlinux. So parse
> these files with 'btf__parse' which tries both raw format and
> ELF format.
>

Thanks, Yonghong, I used this description verbatim when applying. Also
added a sentence on why users might use this instead of providing the
btf_custom_path option.

> It would be great if you can add more information on why
> '/boot/vmlinux-*' or '/lib/modules/*/vmlinux-*' might be
> a raw BTF file in your system.
>
> >
> > Signed-off-by: Tao Chen <chentao.kernel@linux.alibaba.com>
>
> Ack with some commit message changes in the above.
>
> Acked-by: Yonghong Song <yhs@fb.com>

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

* Re: [PATCH v2] libbpf: Support raw btf placed in the default path
  2022-09-12 16:43 [PATCH v2] libbpf: Support raw btf placed in the default path Tao Chen
  2022-09-20  3:40 ` Yonghong Song
@ 2022-09-22  0:40 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-09-22  0:40 UTC (permalink / raw)
  To: Tao Chen
  Cc: ast, daniel, andrii, kafai, yhs, songliubraving, john.fastabend,
	kpsingh, netdev, bpf, linux-kernel

Hello:

This patch was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:

On Tue, 13 Sep 2022 00:43:00 +0800 you wrote:
> Now only elf btf can be placed in the default path(/boot), raw
> btf should also can be there.
> 
> Signed-off-by: Tao Chen <chentao.kernel@linux.alibaba.com>
> ---
> v2->v1: Remove the locations[i].raw_btf check
> 
> [...]

Here is the summary with links:
  - [v2] libbpf: Support raw btf placed in the default path
    https://git.kernel.org/bpf/bpf-next/c/01f2e36c959c

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2022-09-22  0:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-12 16:43 [PATCH v2] libbpf: Support raw btf placed in the default path Tao Chen
2022-09-20  3:40 ` Yonghong Song
2022-09-22  0:29   ` Andrii Nakryiko
2022-09-22  0:40 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.