On Tue, Oct 14, 2025 at 4:27 AM Menglong Dong <menglong8.dong@gmail.com> wrote:
>
> Factor out migrate_enable_rcu/migrate_disable_rcu from
> rcu_read_lock_dont_migrate/rcu_read_unlock_migrate.
>
> These functions will be used in the following patches.
>
> It's a little weird to define them in rcupdate.h. Maybe we should move
> them to sched.h?
>
> Signed-off-by: Menglong Dong <dongml2@chinatelecom.cn>
> ---
> include/linux/rcupdate.h | 20 +++++++++++++++++---
> 1 file changed, 17 insertions(+), 3 deletions(-)
>
> diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
> index c5b30054cd01..43626ccc07e2 100644
> --- a/include/linux/rcupdate.h
> +++ b/include/linux/rcupdate.h
> @@ -988,18 +988,32 @@ static inline notrace void rcu_read_unlock_sched_notrace(void)
> preempt_enable_notrace();
> }
>
> -static __always_inline void rcu_read_lock_dont_migrate(void)
> +/* This can only be used with rcu_read_lock held */
> +static inline void migrate_enable_rcu(void)
> +{
> + WARN_ON_ONCE(!rcu_read_lock_held());
> + if (IS_ENABLED(CONFIG_PREEMPT_RCU))
> + migrate_enable();
> +}
> +
> +/* This can only be used with rcu_read_lock held */
> +static inline void migrate_disable_rcu(void)
> {
> + WARN_ON_ONCE(!rcu_read_lock_held());
> if (IS_ENABLED(CONFIG_PREEMPT_RCU))
> migrate_disable();
> +}
> +
> +static __always_inline void rcu_read_lock_dont_migrate(void)
> +{
> rcu_read_lock();
> + migrate_disable_rcu();
> }
>
> static inline void rcu_read_unlock_migrate(void)
> {
> + migrate_enable_rcu();
> rcu_read_unlock();
> - if (IS_ENABLED(CONFIG_PREEMPT_RCU))
> - migrate_enable();
> }
Sorry. I don't like any of it. It obfuscates the code
without adding any benefits.
pw-bot: cr