Re: [PATCH] /dev/random: Insufficient of entropy on manyarchitectures

From: JÃrn Engel
Date: Thu Sep 12 2013 - 21:10:25 EST


On Thu, 12 September 2013 19:31:55 -0400, Theodore Ts'o wrote:
> On Thu, Sep 12, 2013 at 05:07:17PM -0400, JÃrn Engel wrote:
> >
> > I happen to have a real-world system with >100k interrupts per second
> > and - surprise - add_interrupt_randomness() showed up prominently in
> > the profiles. I was also told twice to just remove that call. I
> > resisted both times and have done far more work to reduce overhead
> > while still collecting entropy. Some others would have caved in.
>
> Would it be possible for you to send me the perf numbers that you saw?

Eventually. The idiot that was me half a year ago failed to attach
perf numbers to the patch description.

> What platform is this? x86? Some embedded processor?

x86. I suspect NAPI significantly cuts down the number of interrupts
for ethernet cards. My case is with FC interrupts. Quite likely
doing something like NAPI would help far more for performance than
disabling add_interrupt_randomness().

> > One option is to add the "input_pool.entropy_count > trickle_thresh"
> > condition that all other entropy sources currently have. But instead
> > I would rather rename fast_mix() to not_too_fast_mix() and implement a
> > real fast_mix(). Essentially just xor the collected numbers into a
> > pool and schedule something to shuffle the bits at a later point.
>
> We can try some different things to make fast_mix() faster, but it
> would be good to get some hard numbers before we start deciding we
> need to do something more complicated.
>
> One thing that comes to mind is that fast_mix() is only called in
> exactly one place, and we always pass in a long. So there are
> certainly ways that we could optimize fast_mix even keeping the
> current mixing algorithm.

I think the existing code is doing just fine for low interrupt loads.
It makes sense to spend a bit more work to squeeze the last bit of
randomness out. But when you get lots of interrupts, you can be
sloppy and just xor things into the pool.

My patch below is going too far by not even doing the xor. I was
stupid and under time pressure. But to my defence,
add_timer_randomness() makes the same mistake.

JÃrn

--
Eighty percent of success is showing up.
-- Woody Allen