diff mbox series

[bpf-next] bpf: Fix a 'unused function' compilation error

Message ID 20240112041649.2891872-1-yonghong.song@linux.dev (mailing list archive)
State Changes Requested
Delegated to: BPF
Headers show
Series [bpf-next] bpf: Fix a 'unused function' compilation error | expand

Checks

Context Check Description
bpf/vmtest-bpf-next-VM_Test-29 success Logs for x86_64-llvm-17 / veristat
bpf/vmtest-bpf-next-VM_Test-30 success Logs for x86_64-llvm-18 / build / build for x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-37 success Logs for x86_64-llvm-18 / veristat
bpf/vmtest-bpf-next-VM_Test-26 success Logs for x86_64-llvm-17 / test (test_progs, false, 360) / test_progs on x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-25 success Logs for x86_64-llvm-17 / test (test_maps, false, 360) / test_maps on x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-28 success Logs for x86_64-llvm-17 / test (test_verifier, false, 360) / test_verifier on x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-34 success Logs for x86_64-llvm-18 / test (test_progs_cpuv4, false, 360) / test_progs_cpuv4 on x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-32 success Logs for x86_64-llvm-18 / test (test_maps, false, 360) / test_maps on x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-35 success Logs for x86_64-llvm-18 / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-36 success Logs for x86_64-llvm-18 / test (test_verifier, false, 360) / test_verifier on x86_64 with llvm-18
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for bpf-next
netdev/ynl success SINGLE THREAD; Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1105 this patch: 1104
netdev/cc_maintainers success CCed 0 of 0 maintainers
netdev/build_clang success Errors and warnings before: 1110 this patch: 1108
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1120 this patch: 1119
netdev/checkpatch warning WARNING: Consider removing the code enclosed by this #if 0 and its #endif WARNING: use relative pathname instead of absolute in changelog text
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
bpf/vmtest-bpf-next-VM_Test-27 success Logs for x86_64-llvm-17 / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-31 success Logs for x86_64-llvm-18 / build-release / build for x86_64 with llvm-18 and -O2 optimization
bpf/vmtest-bpf-next-VM_Test-33 success Logs for x86_64-llvm-18 / test (test_progs, false, 360) / test_progs on x86_64 with llvm-18
bpf/vmtest-bpf-next-PR fail PR summary
bpf/vmtest-bpf-next-VM_Test-0 success Logs for Lint
bpf/vmtest-bpf-next-VM_Test-1 success Logs for ShellCheck
bpf/vmtest-bpf-next-VM_Test-2 success Logs for Unittests
bpf/vmtest-bpf-next-VM_Test-3 success Logs for Validate matrix.py
bpf/vmtest-bpf-next-VM_Test-5 success Logs for aarch64-gcc / build-release
bpf/vmtest-bpf-next-VM_Test-6 success Logs for aarch64-gcc / test
bpf/vmtest-bpf-next-VM_Test-4 fail Logs for aarch64-gcc / build / build for aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-7 success Logs for aarch64-gcc / veristat
bpf/vmtest-bpf-next-VM_Test-9 success Logs for s390x-gcc / build-release
bpf/vmtest-bpf-next-VM_Test-8 fail Logs for s390x-gcc / build / build for s390x with gcc
bpf/vmtest-bpf-next-VM_Test-10 success Logs for s390x-gcc / test
bpf/vmtest-bpf-next-VM_Test-11 success Logs for s390x-gcc / veristat
bpf/vmtest-bpf-next-VM_Test-12 success Logs for set-matrix
bpf/vmtest-bpf-next-VM_Test-13 fail Logs for x86_64-gcc / build / build for x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-14 success Logs for x86_64-gcc / build-release
bpf/vmtest-bpf-next-VM_Test-17 fail Logs for x86_64-llvm-17 / build / build for x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-16 success Logs for x86_64-gcc / veristat
bpf/vmtest-bpf-next-VM_Test-15 success Logs for x86_64-gcc / test
bpf/vmtest-bpf-next-VM_Test-19 success Logs for x86_64-llvm-17 / test
bpf/vmtest-bpf-next-VM_Test-20 success Logs for x86_64-llvm-17 / veristat
bpf/vmtest-bpf-next-VM_Test-18 fail Logs for x86_64-llvm-17 / build-release / build for x86_64 with llvm-17 and -O2 optimization
bpf/vmtest-bpf-next-VM_Test-21 fail Logs for x86_64-llvm-18 / build / build for x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-22 fail Logs for x86_64-llvm-18 / build-release / build for x86_64 with llvm-18 and -O2 optimization
bpf/vmtest-bpf-next-VM_Test-23 success Logs for x86_64-llvm-18 / test
bpf/vmtest-bpf-next-VM_Test-24 success Logs for x86_64-llvm-18 / veristat

