Re: [PATCH 02/10] random: use lockless techniques when mixing entropy pools
From: Linus Torvalds
Date: Thu Jul 05 2012 - 14:19:12 EST
On Thu, Jul 5, 2012 at 11:12 AM, Theodore Ts'o <tytso@xxxxxxx> wrote:
>
> Also, we will use a trylock when trying to increase then entropy
> accounting during the interrupt path to avoid taking a spinlock there;
> if there is contention, we will simply not credit the entropy count,
> thus failing safe. Thanks to Dan Carpenter for suggesting this
> approach.
Actually, I hate that. If the *only* thing the spinlock protects is
that entropy count, then use one single cmpxchg() for that field
instead.
The trylock means that now you need to disable interrupts etc. Just
don't do it. Do things entirely locklessly, and minimizing atomics.
Quite frankly, I think that protecting the entropy count is completely
idiotic, since it's not "real" in any form anyway, but if you
absolutely have to, a single cmpxchg is much better than playing games
with spinlocks and interrupt disables.
Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/