Tweak to earlier fix to p_estcpu:

- no longer conditionalized
	- when traced, charge time to real parent, not debugger
	- make it clear for future rototillers that p_estcpu should be moved
	  to the "copy" region of struct proc.
This commit is contained in:
sommerfe 1999-01-23 22:23:19 +00:00
parent 83940dae72
commit 31a1ef68c7
3 changed files with 16 additions and 18 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_exit.c,v 1.62 1999/01/23 08:25:36 ross Exp $ */
/* $NetBSD: kern_exit.c,v 1.63 1999/01/23 22:23:19 sommerfe Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -389,8 +389,6 @@ reaper()
}
}
int chargeparent = 1;
int
sys_wait4(q, v, retval)
register struct proc *q;
@ -436,10 +434,6 @@ loop:
(caddr_t)SCARG(uap, rusage),
sizeof(struct rusage))))
return (error);
/* Charge fork-bomb parents for children's sins */
if (chargeparent)
curproc->p_estcpu = min(curproc->p_estcpu +
p->p_estcpu, UCHAR_MAX);
/*
* If we got the child via ptrace(2) or procfs, and
* the parent is different (meaning the process was
@ -458,6 +452,11 @@ loop:
wakeup((caddr_t)p->p_pptr);
return (0);
}
/* Charge us for our child's sins */
curproc->p_estcpu = min(curproc->p_estcpu +
p->p_estcpu, UCHAR_MAX);
p->p_xstat = 0;
ruadd(&q->p_stats->p_cru, p->p_ru);
pool_put(&rusage_pool, p->p_ru);

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_fork.c,v 1.51 1999/01/23 17:02:35 sommerfe Exp $ */
/* $NetBSD: kern_fork.c,v 1.52 1999/01/23 22:23:19 sommerfe Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1991, 1993
@ -111,8 +111,6 @@ sys___vfork14(p, v, retval)
return (fork1(p, FORK_PPWAIT|FORK_SHAREVM, retval, NULL));
}
int slowchild = 1;
int
fork1(p1, flags, retval, rnewprocp)
register struct proc *p1;
@ -278,12 +276,6 @@ again:
p2->p_cred->p_refcnt = 1;
crhold(p1->p_ucred);
/*
* slow us down if parent was cpu-bound
*/
if (slowchild)
p2->p_estcpu = p1->p_estcpu;
/* bump references to the text vnode (for procfs) */
p2->p_textvp = p1->p_textvp;
if (p2->p_textvp)
@ -324,6 +316,13 @@ again:
}
#endif
/*
* set priority of child to be that of parent
* XXX should move p_estcpu into the region of struct proc which gets
* copied.
*/
p2->p_estcpu = p1->p_estcpu;
/*
* This begins the section where we must prevent the parent
* from being swapped.

View File

@ -1,4 +1,4 @@
/* $NetBSD: proc.h,v 1.70 1999/01/21 23:12:50 christos Exp $ */
/* $NetBSD: proc.h,v 1.71 1999/01/23 22:23:19 sommerfe Exp $ */
/*-
* Copyright (c) 1986, 1989, 1991, 1993
@ -145,7 +145,7 @@ struct proc {
int p_dupfd; /* Sideways return value from filedescopen. XXX */
/* scheduling */
u_int p_estcpu; /* Time averaged value of p_cpticks. */
u_int p_estcpu; /* Time averaged value of p_cpticks. XXX belongs in p_startcopy section */
int p_cpticks; /* Ticks of cpu time. */
fixpt_t p_pctcpu; /* %cpu for this process during p_swtime */
void *p_wchan; /* Sleep address. */