On Mon, 2014-07-07 at 16:20 -0700, Andrew Morton wrote: > On Fri, 4 Jul 2014 00:42:46 +0200 Rasmus Villemoes > <li...@rasmusvillemoes.dk> wrote: > > > Many functions in lib/bitmap.c start with an expression such as lim = > > bits/BITS_PER_LONG. Since bits has type (signed) int, and since gcc > > cannot know that it is in fact non-negative, it generates worse code > > than it could. These patches, mostly consisting of changing various > > parameters to unsigned, gives a slight overall code reduction: > > Yes, we have a bad habit of using signed types for things where > negative values are absurd.
Linus at one time wrote: http://thread.gmane.org/gmane.linux.kernel/1526174 --------------------------------------------------------- The fact is, the x86 bitop instructions act on a signed index. Making the index be "unsigned long" would violate the actual *behavior* of the function, so it would be singularly stupid. --------------------------------------------------------- > The patches look OK to me. Me too. But this does have the unfortunate effect of allowing bitmap tests on bitmaps that are unable to be set/cleared when the bitmap is larger than INT_MAX size. There could be some check to make sure size <= INT_MAX. The docs could be clearer here too about the actual maximum size of a bitmap. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/