]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
bpf: use rcu_read_lock_dont_migrate() for bpf_prog_run_array_cg()
authorMenglong Dong <menglong8.dong@gmail.com>
Thu, 21 Aug 2025 09:06:08 +0000 (17:06 +0800)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 26 Aug 2025 01:52:16 +0000 (18:52 -0700)
Use rcu_read_lock_dont_migrate() and rcu_read_unlock_migrate() in
bpf_prog_run_array_cg to obtain better performance when PREEMPT_RCU is
not enabled.

Signed-off-by: Menglong Dong <dongml2@chinatelecom.cn>
Link: https://lore.kernel.org/r/20250821090609.42508-7-dongml2@chinatelecom.cn
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/cgroup.c

index 180b630279b9cb4927e9ef66874e1972782501fd..9912c7b9a266043dbd7b9c99cb534c0f78040f8d 100644 (file)
@@ -71,8 +71,7 @@ bpf_prog_run_array_cg(const struct cgroup_bpf *cgrp,
        u32 func_ret;
 
        run_ctx.retval = retval;
-       migrate_disable();
-       rcu_read_lock();
+       rcu_read_lock_dont_migrate();
        array = rcu_dereference(cgrp->effective[atype]);
        item = &array->items[0];
        old_run_ctx = bpf_set_run_ctx(&run_ctx.run_ctx);
@@ -88,8 +87,7 @@ bpf_prog_run_array_cg(const struct cgroup_bpf *cgrp,
                item++;
        }
        bpf_reset_run_ctx(old_run_ctx);
-       rcu_read_unlock();
-       migrate_enable();
+       rcu_read_unlock_migrate();
        return run_ctx.retval;
 }