From: Mikulas Patocka <mpatocka@redhat.com>
To: Ingo Molnar <mingo@redhat.com>
Cc: linux-mm@kvack.org
Subject: [PATCH] mempool: add unlikely and likely hints
Date: Thu, 6 Mar 2014 17:15:16 -0500 (EST) [thread overview]
Message-ID: <alpine.LRH.2.02.1403061713300.928@file01.intranet.prod.int.rdu2.redhat.com> (raw)
This patch adds 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>
---
mm/mempool.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Index: linux-3.13.5/mm/mempool.c
===================================================================
--- linux-3.13.5.orig/mm/mempool.c 2014-02-23 22:50:11.481071417 +0100
+++ linux-3.13.5/mm/mempool.c 2014-03-06 23:02:24.264538587 +0100
@@ -306,9 +306,9 @@ void mempool_free(void *element, mempool
* 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);
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next reply other threads:[~2014-03-06 22:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-06 22:15 Mikulas Patocka [this message]
2014-03-07 10:10 ` David Rientjes
2014-03-07 14:50 ` Mikulas Patocka
2014-03-07 20:54 ` David Rientjes
2014-03-07 21:15 ` Mikulas Patocka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.LRH.2.02.1403061713300.928@file01.intranet.prod.int.rdu2.redhat.com \
--to=mpatocka@redhat.com \
--cc=linux-mm@kvack.org \
--cc=mingo@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox