From: Steffen Klassert <steffen.klassert@secunet.com>
To: Sebastian Sewior <bigeasy@linutronix.de>
Cc: Alexei Starovoitov <alexei.starovoitov@gmail.com>,
Network Development <netdev@vger.kernel.org>,
Jakub Kicinski <kuba@kernel.org>
Subject: Re: xfrm in RT
Date: Fri, 17 Jan 2025 09:02:29 +0100 [thread overview]
Message-ID: <Z4oOldW33zFbYQ6/@gauss3.secunet.de> (raw)
In-Reply-To: <20241218154426.E4hsgTfF@linutronix.de>
On Wed, Dec 18, 2024 at 04:44:26PM +0100, Sebastian Sewior wrote:
> On 2024-12-18 09:32:26 [+0100], Steffen Klassert wrote:
> > On Tue, Dec 17, 2024 at 04:07:16PM -0800, Alexei Starovoitov wrote:
> > > Hi,
> > >
> > > Looks like xfrm isn't friendly to PREEMPT_RT.
> Thank you for the report.
Sorry for the delay.
> > > xfrm_input_state_lookup() is doing:
> > >
> > > int cpu = get_cpu();
> > > ...
> > > spin_lock_bh(&net->xfrm.xfrm_state_lock);
> >
> > We just need the cpu as a lookup key, no need to
> > hold on the cpu. So we just can do put_cpu()
> > directly after we fetched the value.
>
> I would assume that the espX_gro_receive() caller is within NAPI. Can't
> tell what xfrm_input() is.
> However if you don't care about staying on the current CPU for the whole
> time (your current get_cpu() -> put_cpu() span) you could do something
> like
>
> diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
> index 67ca7ac955a37..66b108a5b87d4 100644
> --- a/net/xfrm/xfrm_state.c
> +++ b/net/xfrm/xfrm_state.c
> @@ -1116,9 +1116,8 @@ struct xfrm_state *xfrm_input_state_lookup(struct net *net, u32 mark,
> {
> struct hlist_head *state_cache_input;
> struct xfrm_state *x = NULL;
> - int cpu = get_cpu();
>
> - state_cache_input = per_cpu_ptr(net->xfrm.state_cache_input, cpu);
> + state_cache_input = raw_cpu_ptr(net->xfrm.state_cache_input);
>
> rcu_read_lock();
> hlist_for_each_entry_rcu(x, state_cache_input, state_cache_input) {
> @@ -1150,7 +1149,6 @@ struct xfrm_state *xfrm_input_state_lookup(struct net *net, u32 mark,
>
> out:
> rcu_read_unlock();
> - put_cpu();
> return x;
> }
This looks like the correct fix. Do you want to submit this pach?
next prev parent reply other threads:[~2025-01-17 8:02 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-18 0:07 xfrm in RT Alexei Starovoitov
2024-12-18 8:32 ` Steffen Klassert
2024-12-18 15:44 ` Sebastian Sewior
2024-12-18 16:07 ` Sebastian Sewior
2025-01-17 8:17 ` Steffen Klassert
2025-01-17 8:02 ` Steffen Klassert [this message]
2025-01-23 16:20 ` [PATCH net] xfrm: Don't disable preemption while looking up cache state Sebastian Sewior
2025-01-27 5:33 ` Steffen Klassert
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=Z4oOldW33zFbYQ6/@gauss3.secunet.de \
--to=steffen.klassert@secunet.com \
--cc=alexei.starovoitov@gmail.com \
--cc=bigeasy@linutronix.de \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).