Skip to content

Commit baa35b3

Browse files
kkdwvdAlexei Starovoitov
authored andcommitted
bpf: Retire rcu_trace_implies_rcu_gp() from local storage
This assumption will always hold going forward, hence just remove the various checks and assume it is true with a comment for the uninformed reader. Reviewed-by: Paul E. McKenney <paulmck@kernel.org> Reviewed-by: Amery Hung <ameryhung@gmail.com> Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com> Link: https://lore.kernel.org/r/20260227224806.646888-5-memxor@gmail.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
1 parent f41deee commit baa35b3

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

kernel/bpf/bpf_local_storage.c

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,12 @@ static void __bpf_local_storage_free_trace_rcu(struct rcu_head *rcu)
107107
{
108108
struct bpf_local_storage *local_storage;
109109

110-
/* If RCU Tasks Trace grace period implies RCU grace period, do
111-
* kfree(), else do kfree_rcu().
110+
/*
111+
* RCU Tasks Trace grace period implies RCU grace period, do
112+
* kfree() directly.
112113
*/
113114
local_storage = container_of(rcu, struct bpf_local_storage, rcu);
114-
if (rcu_trace_implies_rcu_gp())
115-
kfree(local_storage);
116-
else
117-
kfree_rcu(local_storage, rcu);
115+
kfree(local_storage);
118116
}
119117

120118
/* Handle use_kmalloc_nolock == false */
@@ -138,10 +136,11 @@ static void bpf_local_storage_free_rcu(struct rcu_head *rcu)
138136

139137
static void bpf_local_storage_free_trace_rcu(struct rcu_head *rcu)
140138
{
141-
if (rcu_trace_implies_rcu_gp())
142-
bpf_local_storage_free_rcu(rcu);
143-
else
144-
call_rcu(rcu, bpf_local_storage_free_rcu);
139+
/*
140+
* RCU Tasks Trace grace period implies RCU grace period, do
141+
* kfree() directly.
142+
*/
143+
bpf_local_storage_free_rcu(rcu);
145144
}
146145

147146
static void bpf_local_storage_free(struct bpf_local_storage *local_storage,
@@ -182,10 +181,11 @@ static void __bpf_selem_free_rcu(struct rcu_head *rcu)
182181
/* rcu tasks trace callback for use_kmalloc_nolock == false */
183182
static void __bpf_selem_free_trace_rcu(struct rcu_head *rcu)
184183
{
185-
if (rcu_trace_implies_rcu_gp())
186-
__bpf_selem_free_rcu(rcu);
187-
else
188-
call_rcu(rcu, __bpf_selem_free_rcu);
184+
/*
185+
* RCU Tasks Trace grace period implies RCU grace period, do
186+
* kfree() directly.
187+
*/
188+
__bpf_selem_free_rcu(rcu);
189189
}
190190

191191
/* Handle use_kmalloc_nolock == false */
@@ -214,10 +214,11 @@ static void bpf_selem_free_rcu(struct rcu_head *rcu)
214214

215215
static void bpf_selem_free_trace_rcu(struct rcu_head *rcu)
216216
{
217-
if (rcu_trace_implies_rcu_gp())
218-
bpf_selem_free_rcu(rcu);
219-
else
220-
call_rcu(rcu, bpf_selem_free_rcu);
217+
/*
218+
* RCU Tasks Trace grace period implies RCU grace period, do
219+
* kfree() directly.
220+
*/
221+
bpf_selem_free_rcu(rcu);
221222
}
222223

223224
void bpf_selem_free(struct bpf_local_storage_elem *selem,

0 commit comments

Comments
 (0)