Skip to content

Commit 75134f1

Browse files
edumazetAlexei Starovoitov
authored andcommitted
bpf: Add schedule points in batch ops
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. Fixes: aa2e93b ("bpf: Add generic support for update and delete batch ops") Fixes: cb4d03a ("bpf: Add generic support for lookup batch op") Reported-by: syzbot <syzkaller@googlegroups.com> Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Reviewed-by: Stanislav Fomichev <sdf@google.com> Acked-by: Brian Vazquez <brianvv@google.com> Link: https://lore.kernel.org/bpf/20220217181902.808742-1-eric.dumazet@gmail.com
1 parent 45ce4b4 commit 75134f1

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

kernel/bpf/syscall.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,6 +1355,7 @@ int generic_map_delete_batch(struct bpf_map *map,
13551355
maybe_wait_bpf_programs(map);
13561356
if (err)
13571357
break;
1358+
cond_resched();
13581359
}
13591360
if (copy_to_user(&uattr->batch.count, &cp, sizeof(cp)))
13601361
err = -EFAULT;
@@ -1412,6 +1413,7 @@ int generic_map_update_batch(struct bpf_map *map,
14121413

14131414
if (err)
14141415
break;
1416+
cond_resched();
14151417
}
14161418

14171419
if (copy_to_user(&uattr->batch.count, &cp, sizeof(cp)))
@@ -1509,6 +1511,7 @@ int generic_map_lookup_batch(struct bpf_map *map,
15091511
swap(prev_key, key);
15101512
retry = MAP_LOOKUP_RETRIES;
15111513
cp++;
1514+
cond_resched();
15121515
}
15131516

15141517
if (err == -EFAULT)

0 commit comments

Comments
 (0)