From: Sebastien Dugue Date: Tue, 27 Jun 2006 09:55:03 +0000 (-0700) Subject: [PATCH] futex_requeue() optimization X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=59e0e0ace7d33e8c0c125042f153f80fcc56b39e;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git [PATCH] futex_requeue() optimization In futex_requeue(), when the 2 futexes keys hash to the same bucket, there is no need to move the futex_q to the end of the bucket list. Signed-off-by: Sebastien Dugue Cc: Ingo Molnar Cc: Thomas Gleixner Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/kernel/futex.c b/kernel/futex.c index b305b7f8dad5..6c91f938005d 100644 --- a/kernel/futex.c +++ b/kernel/futex.c @@ -827,17 +827,20 @@ static int futex_requeue(u32 __user *uaddr1, u32 __user *uaddr2, if (++ret <= nr_wake) { wake_futex(this); } else { - list_move_tail(&this->list, &hb2->chain); - this->lock_ptr = &hb2->lock; + /* + * If key1 and key2 hash to the same bucket, no need to + * requeue. + */ + if (likely(head1 != &hb2->chain)) { + list_move_tail(&this->list, &hb2->chain); + this->lock_ptr = &hb2->lock; + } this->key = key2; get_key_refs(&key2); drop_count++; if (ret - nr_wake >= nr_requeue) break; - /* Make sure to stop if key1 == key2: */ - if (head1 == &hb2->chain && head1 != &next->list) - head1 = &this->list; } }