[lkml]   [2003]   [Aug]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH] sched: CPU_THRESHOLD
hello Frank,

> - *imbalance = (max_load - nr_running) / 2;
> + *imbalance = (max_load - nr_running) >> 1;

I think it is a good coding practice to keep things human-readable.
In this code snippet, the division by 2 is quickly understood by most
readers (specially those who didn't write it). The right shift may
obfuscate the real meaning of this operation, which is a single
division by 2, not a bit-oriented expression.

Assuming that sched.c will be compiled with optimizations enabled, the
compiler will change the human-readable division by a fast machine
right shift operation, whenever possible (gcc surely will).

Thus, we keep the kernel code more readable, and sometimes let the
compiler apply newer (and hopefully faster) optimizations than some
tricks we have known as fastest available.

Regards, and please let me know what do you think about it.

Ricardo Nabinger Sanchez
GNU/Linux #140696 []
Slackware Linux

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-03-22 13:48    [W:0.048 / U:1.296 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site