From: Willy Tarreau <w@1wt.eu>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: "David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
netdev <netdev@vger.kernel.org>,
Eric Dumazet <edumazet@google.com>,
Christophe Leroy <christophe.leroy@csgroup.eu>
Subject: Re: [PATCH net-next] once: add DO_ONCE_SLOW() for sleepable contexts
Date: Sat, 1 Oct 2022 23:15:29 +0200 [thread overview]
Message-ID: <20221001211529.GC15441@1wt.eu> (raw)
In-Reply-To: <20221001205102.2319658-1-eric.dumazet@gmail.com>
Hi Eric,
On Sat, Oct 01, 2022 at 01:51:02PM -0700, Eric Dumazet wrote:
> From: Eric Dumazet <edumazet@google.com>
>
> Christophe Leroy reported a ~80ms latency spike
> happening at first TCP connect() time.
Seeing Christophe's message also made me wonder if we didn't break
something back then :-/
> This is because __inet_hash_connect() uses get_random_once()
> to populate a perturbation table which became quite big
> after commit 4c2c8f03a5ab ("tcp: increase source port perturb table to 2^16")
>
> get_random_once() uses DO_ONCE(), which block hard irqs for the duration
> of the operation.
>
> This patch adds DO_ONCE_SLOW() which uses a mutex instead of a spinlock
> for operations where we prefer to stay in process context.
That's a nice improvement I think. I was wondering if, for this special
case, we *really* need an exclusive DO_ONCE(). I mean, we're getting
random bytes, we really do not care if two CPUs change them in parallel
provided that none uses them before the table is entirely filled. Thus
that could probably end up as something like:
if (!atomic_read(&done)) {
get_random_bytes(array);
atomic_set(&done, 1);
}
In any case, your solution remains cleaner and more robust, though.
Thanks,
Willy
next prev parent reply other threads:[~2022-10-01 21:15 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-01 20:51 [PATCH net-next] once: add DO_ONCE_SLOW() for sleepable contexts Eric Dumazet
2022-10-01 21:15 ` Willy Tarreau [this message]
2022-10-01 22:50 ` Jason A. Donenfeld
2022-10-02 5:38 ` Willy Tarreau
2022-10-01 22:44 ` Jason A. Donenfeld
2022-10-01 22:50 ` Eric Dumazet
2022-10-03 17:25 ` Jakub Kicinski
2022-10-03 17:43 ` Jason A. Donenfeld
2022-10-03 18:14 ` [PATCH] once: rename _SLOW to _SLEEPABLE Jason A. Donenfeld
2022-10-03 18:14 ` [PATCH net-next] " Jason A. Donenfeld
2022-10-03 22:50 ` [PATCH] " Eric Dumazet
2022-10-02 8:58 ` [PATCH net-next] once: add DO_ONCE_SLOW() for sleepable contexts Christophe Leroy
2022-10-03 12:40 ` patchwork-bot+netdevbpf
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=20221001211529.GC15441@1wt.eu \
--to=w@1wt.eu \
--cc=christophe.leroy@csgroup.eu \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=eric.dumazet@gmail.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).