From: behanw@converseincode.com
To: viro@zeniv.linux.org.uk
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
torvalds@linux-foundation.org, hpa@zytor.com,
dwmw2@infradead.org, Mark Charlebois <charlebm@gmail.com>,
Behan Webster <behanw@converseincode.com>
Subject: [PATCH] mbcache: LLVMLinux: Remove double calculation from mbcache
Date: Tue, 29 Apr 2014 18:10:39 -0700 [thread overview]
Message-ID: <1398820239-1890-1-git-send-email-behanw@converseincode.com> (raw)
From: Mark Charlebois <charlebm@gmail.com>
The call to __builtin_log2 presumes there is a
double log2(double x) function defined in the kernel.
The call to hash_log is a call to hash_64 which is
defined in include/linux/hash.h
static __always_inline u64 hash_64(u64 val, unsigned int bits)
That means that __builtin_log2(NR_BG_LOCKS) is converting
NR_BG_LOCKS to a double and returning a double and then that
is converted to an unsigned int.
Using ilog2 is much more appropriate and efficient.
Another side effect of using __builtin_log2 is that is uses
__aeabi_* functions for ARM that require linking with libgcc.a.
Author: Mark Charlebois <charlebm@gmail.com>
Signed-off-by: Mark Charlebois <charlebm@gmail.com>
Signed-off-by: Behan Webster <behanw@converseincode.com>
---
fs/mbcache.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/mbcache.c b/fs/mbcache.c
index bf166e3..2c0752b 100644
--- a/fs/mbcache.c
+++ b/fs/mbcache.c
@@ -93,7 +93,7 @@
#define MB_CACHE_WRITER ((unsigned short)~0U >> 1)
-#define MB_CACHE_ENTRY_LOCK_BITS __builtin_log2(NR_BG_LOCKS)
+#define MB_CACHE_ENTRY_LOCK_BITS ilog2(NR_BG_LOCKS)
#define MB_CACHE_ENTRY_LOCK_INDEX(ce) \
(hash_long((unsigned long)ce, MB_CACHE_ENTRY_LOCK_BITS))
--
1.8.3.2
next reply other threads:[~2014-04-30 1:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-30 1:10 behanw [this message]
2014-04-30 1:13 ` [PATCH] mbcache: LLVMLinux: Remove double calculation from mbcache H. Peter Anvin
2014-04-30 5:19 ` H. Peter Anvin
-- strict thread matches above, loose matches on Subject: below --
2014-04-22 5:19 behanw
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=1398820239-1890-1-git-send-email-behanw@converseincode.com \
--to=behanw@converseincode.com \
--cc=charlebm@gmail.com \
--cc=dwmw2@infradead.org \
--cc=hpa@zytor.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=viro@zeniv.linux.org.uk \
/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;
as well as URLs for NNTP newsgroup(s).