diff options
author | Artur Grabowski <art@cvs.openbsd.org> | 2004-06-20 06:47:32 +0000 |
---|---|---|
committer | Artur Grabowski <art@cvs.openbsd.org> | 2004-06-20 06:47:32 +0000 |
commit | bd9a9fb90879b3935ff21f0d13dd776954abe71c (patch) | |
tree | cc2059f03516f25be4cc7b6dfac6ae333c3015aa /sys | |
parent | 107ab1c86e995332dbaf688211ff37c5f4a12740 (diff) |
Move schedstate_percpu into sched.h so that we don't have to include
proc.h in cpu.h on __HAVE_CPU_INFO architectures. cpu.h is usually included
in param.h.
This also removes the horrible kludge with ifdef SYS_PROC_H in sched.h
by simply converting the inline functions into macros.
With a few suggestions from nordin@
deraadt@ ok
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/i386/include/cpu.h | 4 | ||||
-rw-r--r-- | sys/arch/sparc64/include/cpu.h | 4 | ||||
-rw-r--r-- | sys/sys/proc.h | 41 | ||||
-rw-r--r-- | sys/sys/sched.h | 63 |
4 files changed, 45 insertions, 67 deletions
diff --git a/sys/arch/i386/include/cpu.h b/sys/arch/i386/include/cpu.h index 9d66a9c496c..47dbd06e31e 100644 --- a/sys/arch/i386/include/cpu.h +++ b/sys/arch/i386/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.61 2004/06/13 21:49:16 niklas Exp $ */ +/* $OpenBSD: cpu.h,v 1.62 2004/06/20 06:47:31 art Exp $ */ /* $NetBSD: cpu.h,v 1.35 1996/05/05 19:29:26 christos Exp $ */ /*- @@ -72,7 +72,7 @@ #include <sys/device.h> #include <sys/lock.h> /* will also get LOCKDEBUG */ -#include <sys/proc.h> +#include <sys/sched.h> struct intrsource; diff --git a/sys/arch/sparc64/include/cpu.h b/sys/arch/sparc64/include/cpu.h index 278f7a3031b..4d408ab68cd 100644 --- a/sys/arch/sparc64/include/cpu.h +++ b/sys/arch/sparc64/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.25 2004/06/13 21:49:20 niklas Exp $ */ +/* $OpenBSD: cpu.h,v 1.26 2004/06/20 06:47:31 art Exp $ */ /* $NetBSD: cpu.h,v 1.28 2001/06/14 22:56:58 thorpej Exp $ */ /* @@ -75,7 +75,7 @@ #include <machine/reg.h> #include <machine/intr.h> -#include <sys/proc.h> +#include <sys/sched.h> /* * The cpu_info structure is part of a 64KB structure mapped both the kernel diff --git a/sys/sys/proc.h b/sys/sys/proc.h index 9f64ed24839..cf3801057e4 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.h,v 1.71 2004/06/13 21:49:28 niklas Exp $ */ +/* $OpenBSD: proc.h,v 1.72 2004/06/20 06:47:31 art Exp $ */ /* $NetBSD: proc.h,v 1.44 1996/04/22 01:23:21 christos Exp $ */ /*- @@ -46,46 +46,7 @@ #include <sys/timeout.h> /* For struct timeout. */ #include <sys/event.h> /* For struct klist */ -/* - * CPU states. - * XXX Not really scheduler state, but no other good place to put - * it right now, and it really is per-CPU. - */ -#define CP_USER 0 -#define CP_NICE 1 -#define CP_SYS 2 -#define CP_INTR 3 -#define CP_IDLE 4 -#define CPUSTATES 5 - -/* - * Per-CPU scheduler state. - */ -struct schedstate_percpu { - struct timeval spc_runtime; /* time curproc started running */ - __volatile int spc_schedflags; /* flags; see below */ - u_int spc_schedticks; /* ticks for schedclock() */ - u_int64_t spc_cp_time[CPUSTATES]; /* CPU state statistics */ - u_char spc_curpriority; /* usrpri of curproc */ - int spc_rrticks; /* ticks until roundrobin() */ - int spc_pscnt; /* prof/stat counter */ - int spc_psdiv; /* prof/stat divisor */ -}; - -/* spc_flags */ -#define SPCF_SEENRR 0x0001 /* process has seen roundrobin() */ -#define SPCF_SHOULDYIELD 0x0002 /* process should yield the CPU */ -#define SPCF_SWITCHCLEAR (SPCF_SEENRR|SPCF_SHOULDYIELD) - #ifdef __HAVE_CPUINFO -/* - * These are the fields we require in struct cpu_info that we get from - * curcpu(): - * - * struct proc *ci_curproc; - * struct schedstate_percpu ci_schedstate; - * cpuid_t ci_cpuid; - */ #define curproc curcpu()->ci_curproc #endif diff --git a/sys/sys/sched.h b/sys/sys/sched.h index 50625e84149..badaf18396f 100644 --- a/sys/sys/sched.h +++ b/sys/sys/sched.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sched.h,v 1.6 2004/06/13 21:49:28 niklas Exp $ */ +/* $OpenBSD: sched.h,v 1.7 2004/06/20 06:47:31 art Exp $ */ /* $NetBSD: sched.h,v 1.2 1999/02/28 18:14:58 ross Exp $ */ /*- @@ -80,8 +80,39 @@ * Posix defines a <sched.h> which may want to include <sys/sched.h> */ +/* + * CPU states. + * XXX Not really scheduler state, but no other good place to put + * it right now, and it really is per-CPU. + */ +#define CP_USER 0 +#define CP_NICE 1 +#define CP_SYS 2 +#define CP_INTR 3 +#define CP_IDLE 4 +#define CPUSTATES 5 + #ifdef _KERNEL +/* + * Per-CPU scheduler state. + */ +struct schedstate_percpu { + struct timeval spc_runtime; /* time curproc started running */ + __volatile int spc_schedflags; /* flags; see below */ + u_int spc_schedticks; /* ticks for schedclock() */ + u_int64_t spc_cp_time[CPUSTATES]; /* CPU state statistics */ + u_char spc_curpriority; /* usrpri of curproc */ + int spc_rrticks; /* ticks until roundrobin() */ + int spc_pscnt; /* prof/stat counter */ + int spc_psdiv; /* prof/stat divisor */ +}; + +/* spc_flags */ +#define SPCF_SEENRR 0x0001 /* process has seen roundrobin() */ +#define SPCF_SHOULDYIELD 0x0002 /* process should yield the CPU */ +#define SPCF_SWITCHCLEAR (SPCF_SEENRR|SPCF_SHOULDYIELD) + #define PPQ (128 / NQS) /* priorities per queue */ #define NICE_WEIGHT 2 /* priorities per nice level */ #define ESTCPULIM(e) min((e), NICE_WEIGHT * PRIO_MAX - PPQ) @@ -89,36 +120,22 @@ extern int schedhz; /* ideally: 16 */ extern int rrticks_init; /* ticks per roundrobin() */ -#ifdef _SYS_PROC_H_ +struct proc; void schedclock(struct proc *); #ifdef __HAVE_CPUINFO +struct cpu_info; void roundrobin(struct cpu_info *); #endif -static __inline void scheduler_fork_hook( - struct proc *parent, struct proc *child); -static __inline void scheduler_wait_hook( - struct proc *parent, struct proc *child); /* Inherit the parent's scheduler history */ - -static __inline void -scheduler_fork_hook(parent, child) - struct proc *parent, *child; -{ - child->p_estcpu = parent->p_estcpu; -} +#define scheduler_fork_hook(parent, child) do { \ + (child)->p_estcpu = (parent)->p_estcpu; \ +} while (0) /* Chargeback parents for the sins of their children. */ - -static __inline void -scheduler_wait_hook(parent, child) - struct proc *parent, *child; -{ - /* XXX just return if parent == init?? */ - - parent->p_estcpu = ESTCPULIM(parent->p_estcpu + child->p_estcpu); -} -#endif /* _SYS_PROC_H_ */ +#define scheduler_wait_hook(parent, child) do { \ + (parent)->p_estcpu = ESTCPULIM((parent)->p_estcpu + (child)->p_estcpu);\ +} while (0) #ifndef splsched #define splsched() splhigh() |