linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: "Jason A. Donenfeld" <Jason@zx2c4.com>
Cc: linux-kernel@vger.kernel.org,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Peter Zijlstra" <peterz@infradead.org>,
	"Theodore Ts'o" <tytso@mit.edu>,
	"Jonathan Neuschäfer" <j.neuschaefer@gmx.net>,
	"Sultan Alsawaf" <sultan@kerneltoast.com>,
	"Dominik Brodowski" <linux@dominikbrodowski.net>
Subject: Re: [PATCH v2] random: set fast pool count to zero in cpuhp teardown
Date: Mon, 14 Feb 2022 15:17:30 +0100	[thread overview]
Message-ID: <Ygpkej/vnMvUDIlP@linutronix.de> (raw)
In-Reply-To: <20220214133735.966528-1-Jason@zx2c4.com>

On 2022-02-14 14:37:35 [+0100], Jason A. Donenfeld wrote:
> Rather than having to use expensive atomics, which were visibly the most
> expensive thing in the entire irq handler, simply take care of the
> extreme edge case of resetting count to 0 in the cpuhp teardown handler,
> after no more interrupts will arrive on that CPU. This simplifies the
> code a bit and lets us use vanilla variables rather than atomics, and
> performance should be improved.
> 
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Theodore Ts'o <tytso@mit.edu>
> Cc: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
> Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> Cc: Sultan Alsawaf <sultan@kerneltoast.com>
> Cc: Dominik Brodowski <linux@dominikbrodowski.net>
> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
> ---
> Sebastian -
> 
> v2 moves the teardown to CPUHP_OFFLINE…CPUHP_BRINGUP_CPU, per our
> discussion.

My suggestion was to move it to the startup handler with the code
snippet I had.
As I tried to explain, this may have two problems:
- worker scheduled during CPU-UP before CPUHP_AP_WORKQUEUE_ONLINE are
  probably unbound.

- worker scheduled during CPU-DOWN after CPUHP_AP_WORKQUEUE_ONLINE are
  probably unbound.

The unbound worker may run on any CPU and thus do nothing.
In the CPU-DOWN case before: should we rollback before
CPUHP_RANDOM_PREPARE but after CPUHP_AP_WORKQUEUE_ONLINE then the needed
reset (in case the worker did nothing because it was on the wrong CPU)
will not happen.
Therefore I think, moving it to startup, online, (as suggested in
https://lore.kernel.org/all/Ygo3%2FpuhZFpuX91x@linutronix.de/).

will not have any of this downsides/ corner cases.

Sebastian

  reply	other threads:[~2022-02-14 14:17 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-13 21:53 [PATCH] random: set fast pool count to zero in cpuhp teardown Jason A. Donenfeld
2022-02-14 11:07 ` Sebastian Andrzej Siewior
2022-02-14 13:28   ` Jason A. Donenfeld
2022-02-14 13:37     ` [PATCH v2] " Jason A. Donenfeld
2022-02-14 14:17       ` Sebastian Andrzej Siewior [this message]
2022-02-14 14:42         ` Jason A. Donenfeld
2022-02-14 14:49           ` Sebastian Andrzej Siewior
2022-02-14 14:52             ` Jason A. Donenfeld
2022-02-14 15:06               ` Sebastian Andrzej Siewior
2022-02-14 15:10                 ` Jason A. Donenfeld
2022-02-14 15:17                   ` Sebastian Andrzej Siewior
2022-02-14 16:15                     ` Jason A. Donenfeld

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=Ygpkej/vnMvUDIlP@linutronix.de \
    --to=bigeasy@linutronix.de \
    --cc=Jason@zx2c4.com \
    --cc=j.neuschaefer@gmx.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@dominikbrodowski.net \
    --cc=peterz@infradead.org \
    --cc=sultan@kerneltoast.com \
    --cc=tglx@linutronix.de \
    --cc=tytso@mit.edu \
    /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).