diff options
-rw-r--r-- | sys/kern/init_main.c | 4 | ||||
-rw-r--r-- | sys/kern/kern_clock.c | 4 | ||||
-rw-r--r-- | sys/kern/kern_proc.c | 4 | ||||
-rw-r--r-- | sys/kern/kern_resource.c | 26 | ||||
-rw-r--r-- | sys/kern/kern_sig.c | 6 | ||||
-rw-r--r-- | sys/kern/sched_bsd.c | 5 | ||||
-rw-r--r-- | sys/sys/proc.h | 6 | ||||
-rw-r--r-- | sys/sys/sysctl.h | 6 |
8 files changed, 29 insertions, 32 deletions
diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index fc78df2c2a3..84dc1943c12 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init_main.c,v 1.174 2011/01/08 19:45:09 deraadt Exp $ */ +/* $OpenBSD: init_main.c,v 1.175 2011/03/07 07:07:13 guenther Exp $ */ /* $NetBSD: init_main.c,v 1.84.4.1 1996/06/02 09:08:06 mrg Exp $ */ /* @@ -285,7 +285,7 @@ main(void *framep) atomic_setbits_int(&p->p_flag, P_SYSTEM | P_NOCLDWAIT); p->p_stat = SONPROC; - p->p_nice = NZERO; + pr->ps_nice = NZERO; p->p_emul = &emul_native; bcopy("swapper", p->p_comm, sizeof ("swapper")); diff --git a/sys/kern/kern_clock.c b/sys/kern/kern_clock.c index 7a7911fbe40..7e85444d988 100644 --- a/sys/kern/kern_clock.c +++ b/sys/kern/kern_clock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_clock.c,v 1.71 2010/08/20 22:03:22 matthew Exp $ */ +/* $OpenBSD: kern_clock.c,v 1.72 2011/03/07 07:07:13 guenther Exp $ */ /* $NetBSD: kern_clock.c,v 1.34 1996/06/09 04:51:03 briggs Exp $ */ /*- @@ -491,7 +491,7 @@ statclock(struct clockframe *frame) * If this process is being profiled record the tick. */ p->p_uticks++; - if (p->p_nice > NZERO) + if (p->p_p->ps_nice > NZERO) spc->spc_cp_time[CP_NICE]++; else spc->spc_cp_time[CP_USER]++; diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c index d609994c930..26237725956 100644 --- a/sys/kern/kern_proc.c +++ b/sys/kern/kern_proc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_proc.c,v 1.45 2010/07/26 01:56:27 guenther Exp $ */ +/* $OpenBSD: kern_proc.c,v 1.46 2011/03/07 07:07:13 guenther Exp $ */ /* $NetBSD: kern_proc.c,v 1.14 1996/02/09 18:59:41 christos Exp $ */ /* @@ -397,7 +397,7 @@ proc_printit(struct proc *p, const char *modif, int (*pr)(const char *, ...)) (*pr)("PROC (%s) pid=%d stat=%s flags=%b\n", p->p_comm, p->p_pid, pst, p->p_flag, P_BITS); (*pr)(" pri=%u, usrpri=%u, nice=%d\n", - p->p_priority, p->p_usrpri, p->p_nice); + p->p_priority, p->p_usrpri, p->p_p->ps_nice); (*pr)(" forw=%p, list=%p,%p\n", TAILQ_NEXT(p, p_runq), p->p_list.le_next, p->p_list.le_prev); (*pr)(" process=%p user=%p, vmspace=%p\n", diff --git a/sys/kern/kern_resource.c b/sys/kern/kern_resource.c index 76a078d9e03..15d66f5555b 100644 --- a/sys/kern/kern_resource.c +++ b/sys/kern/kern_resource.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_resource.c,v 1.36 2010/07/26 01:56:27 guenther Exp $ */ +/* $OpenBSD: kern_resource.c,v 1.37 2011/03/07 07:07:13 guenther Exp $ */ /* $NetBSD: kern_resource.c,v 1.38 1996/10/23 07:19:38 matthias Exp $ */ /*- @@ -81,10 +81,8 @@ sys_getpriority(struct proc *curp, void *v, register_t *retval) pr = prfind(SCARG(uap, who)); if (pr == NULL) break; - TAILQ_FOREACH(p, &pr->ps_threads, p_thr_link) { - if (p->p_nice < low) - low = p->p_nice; - } + if (pr->ps_nice < low) + low = pr->ps_nice; break; case PRIO_PGRP: { @@ -95,10 +93,8 @@ sys_getpriority(struct proc *curp, void *v, register_t *retval) else if ((pg = pgfind(SCARG(uap, who))) == NULL) break; LIST_FOREACH(pr, &pg->pg_members, ps_pglist) - TAILQ_FOREACH(p, &pr->ps_threads, p_thr_link) { - if (p->p_nice < low) - low = p->p_nice; - } + if (pr->ps_nice < low) + low = pr->ps_nice; break; } @@ -106,9 +102,10 @@ sys_getpriority(struct proc *curp, void *v, register_t *retval) if (SCARG(uap, who) == 0) SCARG(uap, who) = curp->p_ucred->cr_uid; LIST_FOREACH(p, &allproc, p_list) - if (p->p_ucred->cr_uid == SCARG(uap, who) && - p->p_nice < low) - low = p->p_nice; + if ((p->p_flag & P_THREAD) == 0 && + p->p_ucred->cr_uid == SCARG(uap, who) && + p->p_p->ps_nice < low) + low = p->p_p->ps_nice; break; default: @@ -196,10 +193,9 @@ donice(struct proc *curp, struct process *chgpr, int n) if (n < PRIO_MIN) n = PRIO_MIN; n += NZERO; - /* XXX wrong: p_nice should be in process */ - if (n < chgpr->ps_mainproc->p_nice && suser(curp, 0)) + if (n < chgpr->ps_nice && suser(curp, 0)) return (EACCES); - chgpr->ps_mainproc->p_nice = n; + chgpr->ps_nice = n; SCHED_LOCK(s); TAILQ_FOREACH(p, &chgpr->ps_threads, p_thr_link) (void)resetpriority(p); diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index a672064a4d1..3d900be04b4 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sig.c,v 1.116 2010/07/26 01:56:27 guenther Exp $ */ +/* $OpenBSD: kern_sig.c,v 1.117 2011/03/07 07:07:13 guenther Exp $ */ /* $NetBSD: kern_sig.c,v 1.54 1996/04/22 01:38:32 christos Exp $ */ /* @@ -858,8 +858,8 @@ ptsignal(struct proc *p, int signum, enum signal_type type) else { action = SIG_DFL; - if (prop & SA_KILL && p->p_nice > NZERO) - p->p_nice = NZERO; + if (prop & SA_KILL && p->p_p->ps_nice > NZERO) + p->p_p->ps_nice = NZERO; /* * If sending a tty stop signal to a member of an diff --git a/sys/kern/sched_bsd.c b/sys/kern/sched_bsd.c index c67171203ab..9290d0105c8 100644 --- a/sys/kern/sched_bsd.c +++ b/sys/kern/sched_bsd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sched_bsd.c,v 1.24 2010/09/24 13:21:30 matthew Exp $ */ +/* $OpenBSD: sched_bsd.c,v 1.25 2011/03/07 07:07:13 guenther Exp $ */ /* $NetBSD: kern_synch.c,v 1.37 1996/04/22 01:38:37 christos Exp $ */ /*- @@ -537,7 +537,8 @@ resetpriority(struct proc *p) SCHED_ASSERT_LOCKED(); - newpriority = PUSER + p->p_estcpu + NICE_WEIGHT * (p->p_nice - NZERO); + newpriority = PUSER + p->p_estcpu + + NICE_WEIGHT * (p->p_p->ps_nice - NZERO); newpriority = min(newpriority, MAXPRI); p->p_usrpri = newpriority; resched_proc(p, p->p_usrpri); diff --git a/sys/sys/proc.h b/sys/sys/proc.h index b04820ec06e..4c5b8fb4164 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.h,v 1.132 2010/07/26 01:56:27 guenther Exp $ */ +/* $OpenBSD: proc.h,v 1.133 2011/03/07 07:07:13 guenther Exp $ */ /* $NetBSD: proc.h,v 1.44 1996/04/22 01:23:21 christos Exp $ */ /*- @@ -164,6 +164,7 @@ struct process { struct plimit *ps_limit; /* Process limits. */ struct pgrp *ps_pgrp; /* Pointer to process group. */ u_int ps_rtableid; /* Process routing table/domain. */ + char ps_nice; /* Process "nice" value. */ /* End area that is copied on creation. */ #define ps_endcopy ps_refcnt @@ -282,8 +283,7 @@ struct proc { sigset_t p_sigcatch; /* Signals being caught by user. */ u_char p_priority; /* Process priority. */ - u_char p_usrpri; /* User-priority based on p_cpu and p_nice. */ - char p_nice; /* Process "nice" value. */ + u_char p_usrpri; /* User-priority based on p_cpu and ps_nice. */ char p_comm[MAXCOMLEN+1]; struct emul *p_emul; /* Emulation information */ diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h index c3852f7f3b0..f73a1cb5647 100644 --- a/sys/sys/sysctl.h +++ b/sys/sys/sysctl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sysctl.h,v 1.107 2010/11/02 09:36:09 dlg Exp $ */ +/* $OpenBSD: sysctl.h,v 1.108 2011/03/07 07:07:13 guenther Exp $ */ /* $NetBSD: sysctl.h,v 1.16 1996/04/09 20:55:36 cgd Exp $ */ /* @@ -421,7 +421,7 @@ struct kinfo_proc2 { int8_t p_stat; /* CHAR: S* process status (from LWP). */ u_int8_t p_priority; /* U_CHAR: Process priority. */ - u_int8_t p_usrpri; /* U_CHAR: User-priority based on p_cpu and p_nice. */ + u_int8_t p_usrpri; /* U_CHAR: User-priority based on p_cpu and ps_nice. */ u_int8_t p_nice; /* U_CHAR: Process "nice" value. */ u_int16_t p_xstat; /* U_SHORT: Exit status for wait; also stop signal. */ @@ -554,7 +554,7 @@ do { \ (kp)->p_sigcatch = (p)->p_sigcatch; \ \ (kp)->p_stat = (p)->p_stat; \ - (kp)->p_nice = (p)->p_nice; \ + (kp)->p_nice = (pr)->ps_nice; \ \ (kp)->p_xstat = (p)->p_xstat; \ (kp)->p_acflag = (p)->p_acflag; \ |