netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steffen Klassert <steffen.klassert@secunet.com>
To: Eric Dumazet <edumazet@kernel.org>
Cc: "David S . Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Willem de Bruijn <willemb@google.com>,
	Simon Horman <horms@kernel.org>, <netdev@vger.kernel.org>
Subject: Re: [PATCH net-next] xfrm: remove three registration spinlocks
Date: Thu, 26 Nov 2026 07:31:54 +0100	[thread overview]
Message-ID: <awfSWovE7zDwHYpk@gauss4> (raw)
In-Reply-To: <20261118230715.1630439-1-edumazet@kernel.org>

On Thu, Nov 19, 2026 at 12:07:15AM +0100, Eric Dumazet wrote:
> xfrm_state_afinfo[], xfrm_translator and xfrm_mode_cbs_map[] are
> RCU protected pointers which are only written when a module or an
> address family registers or unregisters itself. All their readers
> already use rcu_read_lock() and rcu_dereference(), and the unregister
> functions already call synchronize_rcu().
> 
> Each of them has a dedicated spinlock which only serializes these
> rare writers:
> 
> - xfrm_state_afinfo_lock and xfrm_translator_lock make "install if
>   the slot is empty" and "clear if the slot is ours" atomic. Use
>   cmpxchg() instead. The return values are unchanged: -EEXIST if the
>   slot is already used at registration, -EINVAL when unregistering
>   while another object is installed, 0 otherwise.
> 
> - xfrm_mode_cbs_map_lock protects nothing: registration overwrites
>   the slot and unregistration clears it, both unconditionally. Remove
>   it, the existing behavior is kept.
> 
> Tested with the xfrm_policy.sh and xfrm_state.sh selftests. The
> translator code was only compile tested, with
> CONFIG_XFRM_USER_COMPAT=y, and the unregister paths were not
> exercised. sparse (C=2) reports no warning.
> 
> Signed-off-by: Eric Dumazet <edumazet@kernel.org>
> Cc: Steffen Klassert <steffen.klassert@secunet.com>

Applied to ipsec-next, thanks a lot Eric!

      reply	other threads:[~2026-11-26  6:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18 23:07 [PATCH net-next] xfrm: remove three registration spinlocks Eric Dumazet
2026-11-26  6:31 ` Steffen Klassert [this message]

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=awfSWovE7zDwHYpk@gauss4 \
    --to=steffen.klassert@secunet.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=willemb@google.com \
    /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).