[RFC PATCH 02/11] sched: debug spread check account for nr_running

Mathieu Desnoyers
2010-08-26T18:14:30Z

[-- Attachment #1: sched-fair-check-spread-with-running.patch --]
[-- Type: text/plain, Size: 1497 bytes --]

Extracted from a "sched-misc-bits.patch" patch from
Peter Zijlstra <a.p.zijlstra@chello.nl>.

This patch also moves the check_spread test where nr_running is always non-zero.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
CC: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
kernel/sched_fair.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)

Index: linux-2.6-lttng.git/kernel/sched_fair.c
===================================================================
--- linux-2.6-lttng.git.orig/kernel/sched_fair.c
+++ linux-2.6-lttng.git/kernel/sched_fair.c
@@ -715,7 +715,7 @@ static void check_spread(struct cfs_rq *
if (d < 0)
d = -d;

- if (d > 3*sysctl_sched_latency)
+ if (d > 3*cfs_rq->nr_running*sysctl_sched_latency)
schedstat_inc(cfs_rq, nr_spread_over);
#endif
}
@@ -803,6 +803,7 @@ dequeue_entity(struct cfs_rq *cfs_rq, st
* Update run-time statistics of the 'current'.
*/
update_curr(cfs_rq);
+ check_spread(cfs_rq, se);

update_stats_dequeue(cfs_rq, se);
if (flags & DEQUEUE_SLEEP) {
@@ -932,11 +933,9 @@ static void put_prev_entity(struct cfs_r
* If still on the runqueue then deactivate_task()
* was not called and update_curr() has to be done:
*/
- if (prev->on_rq)
- update_curr(cfs_rq);
-
- check_spread(cfs_rq, prev);
if (prev->on_rq) {
+ update_curr(cfs_rq);
+ check_spread(cfs_rq, prev);
update_stats_wait_start(cfs_rq, prev);
/* Put 'current' back into the tree. */
__enqueue_entity(cfs_rq, prev);