Skip to contentSkip to conversation

ebpf/rss.bpf.skeleton.h generated by what?

DISCUSSION Markus Armbruster 5 participants 13 messages May 6, 2022 – May 11, 2022

lore
Share & tools
lore
#0 lore raw

ebpf/rss.bpf.skeleton.h contains

    /* THIS FILE IS AUTOGENERATED! */

If it was generated by something in the tree, it should not be committed to git. Doesn't look like it is.

Perhaps it was copied from elsewhere, but the commit message offers no clue.

Please advise.

#1 lore raw
Quoted 7 lines · Markus Armbruster

ebpf/rss.bpf.skeleton.h contains

    /* THIS FILE IS AUTOGENERATED! */

If it was generated by something in the tree, it should not be committed to git. Doesn't look like it is.

Andrew may know more.

I remember it was generated by libbpf.

Thanks

Quoted 6 lines

Perhaps it was copied from elsewhere, but the commit message offers no clue.

Please advise.

#2 lore raw
Quoted 5 lines · Jason Wang
Quoted 2 lines

If it was generated by something in the tree, it should not be committed to git. Doesn't look like it is.

Andrew may know more.

I remember it was generated by libbpf.

What is the source?

Paolo

#3 lore raw
Quoted 9 lines · Paolo Bonzini
Quoted 5 lines · Jason Wang
Quoted 2 lines

If it was generated by something in the tree, it should not be committed to git. Doesn't look like it is.

Andrew may know more.

I remember it was generated by libbpf.

What is the source?

It's tools/ebpf/rss.bpf.c.

Thanks

Quoted 3 lines

Paolo

#4 lore raw
Quoted 5 lines · Jason Wang
Quoted 4 lines · Paolo Bonzini
Quoted 2 lines · Jason Wang
Quoted 2 lines

If it was generated by something in the tree, it should not be committed to git. Doesn't look like it is.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

Andrew may know more.

I remember it was generated by libbpf.

What is the source?

It's tools/ebpf/rss.bpf.c.

Thanks, maybe we can reuse some of the support for cross compilation that will be introduced soon.

Paolo

#5 lore raw
Quoted 9 lines · Paolo Bonzini
Quoted 7 lines · Jason Wang
Quoted 6 lines · Paolo Bonzini
Quoted 4 lines · Jason Wang
Quoted 2 lines

If it was generated by something in the tree, it should not be committed to git. Doesn't look like it is.

Andrew may know more.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

I remember it was generated by libbpf.

What is the source?

It's tools/ebpf/rss.bpf.c.

Thanks, maybe we can reuse some of the support for cross compilation that will be introduced soon.

That would be better. The reason we don't auto generate during make is to avoid adding new dependencies (where libbpf/bpftool is not popular at that time).

Thanks

Quoted 3 lines

Paolo

#6 lore raw
Quoted 8 lines · Jason Wang
Quoted 7 lines · Paolo Bonzini
Quoted 5 lines · Jason Wang
Quoted 4 lines · Paolo Bonzini
Quoted 2 lines · Jason Wang
Quoted 2 lines

If it was generated by something in the tree, it should not be committed to git. Doesn't look like it is.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

Andrew may know more.

I remember it was generated by libbpf.

What is the source?

It's tools/ebpf/rss.bpf.c.

Aha:

    $ cat tools/ebpf/Makefile.ebpf
    [...]
    $(OBJS):  %.o:%.c
            $(CLANG) $(INC_FLAGS) \
                    -D__KERNEL__ -D__ASM_SYSREG_H \
                    -I../include $(LINUXINCLUDE) \
                    $(EXTRA_CFLAGS) -c $< -o -| $(LLC) -march=bpf -filetype=obj -o $@
            bpftool gen skeleton rss.bpf.o > rss.bpf.skeleton.h
--->        cp rss.bpf.skeleton.h ../../ebpf/

and

    $ cat docs/devel/ebpf_rss.rst
    [...]
    RSS eBPF program
    ----------------

RSS program located in ebpf/rss.bpf.skeleton.h generated by bpftool.
So the program is part of the qemu binary.
Initially, the eBPF program was compiled by clang and source code located at tools/ebpf/rss.bpf.c. Prerequisites to recompile the eBPF program (regenerate ebpf/rss.bpf.skeleton.h):

