Skip to content

Commit 9a1212e

Browse files
image-dragonKernel Patches Daemon
authored andcommitted
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 <[email protected]>
1 parent cffbb10 commit 9a1212e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

include/linux/rcupdate.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,20 @@ static inline notrace void rcu_read_unlock_sched_notrace(void)
962962
preempt_enable_notrace();
963963
}
964964

965+
static __always_inline void rcu_read_lock_dont_migrate(void)
966+
{
967+
if (IS_ENABLED(CONFIG_PREEMPT_RCU))
968+
migrate_disable();
969+
rcu_read_lock();
970+
}
971+
972+
static inline void rcu_read_unlock_migrate(void)
973+
{
974+
rcu_read_unlock();
975+
if (IS_ENABLED(CONFIG_PREEMPT_RCU))
976+
migrate_enable();
977+
}
978+
965979
/**
966980
* RCU_INIT_POINTER() - initialize an RCU protected pointer
967981
* @p: The pointer to be initialized.

0 commit comments

Comments
 (0)