diff options
author | Mikulas Patocka <mpatocka@redhat.com> | 2014-04-07 18:37:35 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-04-07 19:35:55 -0400 |
commit | eb9a3c62a0b6064c7f7e5b961ce00c646d21cb78 (patch) | |
tree | fecb27f0ba700b13c2b05364159c4230589b0099 | |
parent | da1c67a76f7cf2b3404823d24f9f10fa91aa5dc5 (diff) |
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>
-rw-r--r-- | mm/mempool.c | 4 |
1 files changed, 2 insertions, 2 deletions
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) | |||
304 | * ensures that there will be frees which return elements to the | 304 | * ensures that there will be frees which return elements to the |
305 | * pool waking up the waiters. | 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 | spin_lock_irqsave(&pool->lock, flags); | 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 | add_element(pool, element); | 310 | add_element(pool, element); |
311 | spin_unlock_irqrestore(&pool->lock, flags); | 311 | spin_unlock_irqrestore(&pool->lock, flags); |
312 | wake_up(&pool->wait); | 312 | wake_up(&pool->wait); |