[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <a9745beb-133a-447d-80ea-b7322676b3ed@paulmck-laptop>
Date: Thu, 21 Aug 2025 04:41:49 -0700
From: "Paul E. McKenney" <paulmck@...nel.org>
To: Menglong Dong <menglong8.dong@...il.com>
Cc: ast@...nel.org, frederic@...nel.org, neeraj.upadhyay@...nel.org,
joelagnelf@...dia.com, josh@...htriplett.org, boqun.feng@...il.com,
urezki@...il.com, rostedt@...dmis.org,
mathieu.desnoyers@...icios.com, jiangshanlai@...il.com,
qiang.zhang@...ux.dev, daniel@...earbox.net,
john.fastabend@...il.com, andrii@...nel.org, martin.lau@...ux.dev,
eddyz87@...il.com, song@...nel.org, yonghong.song@...ux.dev,
kpsingh@...nel.org, sdf@...ichev.me, haoluo@...gle.com,
jolsa@...nel.org, rcu@...r.kernel.org, linux-kernel@...r.kernel.org,
bpf@...r.kernel.org
Subject: Re: [PATCH bpf-next v3 1/7] rcu: add rcu_read_lock_dont_migrate()
On Thu, Aug 21, 2025 at 05:06:03PM +0800, Menglong Dong wrote:
> 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@...natelecom.cn>
Much better!
Reviewed-by: Paul E. McKenney <paulmck@...nel.org>
> ---
> v3:
> - make rcu_read_lock_dont_migrate() more compact
>
> v2:
> - introduce rcu_read_lock_dont_migrate() instead of rcu_migrate_disable()
> ---
> include/linux/rcupdate.h | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> 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.
> --
> 2.50.1
>
Powered by blists - more mailing lists