From: Hou Tao <houtao1@xxxxxxxxxx> Local storage map is accessible for both sleepable and normal bpf program, so its memory is freed by using both call_rcu_tasks_trace() and kfree_rcu() to wait for both RCU-tasks-trace grace period and RCU grace period to expire. However According to the current implementation of RCU-tasks-trace, one RCU-tasks-trace grace period waits for one RCU grace period, so there is no need to call kfree_rcu(), it is safe to call kfree() directly. Signed-off-by: Hou Tao <houtao1@xxxxxxxxxx> --- kernel/bpf/bpf_local_storage.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/kernel/bpf/bpf_local_storage.c b/kernel/bpf/bpf_local_storage.c index 802fc15b0d73..18a2dd611635 100644 --- a/kernel/bpf/bpf_local_storage.c +++ b/kernel/bpf/bpf_local_storage.c @@ -84,20 +84,26 @@ bpf_selem_alloc(struct bpf_local_storage_map *smap, void *owner, return NULL; } +/* Now RCU Tasks grace period implies RCU grace period, so no need to call + * kfree_rcu(), just call kfree() directly. + */ void bpf_local_storage_free_rcu(struct rcu_head *rcu) { struct bpf_local_storage *local_storage; local_storage = container_of(rcu, struct bpf_local_storage, rcu); - kfree_rcu(local_storage, rcu); + kfree(local_storage); } +/* Now RCU Tasks grace period implies RCU grace period, so no need to call + * kfree_rcu(), just call kfree() directly. + */ static void bpf_selem_free_rcu(struct rcu_head *rcu) { struct bpf_local_storage_elem *selem; selem = container_of(rcu, struct bpf_local_storage_elem, rcu); - kfree_rcu(selem, rcu); + kfree(selem); } /* local_storage->lock must be held and selem->local_storage == local_storage. -- 2.29.2