llvm, clang, kernel source tree, bpftool
Adjust Makefile.ebpf to reflect the location of the kernel source tree

$ cd tools/ebpf
$ make -f Makefile.ebpf
[...]

Together, this answers my "what" question. It doesn't answer my next
question: why? That one gets answered ...

Quoted 4 lines
Quoted 2 lines

Thanks, maybe we can reuse some of the support for cross compilation that will be introduced soon.

That would be better.

... here:

Quoted 3 lines

The reason we don't auto generate during make is
to avoid adding new dependencies (where libbpf/bpftool is not popular at that time).

Always, always, *always* document your reasons for doing stuff right in the commit message, unless they are blindingly obvious. I understand reasons can be obvious enough to the author. Document them anyway if there is any chance they are not obvious to others.

#7 lore raw
Quoted 60 lines · Markus Armbruster
Quoted 8 lines · Jason Wang
Quoted 7 lines · Paolo Bonzini
Quoted 5 lines · Jason Wang
Quoted 4 lines · Paolo Bonzini
Quoted 2 lines · Jason Wang
Quoted 2 lines

If it was generated by something in the tree, it should not be committed to git. Doesn't look like it is.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

Andrew may know more.

I remember it was generated by libbpf.

What is the source?

It's tools/ebpf/rss.bpf.c.

Aha:

    $ cat tools/ebpf/Makefile.ebpf
    [...]
    $(OBJS):  %.o:%.c
            $(CLANG) $(INC_FLAGS) \
                    -D__KERNEL__ -D__ASM_SYSREG_H \
                    -I../include $(LINUXINCLUDE) \
                    $(EXTRA_CFLAGS) -c $< -o -| $(LLC) -march=bpf -filetype=obj -o $@
            bpftool gen skeleton rss.bpf.o > rss.bpf.skeleton.h
--->        cp rss.bpf.skeleton.h ../../ebpf/

and

    $ cat docs/devel/ebpf_rss.rst
    [...]
    RSS eBPF program
    ----------------

RSS program located in ebpf/rss.bpf.skeleton.h generated by bpftool.
So the program is part of the qemu binary.
Initially, the eBPF program was compiled by clang and source code located at tools/ebpf/rss.bpf.c. Prerequisites to recompile the eBPF program (regenerate ebpf/rss.bpf.skeleton.h):

llvm, clang, kernel source tree, bpftool
Adjust Makefile.ebpf to reflect the location of the kernel source tree

$ cd tools/ebpf
$ make -f Makefile.ebpf
[...]

Together, this answers my "what" question. It doesn't answer my next
question: why? That one gets answered ...

Quoted 4 lines
Quoted 2 lines

Thanks, maybe we can reuse some of the support for cross compilation that will be introduced soon.

That would be better.

... here:

Quoted 9 lines
Quoted 3 lines

The reason we don't auto generate during make is
to avoid adding new dependencies (where libbpf/bpftool is not popular at that time).

Always, always, *always* document your reasons for doing stuff right in the commit message, unless they are blindingly obvious. I understand reasons can be obvious enough to the author. Document them anyway if there is any chance they are not obvious to others.

Ok.

Andrew, want to post a patch to explain this?

Thanks

#8 lore raw
In reply to Markus Armbruster
Quoted 4 lines · Markus Armbruster

Always, always, *always* document your reasons for doing stuff right in the commit message, unless they are blindingly obvious. I understand reasons can be obvious enough to the author. Document them anyway if there is any chance they are not obvious to others.

It's also nice for code-generators to say who they are in this kind of "this file is autogenerated" comment. For instance our own decodetree script's comments read
/* This file is autogenerated by scripts/decodetree.py. */

-- PMM

#9 lore raw
Quoted 11 lines · Peter Maydell
Quoted 4 lines · Markus Armbruster

Always, always, *always* document your reasons for doing stuff right in the commit message, unless they are blindingly obvious. I understand reasons can be obvious enough to the author. Document them anyway if there is any chance they are not obvious to others.

It's also nice for code-generators to say who they are in this kind of "this file is autogenerated" comment. For instance our own decodetree script's comments read
/* This file is autogenerated by scripts/decodetree.py. */

