From: Jiayuan Chen <jiayuan.chen@linux.dev>
To: netdev@vger.kernel.org
Cc: jiayuan.chen@linux.dev, Jiayuan Chen <jiayuan.chen@shopee.com>,
Eric Dumazet <edumazet@google.com>,
Kuniyuki Iwashima <kuniyu@google.com>,
Paolo Abeni <pabeni@redhat.com>,
Willem de Bruijn <willemb@google.com>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Simon Horman <horms@kernel.org>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Clark Williams <clrkwllms@kernel.org>,
Steven Rostedt <rostedt@goodmis.org>,
Jason Xing <kerneljasonxing@gmail.com>,
linux-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev
Subject: [PATCH net-next v1] net: fix sock compilation error under CONFIG_PREEMPT_RT
Date: Sat, 28 Feb 2026 17:06:43 +0800 [thread overview]
Message-ID: <20260228090644.362807-1-jiayuan.chen@linux.dev> (raw)
From: Jiayuan Chen <jiayuan.chen@shopee.com>
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()")
Signed-off-by: Jiayuan Chen <jiayuan.chen@shopee.com>
---
net/core/sock.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/net/core/sock.c b/net/core/sock.c
index 9d841975a7a1..2461aba7b18a 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -3782,12 +3782,10 @@ void noinline lock_sock_nested(struct sock *sk, int subclass)
might_sleep();
#ifdef CONFIG_64BIT
if (sizeof(struct slock_owned) == sizeof(long)) {
- socket_lock_t tmp, old;
-
- tmp.slock = __SPIN_LOCK_UNLOCKED(tmp.slock);
- tmp.owned = 1;
- old.slock = __SPIN_LOCK_UNLOCKED(old.slock);
- old.owned = 0;
+ socket_lock_t tmp = { .slock = __SPIN_LOCK_UNLOCKED(tmp.slock),
+ .owned = 1 };
+ socket_lock_t old = { .slock = __SPIN_LOCK_UNLOCKED(old.slock),
+ .owned = 0 };
if (likely(try_cmpxchg(&sk->sk_lock.combined,
&old.combined, tmp.combined)))
return;
--
2.43.0
next reply other threads:[~2026-02-28 9:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-28 9:06 Jiayuan Chen [this message]
2026-02-28 10:43 ` [PATCH net-next v1] net: fix sock compilation error under CONFIG_PREEMPT_RT Eric Dumazet
2026-02-28 10:48 ` Jiayuan Chen
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=20260228090644.362807-1-jiayuan.chen@linux.dev \
--to=jiayuan.chen@linux.dev \
--cc=bigeasy@linutronix.de \
--cc=clrkwllms@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jiayuan.chen@shopee.com \
--cc=kerneljasonxing@gmail.com \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-devel@lists.linux.dev \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rostedt@goodmis.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.