summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2008-10-15 23:23:52 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2008-10-15 23:23:52 +0000
commit402af595bcaa120a104360ebebeb3d8f5eac8859 (patch)
tree246ce2dffcd538c7674e8ed19b552cbadd811192 /sys/arch
parent01ed2ea8940e2739cafb585b7d5f8d8db553c397 (diff)
make random(9) return per-cpu values (by saving the seed in the cpuinfo),
which are uniform for the profclock on each cpu in a SMP system (but using a different seed for each cpu). on all cpus, avoid seeding with a value out of the [0, 2^31-1] range (since that is not stable) ok kettenis drahn
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/alpha/include/cpu.h3
-rw-r--r--sys/arch/amd64/amd64/cpu.c3
-rw-r--r--sys/arch/amd64/include/cpu.h3
-rw-r--r--sys/arch/arm/include/cpu.h3
-rw-r--r--sys/arch/hppa/include/cpu.h5
-rw-r--r--sys/arch/i386/i386/cpu.c3
-rw-r--r--sys/arch/i386/include/cpu.h3
-rw-r--r--sys/arch/m68k/include/cpu.h3
-rw-r--r--sys/arch/m88k/include/cpu.h3
-rw-r--r--sys/arch/macppc/macppc/cpu.c3
-rw-r--r--sys/arch/mips64/include/cpu.h3
-rw-r--r--sys/arch/powerpc/include/cpu.h4
-rw-r--r--sys/arch/sh/include/cpu.h3
-rw-r--r--sys/arch/sparc/sparc/cpuvar.h3
-rw-r--r--sys/arch/sparc64/include/cpu.h3
-rw-r--r--sys/arch/sparc64/sparc64/cpu.c3
-rw-r--r--sys/arch/vax/include/cpu.h3
17 files changed, 35 insertions, 19 deletions
diff --git a/sys/arch/alpha/include/cpu.h b/sys/arch/alpha/include/cpu.h
index 3351d04a32a..508c3d00c58 100644
--- a/sys/arch/alpha/include/cpu.h
+++ b/sys/arch/alpha/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.35 2008/10/10 08:36:28 art Exp $ */
+/* $OpenBSD: cpu.h,v 1.36 2008/10/15 23:23:44 deraadt Exp $ */
/* $NetBSD: cpu.h,v 1.45 2000/08/21 02:03:12 thorpej Exp $ */
/*-
@@ -202,6 +202,7 @@ struct cpu_info {
u_long ci_flags; /* flags; see below */
u_long ci_ipis; /* interprocessor interrupts pending */
#endif
+ u_int32_t ci_randseed;
};
#define CPUF_PRIMARY 0x01 /* CPU is primary CPU */
diff --git a/sys/arch/amd64/amd64/cpu.c b/sys/arch/amd64/amd64/cpu.c
index c7222a901d4..ee47764724e 100644
--- a/sys/arch/amd64/amd64/cpu.c
+++ b/sys/arch/amd64/amd64/cpu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.c,v 1.20 2008/10/06 20:42:02 chl Exp $ */
+/* $OpenBSD: cpu.c,v 1.21 2008/10/15 23:23:46 deraadt Exp $ */
/* $NetBSD: cpu.c,v 1.1 2003/04/26 18:39:26 fvdl Exp $ */
/*-
@@ -397,6 +397,7 @@ cpu_boot_secondary_processors(void)
ci = cpu_info[i];
if (ci == NULL)
continue;
+ ci->ci_randseed = random();
if (ci->ci_idle_pcb == NULL)
continue;
if ((ci->ci_flags & CPUF_PRESENT) == 0)
diff --git a/sys/arch/amd64/include/cpu.h b/sys/arch/amd64/include/cpu.h
index 248a9659c6e..8bbe67e6ebc 100644
--- a/sys/arch/amd64/include/cpu.h
+++ b/sys/arch/amd64/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.37 2008/07/18 23:43:31 art Exp $ */
+/* $OpenBSD: cpu.h,v 1.38 2008/10/15 23:23:46 deraadt Exp $ */
/* $NetBSD: cpu.h,v 1.1 2003/04/26 18:39:39 fvdl Exp $ */
/*-
@@ -71,6 +71,7 @@ struct cpu_info {
u_int ci_apicid;
u_long ci_spin_locks;
u_long ci_simple_locks;
+ u_int32_t ci_randseed;
u_int64_t ci_scratch;
diff --git a/sys/arch/arm/include/cpu.h b/sys/arch/arm/include/cpu.h
index 45673233d2f..c517b9c5268 100644
--- a/sys/arch/arm/include/cpu.h
+++ b/sys/arch/arm/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.22 2008/10/10 08:36:28 art Exp $ */
+/* $OpenBSD: cpu.h,v 1.23 2008/10/15 23:23:46 deraadt Exp $ */
/* $NetBSD: cpu.h,v 1.34 2003/06/23 11:01:08 martin Exp $ */
/*
@@ -216,6 +216,7 @@ struct cpu_info {
#ifdef MULTIPROCESSOR
MP_CPU_INFO_MEMBERS
#endif
+ u_int32_t ci_randseed;
};
#ifndef MULTIPROCESSOR
diff --git a/sys/arch/hppa/include/cpu.h b/sys/arch/hppa/include/cpu.h
index d908c3ba425..8763c036dca 100644
--- a/sys/arch/hppa/include/cpu.h
+++ b/sys/arch/hppa/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.58 2008/10/10 08:36:28 art Exp $ */
+/* $OpenBSD: cpu.h,v 1.59 2008/10/15 23:23:47 deraadt Exp $ */
/*
* Copyright (c) 2000-2004 Michael Shalayeff
@@ -68,9 +68,10 @@
#include <sys/sched.h>
struct cpu_info {
- struct proc *ci_curproc;
+ struct proc *ci_curproc;
struct schedstate_percpu ci_schedstate;
+ u_int32_t ci_randseed;
};
extern struct cpu_info cpu_info_primary;
diff --git a/sys/arch/i386/i386/cpu.c b/sys/arch/i386/i386/cpu.c
index 23e5ae3911e..b994c40610b 100644
--- a/sys/arch/i386/i386/cpu.c
+++ b/sys/arch/i386/i386/cpu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.c,v 1.31 2008/10/05 16:57:36 kettenis Exp $ */
+/* $OpenBSD: cpu.c,v 1.32 2008/10/15 23:23:47 deraadt Exp $ */
/* $NetBSD: cpu.c,v 1.1.2.7 2000/06/26 02:04:05 sommerfeld Exp $ */
/*-
@@ -355,6 +355,7 @@ cpu_boot_secondary_processors()
ci = cpu_info[i];
if (ci == NULL)
continue;
+ ci->ci_randseed = random();
if (ci->ci_idle_pcb == NULL)
continue;
if ((ci->ci_flags & CPUF_PRESENT) == 0)
diff --git a/sys/arch/i386/include/cpu.h b/sys/arch/i386/include/cpu.h
index 53d9764f966..48fd4f35843 100644
--- a/sys/arch/i386/include/cpu.h
+++ b/sys/arch/i386/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.104 2008/09/28 20:32:17 brad Exp $ */
+/* $OpenBSD: cpu.h,v 1.105 2008/10/15 23:23:47 deraadt Exp $ */
/* $NetBSD: cpu.h,v 1.35 1996/05/05 19:29:26 christos Exp $ */
/*-
@@ -86,6 +86,7 @@ struct cpu_info {
u_long ci_spin_locks; /* # of spin locks held */
u_long ci_simple_locks; /* # of simple locks held */
#endif
+ u_int32_t ci_randseed;
/*
* Private members.
diff --git a/sys/arch/m68k/include/cpu.h b/sys/arch/m68k/include/cpu.h
index f498b8a3b0c..2fd7b60f243 100644
--- a/sys/arch/m68k/include/cpu.h
+++ b/sys/arch/m68k/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.21 2008/10/10 08:36:28 art Exp $ */
+/* $OpenBSD: cpu.h,v 1.22 2008/10/15 23:23:48 deraadt Exp $ */
/* $NetBSD: cpu.h,v 1.3 1997/02/02 06:56:57 thorpej Exp $ */
/*
@@ -73,6 +73,7 @@ struct cpu_info {
struct proc *ci_curproc;
struct schedstate_percpu ci_schedstate;
+ u_int32_t ci_randseed;
};
extern struct cpu_info cpu_info_store;
diff --git a/sys/arch/m88k/include/cpu.h b/sys/arch/m88k/include/cpu.h
index c4b5d6fbc25..f4de3b9eb8e 100644
--- a/sys/arch/m88k/include/cpu.h
+++ b/sys/arch/m88k/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.37 2008/10/10 08:36:28 art Exp $ */
+/* $OpenBSD: cpu.h,v 1.38 2008/10/15 23:23:48 deraadt Exp $ */
/*
* Copyright (c) 1996 Nivas Madhur
* Copyright (c) 1992, 1993
@@ -110,6 +110,7 @@ struct cpu_info {
#define CI_DDB_PAUSE 3
int ci_softintr; /* pending soft interrupts */
+ u_int32_t ci_randseed;
#ifdef MULTIPROCESSOR
diff --git a/sys/arch/macppc/macppc/cpu.c b/sys/arch/macppc/macppc/cpu.c
index 1c7e58ea528..d443aa4f15a 100644
--- a/sys/arch/macppc/macppc/cpu.c
+++ b/sys/arch/macppc/macppc/cpu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.c,v 1.58 2008/09/18 03:56:25 drahn Exp $ */
+/* $OpenBSD: cpu.c,v 1.59 2008/10/15 23:23:49 deraadt Exp $ */
/*
* Copyright (c) 1997 Per Fogelstrom
@@ -672,6 +672,7 @@ cpu_boot_secondary_processors(void)
ci = &cpu_info[i];
if (ci->ci_cpuid == 0)
continue;
+ ci->ci_randseed = random();
sched_init_cpu(ci);
diff --git a/sys/arch/mips64/include/cpu.h b/sys/arch/mips64/include/cpu.h
index e56b62491c1..fec803b246a 100644
--- a/sys/arch/mips64/include/cpu.h
+++ b/sys/arch/mips64/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.28 2008/10/10 08:36:28 art Exp $ */
+/* $OpenBSD: cpu.h,v 1.29 2008/10/15 23:23:49 deraadt Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -374,6 +374,7 @@ struct cpu_info {
struct schedstate_percpu ci_schedstate;
struct proc *ci_curproc;
+ u_int32_t ci_randseed;
};
extern struct cpu_info cpu_info_primary;
diff --git a/sys/arch/powerpc/include/cpu.h b/sys/arch/powerpc/include/cpu.h
index b14490768a1..5bb8462ef08 100644
--- a/sys/arch/powerpc/include/cpu.h
+++ b/sys/arch/powerpc/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.40 2008/10/10 08:05:45 art Exp $ */
+/* $OpenBSD: cpu.h,v 1.41 2008/10/15 23:23:49 deraadt Exp $ */
/* $NetBSD: cpu.h,v 1.1 1996/09/30 16:34:21 ws Exp $ */
/*
@@ -80,7 +80,7 @@ struct cpu_info {
#define CI_DDB_ENTERDDB 3
#define CI_DDB_INDDB 4
- u_long ci_randseed;
+ u_int32_t ci_randseed;
};
static __inline struct cpu_info *
diff --git a/sys/arch/sh/include/cpu.h b/sys/arch/sh/include/cpu.h
index 39d386f893d..681b799c039 100644
--- a/sys/arch/sh/include/cpu.h
+++ b/sys/arch/sh/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.17 2008/10/10 08:36:28 art Exp $ */
+/* $OpenBSD: cpu.h,v 1.18 2008/10/15 23:23:49 deraadt Exp $ */
/* $NetBSD: cpu.h,v 1.41 2006/01/21 04:24:12 uwe Exp $ */
/*-
@@ -59,6 +59,7 @@ struct cpu_info {
struct proc *ci_curproc;
struct schedstate_percpu ci_schedstate; /* scheduler state */
+ u_int32_t ci_randseed;
};
extern struct cpu_info cpu_info_store;
diff --git a/sys/arch/sparc/sparc/cpuvar.h b/sys/arch/sparc/sparc/cpuvar.h
index 65cc5202053..63b12a0d66f 100644
--- a/sys/arch/sparc/sparc/cpuvar.h
+++ b/sys/arch/sparc/sparc/cpuvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpuvar.h,v 1.15 2008/10/10 08:36:28 art Exp $ */
+/* $OpenBSD: cpuvar.h,v 1.16 2008/10/15 23:23:50 deraadt Exp $ */
/* $NetBSD: cpuvar.h,v 1.4 1997/07/06 21:14:25 pk Exp $ */
/*
@@ -79,6 +79,7 @@ struct cpu_info {
struct cpu_info *ci_next;
struct schedstate_percpu ci_schedstate;
+ u_int32_t ci_randseed;
};
#define curcpu() (&cpuinfo.ci)
diff --git a/sys/arch/sparc64/include/cpu.h b/sys/arch/sparc64/include/cpu.h
index 1178403d9e2..bd1a79ffcb8 100644
--- a/sys/arch/sparc64/include/cpu.h
+++ b/sys/arch/sparc64/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.68 2008/10/10 08:05:45 art Exp $ */
+/* $OpenBSD: cpu.h,v 1.69 2008/10/15 23:23:50 deraadt Exp $ */
/* $NetBSD: cpu.h,v 1.28 2001/06/14 22:56:58 thorpej Exp $ */
/*
@@ -119,6 +119,7 @@ struct cpu_info {
int ci_itid;
#endif
int ci_node;
+ u_int32_t ci_randseed;
struct schedstate_percpu ci_schedstate; /* scheduler state */
int ci_want_resched;
diff --git a/sys/arch/sparc64/sparc64/cpu.c b/sys/arch/sparc64/sparc64/cpu.c
index adf48401b8d..3678a7fafad 100644
--- a/sys/arch/sparc64/sparc64/cpu.c
+++ b/sys/arch/sparc64/sparc64/cpu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.c,v 1.49 2008/08/17 15:55:55 kettenis Exp $ */
+/* $OpenBSD: cpu.c,v 1.50 2008/10/15 23:23:50 deraadt Exp $ */
/* $NetBSD: cpu.c,v 1.13 2001/05/26 21:27:15 chs Exp $ */
/*
@@ -701,6 +701,7 @@ cpu_boot_secondary_processors(void)
for (ci = cpus; ci != NULL; ci = ci->ci_next) {
if (ci->ci_upaid == cpu_myid())
continue;
+ ci->ci_randseed = random();
if (CPU_ISSUN4V)
cpuid = ci->ci_upaid;
diff --git a/sys/arch/vax/include/cpu.h b/sys/arch/vax/include/cpu.h
index a7af7b5a25c..68e9478ee17 100644
--- a/sys/arch/vax/include/cpu.h
+++ b/sys/arch/vax/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.32 2008/10/10 08:36:28 art Exp $ */
+/* $OpenBSD: cpu.h,v 1.33 2008/10/15 23:23:50 deraadt Exp $ */
/* $NetBSD: cpu.h,v 1.41 1999/10/21 20:01:36 ragge Exp $ */
/*
@@ -54,6 +54,7 @@ struct cpu_info {
struct proc *ci_curproc;
struct schedstate_percpu ci_schedstate; /* scheduler state */
+ u_int32_t ci_randseed;
};
extern struct cpu_info cpu_info_store;