From: Willy Tarreau <w@1wt.eu>
To: "Jason A. Donenfeld" <Jason@zx2c4.com>
Cc: Eric Dumazet <eric.dumazet@gmail.com>,
"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: Sun, 2 Oct 2022 07:38:12 +0200 [thread overview]
Message-ID: <20221002053812.GA18978@1wt.eu> (raw)
In-Reply-To: <YzjEPq6owOKBACj3@zx2c4.com>
On Sun, Oct 02, 2022 at 12:50:38AM +0200, Jason A. Donenfeld wrote:
> > > 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);
> > }
>
> If you don't care about the tables being consistent between CPUs, then
> yea, sure, that seems like a reasonable approach, and I like not
> polluting once.{c,h} with some _SLOW() special cases.
I don't see this as pollution, it possibly is a nice addition for certain
use cases or early fast paths where the risk of contention is high.
> If you don't want
> the atomic read in there you could also do the same pattern with a
> static branch, like what DO_ONCE() does:
>
> if (static_branch_unlikely(&need_bytes)) {
> get_random_bytes(array);
> static_branch_disable(&need_bytes);
> }
>
> Anyway, same thing as your suggestion more or less.
What I don't know in fact is if the code patching itself can be
responsible for a measurable part of the extra time Christophe noticed.
Anyway at least Christophe now has a few approaches to try, let's first
see if any of them fixes the regression.
Willy
next prev parent reply other threads:[~2022-10-02 5:46 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
2022-10-01 22:50 ` Jason A. Donenfeld
2022-10-02 5:38 ` Willy Tarreau [this message]
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=20221002053812.GA18978@1wt.eu \
--to=w@1wt.eu \
--cc=Jason@zx2c4.com \
--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).