Commit Message

Yonghong Song Jan. 12, 2024, 4:16 a.m. UTC
Building the kernel with latest llvm18, I hit the following error:

 /home/yhs/work/bpf-next/kernel/bpf/verifier.c:4383:13: error: unused function '__is_scalar_unbounded' [-Werror,-Wunused-function]
  4383 | static bool __is_scalar_unbounded(struct bpf_reg_state *reg)
       |             ^~~~~~~~~~~~~~~~~~~~~
 1 error generated.

Patches [1] and [2] are in the same patch set. Patch [1] removed
the usage of __is_scalar_unbounded(), and patch [2] re-introduced
the usage of the function. Currently patch [1] is merged into
bpf-next while patch [2] does not, hence the above compilation
error is triggered.

To fix the compilation failure, let us temporarily make
__is_scalar_unbounded() not accessible through macro '#if 0'.
It can be re-introduced later when [2] is ready to merge.

  [1] https://lore.kernel.org/bpf/20240108205209.838365-11-maxtram95@gmail.com/
  [2] https://lore.kernel.org/bpf/20240108205209.838365-15-maxtram95@gmail.com/

Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
---
 kernel/bpf/verifier.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Alexei Starovoitov Jan. 12, 2024, 4:59 a.m. UTC | #1
On Thu, Jan 11, 2024 at 8:17 PM Yonghong Song <yonghong.song@linux.dev> wrote:
>
> Building the kernel with latest llvm18, I hit the following error:
>
>  /home/yhs/work/bpf-next/kernel/bpf/verifier.c:4383:13: error: unused function '__is_scalar_unbounded' [-Werror,-Wunused-function]
>   4383 | static bool __is_scalar_unbounded(struct bpf_reg_state *reg)
>        |             ^~~~~~~~~~~~~~~~~~~~~
>  1 error generated.
>
> Patches [1] and [2] are in the same patch set. Patch [1] removed
> the usage of __is_scalar_unbounded(), and patch [2] re-introduced
> the usage of the function. Currently patch [1] is merged into
> bpf-next while patch [2] does not, hence the above compilation
> error is triggered.
>
> To fix the compilation failure, let us temporarily make
> __is_scalar_unbounded() not accessible through macro '#if 0'.
> It can be re-introduced later when [2] is ready to merge.
>
>   [1] https://lore.kernel.org/bpf/20240108205209.838365-11-maxtram95@gmail.com/
>   [2] https://lore.kernel.org/bpf/20240108205209.838365-15-maxtram95@gmail.com/

Ouch. Sorry. This interaction between patches was unexpected.
Instead of this particular if 0 patch, is there a way to amend pushed
patches to avoid this issue?
Yonghong Song Jan. 12, 2024, 5:29 a.m. UTC | #2
On 1/11/24 8:59 PM, Alexei Starovoitov wrote:
> On Thu, Jan 11, 2024 at 8:17 PM Yonghong Song <yonghong.song@linux.dev> wrote:
>> Building the kernel with latest llvm18, I hit the following error:
>>
>>   /home/yhs/work/bpf-next/kernel/bpf/verifier.c:4383:13: error: unused function '__is_scalar_unbounded' [-Werror,-Wunused-function]
>>    4383 | static bool __is_scalar_unbounded(struct bpf_reg_state *reg)
>>         |             ^~~~~~~~~~~~~~~~~~~~~
>>   1 error generated.
>>
>> Patches [1] and [2] are in the same patch set. Patch [1] removed
>> the usage of __is_scalar_unbounded(), and patch [2] re-introduced
>> the usage of the function. Currently patch [1] is merged into
>> bpf-next while patch [2] does not, hence the above compilation
>> error is triggered.
>>
>> To fix the compilation failure, let us temporarily make
>> __is_scalar_unbounded() not accessible through macro '#if 0'.
>> It can be re-introduced later when [2] is ready to merge.
>>
>>    [1] https://lore.kernel.org/bpf/20240108205209.838365-11-maxtram95@gmail.com/
>>    [2] https://lore.kernel.org/bpf/20240108205209.838365-15-maxtram95@gmail.com/
> Ouch. Sorry. This interaction between patches was unexpected.
> Instead of this particular if 0 patch, is there a way to amend pushed
> patches to avoid this issue?

