diff options
| author | Menglong Dong <menglong8.dong@gmail.com> | 2025-08-21 12:06:03 +0300 |
|---|---|---|
| committer | Alexei Starovoitov <ast@kernel.org> | 2025-08-26 04:52:16 +0300 |
| commit | 1b93c03fb319d72a1f5f4723abd5df15ce40f4e2 (patch) | |
| tree | e58094f04fdcca3fdaa21ff0e0e0c0e8f724e353 /include | |
| parent | 4223bf833c8495e40ae2886acbc0ecbe88fa6306 (diff) | |
| download | linux-1b93c03fb319d72a1f5f4723abd5df15ce40f4e2.tar.xz | |
rcu: add rcu_read_lock_dont_migrate()
migrate_disable() is called to disable migration in the kernel, and it is
often used together with rcu_read_lock().
However, with PREEMPT_RCU disabled, it's unnecessary, as rcu_read_lock()
will always disable preemption, which will also disable migration.
Introduce rcu_read_lock_dont_migrate() and rcu_read_unlock_migrate(),
which will do the migration enable and disable only when PREEMPT_RCU.
Signed-off-by: Menglong Dong <dongml2@chinatelecom.cn>
Reviewed-by: Paul E. McKenney <paulmck@kernel.org>
Link: https://lore.kernel.org/r/20250821090609.42508-2-dongml2@chinatelecom.cn
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'include')
| -rw-r--r-- | include/linux/rcupdate.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h index 120536f4c6eb..9691ca380a4f 100644 --- a/include/linux/rcupdate.h +++ b/include/linux/rcupdate.h @@ -962,6 +962,20 @@ static inline notrace void rcu_read_unlock_sched_notrace(void) preempt_enable_notrace(); } +static __always_inline void rcu_read_lock_dont_migrate(void) +{ + if (IS_ENABLED(CONFIG_PREEMPT_RCU)) + migrate_disable(); + rcu_read_lock(); +} + +static inline void rcu_read_unlock_migrate(void) +{ + rcu_read_unlock(); + if (IS_ENABLED(CONFIG_PREEMPT_RCU)) + migrate_enable(); +} + /** * RCU_INIT_POINTER() - initialize an RCU protected pointer * @p: The pointer to be initialized. |