Unfortunately, this is not what bpftool did right now.

Have posted a patch (with Markus and you cced).

Thanks

Quoted 3 lines

-- PMM

#10 lore raw

Hi all,
The ebpf/rss.bpf.skeleton.h is generetad by bpftool from tools/ebpf/rss.bpf.c. To generate the skeleton - would require dependencies of llvm and bpftool. RSS eBPF solution, for now, is only for Linux hosts.

Quoted 1 line

Andrew, want to post a patch to explain this?

I am all in for clarification. And will prepare a new patch if required. Please advise, what those patches should be? Documentation update?

Quoted 24 lines · Jason Wang
Quoted 11 lines · Peter Maydell
Quoted 4 lines · Markus Armbruster

Always, always, *always* document your reasons for doing stuff right in the commit message, unless they are blindingly obvious. I understand reasons can be obvious enough to the author. Document them anyway if there is any chance they are not obvious to others.

It's also nice for code-generators to say who they are in this kind of "this file is autogenerated" comment. For instance our own decodetree script's comments read
/* This file is autogenerated by scripts/decodetree.py. */

Unfortunately, this is not what bpftool did right now.

Have posted a patch (with Markus and you cced).

Thanks

Quoted 3 lines

-- PMM

#11 lore raw
Quoted 9 lines · Andrew Melnichenko

Hi all,
The ebpf/rss.bpf.skeleton.h is generetad by bpftool from tools/ebpf/rss.bpf.c. To generate the skeleton - would require dependencies of llvm and bpftool. RSS eBPF solution, for now, is only for Linux hosts.

Quoted 1 line

Andrew, want to post a patch to explain this?

I am all in for clarification. And will prepare a new patch if required. Please advise, what those patches should be? Documentation update?

It looks to me the doc are fine:

"""
RSS eBPF program
----------------

RSS program located in ebpf/rss.bpf.skeleton.h generated by bpftool. So the program is part of the qemu binary.
Initially, the eBPF program was compiled by clang and source code located at tools/ebpf/rss.bpf.c.
"""

It was too late to fix the changelog but we probably don't have anything to do.

Or we can update ebpf/rss.bpf.skeleton.h by using the most recent bpftool where I've added the BPFTOOL as the generator name[1].

Thanks

[1] https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/commit/?id=56c3e749d08a

Quoted 28 lines · Jason Wang
Quoted 24 lines · Peter Maydell
Quoted 11 lines · Markus Armbruster
Quoted 4 lines

Always, always, *always* document your reasons for doing stuff right in the commit message, unless they are blindingly obvious. I understand reasons can be obvious enough to the author. Document them anyway if there is any chance they are not obvious to others.

It's also nice for code-generators to say who they are in this kind of "this file is autogenerated" comment. For instance our own decodetree script's comments read
/* This file is autogenerated by scripts/decodetree.py. */

Unfortunately, this is not what bpftool did right now.

Have posted a patch (with Markus and you cced).

Thanks

Quoted 3 lines

-- PMM

#12 lore raw
Quoted 17 lines · Jason Wang
Quoted 9 lines · Andrew Melnichenko

Hi all,
The ebpf/rss.bpf.skeleton.h is generetad by bpftool from tools/ebpf/rss.bpf.c. To generate the skeleton - would require dependencies of llvm and bpftool. RSS eBPF solution, for now, is only for Linux hosts.

Quoted 1 line

Andrew, want to post a patch to explain this?

I am all in for clarification. And will prepare a new patch if required. Please advise, what those patches should be? Documentation update?

It looks to me the doc are fine:

"""
RSS eBPF program
----------------

Quoted 5 lines

RSS program located in ebpf/rss.bpf.skeleton.h generated by bpftool. So the program is part of the qemu binary.
Initially, the eBPF program was compiled by clang and source code located at tools/ebpf/rss.bpf.c.
"""

Agreed.

Quoted 1 line

It was too late to fix the changelog but we probably don't have anything to do.

Next time :)

Quoted 2 lines

Or we can update ebpf/rss.bpf.skeleton.h by using the most recent bpftool where I've added the BPFTOOL as the generator name[1].

Won't hurt, but no rush.

Quoted 3 lines

Thanks

[1] https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/commit/?id=56c3e749d08a