Another option is that in merged patch [1] removing the function __is_scalar_unbounded().
And the function can be re-introduced later if needed.
Alexei Starovoitov Jan. 12, 2024, 6:02 a.m. UTC | #3
On Thu, Jan 11, 2024 at 9:29 PM Yonghong Song <yonghong.song@linux.dev> wrote:
>
>
> On 1/11/24 8:59 PM, Alexei Starovoitov wrote:
> > On Thu, Jan 11, 2024 at 8:17 PM Yonghong Song <yonghong.song@linux.dev> wrote:
> >> Building the kernel with latest llvm18, I hit the following error:
> >>
> >>   /home/yhs/work/bpf-next/kernel/bpf/verifier.c:4383:13: error: unused function '__is_scalar_unbounded' [-Werror,-Wunused-function]
> >>    4383 | static bool __is_scalar_unbounded(struct bpf_reg_state *reg)
> >>         |             ^~~~~~~~~~~~~~~~~~~~~
> >>   1 error generated.
> >>
> >> Patches [1] and [2] are in the same patch set. Patch [1] removed
> >> the usage of __is_scalar_unbounded(), and patch [2] re-introduced
> >> the usage of the function. Currently patch [1] is merged into
> >> bpf-next while patch [2] does not, hence the above compilation
> >> error is triggered.
> >>
> >> To fix the compilation failure, let us temporarily make
> >> __is_scalar_unbounded() not accessible through macro '#if 0'.
> >> It can be re-introduced later when [2] is ready to merge.
> >>
> >>    [1] https://lore.kernel.org/bpf/20240108205209.838365-11-maxtram95@gmail.com/
> >>    [2] https://lore.kernel.org/bpf/20240108205209.838365-15-maxtram95@gmail.com/
> > Ouch. Sorry. This interaction between patches was unexpected.
> > Instead of this particular if 0 patch, is there a way to amend pushed
> > patches to avoid this issue?
>
> Another option is that in merged patch [1] removing the function __is_scalar_unbounded().
> And the function can be re-introduced later if needed.

Right. That will work, but it's not a tiny function.
So it's a code churn to remove it in a commit just to add it back
a few commits later.

To fix the build I dropped the last two commits,
but the issue remains.
If they're resend in the same shape later they will
re-introduce a bisect issue. Hence the question,
how we can tweak the patch "bpf: Track spilled unbounded scalars"
so it doesn't leave behind an unused static function.
diff mbox series

Patch

diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 7ddad07ae928..e1f42082f32f 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -4380,6 +4380,7 @@  static u64 reg_const_value(struct bpf_reg_state *reg, bool subreg32)
 	return subreg32 ? tnum_subreg(reg->var_off).value : reg->var_off.value;
 }
 
+#if 0
 static bool __is_scalar_unbounded(struct bpf_reg_state *reg)
 {
 	return tnum_is_unknown(reg->var_off) &&
@@ -4388,6 +4389,7 @@  static bool __is_scalar_unbounded(struct bpf_reg_state *reg)
 	       reg->s32_min_value == S32_MIN && reg->s32_max_value == S32_MAX &&
 	       reg->u32_min_value == 0 && reg->u32_max_value == U32_MAX;
 }
+#endif
 
 static bool __is_pointer_value(bool allow_ptr_leaks,
 			       const struct bpf_reg_state *reg)