Re: [PATCH net-next v2] net: fix sock compilation error under CONFIG_PREEMPT_RT
From: Eric Dumazet
Date: Sat Feb 28 2026 - 09:35:31 EST
On Sat, Feb 28, 2026 at 12:13 PM Jiayuan Chen <jiayuan.chen@xxxxxxxxx> wrote:
>
> From: Jiayuan Chen <jiayuan.chen@xxxxxxxxxx>
>
> When CONFIG_PREEMPT_RT is enabled, __SPIN_LOCK_UNLOCKED() expands to a
> brace-enclosed initializer rather than a compound literal, which cannot
> be used in assignment expressions. This causes a build failure:
>
> net/core/sock.c:3787:29: error: expected expression before '{' token
> 3787 | tmp.slock = __SPIN_LOCK_UNLOCKED(tmp.slock);
>
> Use declaration-with-initializer instead of assignment, consistent with
> how __SPIN_LOCK_UNLOCKED() is used elsewhere in the kernel (e.g.
> DEFINE_SPINLOCK).
>
> Fixes: 5151ec54f586 ("net: use try_cmpxchg() in lock_sock_nested()")
> Suggested-by: Eric Dumazet <edumazet@xxxxxxxxxx>
> Signed-off-by: Jiayuan Chen <jiayuan.chen@xxxxxxxxxx>
Reviewed-by: Eric Dumazet <edumazet@xxxxxxxxxx>
Thanks !