From: Hou Tao <houtao1@xxxxxxxxxx> To support sleepable uprobe bpf program, the freeing of trace program array chains a RCU-tasks-trace grace period with a normal RCU grace period. But considering in the current implementation of RCU-tasks-trace that one RCU-tasks-trace grace period implies one normal RCU grace period, so it is not need for such chaining and it is safe to free the array in the callback of call_rcu_tasks_trace(). Signed-off-by: Hou Tao <houtao1@xxxxxxxxxx> --- kernel/bpf/core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c index 711fd293b6de..f943620b55b0 100644 --- a/kernel/bpf/core.c +++ b/kernel/bpf/core.c @@ -2247,12 +2247,15 @@ void bpf_prog_array_free(struct bpf_prog_array *progs) kfree_rcu(progs, rcu); } +/* Now RCU Tasks grace period implies RCU grace period, so no need to call + * kfree_rcu(), just call kfree() directly. + */ static void __bpf_prog_array_free_sleepable_cb(struct rcu_head *rcu) { struct bpf_prog_array *progs; progs = container_of(rcu, struct bpf_prog_array, rcu); - kfree_rcu(progs, rcu); + kfree(progs); } void bpf_prog_array_free_sleepable(struct bpf_prog_array *progs) -- 2.29.2