diff mbox series

[bpf-next] bpf: Call maybe_wait_bpf_programs() only once from generic_map_delete_batch()

Message ID 20220218181801.2971275-1-eric.dumazet@gmail.com (mailing list archive)
State Accepted
Commit 9087c6ff8dfe0a070e4e05a434399080603c29de
Delegated to: BPF
Headers show
Series [bpf-next] bpf: Call maybe_wait_bpf_programs() only once from generic_map_delete_batch() | 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: 12 this patch: 12
netdev/cc_maintainers warning 6 maintainers not CCed: andrii@kernel.org kpsingh@kernel.org john.fastabend@gmail.com kafai@fb.com songliubraving@fb.com yhs@fb.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: 17 this patch: 17
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 15 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 fail PR summary
bpf/vmtest-bpf-next fail VM_Test

Commit Message

Eric Dumazet Feb. 18, 2022, 6:18 p.m. UTC
From: Eric Dumazet <edumazet@google.com>

As stated in the comment found in maybe_wait_bpf_programs(),
the synchronize_rcu() barrier is only needed before returning
to userspace, not after each deletion in the batch.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Stanislav Fomichev <sdf@google.com>
Cc: Brian Vazquez <brianvv@google.com>
---
 kernel/bpf/syscall.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Stanislav Fomichev Feb. 18, 2022, 6:43 p.m. UTC | #1
On 02/18, Eric Dumazet wrote:
> From: Eric Dumazet <edumazet@google.com>

> As stated in the comment found in maybe_wait_bpf_programs(),
> the synchronize_rcu() barrier is only needed before returning
> to userspace, not after each deletion in the batch.

> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Stanislav Fomichev <sdf@google.com>

Makes sense. Probably a copy-paste from the non-batch case...

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

> Cc: Brian Vazquez <brianvv@google.com>
> ---
>   kernel/bpf/syscall.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)

> diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
> index  
> a72f63d5a7daee057bcec3fa6119aca32e2945f7..9c7a72b65eee0ec8d54d36e2c0ab9ff4962091af  
> 100644
> --- a/kernel/bpf/syscall.c
> +++ b/kernel/bpf/syscall.c
> @@ -1352,7 +1352,6 @@ int generic_map_delete_batch(struct bpf_map *map,
>   		err = map->ops->map_delete_elem(map, key);
>   		rcu_read_unlock();
>   		bpf_enable_instrumentation();
> -		maybe_wait_bpf_programs(map);
>   		if (err)
>   			break;
>   		cond_resched();
> @@ -1361,6 +1360,8 @@ int generic_map_delete_batch(struct bpf_map *map,
>   		err = -EFAULT;

>   	kvfree(key);
> +
> +	maybe_wait_bpf_programs(map);
>   	return err;
>   }

> --
> 2.35.1.473.g83b2b277ed-goog
patchwork-bot+netdevbpf@kernel.org Feb. 18, 2022, 7:50 p.m. UTC | #2
Hello:

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

On Fri, 18 Feb 2022 10:18:01 -0800 you wrote:
> From: Eric Dumazet <edumazet@google.com>
> 
> As stated in the comment found in maybe_wait_bpf_programs(),
> the synchronize_rcu() barrier is only needed before returning
> to userspace, not after each deletion in the batch.
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Stanislav Fomichev <sdf@google.com>
> Cc: Brian Vazquez <brianvv@google.com>
> 
> [...]

Here is the summary with links:
  - [bpf-next] bpf: Call maybe_wait_bpf_programs() only once from generic_map_delete_batch()
    https://git.kernel.org/bpf/bpf-next/c/9087c6ff8dfe

You are awesome, thank you!
diff mbox series

Patch

diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index a72f63d5a7daee057bcec3fa6119aca32e2945f7..9c7a72b65eee0ec8d54d36e2c0ab9ff4962091af 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -1352,7 +1352,6 @@  int generic_map_delete_batch(struct bpf_map *map,
 		err = map->ops->map_delete_elem(map, key);
 		rcu_read_unlock();
 		bpf_enable_instrumentation();
-		maybe_wait_bpf_programs(map);
 		if (err)
 			break;
 		cond_resched();
@@ -1361,6 +1360,8 @@  int generic_map_delete_batch(struct bpf_map *map,
 		err = -EFAULT;
 
 	kvfree(key);
+
+	maybe_wait_bpf_programs(map);
 	return err;
 }