Re: the random driver

Oliver Xymoron
2002-11-20T20:35:34Z

On Tue, Nov 19, 2002 at 11:46:53PM -0800, Andrew Morton wrote:
>
> I'm seeing a context switch rate of 150/sec just writing a
> big file to disk at 20 megabytes/sec.
>
> It is coming out of add_disk_randomness()'s invokation of
> batch_entropy_store().

First off, there's very little unobservable randomness in those disk
ops, especially in a file/webserver context, so the value of
add_disk_randomness is questionable.

> That function is setting up deferred punt-to-process-context
> for every disk request, and has the potential to cause 1000
> context switches per second. This is clearly excessive.
>
> There is a 256 slot buffer in the random driver for this,
> and we are not using it at all effectively. I do intend
> to submit the below patch which will cause one context switch
> per 128 requests.

Done that.

> But this is a minimal fix. The batch_entropy_pool handling
> in there needs work.
>
> a) It's racy. The head and tail pointers have no SMP protection
> and a race will cause it to dump 128 already-processed items
> back into the entropy pool.

I have a rewrite that fails safe and is lockless. But this is nothing
compared to the completely broken entropy accounting in
xfer_secondary_pool. Try this: cat /dev/random, wait for it to block,
and then tap your mouse.

> d) It's punting work up to process context which could be performed
> right there in interrupt context.

Disagree. Did you look at the mixing function? It'll dirty a large
chunk of cache.

--
"Love the dolphins," she advised him. "Write by W.A.S.T.E.."