From: Jakub Kicinski <kuba@kernel.org>
To: Kuniyuki Iwashima <kuniyu@amazon.com>
Cc: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>,
Kuniyuki Iwashima <kuni1840@gmail.com>, <netdev@vger.kernel.org>,
kernel test robot <oliver.sang@intel.com>
Subject: Re: [PATCH v1 net-next] af_unix: Try not to hold unix_gc_lock during accept().
Date: Fri, 12 Apr 2024 19:05:22 -0700 [thread overview]
Message-ID: <20240412190522.3a157f00@kernel.org> (raw)
In-Reply-To: <20240410201929.34716-1-kuniyu@amazon.com>
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?
next prev parent reply other threads:[~2024-04-13 2:05 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 [this message]
2024-04-13 2:10 ` Kuniyuki Iwashima
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=20240412190522.3a157f00@kernel.org \
--to=kuba@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuni1840@gmail.com \
--cc=kuniyu@amazon.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