Skip to content

Commit

Permalink
bpf: Add schedule points in batch ops
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Eric Dumazet <[email protected]>
Signed-off-by: Alexei Starovoitov <[email protected]>
Reviewed-by: Stanislav Fomichev <[email protected]>
Acked-by: Brian Vazquez <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
  • Loading branch information
Eric Dumazet authored and Alexei Starovoitov committed Feb 17, 2022
1 parent 45ce4b4 commit 75134f1
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions kernel/bpf/syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)))
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 75134f1

Please sign in to comment.