I cannot understand the following function called from load_balance() It is called with this_rq->lock held, from load_balance() (et. al) to make sure that we hold both runque->lock's before move_tasks(). static void double_lock_balance(runqueue_t *this_rq, runqueue_t *busiest) { if (unlikely(!spin_trylock(&busiest->lock))) { if (busiest < this_rq) { spin_unlock(&this_rq->lock); spin_lock(&busiest->lock); spin_lock(&this_rq->lock); } else spin_lock(&busiest->lock); } } What I understand is that, the branch unlikely() is very unlikely to be taken. => !spin_trylock(&busiest->lock) is almost always false (0) => spin_trylock(&busieset->lock) is almost always nonzero => failure to lock, i.e, already locked by some other thread. If it fails, then this function does not do anything, it simply returns. And to complicate matters, move_tasks() assumes that it is called with both busiest->lock and this_rq->lock held. (presumably by the calling thread) What is wrong with my understanding? or is it a bug in kernel ;-) ? Regards, Om. -- Modeling paged and segmented memories is tricky business. -- P.J. Denning -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/