Re: [patch] CFS scheduler, -v8

Ingo Molnar
2007-05-06T08:52:38Z

* Willy Tarreau <w@1wt.eu> wrote:

> Just a hint: while your code here is correct, it is a good practise to
> check against < 0 instead, so that if for any reason you sometimes
> forget to cast to signed, the compiler will emit a warning stating
> that the condition is always false. This would simply become :
>
> - if (key < entry->fair_key) {
> + if ((s64)(key - entry->fair_key) < 0) {

done :-) (Btw., the key is still s64 so the cast is technically
unnecessary - but now the code would be correct with the key being u64
too.)

Ingo

Index: linux/kernel/sched_fair.c
===================================================================
--- linux.orig/kernel/sched_fair.c
+++ linux/kernel/sched_fair.c
@@ -60,7 +60,7 @@ static inline void __enqueue_task_fair(s
* We dont care about collisions. Nodes with
* the same key stay together.
*/
- if (key < entry->fair_key) {
+ if ((s64)(key - entry->fair_key) < 0) {
link = &parent->rb_left;
} else {
link = &parent->rb_right;