diff mbox series

[bpf-next,v1] bpf: Remove the unnecessary insn buffer comparison

Message ID 20230108151258.96570-1-haiyue.wang@intel.com (mailing list archive)
State Accepted
Commit 66cf99b55e587aa4c20d5e572142dcbf80b2684d
Delegated to: BPF
Headers show
Series [bpf-next,v1] bpf: Remove the unnecessary insn buffer comparison | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for bpf-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 23 this patch: 23
netdev/cc_maintainers success CCed 17 of 17 maintainers
netdev/build_clang success Errors and warnings before: 1 this patch: 1
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
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: 23 this patch: 23
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 18 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
bpf/vmtest-bpf-next-PR success PR summary
bpf/vmtest-bpf-next-VM_Test-1 success Logs for ShellCheck
bpf/vmtest-bpf-next-VM_Test-2 success Logs for build for aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-3 success Logs for build for aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-4 success Logs for build for s390x with gcc
bpf/vmtest-bpf-next-VM_Test-5 success Logs for build for x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-6 success Logs for build for x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-7 success Logs for llvm-toolchain
bpf/vmtest-bpf-next-VM_Test-8 success Logs for set-matrix
bpf/vmtest-bpf-next-VM_Test-9 success Logs for test_maps on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-10 success Logs for test_maps on aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-11 success Logs for test_maps on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-12 success Logs for test_maps on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-13 success Logs for test_maps on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-15 success Logs for test_progs on aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-16 success Logs for test_progs on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-17 success Logs for test_progs on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-18 success Logs for test_progs on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-19 success Logs for test_progs_no_alu32 on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-20 success Logs for test_progs_no_alu32 on aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-21 success Logs for test_progs_no_alu32 on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-22 success Logs for test_progs_no_alu32 on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-23 success Logs for test_progs_no_alu32 on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-24 success Logs for test_progs_no_alu32_parallel on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-25 success Logs for test_progs_no_alu32_parallel on aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-26 success Logs for test_progs_no_alu32_parallel on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-27 success Logs for test_progs_no_alu32_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-28 success Logs for test_progs_no_alu32_parallel on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-29 success Logs for test_progs_parallel on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-30 success Logs for test_progs_parallel on aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-31 success Logs for test_progs_parallel on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-32 success Logs for test_progs_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-33 success Logs for test_progs_parallel on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-34 success Logs for test_verifier on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-35 success Logs for test_verifier on aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-36 success Logs for test_verifier on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-37 success Logs for test_verifier on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-38 success Logs for test_verifier on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-14 success Logs for test_progs on aarch64 with gcc

Commit Message

Wang, Haiyue Jan. 8, 2023, 3:12 p.m. UTC
The variable 'insn' is initialized to 'insn_buf' without being changed,
only some helper macros are defined, so the insn buffer comparison is
unnecessary, just remove it.

Signed-off-by: Haiyue Wang <haiyue.wang@intel.com>
---
 net/core/filter.c | 6 ------
 1 file changed, 6 deletions(-)

Comments

Stanislav Fomichev Jan. 9, 2023, 5:39 p.m. UTC | #1
On 01/08, Haiyue Wang wrote:
> The variable 'insn' is initialized to 'insn_buf' without being changed,
> only some helper macros are defined, so the insn buffer comparison is
> unnecessary, just remove it.

> Signed-off-by: Haiyue Wang <haiyue.wang@intel.com>

Acked-by: Stanislav Fomichev <sdf@google.com>

Looks like these should have been removed as part of commit 2377b81de527
("bpf: split shared bpf_tcp_sock and bpf_sock_ops implementation").

> ---
>   net/core/filter.c | 6 ------
>   1 file changed, 6 deletions(-)

> diff --git a/net/core/filter.c b/net/core/filter.c
> index ab811293ae5d..d9befa6ba04e 100644
> --- a/net/core/filter.c
> +++ b/net/core/filter.c
> @@ -6847,9 +6847,6 @@ u32 bpf_tcp_sock_convert_ctx_access(enum  
> bpf_access_type type,
>   					FIELD));			\
>   	} while (0)

