diff mbox series

[bpf-next] bpf, x86: remove unnecessary handling of BPF_SUB atomic op

Message ID 20220127083240.1425481-1-houtao1@huawei.com (mailing list archive)
State Accepted
Commit b6ec79518ef0c84d1ed0f76b8af9592a75eb29b6
Delegated to: BPF
Headers show
Series [bpf-next] bpf, x86: remove unnecessary handling of BPF_SUB atomic op | 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: 0 this patch: 0
netdev/cc_maintainers warning 13 maintainers not CCed: hpa@zytor.com bp@alien8.de kpsingh@kernel.org yoshfuji@linux-ipv6.org songliubraving@fb.com x86@kernel.org dsahern@kernel.org nathan@kernel.org llvm@lists.linux.dev dave.hansen@linux.intel.com mingo@redhat.com tglx@linutronix.de ndesaulniers@google.com
netdev/build_clang success Errors and warnings before: 18 this patch: 18
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 7 this patch: 7
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 7 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 success VM_Test

Commit Message

Hou Tao Jan. 27, 2022, 8:32 a.m. UTC
According to the LLVM commit (https://reviews.llvm.org/D72184),
sync_fetch_and_sub() is implemented as a negation followed by
sync_fetch_and_add(), so there will be no BPF_SUB op and just
remove it.

Signed-off-by: Hou Tao <houtao1@huawei.com>
---
 arch/x86/net/bpf_jit_comp.c | 1 -
 1 file changed, 1 deletion(-)

Comments

Brendan Jackman Jan. 27, 2022, 10:48 a.m. UTC | #1
Yep - BPF_SUB is also excluded in Documentation/networking/filter.rst,
plus the interpreter and verifier don't support it.

Thanks,

Acked-by: Brendan Jackman <jackmanb@google.com>


On Thu, 27 Jan 2022 at 09:17, Hou Tao <houtao1@huawei.com> wrote:
>
> According to the LLVM commit (https://reviews.llvm.org/D72184),
> sync_fetch_and_sub() is implemented as a negation followed by
> sync_fetch_and_add(), so there will be no BPF_SUB op and just
> remove it.
>
> Signed-off-by: Hou Tao <houtao1@huawei.com>
> ---
>  arch/x86/net/bpf_jit_comp.c | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
> index ce1f86f245c9..5d643ebb1e56 100644
> --- a/arch/x86/net/bpf_jit_comp.c
> +++ b/arch/x86/net/bpf_jit_comp.c
> @@ -787,7 +787,6 @@ static int emit_atomic(u8 **pprog, u8 atomic_op,
>         /* emit opcode */
>         switch (atomic_op) {
>         case BPF_ADD:
> -       case BPF_SUB:
>         case BPF_AND:
>         case BPF_OR:
>         case BPF_XOR:
> --
> 2.29.2
>
patchwork-bot+netdevbpf@kernel.org Jan. 27, 2022, 9:50 p.m. UTC | #2
Hello:

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

On Thu, 27 Jan 2022 16:32:40 +0800 you wrote:
> According to the LLVM commit (https://reviews.llvm.org/D72184),
> sync_fetch_and_sub() is implemented as a negation followed by
> sync_fetch_and_add(), so there will be no BPF_SUB op and just
> remove it.
> 
> Signed-off-by: Hou Tao <houtao1@huawei.com>
> 
> [...]

Here is the summary with links:
  - [bpf-next] bpf, x86: remove unnecessary handling of BPF_SUB atomic op
    https://git.kernel.org/bpf/bpf-next/c/b6ec79518ef0

You are awesome, thank you!
Daniel Borkmann Jan. 27, 2022, 9:51 p.m. UTC | #3
On 1/27/22 11:48 AM, Brendan Jackman wrote:
> Yep - BPF_SUB is also excluded in Documentation/networking/filter.rst,
> plus the interpreter and verifier don't support it.
> 
> Thanks,
> 
> Acked-by: Brendan Jackman <jackmanb@google.com>

I was wondering about verifier specifically as well. Added a note to the
commit log that verifier rejects BPF_SUB while applying, thanks!

> On Thu, 27 Jan 2022 at 09:17, Hou Tao <houtao1@huawei.com> wrote:
>>
>> According to the LLVM commit (https://reviews.llvm.org/D72184),
>> sync_fetch_and_sub() is implemented as a negation followed by
>> sync_fetch_and_add(), so there will be no BPF_SUB op and just
>> remove it.
>>
>> Signed-off-by: Hou Tao <houtao1@huawei.com>
>> ---
>>   arch/x86/net/bpf_jit_comp.c | 1 -
>>   1 file changed, 1 deletion(-)
>>
>> diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
>> index ce1f86f245c9..5d643ebb1e56 100644
>> --- a/arch/x86/net/bpf_jit_comp.c
>> +++ b/arch/x86/net/bpf_jit_comp.c
>> @@ -787,7 +787,6 @@ static int emit_atomic(u8 **pprog, u8 atomic_op,
>>          /* emit opcode */
>>          switch (atomic_op) {
>>          case BPF_ADD:
>> -       case BPF_SUB:
>>          case BPF_AND:
>>          case BPF_OR:
>>          case BPF_XOR:
>> --
>> 2.29.2
>>
John Fastabend Jan. 28, 2022, 2:40 a.m. UTC | #4
Daniel Borkmann wrote:
> On 1/27/22 11:48 AM, Brendan Jackman wrote:
> > Yep - BPF_SUB is also excluded in Documentation/networking/filter.rst,
> > plus the interpreter and verifier don't support it.
> > 
> > Thanks,
> > 
> > Acked-by: Brendan Jackman <jackmanb@google.com>
> 
> I was wondering about verifier specifically as well. Added a note to the
> commit log that verifier rejects BPF_SUB while applying, thanks!
> 

Thanks for the follow up Hou/Brendan LGTM as well. After its been
merged, but ACK from me as well.
diff mbox series

Patch

diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
index ce1f86f245c9..5d643ebb1e56 100644
--- a/arch/x86/net/bpf_jit_comp.c
+++ b/arch/x86/net/bpf_jit_comp.c
@@ -787,7 +787,6 @@  static int emit_atomic(u8 **pprog, u8 atomic_op,
 	/* emit opcode */
 	switch (atomic_op) {
 	case BPF_ADD:
-	case BPF_SUB:
 	case BPF_AND:
 	case BPF_OR:
 	case BPF_XOR: