aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Roberson <jeff@FreeBSD.org>2003-09-20 02:05:58 +0000
committerJeff Roberson <jeff@FreeBSD.org>2003-09-20 02:05:58 +0000
commit81de51bf1dc4d63746688fed4fadd6f1083773c4 (patch)
treed5beab0d1c08f1c219cffd487a693a444fe553a8
parent51b575490c8776d2a903861d309976418b0925f6 (diff)
downloadsrc-81de51bf1dc4d63746688fed4fadd6f1083773c4.tar.gz
src-81de51bf1dc4d63746688fed4fadd6f1083773c4.zip
- Somewhere along the line I stupidly removed critical logic from
sched_ptcpu_update(). This caused erroneous cpu times in TOP for processes that were asleep. Replace the code that was removed.
Notes
Notes: svn path=/head/; revision=120272
-rw-r--r--sys/kern/sched_ule.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/sys/kern/sched_ule.c b/sys/kern/sched_ule.c
index 319a38de6ef8..cab763a5579f 100644
--- a/sys/kern/sched_ule.c
+++ b/sys/kern/sched_ule.c
@@ -718,15 +718,17 @@ sched_pctcpu_update(struct kse *ke)
/*
* Adjust counters and watermark for pctcpu calc.
*/
-
- /*
- * Shift the tick count out so that the divide doesn't round away
- * our results.
- */
- ke->ke_ticks <<= 10;
- ke->ke_ticks = (ke->ke_ticks / (ke->ke_ltick - ke->ke_ftick)) *
- SCHED_CPU_TICKS;
- ke->ke_ticks >>= 10;
+ if (ke->ke_ltick > ticks - SCHED_CPU_TICKS) {
+ /*
+ * Shift the tick count out so that the divide doesn't
+ * round away our results.
+ */
+ ke->ke_ticks <<= 10;
+ ke->ke_ticks = (ke->ke_ticks / (ticks - ke->ke_ftick)) *
+ SCHED_CPU_TICKS;
+ ke->ke_ticks >>= 10;
+ } else
+ ke->ke_ticks = 0;
ke->ke_ltick = ticks;
ke->ke_ftick = ke->ke_ltick - SCHED_CPU_TICKS;
}
@@ -1307,7 +1309,6 @@ sched_pctcpu(struct kse *ke)
*/
if (ke->ke_ltick < (ticks - (hz / 2)))
sched_pctcpu_update(ke);
-
/* How many rtick per second ? */
rtick = min(ke->ke_ticks / SCHED_CPU_TIME, SCHED_CPU_TICKS);
pctcpu = (FSCALE * ((FSCALE * rtick)/realstathz)) >> FSHIFT;