Sat Jun 6 22:12:44 2009 UTC ()
Pull up following revision(s) (requested by rmind in ticket #791):
	sys/kern/sched_4bsd.c: revision 1.25
sched_pstats_hook: fix estcpu decay.
this makes my desktop usable when running "make -j4".


(bouyer)
diff -r1.24 -r1.24.4.1 src/sys/kern/sched_4bsd.c

cvs diff -r1.24 -r1.24.4.1 src/sys/kern/sched_4bsd.c (expand / switch to unified diff)

--- src/sys/kern/sched_4bsd.c 2008/10/07 09:48:27 1.24
+++ src/sys/kern/sched_4bsd.c 2009/06/06 22:12:44 1.24.4.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: sched_4bsd.c,v 1.24 2008/10/07 09:48:27 rmind Exp $ */ 1/* $NetBSD: sched_4bsd.c,v 1.24.4.1 2009/06/06 22:12:44 bouyer Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1999, 2000, 2004, 2006, 2007, 2008 The NetBSD Foundation, Inc. 4 * Copyright (c) 1999, 2000, 2004, 2006, 2007, 2008 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, 8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 * NASA Ames Research Center, by Charles M. Hannum, Andrew Doran, and 9 * NASA Ames Research Center, by Charles M. Hannum, Andrew Doran, and
10 * Daniel Sieger. 10 * Daniel Sieger.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions 13 * modification, are permitted provided that the following conditions
14 * are met: 14 * are met:
@@ -58,27 +58,27 @@ @@ -58,27 +58,27 @@
58 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 58 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
59 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 59 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
60 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 60 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
61 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 61 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
62 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 62 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
63 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 63 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
64 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 64 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
65 * SUCH DAMAGE. 65 * SUCH DAMAGE.
66 * 66 *
67 * @(#)kern_synch.c 8.9 (Berkeley) 5/19/95 67 * @(#)kern_synch.c 8.9 (Berkeley) 5/19/95
68 */ 68 */
69 69
70#include <sys/cdefs.h> 70#include <sys/cdefs.h>
71__KERNEL_RCSID(0, "$NetBSD: sched_4bsd.c,v 1.24 2008/10/07 09:48:27 rmind Exp $"); 71__KERNEL_RCSID(0, "$NetBSD: sched_4bsd.c,v 1.24.4.1 2009/06/06 22:12:44 bouyer Exp $");
72 72
73#include "opt_ddb.h" 73#include "opt_ddb.h"
74#include "opt_lockdebug.h" 74#include "opt_lockdebug.h"
75#include "opt_perfctrs.h" 75#include "opt_perfctrs.h"
76 76
77#include <sys/param.h> 77#include <sys/param.h>
78#include <sys/systm.h> 78#include <sys/systm.h>
79#include <sys/callout.h> 79#include <sys/callout.h>
80#include <sys/cpu.h> 80#include <sys/cpu.h>
81#include <sys/proc.h> 81#include <sys/proc.h>
82#include <sys/kernel.h> 82#include <sys/kernel.h>
83#include <sys/signalvar.h> 83#include <sys/signalvar.h>
84#include <sys/resourcevar.h> 84#include <sys/resourcevar.h>
@@ -278,37 +278,42 @@ decay_cpu_batch(fixpt_t loadfac, fixpt_t @@ -278,37 +278,42 @@ decay_cpu_batch(fixpt_t loadfac, fixpt_t
278 } 278 }
279 279
280 return estcpu; 280 return estcpu;
281} 281}
282 282
283/* 283/*
284 * sched_pstats_hook: 284 * sched_pstats_hook:
285 * 285 *
286 * Periodically called from sched_pstats(); used to recalculate priorities. 286 * Periodically called from sched_pstats(); used to recalculate priorities.
287 */ 287 */
288void 288void
289sched_pstats_hook(struct lwp *l, int batch) 289sched_pstats_hook(struct lwp *l, int batch)
290{ 290{
 291 fixpt_t loadfac;
291 292
292 /* 293 /*
293 * If the LWP has slept an entire second, stop recalculating 294 * If the LWP has slept an entire second, stop recalculating
294 * its priority until it wakes up. 295 * its priority until it wakes up.
295 */ 296 */
296 KASSERT(lwp_locked(l, NULL)); 297 KASSERT(lwp_locked(l, NULL));
297 if (l->l_slptime > 0) { 298 if (l->l_stat == LSSLEEP || l->l_stat == LSSTOP ||
298 fixpt_t loadfac = 2 * (averunnable.ldavg[0]); 299 l->l_stat == LSSUSPENDED) {
299 l->l_estcpu = decay_cpu(loadfac, l->l_estcpu); 300 if (l->l_slptime > 1) {
300 resetpriority(l); 301 return;
 302 }
301 } 303 }
 304 loadfac = 2 * (averunnable.ldavg[0]);
 305 l->l_estcpu = decay_cpu(loadfac, l->l_estcpu);
 306 resetpriority(l);
302} 307}
303 308
304/* 309/*
305 * Recalculate the priority of a process after it has slept for a while. 310 * Recalculate the priority of a process after it has slept for a while.
306 */ 311 */
307static void 312static void
308updatepri(struct lwp *l) 313updatepri(struct lwp *l)
309{ 314{
310 fixpt_t loadfac; 315 fixpt_t loadfac;
311 316
312 KASSERT(lwp_locked(l, NULL)); 317 KASSERT(lwp_locked(l, NULL));
313 KASSERT(l->l_slptime > 1); 318 KASSERT(l->l_slptime > 1);
314 319