[PATCH bpf-next v2 0/7] bpf: introduce and use rcu_read_lock_dont_migrate

From: Menglong Dong
Date: Tue Aug 19 2025 - 05:34:58 EST


migrate_disable() and rcu_read_lock() are used to together in many case in
bpf. However, when PREEMPT_RCU is not enabled, rcu_read_lock() will
disable preemption, which indicate migrate_disable(), so we don't need to
call it in this case.

In this series, we introduce rcu_read_lock_dont_migrate and
rcu_read_unlock_migrate, which will call migrate_disable and
migrate_enable only when PREEMPT_RCU enabled. And use
rcu_read_lock_dont_migrate in bpf subsystem.

Not sure if I should send the 1st patch to the RCU subsystem :/

Changes since V1:
* introduce rcu_read_lock_dont_migrate() instead of
rcu_migrate_disable() + rcu_read_lock()

Menglong Dong (7):
rcu: add rcu_read_lock_dont_migrate()
bpf: use rcu_read_lock_dont_migrate() for bpf_cgrp_storage_free()
bpf: use rcu_read_lock_dont_migrate() for bpf_inode_storage_free()
bpf: use rcu_read_lock_dont_migrate() for bpf_iter_run_prog()
bpf: use rcu_read_lock_dont_migrate() for bpf_task_storage_free()
bpf: use rcu_read_lock_dont_migrate() for bpf_prog_run_array_cg()
bpf: use rcu_read_lock_dont_migrate() for trampoline.c

include/linux/rcupdate.h | 24 ++++++++++++++++++++++++
kernel/bpf/bpf_cgrp_storage.c | 6 ++----
kernel/bpf/bpf_inode_storage.c | 6 ++----
kernel/bpf/bpf_iter.c | 6 ++----
kernel/bpf/bpf_task_storage.c | 6 ++----
kernel/bpf/cgroup.c | 6 ++----
kernel/bpf/trampoline.c | 18 ++++++------------
7 files changed, 40 insertions(+), 32 deletions(-)

--
2.50.1