Em Sun, May 30, 2021 at 11:45:15PM +0200, Jiri Olsa escreveu: > On Fri, May 28, 2021 at 04:45:31PM -0300, Arnaldo Carvalho de Melo wrote: > > Em Thu, May 27, 2021 at 01:41:13PM -0700, Andrii Nakryiko escreveu: > > > On Thu, May 27, 2021 at 12:57 PM Arnaldo <arnaldo.melo@xxxxxxxxx> wrote: > > > > On May 27, 2021 4:14:17 PM GMT-03:00, Andrii Nakryiko <andrii.nakryiko@xxxxxxxxx> wrote: > > > > >If we make 1.22 mandatory there will be no good reason to make 1.23 > > > > >mandatory again. So I will have absolutely no inclination to work on > > > > >this, for example. So we are just wasting a chance to clean up the > > > > >Kbuild story w.r.t. pahole. And we are talking about just a few days > > > > >at most, while we do have a reasonable work around on the kernel side. > > > > > > So there were patches for stop using objcopy, which we thought could > > > > uncover some can of worms, were there patches for the detached BTF > > > > file? > > > > > No, there weren't, if I remember correctly. What's the concern, > > > though? That detached BTF file isn't even an ELF, so it's > > > btf__get_raw_data() and write it to the file. Done. > > > > See patch below, lightly tested, now working on making pahole accept raw > > BTF files out of /sys/kernel/btf/ > > > > Please test, and if works as expected, try to bolt this into the kbuild > > process, as intended. > > > > - Arnaldo > > > > commit b579a18a1ea0ee84b90b5302f597dda2edf2f61b > > Author: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx> > > Date: Fri May 28 16:41:30 2021 -0300 > > > > pahole: Allow encoding BTF into a detached file > > > > Previously the newly encoded BTF info was stored into a ELF section in > > the file where the DWARF info was obtained, but it is useful to just > > dump it into a separate file, do it. > > > > Requested-by: Andrii Nakryiko <andrii@xxxxxxxxxx> > > Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx> > > > > diff --git a/btf_encoder.c b/btf_encoder.c > > index 033c927b537dad1e..bc3ac72968cea826 100644 > > --- a/btf_encoder.c > > +++ b/btf_encoder.c > > @@ -21,6 +21,14 @@ > > #include <stdlib.h> /* for qsort() and bsearch() */ > > #include <inttypes.h> > > > > +#include <sys/types.h> > > +#include <sys/stat.h> > > +#include <fcntl.h> > > + > > +#include <unistd.h> > > + > > +#include <errno.h> > > + > > /* > > * This corresponds to the same macro defined in > > * include/linux/kallsyms.h > > @@ -267,14 +275,62 @@ static struct btf_elf *btfe; > > static uint32_t array_index_id; > > static bool has_index_type; > > > > -int btf_encoder__encode() > > +static int btf_encoder__dump(struct btf *btf, const char *filename) > > +{ > > + uint32_t raw_btf_size; > > + const void *raw_btf_data; > > + int fd, err; > > + > > + /* Empty file, nothing to do, so... done! */ > > + if (btf__get_nr_types(btf) == 0) > > + return 0; > > + > > + if (btf__dedup(btf, NULL, NULL)) { > > + fprintf(stderr, "%s: btf__dedup failed!\n", __func__); > > + return -1; > > + } > > + > > + raw_btf_data = btf__get_raw_data(btf, &raw_btf_size); > > + if (raw_btf_data == NULL) { > > + fprintf(stderr, "%s: btf__get_raw_data failed!\n", __func__); > > + return -1; > > + } > > + > > + fd = open(filename, O_WRONLY | O_CREAT); > > I think you need to specify file mode as 3rd param: Right you are! I've read this comment from you and, left it for later and then when I used btf__parse_split("vmlinux.btf", NULL) as Andrii suggested, I got a EPERM, erm? tried btf__parse-split("/sys/kernel/btf/vmlinux", NULL), it worked, humm, yeah, Jiri mentioned something about weird modes... Fixed it using 'chmod 644' and it worked. Now fixing it by adding the 3rd param, thanks! - Arnaldo > $ ./pahole -j krava vmlinux > $ ~/linux/tools/bpf/bpftool/bpftool btf dump file ./krava > Error: failed to load BTF from ./krava: Permission denied > $ ll krava > --w-r-Sr-T. 1 jolsa jolsa 4525734 May 30 23:38 krava > > jirka > -- - Arnaldo