Skip to contentSkip to conversation

bpf: Fix a 'unused function' compilation error

PATCH In review Yonghong Song 2 participants 4 messages Jan 12, 2024

Subsystems (2)
lore
Share & tools
lore

Yonghong Song

author reviewer
#0 lore raw

PATCH 1/1 bpf: Fix a 'unused function' compilation error

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/[email protected]/
[2] https://lore.kernel.org/bpf/[email protected]/

---
 kernel/bpf/verifier.c | 2 ++
 1 file changed, 2 insertions(+)
kernel/bpf/verifier.c +2 -0
index 7ddad07ae928..e1f42082f32f 100644
@@ -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)
Signature · 1 line
2.34.1
#1 lore raw
Quoted 14 lines · Yonghong Song

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.

Quoted 6 lines

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/[email protected]/
[2] https://lore.kernel.org/bpf/[email protected]/

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?

author reviewer
#2 lore raw
Quoted 18 lines · Alexei Starovoitov
Quoted 17 lines · Yonghong Song

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.

Quoted 5 lines
Quoted 2 lines
   [1] https://lore.kernel.org/bpf/[email protected]/
   [2] https://lore.kernel.org/bpf/[email protected]/

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.

#3 lore raw
Quoted 21 lines · Yonghong Song
Quoted 18 lines · Alexei Starovoitov
Quoted 17 lines · Yonghong Song

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.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
   [1] https://lore.kernel.org/bpf/[email protected]/
   [2] https://lore.kernel.org/bpf/[email protected]/

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.