[PATCH] schedstat: fix schedule() statistics

From: Akinobu Mita
Date: Thu Oct 21 2004 - 12:24:01 EST


Hello,

The number of times schedule() left the processor idle in the /proc/schedstat
(runqueue.sched_goidle) seems to be wrong.

The schedule() statistics should satisfy the equation:
sched_cnt == sched_noswitch + sched_switch + sched_goidle

(http://eaglet.rain.com/rick/linux/schedstat/v10/format-10.html)

The below patch fix this, and I have confirmed to be fixed with:
# grep ^cpu /proc/schedstat | awk '{print $6+$7+$9, $8}'

--- 2.6-mm/kernel/sched.c.orig 2004-10-22 01:09:38.391429584 +0900
+++ 2.6-mm/kernel/sched.c 2004-10-22 01:23:18.590740336 +0900
@@ -2809,7 +2809,6 @@ go_idle:
}
} else {
if (dependent_sleeper(cpu, rq)) {
- schedstat_inc(rq, sched_goidle);
next = rq->idle;
goto switch_tasks;
}
@@ -2853,6 +2852,8 @@ go_idle:
}
next->activated = 0;
switch_tasks:
+ if (next == rq->idle)
+ schedstat_inc(rq, sched_goidle);
prefetch(next);
clear_tsk_need_resched(prev);
rcu_qsctr_inc(task_cpu(prev));



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/