Skip to contentSkip to conversation

srandom32 fixes for networking

PATCH In review Andi Kleen 2 participants 7 messages Apr 1, 2008 – Apr 2, 2008

Subsystems (3)
lore
Share & tools
lore
author
#2 lore raw
Quoted 11 lines · David Miller

From: Andi Kleen <[email protected]>
Date: Tue, 1 Apr 2008 13:34:08 +0200

Quoted 5 lines

Still missing from net-2.6.26

http://marc.info/?l=linux-netdev&m=120519912215170&w=2

Please add or justify rejection.

Please fix this patch so that the arch/x86/mm/pageattr-test.c build doesn't get broken by it.

Can you send me your config please? I don't see any build problem here with the patch on top of -rc7-git something on either i386 nor x86-64.

-Andi

Quoted 1 line
maintainer
#3 lore raw

From: Andi Kleen <[email protected]>
Date: Wed, 2 Apr 2008 09:50:11 +0200

Quoted 2 lines

Can you send me your config please? I don't see any build problem here with the patch on top of -rc7-git something on either i386 nor x86-64.

I found it with "git grep srandom32", I guess I'm quite old school in that I actually check the tree when interfaces are being changed.

Even if this code is not built into the tree somehow, knowingly breaking code like this is not very nice.

It does seem to get built with CONFIG_CPA_DEBUG, which is available from arch/x86/Kconfig.debug

author
#4 lore raw
Quoted 8 lines · David Miller

From: Andi Kleen <[email protected]>
Date: Wed, 2 Apr 2008 09:50:11 +0200

Quoted 2 lines

Can you send me your config please? I don't see any build problem here with the patch on top of -rc7-git something on either i386 nor x86-64.

I found it with "git grep srandom32", I guess I'm quite old school in that I actually check the tree when interfaces are being changed.

Ah I see the problem now. The patch requires

ftp://firstfloor.org/pub/ak/misc/patches/pageattr-own-random

applied first to remove this reference. Sorry should have made that more clear. The original post had both patches, but in the reposts the reference to the dependency got dropped somehow, sorry.

-Andi

maintainer
#5 lore raw

From: Andi Kleen <[email protected]>
Date: Wed, 2 Apr 2008 10:21:03 +0200

Quoted 10 lines · David Miller
Quoted 8 lines

From: Andi Kleen <[email protected]>
Date: Wed, 2 Apr 2008 09:50:11 +0200

Quoted 2 lines

Can you send me your config please? I don't see any build problem here with the patch on top of -rc7-git something on either i386 nor x86-64.

I found it with "git grep srandom32", I guess I'm quite old school in that I actually check the tree when interfaces are being changed.

Quoted 8 lines

Ah I see the problem now. The patch requires

ftp://firstfloor.org/pub/ak/misc/patches/pageattr-own-random

applied first to remove this reference. Sorry should have made that more clear. The original post had both patches, but in the reposts the reference to the dependency got dropped somehow, sorry.

You have to decide how to submit this without introducing the build failure then.

I would suggest getting your first change in, and when that happens, resubmit this one.

author
#6 lore raw
Quoted 5 lines

You have to decide how to submit this without introducing the build failure then.

I would suggest getting your first change in, and when that happens, resubmit this one.

I did a new version that just updates all CPUs without the rename, so no dependency.

I will resubmit the rename later after the x86 maintainers apply the patch to remove the call in pageattr-test.c (they unfortunately usually need at least three pings too..)

---
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: Dropped rename for now

---
 include/linux/net.h    |    2 +-
 include/linux/random.h |    2 +-
 lib/random32.c         |   19 ++++++++++++-------
 3 files changed, 14 insertions(+), 9 deletions(-)
lib/random32.c +9 -4
Index: 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);