bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next] bpf: Call maybe_wait_bpf_programs() only once from generic_map_delete_batch()
@ 2022-02-18 18:18 Eric Dumazet
  2022-02-18 18:43 ` sdf
  2022-02-18 19:50 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Eric Dumazet @ 2022-02-18 18:18 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann
  Cc: David S . Miller, netdev, Eric Dumazet, Eric Dumazet, bpf,
	Stanislav Fomichev, Brian Vazquez

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(-)

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH bpf-next] bpf: Call maybe_wait_bpf_programs() only once from generic_map_delete_batch()
  2022-02-18 18:18 [PATCH bpf-next] bpf: Call maybe_wait_bpf_programs() only once from generic_map_delete_batch() Eric Dumazet
@ 2022-02-18 18:43 ` sdf
  2022-02-18 19:50 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: sdf @ 2022-02-18 18:43 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: Alexei Starovoitov, Daniel Borkmann, David S . Miller, netdev,
	Eric Dumazet, bpf, Brian Vazquez

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH bpf-next] bpf: Call maybe_wait_bpf_programs() only once from generic_map_delete_batch()
  2022-02-18 18:18 [PATCH bpf-next] bpf: Call maybe_wait_bpf_programs() only once from generic_map_delete_batch() Eric Dumazet
  2022-02-18 18:43 ` sdf
@ 2022-02-18 19:50 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-02-18 19:50 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: ast, daniel, davem, netdev, edumazet, bpf, sdf, brianvv

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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-02-18 19:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-18 18:18 [PATCH bpf-next] bpf: Call maybe_wait_bpf_programs() only once from generic_map_delete_batch() Eric Dumazet
2022-02-18 18:43 ` sdf
2022-02-18 19:50 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).