]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
bpf: Retire rcu_trace_implies_rcu_gp() from local storage
authorKumar Kartikeya Dwivedi <memxor@gmail.com>
Fri, 27 Feb 2026 22:48:04 +0000 (14:48 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 27 Feb 2026 23:39:00 +0000 (15:39 -0800)
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>
kernel/bpf/bpf_local_storage.c

index d7db1ada2dadc1bbaec8c7d3dc07d2744b2dbdb6..9c96a4477f81a8c27af0ef0591b06f9ea156baeb 100644 (file)
@@ -107,14 +107,12 @@ static void __bpf_local_storage_free_trace_rcu(struct rcu_head *rcu)
 {
        struct bpf_local_storage *local_storage;
 
-       /* If RCU Tasks Trace grace period implies RCU grace period, do
-        * kfree(), else do kfree_rcu().
+       /*
+        * RCU Tasks Trace grace period implies RCU grace period, do
+        * kfree() directly.
         */
        local_storage = container_of(rcu, struct bpf_local_storage, rcu);
-       if (rcu_trace_implies_rcu_gp())
-               kfree(local_storage);
-       else
-               kfree_rcu(local_storage, rcu);
+       kfree(local_storage);
 }
 
 /* Handle use_kmalloc_nolock == false */
@@ -138,10 +136,11 @@ static void bpf_local_storage_free_rcu(struct rcu_head *rcu)
 
 static void bpf_local_storage_free_trace_rcu(struct rcu_head *rcu)
 {
-       if (rcu_trace_implies_rcu_gp())
-               bpf_local_storage_free_rcu(rcu);
-       else
-               call_rcu(rcu, bpf_local_storage_free_rcu);
+       /*
+        * RCU Tasks Trace grace period implies RCU grace period, do
+        * kfree() directly.
+        */
+       bpf_local_storage_free_rcu(rcu);
 }
 
 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)
 /* rcu tasks trace callback for use_kmalloc_nolock == false */
 static void __bpf_selem_free_trace_rcu(struct rcu_head *rcu)
 {
-       if (rcu_trace_implies_rcu_gp())
-               __bpf_selem_free_rcu(rcu);
-       else
-               call_rcu(rcu, __bpf_selem_free_rcu);
+       /*
+        * RCU Tasks Trace grace period implies RCU grace period, do
+        * kfree() directly.
+        */
+       __bpf_selem_free_rcu(rcu);
 }
 
 /* Handle use_kmalloc_nolock == false */
@@ -214,10 +214,11 @@ static void bpf_selem_free_rcu(struct rcu_head *rcu)
 
 static void bpf_selem_free_trace_rcu(struct rcu_head *rcu)
 {
-       if (rcu_trace_implies_rcu_gp())
-               bpf_selem_free_rcu(rcu);
-       else
-               call_rcu(rcu, bpf_selem_free_rcu);
+       /*
+        * RCU Tasks Trace grace period implies RCU grace period, do
+        * kfree() directly.
+        */
+       bpf_selem_free_rcu(rcu);
 }
 
 void bpf_selem_free(struct bpf_local_storage_elem *selem,