From: Harald Freudenberger <freude@linux.ibm.com>
To: "Jason A. Donenfeld" <Jason@zx2c4.com>
Cc: linux390-list@tuxmaker.boeblingen.de.ibm.com,
linux-crypto@vger.kernel.org, linux-s390@vger.kernel.org,
jchrist@linux.ibm.com, dengler@linux.ibm.com
Subject: Re: [PATCH] s390/archrandom: remove CPACF trng invocations in interrupt context
Date: Tue, 12 Jul 2022 14:09:35 +0200 [thread overview]
Message-ID: <4881578c512c5420315abfef47068df0@linux.ibm.com> (raw)
In-Reply-To: <Ys1Loyu21C48Zm6n@zx2c4.com>
On 2022-07-12 12:23, Jason A. Donenfeld wrote:
> Hi Harald,
>
> On Tue, Jul 12, 2022 at 12:08:29PM +0200, Harald Freudenberger wrote:
>> This patch introduces two things:
>> 1) The arch_get_random_seed_int() implementation now always
>> returns false. There is no user in the whole kernel using
>> this function.
>
> Please do not do this. It has nothing to do with the rest of the patch,
> but also this isn't really the right place to decide on that. As we
> discussed last week with the arch_get_random_words{,_seed} branch of
> the
> conversation -
> https://lore.kernel.org/all/YsQ%2FvZSkzWPLwIte@zx2c4.com/
> - there are a few things that might be suboptimal about the API. When
> we
> fix these, I'd prefer for it to be done in some coherent step. What
> you're doing here is just gimping the present API, which preemptively
> rots the entire thing and *forces* us to remove it for all
> architectures
> since it would become non-dependable. And I don't like having our hands
> be forced here. I'd much rather carefully consider this.
>
> So please remove this snippet.
Ok, will do.
>
>> 2) For the arch_get_random_seed_long() make sure the CPACF trng
>> instruction is never called in any interrupt context.
>
> I don't object overly loudly to this. However, based on your comment in
> https://lore.kernel.org/all/7e65130c6e66ce7a9f9eb469eb7e64e0@linux.ibm.com/
> , I was under the impression that this wasn't necessary. If you think
> it
> is, it'd be useful to show some measured latency numbers on actual
> systems. Otherwise it seems like premature optimization? Anyway, if you
> have solid rationale, I'm fine with this as I mentioned in the other
> thread. I'm just a bit confused now on the particulars of the "why"
> part
> given your earlier comment.
>
>> This is done by adding an additional condition in_task().
>
> That doesn't seem right. Instead use `!in_hardirq()`, or perhaps
> `!in_nmi() && !in_hardirq()`? Otherwise you also disallow this when
> serving softirqs, which based on the discussion, I don't think you
> really want to do. Or do you? Without actual latency measurements and a
> real world look at the implications, it's hard to see what we're after.
>
>> which confirms that the call is in softirq context. So in_task()
>> covers exactly
>> the cases where we want to have CPACF trng called: not in nmi, not in
>> hard irq,
>> not in soft irq but in normal task context and during kernel init.
>
> You've gone through the troubles of confirming experimentally what
> in_task() does, but that doesn't answer *why* it should be disallowed
> variously in each one of these contexts.
I think, I showed this. The only real occurrences remaining for the
arch_get_random_seed_long() call is within softirq context when the
network layer tries to allocate some skb buffers. My personal feeling
about this is that it does not hurt - but I asked our network guys
and their feedback is clear: no way - every delay there may cause
high bandwidth traffic to stumble and this is to be absolutely avoided.
However, they can't give me any measurements.
So yes, the intention is now with checking for in_task() to prevent
the trng call in hard and soft interrupt context. But still I'd like
to meet your condition to provide good random at kernel startup.
>
> Regards,
> Jason
Regards,
Harald Freudenberger
next prev parent reply other threads:[~2022-07-12 12:09 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-12 10:08 [PATCH] s390/archrandom: remove CPACF trng invocations in interrupt context Harald Freudenberger
2022-07-12 10:23 ` Jason A. Donenfeld
2022-07-12 12:09 ` Harald Freudenberger [this message]
2022-07-12 12:27 ` Jason A. Donenfeld
2022-07-12 14:35 ` Harald Freudenberger
2022-07-12 14:44 ` 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=4881578c512c5420315abfef47068df0@linux.ibm.com \
--to=freude@linux.ibm.com \
--cc=Jason@zx2c4.com \
--cc=dengler@linux.ibm.com \
--cc=jchrist@linux.ibm.com \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=linux390-list@tuxmaker.boeblingen.de.ibm.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