From: Mikulas Patocka Date: Mon, 7 Apr 2014 22:37:35 +0000 (-0700) Subject: mempool: add unlikely and likely hints X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=eb9a3c62a0b6064c7f7e5b961ce00c646d21cb78;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git mempool: add unlikely and likely hints Add unlikely and likely hints to the function mempool_free. It lays out the code in such a way that the common path is executed straighforward and saves a cache line. Signed-off-by: Mikulas Patocka Cc: Ingo Molnar Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/mempool.c b/mm/mempool.c index 659aa42bad16..905434f18c97 100644 --- a/mm/mempool.c +++ b/mm/mempool.c @@ -304,9 +304,9 @@ void mempool_free(void *element, mempool_t *pool) * ensures that there will be frees which return elements to the * pool waking up the waiters. */ - if (pool->curr_nr < pool->min_nr) { + if (unlikely(pool->curr_nr < pool->min_nr)) { spin_lock_irqsave(&pool->lock, flags); - if (pool->curr_nr < pool->min_nr) { + if (likely(pool->curr_nr < pool->min_nr)) { add_element(pool, element); spin_unlock_irqrestore(&pool->lock, flags); wake_up(&pool->wait);