bpf: add schedule points in batch ops
Subsystems (4)
PATCH 1/1 bpf: add schedule points in batch ops
From: Eric Dumazet <[email protected]>
syzbot reported various soft lockups caused by bpf batch operations.
INFO: task kworker/1:1:27 blocked for more than 140 seconds. INFO: task hung in rcu_barrier
Nothing prevents batch ops to process huge amount of data, we need to add schedule points in them.
Note that maybe_wait_bpf_programs(map) calls from generic_map_delete_batch() can be factorized by moving the call after the loop.
This will be done later in -next tree once we get this fix merged, unless there is strong opinion doing this optimization sooner.
--- kernel/bpf/syscall.c | 3 +++ 1 file changed, 3 insertions(+)
kernel/bpf/syscall.c +3 -0
@@ -1355,6 +1355,7 @@ int generic_map_delete_batch(struct bpf_map *map,maybe_wait_bpf_programs (map);if (err)break ; +cond_resched (); }if (copy_to_user (&uattr->batch.count, &cp,sizeof (cp))) err = -EFAULT ;
@@ -1412,6 +1413,7 @@ int generic_map_update_batch(struct bpf_map *map,if (err)break ; +cond_resched (); }if (copy_to_user (&uattr->batch.count, &cp,sizeof (cp)))
@@ -1509,6 +1511,7 @@ int generic_map_lookup_batch(struct bpf_map *map,swap (prev_key, key); retry =MAP_LOOKUP_RETRIES ; cp++; +cond_resched (); }if (err == -EFAULT )
Signature · 1 line
2.35.1.265.g69c8d7142f-goog
Quoted 14 lines · Eric Dumazet
From: Eric Dumazet <[email protected]>
syzbot reported various soft lockups caused by bpf batch operations.
INFO: task kworker/1:1:27 blocked for more than 140 seconds. INFO: task hung in rcu_barrierNothing prevents batch ops to process huge amount of data, we need to add schedule points in them.
Note that
maybe_wait_bpf_programs(map)calls fromgeneric_map_delete_batch()can be factorized by moving the call after the loop.
Quoted 8 lines
This will be done later in -next tree once we get this fix merged, unless there is strong opinion doing this optimization sooner.
Fixes aa2e93b8e58e ("bpf: Add generic support for update and delete batch ops")Fixes cb4d03ab499d ("bpf: Add generic support for lookup batch op")Signed-off-by Eric Dumazet <[email protected]>Cc Brian Vazquez <[email protected]>Cc Stanislav Fomichev <[email protected]>
Looks good, thank you!
Quoted 35 lines
Reported-by syzbot <[email protected]>--- kernel/bpf/syscall.c | 3 +++ 1 file changed, 3 insertions(+)kernel/bpf/syscall.c +3
-1@@ -1355,6 +1355,7 @@ int generic_map_delete_batch(struct bpf_map *map,maybe_wait_bpf_programs (map);if (err)break ; +cond_resched (); }if (copy_to_user (&uattr->batch.count, &cp,sizeof (cp))) err = -EFAULT ;@@ -1412,6 +1413,7 @@ int generic_map_update_batch(struct bpf_map *map,if (err)break ; +cond_resched (); }if (copy_to_user (&uattr->batch.count, &cp,sizeof (cp)))@@ -1509,6 +1511,7 @@ int generic_map_lookup_batch(struct bpf_map *map,swap (prev_key, key); retry =MAP_LOOKUP_RETRIES ; cp++; +cond_resched (); }if (err == -EFAULT ) --2.35.1.265.g69c8d7142f-goog
Quoted 59 lines · Eric Dumazet
From: Eric Dumazet <[email protected]>
syzbot reported various soft lockups caused by bpf batch operations.
INFO: task kworker/1:1:27 blocked for more than 140 seconds. INFO: task hung in rcu_barrierNothing prevents batch ops to process huge amount of data, we need to add schedule points in them.
Note that
maybe_wait_bpf_programs(map)calls fromgeneric_map_delete_batch()can be factorized by moving the call after the loop.This will be done later in -next tree once we get this fix merged, unless there is strong opinion doing this optimization sooner.
Fixes aa2e93b8e58e ("bpf: Add generic support for update and delete batch ops")Fixes cb4d03ab499d ("bpf: Add generic support for lookup batch op")Signed-off-by Eric Dumazet <[email protected]>Cc Brian Vazquez <[email protected]>Cc Stanislav Fomichev <[email protected]>Reported-by syzbot <[email protected]>--- kernel/bpf/syscall.c | 3 +++ 1 file changed, 3 insertions(+)kernel/bpf/syscall.c +3
-1@@ -1355,6 +1355,7 @@ int generic_map_delete_batch(struct bpf_map *map,maybe_wait_bpf_programs (map);if (err)break ; +cond_resched (); }if (copy_to_user (&uattr->batch.count, &cp,sizeof (cp))) err = -EFAULT ;@@ -1412,6 +1413,7 @@ int generic_map_update_batch(struct bpf_map *map,if (err)break ; +cond_resched (); }if (copy_to_user (&uattr->batch.count, &cp,sizeof (cp)))@@ -1509,6 +1511,7 @@ int generic_map_lookup_batch(struct bpf_map *map,swap (prev_key, key); retry =MAP_LOOKUP_RETRIES ; cp++; +cond_resched (); }if (err == -EFAULT ) --2.35.1.265.g69c8d7142f-goog
This patch was applied to bpf/bpf.git (master) by Alexei Starovoitov <[email protected]>:
Hello:
This patch was applied to bpf/bpf.git (master)
by Alexei Starovoitov <[email protected]>:
Quoted 8 lines · On Thu, 17 Feb 2022 10:19:02 -0800 you wrote:
From: Eric Dumazet <[email protected]>
syzbot reported various soft lockups caused by bpf batch operations.
INFO: task kworker/1:1:27 blocked for more than 140 seconds. INFO: task hung in rcu_barrier[...]
Here is the summary with links:
- [bpf] bpf: add schedule points in batch ops
https://git.kernel.org/bpf/bpf/c/75134f16e7dd
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html