diff options
author | Artur Grabowski <art@cvs.openbsd.org> | 2007-05-16 17:27:32 +0000 |
---|---|---|
committer | Artur Grabowski <art@cvs.openbsd.org> | 2007-05-16 17:27:32 +0000 |
commit | a5055ebb8629500104a3b1d3dc614f04db4f363e (patch) | |
tree | e7ea33d78c280d57703780e4a90cb563f4d674b4 /sys/kern | |
parent | 12c89e80fa52a6fdd0b959dbe94d18e61053d63e (diff) |
The world of __HAVEs and __HAVE_NOTs is reducing. All architectures
have cpu_info now, so kill the option.
eyeballed by jsg@ and grange@
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/init_main.c | 15 | ||||
-rw-r--r-- | sys/kern/kern_clock.c | 42 | ||||
-rw-r--r-- | sys/kern/kern_fork.c | 4 | ||||
-rw-r--r-- | sys/kern/kern_ktrace.c | 6 | ||||
-rw-r--r-- | sys/kern/kern_subr.c | 6 | ||||
-rw-r--r-- | sys/kern/kern_synch.c | 10 | ||||
-rw-r--r-- | sys/kern/kern_sysctl.c | 15 | ||||
-rw-r--r-- | sys/kern/sched_bsd.c | 79 |
8 files changed, 18 insertions, 159 deletions
diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index a8cf415a9df..46f9faf3ade 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init_main.c,v 1.139 2007/04/12 22:14:15 tedu Exp $ */ +/* $OpenBSD: init_main.c,v 1.140 2007/05/16 17:27:30 art Exp $ */ /* $NetBSD: init_main.c,v 1.84.4.1 1996/06/02 09:08:06 mrg Exp $ */ /* @@ -113,9 +113,6 @@ struct pcred cred0; struct plimit limit0; struct vmspace vmspace0; struct sigacts sigacts0; -#if !defined(__HAVE_CPUINFO) && !defined(curproc) -struct proc *curproc; -#endif struct proc *initproc; int cmask = CMASK; @@ -125,9 +122,6 @@ void (*md_diskconf)(void) = NULL; struct vnode *rootvp, *swapdev_vp; int boothowto; struct timeval boottime; -#ifndef __HAVE_CPUINFO -struct timeval runtime; -#endif int ncpus = 1; __volatile int start_init_exec; /* semaphore for start_init() */ @@ -199,9 +193,7 @@ main(void *framep) * any possible traps/probes to simplify trap processing. */ curproc = p = &proc0; -#ifdef __HAVE_CPUINFO p->p_cpu = curcpu(); -#endif /* * Initialize timeouts. @@ -484,14 +476,9 @@ main(void *framep) #else boottime = mono_time = time; #endif -#ifndef __HAVE_CPUINFO - microuptime(&runtime); -#endif LIST_FOREACH(p, &allproc, p_list) { p->p_stats->p_start = boottime; -#ifdef __HAVE_CPUINFO microuptime(&p->p_cpu->ci_schedstate.spc_runtime); -#endif p->p_rtime.tv_sec = p->p_rtime.tv_usec = 0; } diff --git a/sys/kern/kern_clock.c b/sys/kern/kern_clock.c index fa1ed4d7450..f4e18101952 100644 --- a/sys/kern/kern_clock.c +++ b/sys/kern/kern_clock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_clock.c,v 1.63 2007/04/17 17:57:32 miod Exp $ */ +/* $OpenBSD: kern_clock.c,v 1.64 2007/05/16 17:27:30 art Exp $ */ /* $NetBSD: kern_clock.c,v 1.34 1996/06/09 04:51:03 briggs Exp $ */ /*- @@ -226,9 +226,7 @@ hardclock(struct clockframe *frame) extern int64_t ntp_tick_permanent; extern int64_t ntp_tick_acc; #endif -#ifdef __HAVE_CPUINFO struct cpu_info *ci = curcpu(); -#endif p = curproc; if (p && ((p->p_flag & (P_SYSTEM | P_WEXIT)) == 0)) { @@ -253,7 +251,6 @@ hardclock(struct clockframe *frame) if (stathz == 0) statclock(frame); -#if defined(__HAVE_CPUINFO) if (--ci->ci_schedstate.spc_rrticks <= 0) roundrobin(ci); @@ -263,7 +260,6 @@ hardclock(struct clockframe *frame) */ if (CPU_IS_PRIMARY(ci) == 0) return; -#endif #ifndef __HAVE_TIMECOUNTER /* @@ -482,15 +478,10 @@ statclock(struct clockframe *frame) struct gmonparam *g; int i; #endif -#ifdef __HAVE_CPUINFO struct cpu_info *ci = curcpu(); struct schedstate_percpu *spc = &ci->ci_schedstate; -#else - static int schedclk; -#endif struct proc *p = curproc; -#ifdef __HAVE_CPUINFO /* * Notice changes in divisor frequency, and adjust clock * frequency accordingly. @@ -505,15 +496,10 @@ statclock(struct clockframe *frame) } } -/* XXX Kludgey */ -#define pscnt spc->spc_pscnt -#define cp_time spc->spc_cp_time -#endif - if (CLKF_USERMODE(frame)) { if (p->p_flag & P_PROFIL) addupc_intr(p, CLKF_PC(frame)); - if (--pscnt > 0) + if (--spc->spc_pscnt > 0) return; /* * Came from user mode; CPU was in user state. @@ -521,9 +507,9 @@ statclock(struct clockframe *frame) */ p->p_uticks++; if (p->p_nice > NZERO) - cp_time[CP_NICE]++; + spc->spc_cp_time[CP_NICE]++; else - cp_time[CP_USER]++; + spc->spc_cp_time[CP_USER]++; } else { #ifdef GPROF /* @@ -542,7 +528,7 @@ statclock(struct clockframe *frame) if (p != NULL && p->p_flag & P_PROFIL) addupc_intr(p, PROC_PC(p)); #endif - if (--pscnt > 0) + if (--spc->spc_pscnt > 0) return; /* * Came from kernel mode, so we were: @@ -559,19 +545,14 @@ statclock(struct clockframe *frame) if (CLKF_INTR(frame)) { if (p != NULL) p->p_iticks++; - cp_time[CP_INTR]++; + spc->spc_cp_time[CP_INTR]++; } else if (p != NULL) { p->p_sticks++; - cp_time[CP_SYS]++; + spc->spc_cp_time[CP_SYS]++; } else - cp_time[CP_IDLE]++; + spc->spc_cp_time[CP_IDLE]++; } - pscnt = psdiv; - -#ifdef __HAVE_CPUINFO -#undef pscnt -#undef cp_time -#endif + spc->spc_pscnt = psdiv; if (p != NULL) { p->p_cpticks++; @@ -580,14 +561,9 @@ statclock(struct clockframe *frame) * ~~16 Hz is best */ if (schedhz == 0) { -#ifdef __HAVE_CPUINFO if ((++curcpu()->ci_schedstate.spc_schedticks & 3) == 0) schedclock(p); -#else - if ((++schedclk & 3) == 0) - schedclock(p); -#endif } } } diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index 71941682d39..d4eb5fcc449 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_fork.c,v 1.90 2007/04/12 22:14:15 tedu Exp $ */ +/* $OpenBSD: kern_fork.c,v 1.91 2007/05/16 17:27:30 art Exp $ */ /* $NetBSD: kern_fork.c,v 1.29 1996/02/09 18:59:34 christos Exp $ */ /* @@ -254,9 +254,7 @@ fork1(struct proc *p1, int exitsig, int flags, void *stack, size_t stacksize, timeout_set(&p2->p_sleep_to, endtsleep, p2); timeout_set(&p2->p_realit_to, realitexpire, p2); -#if defined(__HAVE_CPUINFO) p2->p_cpu = p1->p_cpu; -#endif /* * Duplicate sub-structures as needed. diff --git a/sys/kern/kern_ktrace.c b/sys/kern/kern_ktrace.c index c65b8b78458..ce85d215862 100644 --- a/sys/kern/kern_ktrace.c +++ b/sys/kern/kern_ktrace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_ktrace.c,v 1.41 2006/11/14 09:16:55 deraadt Exp $ */ +/* $OpenBSD: kern_ktrace.c,v 1.42 2007/05/16 17:27:30 art Exp $ */ /* $NetBSD: kern_ktrace.c,v 1.23 1996/02/09 18:59:36 christos Exp $ */ /* @@ -207,11 +207,7 @@ ktrgenio(struct proc *p, int fd, enum uio_rw rw, struct iovec *iov, int len, * Don't allow this process to hog the cpu when doing * huge I/O. */ -#ifdef __HAVE_CPUINFO if (curcpu()->ci_schedstate.spc_schedflags & SPCF_SHOULDYIELD) -#else - if (p->p_schedflags & PSCHED_SHOULDYIELD) -#endif preempt(NULL); count = min(iov->iov_len, buflen); diff --git a/sys/kern/kern_subr.c b/sys/kern/kern_subr.c index 4835da16ec8..023a5867f25 100644 --- a/sys/kern/kern_subr.c +++ b/sys/kern/kern_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_subr.c,v 1.30 2005/11/28 00:14:29 jsg Exp $ */ +/* $OpenBSD: kern_subr.c,v 1.31 2007/05/16 17:27:30 art Exp $ */ /* $NetBSD: kern_subr.c,v 1.15 1996/04/09 17:21:56 ragge Exp $ */ /* @@ -75,12 +75,8 @@ uiomove(void *cp, int n, struct uio *uio) switch (uio->uio_segflg) { case UIO_USERSPACE: -#ifdef __HAVE_CPUINFO if (curcpu()->ci_schedstate.spc_schedflags & SPCF_SHOULDYIELD) -#else - if (p->p_schedflags & PSCHED_SHOULDYIELD) -#endif preempt(NULL); if (uio->uio_rw == UIO_READ) error = copyout(cp, iov->iov_base, cnt); diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c index 5acff3ccad8..849dffefc57 100644 --- a/sys/kern/kern_synch.c +++ b/sys/kern/kern_synch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_synch.c,v 1.79 2007/04/03 08:05:43 art Exp $ */ +/* $OpenBSD: kern_synch.c,v 1.80 2007/05/16 17:27:30 art Exp $ */ /* $NetBSD: kern_synch.c,v 1.37 1996/04/22 01:38:37 christos Exp $ */ /* @@ -185,11 +185,7 @@ sleep_finish(struct sleep_state *sls, int do_sleep) #endif } -#ifdef __HAVE_CPUINFO p->p_cpu->ci_schedstate.spc_curpriority = p->p_usrpri; -#else - curpriority = p->p_usrpri; -#endif SCHED_UNLOCK(sls->sls_s); /* @@ -357,12 +353,8 @@ restart: * resched_proc(). */ setrunqueue(p); -#ifdef __HAVE_CPUINFO KASSERT(p->p_cpu != NULL); need_resched(p->p_cpu); -#else - need_resched(NULL); -#endif /* END INLINE EXPANSION */ if (n != 0) diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index 2c7f0459039..6cf0c7fc2fa 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sysctl.c,v 1.151 2007/04/18 16:57:06 art Exp $ */ +/* $OpenBSD: kern_sysctl.c,v 1.152 2007/05/16 17:27:30 art Exp $ */ /* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */ /*- @@ -433,7 +433,6 @@ kern_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, return (sysctl_malloc(name + 1, namelen - 1, oldp, oldlenp, newp, newlen, p)); case KERN_CPTIME: -#ifdef __HAVE_CPUINFO { CPU_INFO_ITERATOR cii; struct cpu_info *ci; @@ -445,10 +444,10 @@ kern_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, for (i = 0; i < CPUSTATES; i++) cp_time[i] += ci->ci_schedstate.spc_cp_time[i]; } - } -#endif + return (sysctl_rdstruct(oldp, oldlenp, newp, &cp_time, sizeof(cp_time))); + } case KERN_NCHSTATS: return (sysctl_rdstruct(oldp, oldlenp, newp, &nchstats, sizeof(struct nchstats))); @@ -533,11 +532,9 @@ kern_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, #endif case KERN_MAXLOCKSPERUID: return (sysctl_int(oldp, oldlenp, newp, newlen, &maxlocksperuid)); -#ifdef __HAVE_CPUINFO case KERN_CPTIME2: return (sysctl_cptime2(name + 1, namelen -1, oldp, oldlenp, newp, newlen)); -#endif default: return (EOPNOTSUPP); } @@ -1290,11 +1287,7 @@ fill_kproc2(struct proc *p, struct kinfo_proc2 *ki) ki->p_stat = p->p_stat; ki->p_swtime = p->p_swtime; ki->p_slptime = p->p_slptime; -#ifdef __HAVE_CPUINFO ki->p_schedflags = 0; -#else - ki->p_schedflags = p->p_schedflags; -#endif ki->p_holdcnt = 1; ki->p_priority = p->p_priority; ki->p_usrpri = p->p_usrpri; @@ -1873,7 +1866,6 @@ sysctl_emul(int *name, u_int namelen, void *oldp, size_t *oldlenp, #endif /* SMALL_KERNEL */ -#ifdef __HAVE_CPUINFO int sysctl_cptime2(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, size_t newlen) @@ -1898,4 +1890,3 @@ sysctl_cptime2(int *name, u_int namelen, void *oldp, size_t *oldlenp, &ci->ci_schedstate.spc_cp_time, sizeof(ci->ci_schedstate.spc_cp_time))); } -#endif diff --git a/sys/kern/sched_bsd.c b/sys/kern/sched_bsd.c index 699f4dd807a..186be456346 100644 --- a/sys/kern/sched_bsd.c +++ b/sys/kern/sched_bsd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sched_bsd.c,v 1.10 2007/02/06 18:42:37 art Exp $ */ +/* $OpenBSD: sched_bsd.c,v 1.11 2007/05/16 17:27:30 art Exp $ */ /* $NetBSD: kern_synch.c,v 1.37 1996/04/22 01:38:37 christos Exp $ */ /*- @@ -54,13 +54,8 @@ #include <machine/cpu.h> -#ifndef __HAVE_CPUINFO -u_char curpriority; /* usrpri of curproc */ -#endif int lbolt; /* once a second sleep address */ -#ifdef __HAVE_CPUINFO int rrticks_init; /* # of hardclock ticks per roundrobin() */ -#endif int whichqs; /* Bit mask summary of non-empty Q's. */ struct prochd qs[NQS]; @@ -69,11 +64,7 @@ struct SIMPLELOCK sched_lock; void scheduler_start(void); -#ifdef __HAVE_CPUINFO void roundrobin(struct cpu_info *); -#else -void roundrobin(void *); -#endif void schedcpu(void *); void updatepri(struct proc *); void endtsleep(void *); @@ -81,9 +72,6 @@ void endtsleep(void *); void scheduler_start(void) { -#ifndef __HAVE_CPUINFO - static struct timeout roundrobin_to; -#endif static struct timeout schedcpu_to; /* @@ -93,16 +81,9 @@ scheduler_start(void) * make them do their job. */ -#ifndef __HAVE_CPUINFO - timeout_set(&roundrobin_to, roundrobin, &roundrobin_to); -#endif timeout_set(&schedcpu_to, schedcpu, &schedcpu_to); -#ifdef __HAVE_CPUINFO rrticks_init = hz / 10; -#else - roundrobin(&roundrobin_to); -#endif schedcpu(&schedcpu_to); } @@ -110,7 +91,6 @@ scheduler_start(void) * Force switch among equal priority processes every 100ms. */ /* ARGSUSED */ -#ifdef __HAVE_CPUINFO void roundrobin(struct cpu_info *ci) { @@ -136,33 +116,6 @@ roundrobin(struct cpu_info *ci) need_resched(curcpu()); } -#else -void -roundrobin(void *arg) -{ - struct timeout *to = (struct timeout *)arg; - struct proc *p = curproc; - int s; - - if (p != NULL) { - s = splstatclock(); - if (p->p_schedflags & PSCHED_SEENRR) { - /* - * The process has already been through a roundrobin - * without switching and may be hogging the CPU. - * Indicate that the process should yield. - */ - p->p_schedflags |= PSCHED_SHOULDYIELD; - } else { - p->p_schedflags |= PSCHED_SEENRR; - } - splx(s); - } - - need_resched(NULL); - timeout_add(to, hz / 10); -} -#endif /* * Constants for digital decay and forget: @@ -422,9 +375,7 @@ mi_switch(void) int hold_count; int sched_count; #endif -#ifdef __HAVE_CPUINFO struct schedstate_percpu *spc = &p->p_cpu->ci_schedstate; -#endif SCHED_ASSERT_LOCKED(); @@ -445,7 +396,6 @@ mi_switch(void) * XXX - use microuptime here to avoid strangeness. */ microuptime(&tv); -#ifdef __HAVE_CPUINFO if (timercmp(&tv, &spc->spc_runtime, <)) { #if 0 printf("uptime is not monotonic! " @@ -457,18 +407,6 @@ mi_switch(void) timersub(&tv, &spc->spc_runtime, &tv); timeradd(&p->p_rtime, &tv, &p->p_rtime); } -#else - if (timercmp(&tv, &runtime, <)) { -#if 0 - printf("uptime is not monotonic! " - "tv=%lu.%06lu, runtime=%lu.%06lu\n", - tv.tv_sec, tv.tv_usec, runtime.tv_sec, runtime.tv_usec); -#endif - } else { - timersub(&tv, &runtime, &tv); - timeradd(&p->p_rtime, &tv, &p->p_rtime); - } -#endif /* * Check if the process exceeds its cpu resource allocation. @@ -489,11 +427,7 @@ mi_switch(void) * Process is about to yield the CPU; clear the appropriate * scheduling flags. */ -#ifdef __HAVE_CPUINFO spc->spc_schedflags &= ~SPCF_SWITCHCLEAR; -#else - p->p_schedflags &= ~PSCHED_SWITCHCLEAR; -#endif /* * Pick a new current process and record its start time. @@ -512,13 +446,9 @@ mi_switch(void) * be running on a new CPU now, so don't use the cache'd * schedstate_percpu pointer. */ -#ifdef __HAVE_CPUINFO KDASSERT(p->p_cpu != NULL); KDASSERT(p->p_cpu == curcpu()); microuptime(&p->p_cpu->ci_schedstate.spc_runtime); -#else - microuptime(&runtime); -#endif #if defined(MULTIPROCESSOR) /* @@ -549,9 +479,7 @@ rqinit(void) static __inline void resched_proc(struct proc *p, u_char pri) { -#ifdef __HAVE_CPUINFO struct cpu_info *ci; -#endif /* * XXXSMP @@ -575,14 +503,9 @@ resched_proc(struct proc *p, u_char pri) * There is also the issue of locking the other CPU's * sched state, which we currently do not do. */ -#ifdef __HAVE_CPUINFO ci = (p->p_cpu != NULL) ? p->p_cpu : curcpu(); if (pri < ci->ci_schedstate.spc_curpriority) need_resched(ci); -#else - if (pri < curpriority) - need_resched(NULL); -#endif } /* |