From: Kuniyuki Iwashima <kuniyu@amazon.com>
To: <kuba@kernel.org>
Cc: <davem@davemloft.net>, <edumazet@google.com>,
<kuni1840@gmail.com>, <kuniyu@amazon.com>,
<netdev@vger.kernel.org>, <oliver.sang@intel.com>,
<pabeni@redhat.com>
Subject: Re: [PATCH v1 net-next] af_unix: Try not to hold unix_gc_lock during accept().
Date: Fri, 12 Apr 2024 19:10:12 -0700 [thread overview]
Message-ID: <20240413021012.20209-1-kuniyu@amazon.com> (raw)
In-Reply-To: <20240412190522.3a157f00@kernel.org>
From: Jakub Kicinski <kuba@kernel.org>
Date: Fri, 12 Apr 2024 19:05:22 -0700
> On Wed, 10 Apr 2024 13:19:29 -0700 Kuniyuki Iwashima wrote:
> > void unix_update_edges(struct unix_sock *receiver)
> > {
> > - spin_lock(&unix_gc_lock);
> > - unix_update_graph(unix_sk(receiver->listener)->vertex);
> > + /* nr_unix_fds is only updated under unix_state_lock().
> > + * If it's 0 here, the embryo socket is not part of the
> > + * inflight graph, and GC will not see it.
> > + */
> > + bool need_lock = !!receiver->scm_stat.nr_unix_fds;
> > +
> > + if (need_lock) {
> > + spin_lock(&unix_gc_lock);
> > + unix_update_graph(unix_sk(receiver->listener)->vertex);
> > + }
> > +
> > receiver->listener = NULL;
> > - spin_unlock(&unix_gc_lock);
> > +
> > + if (need_lock)
> > + spin_unlock(&unix_gc_lock);
> > }
>
> Are you planning to add more code here? I feel like the sharing of
> a single line is outweighted by the conditionals.. I mean:
>
> /* ...
> */
> if (!receiver->scm_stat.nr_unix_fd) {
> receiver->listener = NULL;
> } else {
> spin_lock(&unix_gc_lock);
> unix_update_graph(unix_sk(receiver->listener)->vertex);
> receiver->listener = NULL;
> spin_unlock(&unix_gc_lock);
> }
>
> no?
Ah exactly, I'll repsin v2 with that style.
Thanks!
prev parent reply other threads:[~2024-04-13 2:10 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-10 20:19 [PATCH v1 net-next] af_unix: Try not to hold unix_gc_lock during accept() Kuniyuki Iwashima
2024-04-13 2:05 ` Jakub Kicinski
2024-04-13 2:10 ` Kuniyuki Iwashima [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=20240413021012.20209-1-kuniyu@amazon.com \
--to=kuniyu@amazon.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=kuni1840@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=oliver.sang@intel.com \
--cc=pabeni@redhat.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