Re: [PATCH bpf] selftests/bpf: Re-add kfunc declarations to qdisc tests

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 7/1/25 23:07, Andrii Nakryiko wrote:
> On Tue, Jul 1, 2025 at 1:54 PM Viktor Malik <vmalik@xxxxxxxxxx> wrote:
>>
>> On 7/1/25 22:28, Andrii Nakryiko wrote:

[...]

>>> Note, we have a VMLINUX_H argument that can be passed into BPF
>>> selftests' makefile. We used to use this for libbpf CI to build latest
>>> selftests against (very) old kernels, and it worked well.
>>>
>>> I don't think we need to make exceptions for a few kfuncs, all it
>>> takes is to have vmlinux.h generated from kernel image built from
>>> proper configuration.
>>>
>>> Also note, that "proper configuration" only applies to *built* kernel,
>>> not the actually running host kernel. See how VMLINUX_BTF_PATHS is
>>> defined and handled: host kernel is the last thing we use for
>>> vmlinux.h generation, only if all other options are unavailable.
>>
>> This is a good point but the problem here is the extra kernel build. If
>> you want to check that BPF in your kernel is working properly, you don't
>> want to do another kernel build with a different config just for the
>> sake of being able to build selftests.
> 
> What exactly is problematic? That's what I and others do all the time.
> If kernel build time is a concern, then pre-generate/pre-package
> vmlinux.h separately and use it to avoid building the kernel. (but BPF
> selftest *expects* kernel to be built first, we also build bpf_testmod
> against that kernel). Or just build/package test_progs itself, if
> that's what works better.

Yes, we need to have a kernel built before building selftests but your
solution would require to build it twice - once with the desired
configuration and once with added selftests/bpf/config to generate
vmlinux.h that can be used for selftests build.

Pre-building vmlinux.h is not really an option for automated builds as
every kernel change may introduce some new kfuncs which will be needed
for selftests build. So, we'd need to build vmlinux.h every time.

> Basically, we have that selftest/bpf/config file for a reason: so that
> we don't guard every single thing that might not build or work
> properly if some of the Kconfig value is not set.

[...]

> we should be getting rid of all those __ksym __weak kfunc
> redefinitions because they now should come from vmlinux.h, not add
> more of that, IMO.

I understand that having those kfunc definitions in selftests is
cumbersome and has maintenence cost. While vmlinux.h works for upstream
use-cases, it has its problems for distro packagers, so I'll try to
think about some solution that would be acceptable for both sides.





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux