netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PING^3] [PATCH] srandom32 fixes for networking v2
@ 2008-04-03 20:36 Andi Kleen
  2008-04-03 21:07 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Andi Kleen @ 2008-04-03 20:36 UTC (permalink / raw)
  To: davem, netdev

srandom32 fixes for networking v2

- Let it update the state of all CPUs. The network stack goes
into pains to feed the current IP addresses in, but it is not very
effective if that is only done for some random CPU instead of all.
So change it to feed bits into all CPUs.  I decided to do that lockless 
because well somewhat random results are ok.

v2: Drop rename so that this patch doesn't depend on x86 maintainers

Signed-off-by: Andi Kleen <ak@suse.de>
---
 include/linux/net.h    |    2 +-
 include/linux/random.h |    2 +-
 lib/random32.c         |   19 ++++++++++++-------
 3 files changed, 14 insertions(+), 9 deletions(-)

Index: linux/lib/random32.c
===================================================================
--- linux.orig/lib/random32.c
+++ linux/lib/random32.c
@@ -97,13 +97,18 @@ EXPORT_SYMBOL(random32);
  *	@seed: seed value
  *
  *	Add some additional seeding to the random32() pool.
- *	Note: this pool is per cpu so it only affects current CPU.
  */
 void srandom32(u32 entropy)
 {
-	struct rnd_state *state = &get_cpu_var(net_rand_state);
-	__set_random32(state, state->s1 ^ entropy);
-	put_cpu_var(state);
+	int i;
+	/*
+	 * No locking on the CPUs, but then somewhat random results are, well,
+	 * expected.
+	 */
+	for_each_possible_cpu (i) {
+		struct rnd_state *state = &per_cpu(net_rand_state, i);
+		__set_random32(state, state->s1 ^ entropy);
+	}
 }
 EXPORT_SYMBOL(srandom32);
 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PING^3] [PATCH] srandom32 fixes for networking v2
  2008-04-03 20:36 [PING^3] [PATCH] srandom32 fixes for networking v2 Andi Kleen
@ 2008-04-03 21:07 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2008-04-03 21:07 UTC (permalink / raw)
  To: andi; +Cc: netdev

From: Andi Kleen <andi@firstfloor.org>
Date: Thu, 3 Apr 2008 22:36:11 +0200

> srandom32 fixes for networking v2
> 
> - Let it update the state of all CPUs. The network stack goes
> into pains to feed the current IP addresses in, but it is not very
> effective if that is only done for some random CPU instead of all.
> So change it to feed bits into all CPUs.  I decided to do that lockless 
> because well somewhat random results are ok.
> 
> v2: Drop rename so that this patch doesn't depend on x86 maintainers
> 
> Signed-off-by: Andi Kleen <ak@suse.de>

Applied, thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-04-03 21:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-03 20:36 [PING^3] [PATCH] srandom32 fixes for networking v2 Andi Kleen
2008-04-03 21:07 ` David Miller

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).