Skip to content

Commit

Permalink
bpf: Call maybe_wait_bpf_programs() only once from generic_map_delete…
Browse files Browse the repository at this point in the history
…_batch()

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 <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
Reviewed-by: Stanislav Fomichev <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
  • Loading branch information
Eric Dumazet authored and borkmann committed Feb 18, 2022
1 parent 086d490 commit 9087c6f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion kernel/bpf/syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -1361,6 +1360,8 @@ int generic_map_delete_batch(struct bpf_map *map,
err = -EFAULT;

kvfree(key);

maybe_wait_bpf_programs(map);
return err;
}

Expand Down

0 comments on commit 9087c6f

Please sign in to comment.