From: Paul Mundt <lethal@linux-sh.org>
To: Paul Jackson <pj@sgi.com>
Cc: akpm@osdl.org, James Bottomley <James.Bottomley@steeleye.com>,
linux-kernel@vger.kernel.org
Subject: Re: [TEST PATCH 3/3] lib bitmap region restructure
Date: Fri, 20 Jan 2006 10:13:05 +0200 [thread overview]
Message-ID: <20060120081305.GB3918@linux-sh.org> (raw)
In-Reply-To: <20060120020808.19584.3859.sendpatchset@jackhammer.engr.sgi.com>
[-- Attachment #1: Type: text/plain, Size: 2441 bytes --]
On Thu, Jan 19, 2006 at 06:08:08PM -0800, Paul Jackson wrote:
> This compiles, but has not been tested past that.
> Be more careful of this patch -- unlike the previous
> two in this set, this patch reworks quite a bit of
> the logic, so is at higher risk of being broken.
>
The first two work fine for me. This one is another case. With this, the
bitmap_find_free_region() switches to walking the bitmap in 1 << order
steps, as opposed to nbitsperlong, which causes it to skip over more
space than it needs to and we end up fragmenting the bitmap pretty
quickly.
By changing bitmap_find_free_region() back to the previous behaviour, it
seems to work again (at least in the bitmap_find_free_region() case). I
hate to invalidate your comments this quickly, though :-)
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
---
lib/bitmap.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/lib/bitmap.c b/lib/bitmap.c
index 72bd06a..adf336e 100644
--- a/lib/bitmap.c
+++ b/lib/bitmap.c
@@ -687,7 +687,7 @@ EXPORT_SYMBOL(bitmap_bitremap);
* depending on which combination of REG_OP_* flag bits is set.
*
* A region of a bitmap is a sequence of bits in the bitmap, of
- * some size '1 << order' (a power of two), alligned to that same
+ * some size '1 << order' (a power of two), aligned to that same
* '1 << order' power of two.
*
* Returns 1 if REG_OP_ISFREE succeeds (region is all zero bits).
@@ -760,7 +760,7 @@ done:
*
* Find a region of free (zero) bits in a @bitmap of @bits bits and
* allocate them (set them to one). Only consider regions of length
- * a power (@order) of two, alligned to that power of two, which
+ * a power (@order) of two, aligned to that power of two, which
* makes the search algorithm much faster.
*
* Return the bit offset in bitmap of the allocated region,
@@ -768,9 +768,14 @@ done:
*/
int bitmap_find_free_region(unsigned long *bitmap, int bits, int order)
{
+ int nbits_reg; /* number of bits in region */
+ int nbitsinlong; /* num bits of region in each spanned long */
int pos; /* scans bitmap by regions of size order */
- for (pos = 0; pos < bits; pos += (1 << order))
+ nbits_reg = 1 << order;
+ nbitsinlong = min(nbits_reg, BITS_PER_LONG);
+
+ for (pos = 0; pos < bits; pos += nbitsinlong)
if (__reg_op(bitmap, pos, order, REG_OP_ISFREE))
break;
if (pos == bits)
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
next prev parent reply other threads:[~2006-01-20 8:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-20 2:07 [TEST PATCH 1/3] lib bitmap region cleanup Paul Jackson
2006-01-20 2:08 ` [TEST PATCH 2/3] lib bitmap region multiword Paul Jackson
2006-01-20 2:08 ` [TEST PATCH 3/3] lib bitmap region restructure Paul Jackson
2006-01-20 8:13 ` Paul Mundt [this message]
2006-01-20 9:56 ` Paul Jackson
2006-01-22 15:03 ` Paul Mundt
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=20060120081305.GB3918@linux-sh.org \
--to=lethal@linux-sh.org \
--cc=James.Bottomley@steeleye.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pj@sgi.com \
/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
Powered by JetHome