From: Menglong Dong <menglong.dong@linux.dev>
To: Menglong Dong <menglong8.dong@gmail.com>,
Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: Alexei Starovoitov <ast@kernel.org>,
"Paul E. McKenney" <paulmck@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Martin KaFai Lau <martin.lau@linux.dev>,
Eduard <eddyz87@gmail.com>, Song Liu <song@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@kernel.org>,
Stanislav Fomichev <sdf@fomichev.me>, Hao Luo <haoluo@google.com>,
Jiri Olsa <jolsa@kernel.org>,
Jakub Sitnicki <jakub@cloudflare.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
jiang.biao@linux.dev, bpf <bpf@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
Network Development <netdev@vger.kernel.org>
Subject: Re: [PATCH bpf-next 1/4] rcu: factor out migrate_enable_rcu and migrate_disable_rcu
Date: Wed, 15 Oct 2025 16:40:43 +0800 [thread overview]
Message-ID: <2239372.irdbgypaU6@7950hx> (raw)
In-Reply-To: <CAADnVQJygR6Pb1SQq=tJUpHVx7wwnSX1A78mXGha+bQArowtHQ@mail.gmail.com>
On 2025/10/14 22:59, Alexei Starovoitov wrote:
> 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.
It has a slight performance improving for some BPF type, such as
SK_SKB, SK_MSG.
Hmm, after we make migrate_disable() inline, the performance
improving here is extremely slight. And you are right, it do obfuscate
the code :/
Thanks!
Menglong Dong
>
> pw-bot: cr
>
>
next prev parent reply other threads:[~2025-10-15 8:41 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-14 11:26 [PATCH bpf-next 0/4] bpf: add and use migrate_enable_rcu Menglong Dong
2025-10-14 11:26 ` [PATCH bpf-next 1/4] rcu: factor out migrate_enable_rcu and migrate_disable_rcu Menglong Dong
2025-10-14 14:59 ` Alexei Starovoitov
2025-10-15 8:40 ` Menglong Dong [this message]
2025-10-14 11:26 ` [PATCH bpf-next 2/4] bpf: introduce bpf_prog_run_pin_on_cpu_rcu() Menglong Dong
2025-10-14 11:26 ` [PATCH bpf-next 3/4] bpf: use bpf_prog_run_pin_on_cpu_rcu() in skmsg.c Menglong Dong
2025-10-14 11:26 ` [PATCH bpf-next 4/4] bpf: use bpf_prog_run_pin_on_cpu_rcu() in bpf_prog_run_clear_cb Menglong Dong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2239372.irdbgypaU6@7950hx \
--to=menglong.dong@linux.dev \
--cc=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=eddyz87@gmail.com \
--cc=edumazet@google.com \
--cc=haoluo@google.com \
--cc=horms@kernel.org \
--cc=jakub@cloudflare.com \
--cc=jiang.biao@linux.dev \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=menglong8.dong@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=paulmck@kernel.org \
--cc=sdf@fomichev.me \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox