2002-02-14 17:28:29

by Mike Kravetz

[permalink] [raw]
Subject: bug/code cleanup for O(1)-K3

In the K3 version of the O(1) scheduler for 2.4.17 there is
either a bug or an opportunity for some code cleanup. At
the beginning of the load_balance() routine we set the local
variable 'nr_running' and use this variable to calculate the
value of 'imbalance'. After this the variable is not used,
even though we go to the trouble of passing it to
double_lock_balance() so that it can be possibly be recomputed.
Note the code:

imbalance = (max_load - nr_running) / 2;

/* It needs an at least ~25% imbalance to trigger balancing. */
if (!idle && (imbalance < (max_load + 3)/4))
return;

nr_running = double_lock_balance(this_rq, busiest, this_cpu, idle, nr_running);
/*
* Make sure nothing changed since we checked the
* runqueue length.
*/
if (busiest->nr_running <= this_rq->nr_running + 1)
goto out_unlock;


In the last if statement above, I suspect we want to compare
'busiest->nr_running' to the local variable nr_running (as was
done in previous versions of the code). If this is not the
case, then we can simplify double_lock_balance() and make it
return a void.

P.S. I've only been working with the 2.4.17 version of the patch,
but I assume the code is the same in other versions.
--
Mike


2002-02-15 08:51:27

by Ingo Molnar

[permalink] [raw]
Subject: Re: bug/code cleanup for O(1)-K3


On Thu, 14 Feb 2002, kravetz wrote:

> if (busiest->nr_running <= this_rq->nr_running + 1)
> goto out_unlock;
>
>
> In the last if statement above, I suspect we want to compare
> 'busiest->nr_running' to the local variable nr_running (as was done in
> previous versions of the code). [...]

indeed we want to do that. I've added your fix to my tree.

Ingo