All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jiayuan Chen" <jiayuan.chen@linux.dev>
To: "Eric Dumazet" <edumazet@google.com>
Cc: netdev@vger.kernel.org, "Jiayuan Chen" <jiayuan.chen@shopee.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: Re: [PATCH net-next v1] net: fix sock compilation error under CONFIG_PREEMPT_RT
Date: Sat, 28 Feb 2026 10:48:15 +0000	[thread overview]
Message-ID: <144847b602a9613d3f91943348294cad3eba6678@linux.dev> (raw)
In-Reply-To: <CANn89iLphv9XtPnW5Bw1UETNoZZO+rdifQfzC8MxYM+gNHAcTA@mail.gmail.com>

February 28, 2026 at 18:43, "Eric Dumazet" <edumazet@google.com mailto:edumazet@google.com?to=%22Eric%20Dumazet%22%20%3Cedumazet%40google.com%3E > wrote:


> 
> On Sat, Feb 28, 2026 at 10:07 AM Jiayuan Chen <jiayuan.chen@linux.dev> wrote:
> 
> > 
> > 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;
> > 
> Thanks for your patch, could you please use a nicer formatting ?
> (And keep an empty line between variables and code)

Ack. I will send it later. 

> diff --git a/net/core/sock.c b/net/core/sock.c
> index 9d841975a7a14a12769450a8d937af96f7777070..fba4d5b8553c58f700bda3dbd82ce68ec74187da
> 100644
> --- a/net/core/sock.c
> +++ b/net/core/sock.c
> @@ -3782,12 +3782,15 @@ 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;
> + socket_lock_t tmp = {
> + .slock = __SPIN_LOCK_UNLOCKED(tmp.slock),
> + .owned = 1,
> + };
> + socket_lock_t old = {
> + .slock = __SPIN_LOCK_UNLOCKED(old.slock),
> + .owned = 0,
> + };
> 
> - tmp.slock = __SPIN_LOCK_UNLOCKED(tmp.slock);
> - tmp.owned = 1;
> - old.slock = __SPIN_LOCK_UNLOCKED(old.slock);
> - old.owned = 0;
>  if (likely(try_cmpxchg(&sk->sk_lock.combined,
>  &old.combined, tmp.combined)))
>  return;
>

      reply	other threads:[~2026-02-28 10:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-28  9:06 [PATCH net-next v1] net: fix sock compilation error under CONFIG_PREEMPT_RT Jiayuan Chen
2026-02-28 10:43 ` Eric Dumazet
2026-02-28 10:48   ` Jiayuan Chen [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=144847b602a9613d3f91943348294cad3eba6678@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.