Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 23 Mar 2004 15:30:58 +0300 (MSK)
From:      Dmitry Morozovsky <marck@rinet.ru>
To:        Matthew Dillon <dillon@apollo.backplane.com>
Cc:        freebsd-stable@freebsd.org
Subject:   Re: Urk, I take it back (was Re: Bug in p_estcpu handling onprocess exit in FBsd-4.x)
Message-ID:  <20040323152935.A3107@woozle.rinet.ru>
In-Reply-To: <200403210031.i2L0Vdoc096697@apollo.backplane.com>
References:  <200403201941.i2KJf6Ml095658@apollo.backplane.com> <200403202244.i2KMiRth096273@apollo.backplane.com> <200403210031.i2L0Vdoc096697@apollo.backplane.com>

next in thread | previous in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
On Sat, 20 Mar 2004, Matthew Dillon wrote:

MD>      All right, I figured out a solution.  Basically the solution for the
MD>      4.x scheduler (and the 4BSD scheduler in 5.x for people still using
MD>      it) is to bump the child's estcpu in fork and recover any delta changes
MD>      back to the parent in exit.  The DFly patch set is rather DFly specific,
MD>      so I will just explain it in case someone in FreeBSD land wants to fix
MD>      the problem in FreeBSD-4.

[snip]

In case abyone interested the patch for stable as of today is attached.

Sincerely,
D.Marck                                     [DM5020, MCK-RIPE, DM3-RIPN]
------------------------------------------------------------------------
*** Dmitry Morozovsky --- D.Marck --- Wild Woozle --- marck@rinet.ru ***
------------------------------------------------------------------------
[-- Attachment #2 --]
# $Id: FreeBSD/Patches/contrib/matt-kernexit.patch,v 1.1 2004/03/23 11:00:44 marck Exp $
#
#-DSC-# DFBSD patch for fork-exit-priority bug

Index: sys/sys/proc.h
===================================================================
RCS file: /home/ncvs/src/sys/sys/proc.h,v
retrieving revision 1.99.2.10
diff -u -r1.99.2.10 proc.h
--- sys/sys/proc.h	6 Jul 2003 16:35:47 -0000	1.99.2.10
+++ sys/sys/proc.h	23 Mar 2004 10:49:12 -0000
@@ -165,6 +165,7 @@
 
 	/* scheduling */
 	u_int	p_estcpu;	 /* Time averaged value of p_cpticks. */
+	u_int	p_estcpu_fork;
 	int	p_cpticks;	 /* Ticks of cpu time. */
 	fixpt_t	p_pctcpu;	 /* %cpu for this process during p_swtime */
 	void	*p_wchan;	 /* Sleep address. */
Index: sys/kern/kern_exit.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/kern_exit.c,v
retrieving revision 1.92.2.13
diff -u -r1.92.2.13 kern_exit.c
--- sys/kern/kern_exit.c	3 Mar 2004 09:21:14 -0000	1.92.2.13
+++ sys/kern/kern_exit.c	23 Mar 2004 10:49:12 -0000
@@ -452,10 +452,16 @@
 
 		nfound++;
 		if (p->p_stat == SZOMB) {
-			/* charge childs scheduling cpu usage to parent */
-			if (curproc->p_pid != 1) {
-				curproc->p_estcpu =
-				    ESTCPULIM(curproc->p_estcpu + p->p_estcpu);
+			/*
+			 * Charge the parent for the child's change in
+			 * estimated cpu as of when the child exits to
+			 * account for batch scripts, large make's, etc.
+			 */
+			if (q->p_pid != 1) {
+				if (p->p_estcpu > p->p_estcpu_fork) {
+					q->p_estcpu = ESTCPULIM(q->p_estcpu +
+					    p->p_estcpu - p->p_estcpu_fork);
+				}                                                
 			}
 
 			q->p_retval[0] = p->p_pid;
Index: sys/kern/kern_fork.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/kern_fork.c,v
retrieving revision 1.72.2.16
diff -u -r1.72.2.16 kern_fork.c
--- sys/kern/kern_fork.c	11 Nov 2003 07:26:44 -0000	1.72.2.16
+++ sys/kern/kern_fork.c	23 Mar 2004 10:49:12 -0000
@@ -506,7 +506,8 @@
 	/*
 	 * set priority of child to be that of parent
 	 */
-	p2->p_estcpu = p1->p_estcpu;
+	p2->p_estcpu_fork = p2->p_estcpu = 
+		ESTCPULIM(p1->p_estcpu + ESTCPURAMP);
 
 	/*
 	 * This begins the section where we must prevent the parent

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040323152935.A3107>