PERFORCE change 46597 for review
John Baldwin
jhb at FreeBSD.org
Fri Feb 6 11:33:08 PST 2004
http://perforce.freebsd.org/chv.cgi?CH=46597
Change 46597 by jhb at 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 <sys/cdefs.h>
-__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);
More information about the p4-projects
mailing list