Fix compiler warnings, looking for suggestions
v2 cover Fix compiler warnings, looking for suggestions
Hi,
This patchset has a few fixes to compiler warnings.
I am studying the BPF subsystem and wish to bring more tangible contributions. I would appreciate receiving suggestions on things to investigate. I also documented a bit in my blog. I could help with docs here, too.
https://rcpassos.me/post/linux-ebpf-understanding-kernel-level-mechanics
Thanks!
Changelog V1 -> V2:
- rebased all commits to updated for-next base
- removes new cases of the extra parameter for bpf_jit_binary_pack_finalize
- built and tested for ARM64
- sent the series for the test workflow:
https://github.com/kernel-patches/bpf/pull/7198
Rafael Passos (3):
bpf: remove unused parameter in bpf_jit_binary_pack_finalize
bpf: remove unused parameter in __bpf_free_used_btfs
bpf: remove redeclaration of new_n in bpf_verifier_vlog
arch/arm64/net/bpf_jit_comp.c | 3 +-- arch/powerpc/net/bpf_jit_comp.c | 4 ++-- arch/riscv/net/bpf_jit_core.c | 5 ++--- arch/x86/net/bpf_jit_comp.c | 4 ++-- include/linux/bpf.h | 3 +-- include/linux/filter.h | 3 +-- kernel/bpf/core.c | 8 +++----- kernel/bpf/log.c | 2 +- kernel/bpf/verifier.c | 3 +-- 9 files changed, 14 insertions(+), 21 deletions(-)
Signature · 1 line
2.45.2
PATCH v2 1/3 bpf: remove unused parameter in bpf_jit_binary_pack_finalize
Fixes a compiler warning. the bpf_jit_binary_pack_finalize function was taking an extra bpf_prog parameter that went unused. This removves it and updates the callers accordingly.
--- arch/arm64/net/bpf_jit_comp.c | 3 +-- arch/powerpc/net/bpf_jit_comp.c | 4 ++-- arch/riscv/net/bpf_jit_core.c | 5 ++--- arch/x86/net/bpf_jit_comp.c | 4 ++-- include/linux/filter.h | 3 +-- kernel/bpf/core.c | 3 +-- 6 files changed, 9 insertions(+), 13 deletions(-)
arch/arm64/net/bpf_jit_comp.c +1 -2
@@ -1829,8 +1829,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog) prog->jited_len =0 ; goto out_free_hdr; } -if (WARN_ON (bpf_jit_binary_pack_finalize (prog, ro_header, - header))) { +if (WARN_ON (bpf_jit_binary_pack_finalize (ro_header, header))) {/* ro_header has been freed */ ro_header =NULL ; prog = orig_prog;
arch/powerpc/net/bpf_jit_comp.c +2 -2
@@ -225,7 +225,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *fp) fp->jited_len = proglen +FUNCTION_DESCR_SIZE ;if (!fp->is_func || extra_pass) { -if (bpf_jit_binary_pack_finalize (fp, fhdr, hdr)) { +if (bpf_jit_binary_pack_finalize (fhdr, hdr)) { fp = org_fp; goto out_addrs; }
@@ -348,7 +348,7 @@ void bpf_jit_free(struct bpf_prog *fp)* before freeing it. */ if (jit_data) { -bpf_jit_binary_pack_finalize (fp, jit_data->fhdr, jit_data->hdr); +bpf_jit_binary_pack_finalize (jit_data->fhdr, jit_data->hdr);kvfree (jit_data->addrs);kfree (jit_data); }
arch/riscv/net/bpf_jit_core.c +2 -3
@@ -178,8 +178,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog) prog->jited_len = prog_size -cfi_get_offset ();if (!prog->is_func || extra_pass) { -if (WARN_ON (bpf_jit_binary_pack_finalize (prog, jit_data->ro_header, - jit_data->header))) { +if (WARN_ON (bpf_jit_binary_pack_finalize (jit_data->ro_header, jit_data->header))) {/* ro_header has been freed */ jit_data->ro_header =NULL ; prog = orig_prog;
@@ -258,7 +257,7 @@ void bpf_jit_free(struct bpf_prog *prog)* before freeing it. */ if (jit_data) { -bpf_jit_binary_pack_finalize (prog, jit_data->ro_header, jit_data->header); +bpf_jit_binary_pack_finalize (jit_data->ro_header, jit_data->header);kfree (jit_data); } hdr =bpf_jit_binary_pack_hdr (prog);
arch/x86/net/bpf_jit_comp.c +2 -2
@@ -3363,7 +3363,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)* * Both cases are serious bugs and justify WARN_ON. */ -if (WARN_ON (bpf_jit_binary_pack_finalize (prog, header, rw_header))) { +if (WARN_ON (bpf_jit_binary_pack_finalize (header, rw_header))) {/* header has been freed */ header =NULL ; goto out_image;
@@ -3442,7 +3442,7 @@ void bpf_jit_free(struct bpf_prog *prog)* before freeing it. */ if (jit_data) { -bpf_jit_binary_pack_finalize (prog, jit_data->header, +bpf_jit_binary_pack_finalize (jit_data->header, jit_data->rw_header);kvfree (jit_data->addrs);kfree (jit_data);
include/linux/filter.h +1 -2
@@ -1129,8 +1129,7 @@ bpf_jit_binary_pack_alloc(unsigned int proglen, u8 **ro_image,struct bpf_binary_header **rw_hdr, u8 **rw_image, bpf_jit_fill_hole_t bpf_fill_ill_insns); -int bpf_jit_binary_pack_finalize (struct bpf_prog *prog, -struct bpf_binary_header *ro_header, +int bpf_jit_binary_pack_finalize (struct bpf_binary_header *ro_header,struct bpf_binary_header *rw_header);void bpf_jit_binary_pack_free (struct bpf_binary_header *ro_header,struct bpf_binary_header *rw_header);
kernel/bpf/core.c +1 -2
@@ -1174,8 +1174,7 @@ bpf_jit_binary_pack_alloc(unsigned int proglen, u8 **image_ptr, }/* Copy JITed text from rw_header to its final location, the ro_header. */ -int bpf_jit_binary_pack_finalize (struct bpf_prog *prog, -struct bpf_binary_header *ro_header, +int bpf_jit_binary_pack_finalize (struct bpf_binary_header *ro_header,struct bpf_binary_header *rw_header) {void *ptr;
Signature · 1 line
2.45.2
PATCH v2 2/3 bpf: remove unused parameter in __bpf_free_used_btfs
In reply to Rafael PassosFixes a compiler warning. The __bpf_free_used_btfs function was taking an extra unused struct bpf_prog_aux *aux param
--- include/linux/bpf.h | 3 +-- kernel/bpf/core.c | 5 ++--- kernel/bpf/verifier.c | 3 +-- 3 files changed, 4 insertions(+), 7 deletions(-)
include/linux/bpf.h +1 -2
@@ -2933,8 +2933,7 @@ bpf_probe_read_kernel_common(void *dst, u32 size, const void *unsafe_ptr)return ret; } -void __bpf_free_used_btfs (struct bpf_prog_aux *aux, -struct btf_mod_pair *used_btfs,u32 len); +void __bpf_free_used_btfs (struct btf_mod_pair *used_btfs,u32 len);static inline struct bpf_prog *bpf_prog_get_type (u32 ufd,enum bpf_prog_type type)
kernel/bpf/core.c +2 -3
@@ -2742,8 +2742,7 @@ static void bpf_free_used_maps(struct bpf_prog_aux *aux)kfree (aux->used_maps); } -void __bpf_free_used_btfs (struct bpf_prog_aux *aux, -struct btf_mod_pair *used_btfs,u32 len) +void __bpf_free_used_btfs (struct btf_mod_pair *used_btfs,u32 len) {#ifdef CONFIG_BPF_SYSCALL struct btf_mod_pair *btf_mod;
@@ -2760,7 +2759,7 @@ void __bpf_free_used_btfs(struct bpf_prog_aux *aux,static void bpf_free_used_btfs (struct bpf_prog_aux *aux) { -__bpf_free_used_btfs (aux, aux->used_btfs, aux->used_btf_cnt); +__bpf_free_used_btfs (aux->used_btfs, aux->used_btf_cnt);kfree (aux->used_btfs); }
kernel/bpf/verifier.c +1 -2
@@ -18619,8 +18619,7 @@ static void release_maps(struct bpf_verifier_env *env)/* drop refcnt of maps used by the rejected program */ static void release_btfs (struct bpf_verifier_env *env) { -__bpf_free_used_btfs (env->prog->aux, env->used_btfs, - env->used_btf_cnt); +__bpf_free_used_btfs (env->used_btfs, env->used_btf_cnt); }/* convert pseudo BPF_LD_IMM64 into generic BPF_LD_IMM64 */
Signature · 1 line
2.45.2
PATCH v2 3/3 bpf: remove redeclaration of new_n in bpf_verifier_vlog
In reply to Rafael PassosThis new_n is defined in the start of this function. Its value is overwritten by new_n = min(n, log->len_total); a couple lines before my change,
rendering the shadow declaration unnecessary.
--- kernel/bpf/log.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/bpf/log.c +1 -1
@@ -91,7 +91,7 @@ void bpf_verifier_vlog(struct bpf_verifier_log *log, const char *fmt, goto fail; }else {u64 new_end, new_start; -u32 buf_start, buf_end, new_n; +u32 buf_start, buf_end; new_end = log->end_pos + n;if (new_end - log->start_pos >= log->len_total)
Signature · 1 line
2.45.2
Quoted 2 lines · Rafael Passos
Hi,
This patchset has a few fixes to compiler warnings.
curious, which compiler/setup displayed the warnings?
Quoted 14 lines
I am studying the BPF subsystem and wish to bring more tangible contributions. I would appreciate receiving suggestions on things to investigate. I also documented a bit in my blog. I could help with docs here, too.
https://rcpassos.me/post/linux-ebpf-understanding-kernel-level-mechanics
Thanks!Changelog V1 -> V2:
- rebased all commits to updated for-next base
- removes new cases of the extra parameter forbpf_jit_binary_pack_finalize
- built and tested for ARM64
- sent the series for the test workflow:
https://github.com/kernel-patches/bpf/pull/7198
Quoted 4 lines
Rafael Passos (3):
bpf: remove unused parameter inbpf_jit_binary_pack_finalize
bpf: remove unused parameter in__bpf_free_used_btfs
bpf: remove redeclaration ofnew_ninbpf_verifier_vlog
lgtm, nice cleanup
jirka
Quoted 16 lines
arch/arm64/net/bpf_jit_comp.c | 3 +-- arch/powerpc/net/bpf_jit_comp.c | 4 ++-- arch/riscv/net/bpf_jit_core.c | 5 ++--- arch/x86/net/bpf_jit_comp.c | 4 ++-- include/linux/bpf.h | 3 +-- include/linux/filter.h | 3 +-- kernel/bpf/core.c | 8 +++----- kernel/bpf/log.c | 2 +- kernel/bpf/verifier.c | 3 +-- 9 files changed, 14 insertions(+), 21 deletions(-)Signature · 1 line
2.45.2
Quoted 5 lines · Jiri Olsa
Quoted 2 lines · Rafael Passos
Hi,
This patchset has a few fixes to compiler warnings.curious, which compiler/setup displayed the warnings?
It took me a few tries with different configs. My most successful one was using gcc (14.1.1) make -j24 ARCH=x86_64 W=12 2>&1 | tee warnings.log I dug through the Logs (with grep)looking for BPF and non macro expansion warnings.
Thanks!
Quoted 40 lines
Quoted 11 lines
I am studying the BPF subsystem and wish to bring more tangible contributions. I would appreciate receiving suggestions on things to investigate. I also documented a bit in my blog. I could help with docs here, too.
https://rcpassos.me/post/linux-ebpf-understanding-kernel-level-mechanics
Thanks!Changelog V1 -> V2:
- rebased all commits to updated for-next base
- removes new cases of the extra parameter forbpf_jit_binary_pack_finalize
- built and tested for ARM64
- sent the series for the test workflow:Quoted 7 lines
https://github.com/kernel-patches/bpf/pull/7198Rafael Passos (3):
bpf: remove unused parameter inbpf_jit_binary_pack_finalize
bpf: remove unused parameter in__bpf_free_used_btfs
bpf: remove redeclaration ofnew_ninbpf_verifier_vloglgtm, nice cleanup
Acked-by Jiri Olsa <[email protected]>jirka
Quoted 15 lines
arch/arm64/net/bpf_jit_comp.c | 3 +-- arch/powerpc/net/bpf_jit_comp.c | 4 ++-- arch/riscv/net/bpf_jit_core.c | 5 ++--- arch/x86/net/bpf_jit_comp.c | 4 ++-- include/linux/bpf.h | 3 +-- include/linux/filter.h | 3 +-- kernel/bpf/core.c | 8 +++----- kernel/bpf/log.c | 2 +- kernel/bpf/verifier.c | 3 +-- 9 files changed, 14 insertions(+), 21 deletions(-)Signature · 1 line
2.45.2
Quoted 21 lines · Rafael Passos
Hi,
This patchset has a few fixes to compiler warnings.
I am studying the BPF subsystem and wish to bring more tangible contributions. I would appreciate receiving suggestions on things to investigate. I also documented a bit in my blog. I could help with docs here, too.
https://rcpassos.me/post/linux-ebpf-understanding-kernel-level-mechanics
Thanks!Changelog V1 -> V2:
- rebased all commits to updated for-next base
- removes new cases of the extra parameter forbpf_jit_binary_pack_finalize
- built and tested for ARM64
- sent the series for the test workflow:
https://github.com/kernel-patches/bpf/pull/7198Rafael Passos (3):
bpf: remove unused parameter inbpf_jit_binary_pack_finalize
bpf: remove unused parameter in__bpf_free_used_btfs
bpf: remove redeclaration ofnew_ninbpf_verifier_vlog
Quoted 13 lines
arch/arm64/net/bpf_jit_comp.c | 3 +-- arch/powerpc/net/bpf_jit_comp.c | 4 ++-- arch/riscv/net/bpf_jit_core.c | 5 ++--- arch/x86/net/bpf_jit_comp.c | 4 ++-- include/linux/bpf.h | 3 +-- include/linux/filter.h | 3 +-- kernel/bpf/core.c | 8 +++----- kernel/bpf/log.c | 2 +- kernel/bpf/verifier.c | 3 +-- 9 files changed, 14 insertions(+), 21 deletions(-)Signature · 1 line
2.45.2
Thanks,
Puranjay
This series was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:
Hello:
This series was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:
Quoted 9 lines · On Fri, 14 Jun 2024 23:24:07 -0300 you wrote:
Hi,
This patchset has a few fixes to compiler warnings.
I am studying the BPF subsystem and wish to bring more tangible contributions. I would appreciate receiving suggestions on things to investigate. I also documented a bit in my blog. I could help with docs here, too.
https://rcpassos.me/post/linux-ebpf-understanding-kernel-level-mechanics
Thanks![...]
Here is the summary with links:
- [bpf-next,V2,1/3] bpf: remove unused parameter in bpf_jit_binary_pack_finalize
https://git.kernel.org/bpf/bpf-next/c/9919c5c98cb2 - [bpf-next,V2,2/3] bpf: remove unused parameter in __bpf_free_used_btfs https://git.kernel.org/bpf/bpf-next/c/ab224b9ef7c4 - [bpf-next,V2,3/3] bpf: remove redeclaration of new_n in bpf_verifier_vlog https://git.kernel.org/bpf/bpf-next/c/21ab4980e02d
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html