> -	if (insn > insn_buf)
> -		return insn - insn_buf;
> -
>   	switch (si->off) {
>   	case offsetof(struct bpf_tcp_sock, rtt_min):
>   		BUILD_BUG_ON(sizeof_field(struct tcp_sock, rtt_min) !=
> @@ -10147,9 +10144,6 @@ static u32 sock_ops_convert_ctx_access(enum  
> bpf_access_type type,
>   			SOCK_OPS_GET_FIELD(BPF_FIELD, OBJ_FIELD, OBJ);	      \
>   	} while (0)

> -	if (insn > insn_buf)
> -		return insn - insn_buf;
> -
>   	switch (si->off) {
>   	case offsetof(struct bpf_sock_ops, op):
>   		*insn++ = BPF_LDX_MEM(BPF_FIELD_SIZEOF(struct bpf_sock_ops_kern,
> --
> 2.39.0
Wang, Haiyue Jan. 9, 2023, 11:52 p.m. UTC | #2
> -----Original Message-----
> From: sdf@google.com <sdf@google.com>
> Sent: Tuesday, January 10, 2023 01:39
> To: Wang, Haiyue <haiyue.wang@intel.com>
> Cc: bpf@vger.kernel.org; Alexei Starovoitov <ast@kernel.org>; Daniel Borkmann <daniel@iogearbox.net>;
> Andrii Nakryiko <andrii@kernel.org>; Martin KaFai Lau <martin.lau@linux.dev>; Song Liu
> <song@kernel.org>; Yonghong Song <yhs@fb.com>; John Fastabend <john.fastabend@gmail.com>; KP Singh
> <kpsingh@kernel.org>; Hao Luo <haoluo@google.com>; Jiri Olsa <jolsa@kernel.org>; David S. Miller
> <davem@davemloft.net>; Eric Dumazet <edumazet@google.com>; Jakub Kicinski <kuba@kernel.org>; Paolo
> Abeni <pabeni@redhat.com>; netdev@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: Re: [PATCH bpf-next v1] bpf: Remove the unnecessary insn buffer comparison
> 
> On 01/08, Haiyue Wang wrote:
> > The variable 'insn' is initialized to 'insn_buf' without being changed,
> > only some helper macros are defined, so the insn buffer comparison is
> > unnecessary, just remove it.
> 
> > Signed-off-by: Haiyue Wang <haiyue.wang@intel.com>
> 
> Acked-by: Stanislav Fomichev <sdf@google.com>
> 
> Looks like these should have been removed as part of commit 2377b81de527
> ("bpf: split shared bpf_tcp_sock and bpf_sock_ops implementation").
> 

Thanks for the information, yes, it was missed. ;-)

> > ---
> >   net/core/filter.c | 6 ------
> >   1 file changed, 6 deletions(-)
> 


> > --
> > 2.39.0
patchwork-bot+netdevbpf@kernel.org Jan. 10, 2023, 10:20 p.m. UTC | #3
Hello:

This patch was applied to bpf/bpf-next.git (master)
by Daniel Borkmann <daniel@iogearbox.net>:

On Sun,  8 Jan 2023 23:12:57 +0800 you wrote:
> The variable 'insn' is initialized to 'insn_buf' without being changed,
> only some helper macros are defined, so the insn buffer comparison is
> unnecessary, just remove it.
> 
> Signed-off-by: Haiyue Wang <haiyue.wang@intel.com>
> ---
>  net/core/filter.c | 6 ------
>  1 file changed, 6 deletions(-)

Here is the summary with links:
  - [bpf-next,v1] bpf: Remove the unnecessary insn buffer comparison
    https://git.kernel.org/bpf/bpf-next/c/66cf99b55e58

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/core/filter.c b/net/core/filter.c
index ab811293ae5d..d9befa6ba04e 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -6847,9 +6847,6 @@  u32 bpf_tcp_sock_convert_ctx_access(enum bpf_access_type type,
 					FIELD));			\
 	} while (0)
 
-	if (insn > insn_buf)
-		return insn - insn_buf;
-
 	switch (si->off) {
 	case offsetof(struct bpf_tcp_sock, rtt_min):
 		BUILD_BUG_ON(sizeof_field(struct tcp_sock, rtt_min) !=
@@ -10147,9 +10144,6 @@  static u32 sock_ops_convert_ctx_access(enum bpf_access_type type,
 			SOCK_OPS_GET_FIELD(BPF_FIELD, OBJ_FIELD, OBJ);	      \
 	} while (0)
 
-	if (insn > insn_buf)
-		return insn - insn_buf;
-
 	switch (si->off) {
 	case offsetof(struct bpf_sock_ops, op):
 		*insn++ = BPF_LDX_MEM(BPF_FIELD_SIZEOF(struct bpf_sock_ops_kern,