From: Joe Perches <joe@perches.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 00/18] lib: bitmap: Various improvements
Date: Mon, 07 Jul 2014 16:45:38 -0700 [thread overview]
Message-ID: <1404776738.932.10.camel@joe-AO725> (raw)
In-Reply-To: <20140707162008.e5b2e1446b2266b50182c723@linux-foundation.org>
On Mon, 2014-07-07 at 16:20 -0700, Andrew Morton wrote:
> On Fri, 4 Jul 2014 00:42:46 +0200 Rasmus Villemoes <linux@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.
prev parent reply other threads:[~2014-07-07 23:45 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-03 22:42 Rasmus Villemoes
2014-07-03 22:42 ` [PATCH 01/18] lib: bitmap: Make nbits parameter of bitmap_empty unsigned Rasmus Villemoes
2014-07-03 22:42 ` [PATCH 02/18] lib: bitmap: Make nbits parameter of bitmap_full unsigned Rasmus Villemoes
2014-07-03 22:42 ` [PATCH 03/18] lib: bitmap: Make nbits parameter of bitmap_equal unsigned Rasmus Villemoes
2014-07-03 22:42 ` [PATCH 04/18] lib: bitmap: Make nbits parameter of bitmap_complement unsigned Rasmus Villemoes
2014-07-03 22:42 ` [PATCH 05/18] lib: bitmap: Remove unnecessary mask from bitmap_complement Rasmus Villemoes
2014-07-03 22:42 ` [PATCH 06/18] lib: bitmap: Make nbits parameter of bitmap_{and,or,xor,andnot} unsigned Rasmus Villemoes
2014-07-03 22:42 ` [PATCH 07/18] lib: bitmap: Make nbits parameter of bitmap_intersects unsigned Rasmus Villemoes
2014-07-03 22:42 ` [PATCH 08/18] lib: bitmap: Make nbits parameter of bitmap_subset unsigned Rasmus Villemoes
2014-07-03 22:42 ` [PATCH 09/18] lib: bitmap: Make nbits parameter of bitmap_weight unsigned Rasmus Villemoes
2014-07-03 22:42 ` [PATCH 10/18] lib: bitmap: Make the start index of bitmap_set unsigned Rasmus Villemoes
2014-07-03 22:42 ` [PATCH 11/18] lib: bitmap: Make the start index of bitmap_clear unsigned Rasmus Villemoes
2014-07-03 22:42 ` [PATCH 12/18] lib: bitmap: Simplify bitmap_parselist Rasmus Villemoes
2014-07-03 22:42 ` [PATCH 13/18] lib: bitmap: Fix typo in kerneldoc for bitmap_pos_to_ord Rasmus Villemoes
2014-07-03 22:43 ` [PATCH 14/18] lib: bitmap: Change parameter of bitmap_*_region to unsigned Rasmus Villemoes
2014-07-03 22:43 ` [PATCH 15/18] lib: bitmap: Micro-optimize bitmap_allocate_region Rasmus Villemoes
2014-07-03 22:43 ` [PATCH 16/18] lib: bitmap: Add missing mask in bitmap_shift_right Rasmus Villemoes
2014-07-03 22:43 ` [PATCH 17/18] lib: bitmap: Add missing mask in bitmap_and Rasmus Villemoes
2014-07-03 22:43 ` [PATCH 18/18] lib: bitmap: Add missing mask in bitmap_andnot Rasmus Villemoes
2014-07-07 23:20 ` [PATCH 00/18] lib: bitmap: Various improvements Andrew Morton
2014-07-07 23:45 ` Joe Perches [this message]
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=1404776738.932.10.camel@joe-AO725 \
--to=joe@perches.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
/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
all inboxes | Powered by JetHome®