Commit eb9a3c62a0b6064c7f7e5b961ce00c646d21cb78
Committed by
Linus Torvalds
1 parent
da1c67a76f
Exists in
master
and in
13 other branches
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 <mpatocka@redhat.com> Cc: Ingo Molnar <mingo@elte.hu> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 1 changed file with 2 additions and 2 deletions Side-by-side Diff
mm/mempool.c
... | ... | @@ -304,9 +304,9 @@ |
304 | 304 | * ensures that there will be frees which return elements to the |
305 | 305 | * pool waking up the waiters. |
306 | 306 | */ |
307 | - if (pool->curr_nr < pool->min_nr) { | |
307 | + if (unlikely(pool->curr_nr < pool->min_nr)) { | |
308 | 308 | spin_lock_irqsave(&pool->lock, flags); |
309 | - if (pool->curr_nr < pool->min_nr) { | |
309 | + if (likely(pool->curr_nr < pool->min_nr)) { | |
310 | 310 | add_element(pool, element); |
311 | 311 | spin_unlock_irqrestore(&pool->lock, flags); |
312 | 312 | wake_up(&pool->wait); |