From: behanw@converseincode.com Subject: [PATCH] mbcache: LLVMLinux: Remove double calculation from mbcache Date: Mon, 21 Apr 2014 22:19:53 -0700 Message-ID: <1398143993-19206-1-git-send-email-behanw@converseincode.com> Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, dwmw2@infradead.org, pageexec@freemail.hu, Mark Charlebois , Behan Webster To: viro@zeniv.linux.org.uk Return-path: Received: from mail-oa0-f42.google.com ([209.85.219.42]:42869 "EHLO mail-oa0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751354AbaDVFUA (ORCPT ); Tue, 22 Apr 2014 01:20:00 -0400 Received: by mail-oa0-f42.google.com with SMTP id i4so5210753oah.29 for ; Mon, 21 Apr 2014 22:20:00 -0700 (PDT) Sender: linux-fsdevel-owner@vger.kernel.org List-ID: From: Mark Charlebois 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 Signed-off-by: Mark Charlebois Signed-off-by: Behan Webster --- 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