From owner-p4-projects@FreeBSD.ORG Fri Feb 6 11:33:08 2004 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 2B05F16A4D0; Fri, 6 Feb 2004 11:33:08 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 05E0416A4CE for ; Fri, 6 Feb 2004 11:33:08 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7DEA343D4C for ; Fri, 6 Feb 2004 11:33:03 -0800 (PST) (envelope-from jhb@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.10/8.12.10) with ESMTP id i16JX30B013071 for ; Fri, 6 Feb 2004 11:33:03 -0800 (PST) (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.10/8.12.10/Submit) id i16JX25t013068 for perforce@freebsd.org; Fri, 6 Feb 2004 11:33:02 -0800 (PST) (envelope-from jhb@freebsd.org) Date: Fri, 6 Feb 2004 11:33:02 -0800 (PST) Message-Id: <200402061933.i16JX25t013068@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin To: Perforce Change Reviews Subject: PERFORCE change 46597 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Feb 2004 19:33:08 -0000 http://perforce.freebsd.org/chv.cgi?CH=46597 Change 46597 by jhb@jhb_slimer on 2004/02/06 11:32:38 Loop back limit merges. Affected files ... .. //depot/projects/smpng/sys/kern/kern_resource.c#42 integrate .. //depot/projects/smpng/sys/sys/resourcevar.h#16 integrate Differences ... ==== //depot/projects/smpng/sys/kern/kern_resource.c#42 (text+ko) ==== @@ -39,7 +39,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/kern/kern_resource.c,v 1.130 2004/02/05 20:53:24 jhb Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/kern_resource.c,v 1.132 2004/02/06 19:30:12 jhb Exp $"); #include "opt_compat.h" @@ -184,7 +184,6 @@ /* * MPSAFE */ -/* ARGSUSED */ int setpriority(td, uap) struct thread *td; @@ -267,8 +266,8 @@ /* * Set "nice" for a process. Doesn't really understand threaded processes * well but does try. Has the unfortunate side effect of making all the NICE - * values for a process's ksegrps the same.. This suggests that - * NICE valuse should be stored as a process nice and deltas for the ksegrps. + * values for a process's ksegrps the same. This suggests that + * NICE values should be stored as a process nice and deltas for the ksegrps. * (but not yet). */ static int @@ -287,7 +286,7 @@ n = PRIO_MIN; /* * Only allow nicing if to more than the lowest nice. - * E.g., for nices of 4,3,2 allow nice to 3 but not 1 + * E.g., for nices of 4,3,2 allow nice to 3 but not 1 */ FOREACH_KSEGRP_IN_PROC(p, kg) { if (kg->kg_nice < low) @@ -303,7 +302,11 @@ return (0); } -/* rtprio system call */ +/* + * Set realtime priority + * + * MPSAFE + */ #ifndef _SYS_SYSPROTO_H_ struct rtprio_args { int function; @@ -312,12 +315,6 @@ }; #endif -/* - * Set realtime priority - * - * MPSAFE - */ -/* ARGSUSED */ int rtprio(td, uap) struct thread *td; @@ -450,7 +447,6 @@ /* * MPSAFE */ -/* ARGSUSED */ int osetrlimit(td, uap) struct thread *td; @@ -477,7 +473,6 @@ /* * MPSAFE */ -/* ARGSUSED */ int ogetrlimit(td, uap) struct thread *td; @@ -494,8 +489,18 @@ PROC_LOCK(p); lim_rlimit(p, uap->which, &rl); PROC_UNLOCK(p); - olim.rlim_cur = rl.rlim_cur == -1 ? 0x7fffffff : rl.rlim_cur; - olim.rlim_max = rl.rlim_max == -1 ? 0x7fffffff : rl.rlim_max; + + /* + * XXX would be more correct to convert only RLIM_INFINITY to the + * old RLIM_INFINITY and fail with EOVERFLOW for other larger + * values. Most 64->32 and 32->16 conversions, including not + * unimportant ones of uids are even more broken than what we + * do here (they blindly truncate). We don't do this correctly + * here since we have little experience with EOVERFLOW yet. + * Elsewhere, getuid() can't fail... + */ + olim.rlim_cur = rl.rlim_cur > 0x7fffffff ? 0x7fffffff : rl.rlim_cur; + olim.rlim_max = rl.rlim_max > 0x7fffffff ? 0x7fffffff : rl.rlim_max; error = copyout(&olim, uap->rlp, sizeof(olim)); return (error); } @@ -510,7 +515,6 @@ /* * MPSAFE */ -/* ARGSUSED */ int setrlimit(td, uap) struct thread *td; @@ -659,8 +663,8 @@ struct thread *td; register struct __getrlimit_args *uap; { + struct rlimit rlim; struct proc *p; - struct rlimit rlim; int error; if (uap->which >= RLIM_NLIMITS) @@ -701,7 +705,7 @@ st = 1; tt = 1; } - if (curthread->td_proc == p) { + if (p == curthread->td_proc) { /* * Adjust for the current time slice. This is actually fairly * important since the error here is on the order of a time @@ -718,9 +722,8 @@ tu = (u_int64_t)tv.tv_sec * 1000000 + tv.tv_usec; ptu = p->p_uu + p->p_su + p->p_iu; if (tu < ptu || (int64_t)tu < 0) { - /* XXX no %qd in kernel. Truncate. */ - printf("calcru: negative time of %ld usec for pid %d (%s)\n", - (long)tu, p->p_pid, p->p_comm); + printf("calcru: negative time of %jd usec for pid %d (%s)\n", + (intmax_t)tu, p->p_pid, p->p_comm); tu = ptu; } @@ -728,7 +731,7 @@ uu = (tu * ut) / tt; su = (tu * st) / tt; iu = tu - uu - su; - + /* Enforce monotonicity. */ if (uu < p->p_uu || su < p->p_su || iu < p->p_iu) { if (uu < p->p_uu) @@ -779,35 +782,33 @@ register struct thread *td; register struct getrusage_args *uap; { - struct proc *p = td->td_proc; - register struct rusage *rup; - int error = 0; + struct rusage ru; + struct proc *p; - mtx_lock(&Giant); + p = td->td_proc; + switch (uap->who) { - switch (uap->who) { case RUSAGE_SELF: - rup = &p->p_stats->p_ru; + mtx_lock(&Giant); mtx_lock_spin(&sched_lock); - calcru(p, &rup->ru_utime, &rup->ru_stime, NULL); + calcru(p, &p->p_stats->p_ru.ru_utime, &p->p_stats->p_ru.ru_stime, + NULL); mtx_unlock_spin(&sched_lock); + ru = p->p_stats->p_ru; + mtx_unlock(&Giant); break; case RUSAGE_CHILDREN: - rup = &p->p_stats->p_cru; + mtx_lock(&Giant); + ru = p->p_stats->p_cru; + mtx_unlock(&Giant); break; default: - rup = NULL; - error = EINVAL; + return (EINVAL); break; } - mtx_unlock(&Giant); - if (error == 0) { - /* XXX Unlocked access to p_stats->p_ru or p_cru. */ - error = copyout(rup, uap->rusage, sizeof (struct rusage)); - } - return(error); + return (copyout(&ru, uap->rusage, sizeof(struct rusage))); } void @@ -1103,7 +1104,7 @@ s = splnet(); UIDINFO_LOCK(uip); new = uip->ui_sbsize + to - *hiwat; - /* don't allow them to exceed max, but allow subtraction */ + /* Don't allow them to exceed max, but allow subtraction */ if (to > *hiwat && new > max) { splx(s); UIDINFO_UNLOCK(uip); ==== //depot/projects/smpng/sys/sys/resourcevar.h#16 (text+ko) ==== @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)resourcevar.h 8.4 (Berkeley) 1/9/95 - * $FreeBSD: src/sys/sys/resourcevar.h,v 1.38 2004/02/05 20:53:25 jhb Exp $ + * $FreeBSD: src/sys/sys/resourcevar.h,v 1.39 2004/02/06 19:25:34 jhb Exp $ */ #ifndef _SYS_RESOURCEVAR_H_ @@ -106,9 +106,8 @@ #define UIDINFO_LOCK(ui) mtx_lock((ui)->ui_mtxp) #define UIDINFO_UNLOCK(ui) mtx_unlock((ui)->ui_mtxp) +struct proc; struct thread; -struct kse; -struct proc; void addupc_intr(struct thread *td, uintptr_t pc, u_int ticks); void addupc_task(struct thread *td, uintptr_t pc, u_int ticks);