* + linux-bitmaph-improve-bitmap_lastfirst_word_mask.patch added to -mm tree
@ 2015-02-18 22:53 akpm
0 siblings, 0 replies; only message in thread
From: akpm @ 2015-02-18 22:53 UTC (permalink / raw)
To: linux, linux, tj, yury.norov, mm-commits
The patch titled
Subject: linux/bitmap.h: improve BITMAP_{LAST,FIRST}_WORD_MASK
has been added to the -mm tree. Its filename is
linux-bitmaph-improve-bitmap_lastfirst_word_mask.patch
This patch should soon appear at
http://ozlabs.org/~akpm/mmots/broken-out/linux-bitmaph-improve-bitmap_lastfirst_word_mask.patch
and later at
http://ozlabs.org/~akpm/mmotm/broken-out/linux-bitmaph-improve-bitmap_lastfirst_word_mask.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/SubmitChecklist when testing your code ***
The -mm tree is included into linux-next and is updated
there every 3-4 working days
------------------------------------------------------
From: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Subject: linux/bitmap.h: improve BITMAP_{LAST,FIRST}_WORD_MASK
The macro BITMAP_LAST_WORD_MASK can be implemented without a conditional,
which will generally lead to slightly better generated code (221 bytes
saved for allmodconfig-GCOV_KERNEL, ~2k with GCOV_KERNEL). As a small
bonus, this also ensures that the nbits parameter is expanded exactly
once.
In BITMAP_FIRST_WORD_MASK, if start is signed gcc is technically allowed
to assume it is positive (or divisible by BITS_PER_LONG), and hence just
do the simple mask. It doesn't seem to use this, and even on an
architecture like x86 where the shift only depends on the lower 5 or 6
bits, and these bits are not affected by the signedness of the expression,
gcc still generates code to compute the C99 mandated value of start %
BITS_PER_LONG. So just use a mask explicitly, also for consistency with
BITMAP_LAST_WORD_MASK.
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Tejun Heo <tj@kernel.org>
Cc: "George Spelvin" <linux@horizon.com>
Cc: Yury Norov <yury.norov@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
include/linux/bitmap.h | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff -puN include/linux/bitmap.h~linux-bitmaph-improve-bitmap_lastfirst_word_mask include/linux/bitmap.h
--- a/include/linux/bitmap.h~linux-bitmaph-improve-bitmap_lastfirst_word_mask
+++ a/include/linux/bitmap.h
@@ -172,12 +172,8 @@ extern unsigned int bitmap_ord_to_pos(co
extern int bitmap_print_to_pagebuf(bool list, char *buf,
const unsigned long *maskp, int nmaskbits);
-#define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) % BITS_PER_LONG))
-#define BITMAP_LAST_WORD_MASK(nbits) \
-( \
- ((nbits) % BITS_PER_LONG) ? \
- (1UL<<((nbits) % BITS_PER_LONG))-1 : ~0UL \
-)
+#define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) & (BITS_PER_LONG - 1)))
+#define BITMAP_LAST_WORD_MASK(nbits) (~0UL >> (-(nbits) & (BITS_PER_LONG - 1)))
#define small_const_nbits(nbits) \
(__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG)
_
Patches currently in -mm which might be from linux@rasmusvillemoes.dk are
origin.patch
linux-bitmaph-improve-bitmap_lastfirst_word_mask.patch
linux-next.patch
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2015-02-18 22:53 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-18 22:53 + linux-bitmaph-improve-bitmap_lastfirst_word_mask.patch added to -mm tree akpm
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.