netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf] sock_map: add a cond_resched() in sock_hash_free()
@ 2024-09-06 15:44 Eric Dumazet
  2024-09-06 21:26 ` Martin KaFai Lau
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Eric Dumazet @ 2024-09-06 15:44 UTC (permalink / raw)
  To: David S . Miller, Jakub Kicinski, Paolo Abeni, Daniel Borkmann,
	Alexei Starovoitov, Martin KaFai Lau
  Cc: Andrii Nakryiko, netdev, bpf, eric.dumazet, Eric Dumazet, syzbot,
	John Fastabend, Jakub Sitnicki

Several syzbot soft lockup reports all have in common sock_hash_free()

If a map with a large number of buckets is destroyed, we need to yield
the cpu when needed.

Fixes: 75e68e5bf2c7 ("bpf, sockhash: Synchronize delete from bucket list on map free")
Reported-by: syzbot <syzkaller@googlegroups.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: John Fastabend <john.fastabend@gmail.com>
Cc: Jakub Sitnicki <jakub@cloudflare.com>
---
 net/core/sock_map.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/core/sock_map.c b/net/core/sock_map.c
index d3dbb92153f2fe7f1ddc8e35b495533fbf60a8cb..724b6856fcc3e9fd51673d31927cfd52d5d7d0aa 100644
--- a/net/core/sock_map.c
+++ b/net/core/sock_map.c
@@ -1183,6 +1183,7 @@ static void sock_hash_free(struct bpf_map *map)
 			sock_put(elem->sk);
 			sock_hash_free_elem(htab, elem);
 		}
+		cond_resched();
 	}
 
 	/* wait for psock readers accessing its map link */
-- 
2.46.0.469.g59c65b2a67-goog


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

* Re: [PATCH bpf] sock_map: add a cond_resched() in sock_hash_free()
  2024-09-06 15:44 [PATCH bpf] sock_map: add a cond_resched() in sock_hash_free() Eric Dumazet
@ 2024-09-06 21:26 ` Martin KaFai Lau
  2024-09-06 21:32 ` John Fastabend
  2024-09-11 20:30 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Martin KaFai Lau @ 2024-09-06 21:26 UTC (permalink / raw)
  To: Eric Dumazet, Jakub Kicinski
  Cc: Andrii Nakryiko, netdev, bpf, eric.dumazet, syzbot,
	John Fastabend, Jakub Sitnicki, Paolo Abeni, David S . Miller,
	Daniel Borkmann, Alexei Starovoitov

On 9/6/24 8:44 AM, Eric Dumazet wrote:
> Several syzbot soft lockup reports all have in common sock_hash_free()
> 
> If a map with a large number of buckets is destroyed, we need to yield
> the cpu when needed.
> 
> Fixes: 75e68e5bf2c7 ("bpf, sockhash: Synchronize delete from bucket list on map free")
> Reported-by: syzbot <syzkaller@googlegroups.com>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: John Fastabend <john.fastabend@gmail.com>
> Cc: Jakub Sitnicki <jakub@cloudflare.com>
> ---
>   net/core/sock_map.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/net/core/sock_map.c b/net/core/sock_map.c
> index d3dbb92153f2fe7f1ddc8e35b495533fbf60a8cb..724b6856fcc3e9fd51673d31927cfd52d5d7d0aa 100644
> --- a/net/core/sock_map.c
> +++ b/net/core/sock_map.c
> @@ -1183,6 +1183,7 @@ static void sock_hash_free(struct bpf_map *map)
>   			sock_put(elem->sk);
>   			sock_hash_free_elem(htab, elem);
>   		}
> +		cond_resched();

Acked-by: Martin KaFai Lau <martin.lau@kernel.org>

Jakub, may be you can directly take it to net tree ?


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

* RE: [PATCH bpf] sock_map: add a cond_resched() in sock_hash_free()
  2024-09-06 15:44 [PATCH bpf] sock_map: add a cond_resched() in sock_hash_free() Eric Dumazet
  2024-09-06 21:26 ` Martin KaFai Lau
@ 2024-09-06 21:32 ` John Fastabend
  2024-09-11 20:30 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: John Fastabend @ 2024-09-06 21:32 UTC (permalink / raw)
  To: Eric Dumazet, David S . Miller, Jakub Kicinski, Paolo Abeni,
	Daniel Borkmann, Alexei Starovoitov, Martin KaFai Lau
  Cc: Andrii Nakryiko, netdev, bpf, eric.dumazet, Eric Dumazet, syzbot,
	John Fastabend, Jakub Sitnicki

Eric Dumazet wrote:
> Several syzbot soft lockup reports all have in common sock_hash_free()
> 
> If a map with a large number of buckets is destroyed, we need to yield
> the cpu when needed.
> 
> Fixes: 75e68e5bf2c7 ("bpf, sockhash: Synchronize delete from bucket list on map free")
> Reported-by: syzbot <syzkaller@googlegroups.com>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: John Fastabend <john.fastabend@gmail.com>
> Cc: Jakub Sitnicki <jakub@cloudflare.com>
> ---
>  net/core/sock_map.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/net/core/sock_map.c b/net/core/sock_map.c
> index d3dbb92153f2fe7f1ddc8e35b495533fbf60a8cb..724b6856fcc3e9fd51673d31927cfd52d5d7d0aa 100644
> --- a/net/core/sock_map.c
> +++ b/net/core/sock_map.c
> @@ -1183,6 +1183,7 @@ static void sock_hash_free(struct bpf_map *map)
>  			sock_put(elem->sk);
>  			sock_hash_free_elem(htab, elem);
>  		}
> +		cond_resched();
>  	}
>  
>  	/* wait for psock readers accessing its map link */
> -- 
> 2.46.0.469.g59c65b2a67-goog
> 

Thanks, looks good to me.

Acked-by: John Fastabend <john.fastabend@gmail.com>

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

* Re: [PATCH bpf] sock_map: add a cond_resched() in sock_hash_free()
  2024-09-06 15:44 [PATCH bpf] sock_map: add a cond_resched() in sock_hash_free() Eric Dumazet
  2024-09-06 21:26 ` Martin KaFai Lau
  2024-09-06 21:32 ` John Fastabend
@ 2024-09-11 20:30 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-09-11 20:30 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: davem, kuba, pabeni, daniel, ast, martin.lau, andrii, netdev, bpf,
	eric.dumazet, syzkaller, john.fastabend, jakub

Hello:

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

On Fri,  6 Sep 2024 15:44:49 +0000 you wrote:
> Several syzbot soft lockup reports all have in common sock_hash_free()
> 
> If a map with a large number of buckets is destroyed, we need to yield
> the cpu when needed.
> 
> Fixes: 75e68e5bf2c7 ("bpf, sockhash: Synchronize delete from bucket list on map free")
> Reported-by: syzbot <syzkaller@googlegroups.com>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: John Fastabend <john.fastabend@gmail.com>
> Cc: Jakub Sitnicki <jakub@cloudflare.com>
> 
> [...]

Here is the summary with links:
  - [bpf] sock_map: add a cond_resched() in sock_hash_free()
    https://git.kernel.org/bpf/bpf-next/c/b1339be951ad

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] 4+ messages in thread

end of thread, other threads:[~2024-09-11 20:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-06 15:44 [PATCH bpf] sock_map: add a cond_resched() in sock_hash_free() Eric Dumazet
2024-09-06 21:26 ` Martin KaFai Lau
2024-09-06 21:32 ` John Fastabend
2024-09-11 20:30 ` 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).