* [PATCH] libbpf: Support raw btf placed in the default path @ 2022-08-24 14:05 chentao.ct 2022-08-25 20:26 ` Andrii Nakryiko 0 siblings, 1 reply; 5+ messages in thread From: chentao.ct @ 2022-08-24 14:05 UTC (permalink / raw) To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko, Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend Cc: KP Singh, netdev, bpf, linux-kernel, chentao.ct Now only elf btf can be placed in the default path, raw btf should also can be there. Signed-off-by: chentao.ct <chentao.kernel@linux.alibaba.com> --- tools/lib/bpf/btf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c index bb1e06e..b22b5b3 100644 --- a/tools/lib/bpf/btf.c +++ b/tools/lib/bpf/btf.c @@ -4661,7 +4661,7 @@ struct btf *btf__load_vmlinux_btf(void) } 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 */ + /* fall back to trying to find vmlinux RAW/ELF on disk otherwise */ { "/boot/vmlinux-%1$s" }, { "/lib/modules/%1$s/vmlinux-%1$s" }, { "/lib/modules/%1$s/build/vmlinux" }, @@ -4686,7 +4686,7 @@ struct btf *btf__load_vmlinux_btf(void) 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] 5+ messages in thread
* Re: [PATCH] libbpf: Support raw btf placed in the default path 2022-08-24 14:05 [PATCH] libbpf: Support raw btf placed in the default path chentao.ct @ 2022-08-25 20:26 ` Andrii Nakryiko 2022-08-29 5:48 ` Tao Chen [not found] ` <b9eef4fe-71b3-d15c-6615-282124155508@linux.alibaba.com> 0 siblings, 2 replies; 5+ messages in thread From: Andrii Nakryiko @ 2022-08-25 20:26 UTC (permalink / raw) To: chentao.ct Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko, Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend, KP Singh, netdev, bpf, linux-kernel On Wed, Aug 24, 2022 at 7:05 AM chentao.ct <chentao.kernel@linux.alibaba.com> wrote: > > Now only elf btf can be placed in the default path, raw btf should > also can be there. > It's not clear what you are trying to achieve. Do you want libbpf to attempt to load /boot/vmlinux-%1$s as raw BTF as well (so you can sort of sneak in pregenerated BTF), or what exactly? btf__load_vmlinux_btf() code already supports loading raw BTF, it just needs to be explicitly specified in locations table. So with your change locations[i].raw_btf check doesn't make sense and we need to clean this up. But first, let's discuss the use case, instead of your specific solution. > Signed-off-by: chentao.ct <chentao.kernel@linux.alibaba.com> > --- > tools/lib/bpf/btf.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c > index bb1e06e..b22b5b3 100644 > --- a/tools/lib/bpf/btf.c > +++ b/tools/lib/bpf/btf.c > @@ -4661,7 +4661,7 @@ struct btf *btf__load_vmlinux_btf(void) > } 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 */ > + /* fall back to trying to find vmlinux RAW/ELF on disk otherwise */ > { "/boot/vmlinux-%1$s" }, > { "/lib/modules/%1$s/vmlinux-%1$s" }, > { "/lib/modules/%1$s/build/vmlinux" }, > @@ -4686,7 +4686,7 @@ struct btf *btf__load_vmlinux_btf(void) > 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 [flat|nested] 5+ messages in thread
* Re: [PATCH] libbpf: Support raw btf placed in the default path 2022-08-25 20:26 ` Andrii Nakryiko @ 2022-08-29 5:48 ` Tao Chen [not found] ` <b9eef4fe-71b3-d15c-6615-282124155508@linux.alibaba.com> 1 sibling, 0 replies; 5+ messages in thread From: Tao Chen @ 2022-08-29 5:48 UTC (permalink / raw) To: Andrii Nakryiko Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko, Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend, KP Singh, netdev, bpf, linux-kernel Hi Nakryiko, thank you for your reply. Yes, i happed to put the raw BTF made by myself in /boot on kernel4.19, unluckly it reported error. So is it possible to allow the raw BTF in /boot directly, athough we can set the specified btf location again to solve the problem with the bpf_object_open_opts interface. As you say, maybe we can remove the locations[i].raw_btf check, just use the btf__parse. It looks more concise. 在 2022/8/26 上午4:26, Andrii Nakryiko 写道: > On Wed, Aug 24, 2022 at 7:05 AM chentao.ct > <chentao.kernel@linux.alibaba.com> wrote: >> >> Now only elf btf can be placed in the default path, raw btf should >> also can be there. >> > > It's not clear what you are trying to achieve. Do you want libbpf to > attempt to load /boot/vmlinux-%1$s as raw BTF as well (so you can sort > of sneak in pregenerated BTF), or what exactly? > btf__load_vmlinux_btf() code already supports loading raw BTF, it just > needs to be explicitly specified in locations table. > > So with your change locations[i].raw_btf check doesn't make sense and > we need to clean this up. > > But first, let's discuss the use case, instead of your specific solution. > > >> Signed-off-by: chentao.ct <chentao.kernel@linux.alibaba.com> >> --- >> tools/lib/bpf/btf.c | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c >> index bb1e06e..b22b5b3 100644 >> --- a/tools/lib/bpf/btf.c >> +++ b/tools/lib/bpf/btf.c >> @@ -4661,7 +4661,7 @@ struct btf *btf__load_vmlinux_btf(void) >> } 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 */ >> + /* fall back to trying to find vmlinux RAW/ELF on disk otherwise */ >> { "/boot/vmlinux-%1$s" }, >> { "/lib/modules/%1$s/vmlinux-%1$s" }, >> { "/lib/modules/%1$s/build/vmlinux" }, >> @@ -4686,7 +4686,7 @@ struct btf *btf__load_vmlinux_btf(void) >> 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 [flat|nested] 5+ messages in thread
[parent not found: <b9eef4fe-71b3-d15c-6615-282124155508@linux.alibaba.com>]
* Re: [PATCH] libbpf: Support raw btf placed in the default path [not found] ` <b9eef4fe-71b3-d15c-6615-282124155508@linux.alibaba.com> @ 2022-09-09 19:00 ` Andrii Nakryiko 2022-09-12 15:37 ` Tao Chen 0 siblings, 1 reply; 5+ messages in thread From: Andrii Nakryiko @ 2022-09-09 19:00 UTC (permalink / raw) To: Tao Chen Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko, Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend, KP Singh, netdev, bpf, linux-kernel On Sun, Aug 28, 2022 at 10:36 PM Tao Chen <chentao.kernel@linux.alibaba.com> wrote: > > Hi Nakryiko, thank you for your reply. Yes, i happed to put the raw > BTF made by myself in /boot on kernel4.19, unluckly it reported error. > So is it possible to allow the raw BTF in /boot directly, athough we > can set the specified btf location again to solve the problem with the > bpf_object_open_opts interface. > > As you say, maybe we can remove the locations[i].raw_btf check, just > use the btf__parse, It looks more concise. Please don't top post, reply inline (that's kernel mail lists rules). But yes, I think we can just use btf__parse and let libbpf figure out. Please send a patch. > > 在 2022/8/26 上午4:26, Andrii Nakryiko 写道: > > On Wed, Aug 24, 2022 at 7:05 AM chentao.ct > <chentao.kernel@linux.alibaba.com> wrote: > > Now only elf btf can be placed in the default path, raw btf should > also can be there. > > It's not clear what you are trying to achieve. Do you want libbpf to > attempt to load /boot/vmlinux-%1$s as raw BTF as well (so you can sort > of sneak in pregenerated BTF), or what exactly? > btf__load_vmlinux_btf() code already supports loading raw BTF, it just > needs to be explicitly specified in locations table. > > So with your change locations[i].raw_btf check doesn't make sense and > we need to clean this up. > > But first, let's discuss the use case, instead of your specific solution. > > > Signed-off-by: chentao.ct <chentao.kernel@linux.alibaba.com> > --- > tools/lib/bpf/btf.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c > index bb1e06e..b22b5b3 100644 > --- a/tools/lib/bpf/btf.c > +++ b/tools/lib/bpf/btf.c > @@ -4661,7 +4661,7 @@ struct btf *btf__load_vmlinux_btf(void) > } 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 */ > + /* fall back to trying to find vmlinux RAW/ELF on disk otherwise */ > { "/boot/vmlinux-%1$s" }, > { "/lib/modules/%1$s/vmlinux-%1$s" }, > { "/lib/modules/%1$s/build/vmlinux" }, > @@ -4686,7 +4686,7 @@ struct btf *btf__load_vmlinux_btf(void) > 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 [flat|nested] 5+ messages in thread
* Re: [PATCH] libbpf: Support raw btf placed in the default path 2022-09-09 19:00 ` Andrii Nakryiko @ 2022-09-12 15:37 ` Tao Chen 0 siblings, 0 replies; 5+ messages in thread From: Tao Chen @ 2022-09-12 15:37 UTC (permalink / raw) To: Andrii Nakryiko Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko, Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend, KP Singh, netdev, bpf, linux-kernel 在 2022/9/10 上午3:00, Andrii Nakryiko 写道: > On Sun, Aug 28, 2022 at 10:36 PM Tao Chen > <chentao.kernel@linux.alibaba.com> wrote: >> >> Hi Nakryiko, thank you for your reply. Yes, i happed to put the raw >> BTF made by myself in /boot on kernel4.19, unluckly it reported error. >> So is it possible to allow the raw BTF in /boot directly, athough we >> can set the specified btf location again to solve the problem with the >> bpf_object_open_opts interface. >> >> As you say, maybe we can remove the locations[i].raw_btf check, just >> use the btf__parse, It looks more concise. > > Please don't top post, reply inline (that's kernel mail lists rules). > > But yes, I think we can just use btf__parse and let libbpf figure out. > Please send a patch. > Thank you, i will send the patch in v2. >> >> 在 2022/8/26 上午4:26, Andrii Nakryiko 写道: >> >> On Wed, Aug 24, 2022 at 7:05 AM chentao.ct >> <chentao.kernel@linux.alibaba.com> wrote: >> >> Now only elf btf can be placed in the default path, raw btf should >> also can be there. >> >> It's not clear what you are trying to achieve. Do you want libbpf to >> attempt to load /boot/vmlinux-%1$s as raw BTF as well (so you can sort >> of sneak in pregenerated BTF), or what exactly? >> btf__load_vmlinux_btf() code already supports loading raw BTF, it just >> needs to be explicitly specified in locations table. >> >> So with your change locations[i].raw_btf check doesn't make sense and >> we need to clean this up. >> >> But first, let's discuss the use case, instead of your specific solution. >> >> >> Signed-off-by: chentao.ct <chentao.kernel@linux.alibaba.com> >> --- >> tools/lib/bpf/btf.c | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c >> index bb1e06e..b22b5b3 100644 >> --- a/tools/lib/bpf/btf.c >> +++ b/tools/lib/bpf/btf.c >> @@ -4661,7 +4661,7 @@ struct btf *btf__load_vmlinux_btf(void) >> } 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 */ >> + /* fall back to trying to find vmlinux RAW/ELF on disk otherwise */ >> { "/boot/vmlinux-%1$s" }, >> { "/lib/modules/%1$s/vmlinux-%1$s" }, >> { "/lib/modules/%1$s/build/vmlinux" }, >> @@ -4686,7 +4686,7 @@ struct btf *btf__load_vmlinux_btf(void) >> 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 [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-09-12 15:38 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-24 14:05 [PATCH] libbpf: Support raw btf placed in the default path chentao.ct
2022-08-25 20:26 ` Andrii Nakryiko
2022-08-29 5:48 ` Tao Chen
[not found] ` <b9eef4fe-71b3-d15c-6615-282124155508@linux.alibaba.com>
2022-09-09 19:00 ` Andrii Nakryiko
2022-09-12 15:37 ` Tao Chen
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox