public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Paul Jackson <pj@sgi.com>
To: Paul Mundt <lethal@linux-sh.org>
Cc: linux-kernel@vger.kernel.org, akpm@osdl.org,
	James Bottomley <James.Bottomley@steeleye.com>
Subject: Re: [PATCH] bitmap: Support for pages > BITS_PER_LONG.
Date: Wed, 18 Jan 2006 22:07:53 -0800	[thread overview]
Message-ID: <20060118220753.3f005b5a.pj@sgi.com> (raw)
In-Reply-To: <20060119014812.GB18181@linux-sh.org>

It looks to me like I never properly reviewed James patch
when it was originally submitted.  It has some minor confusions
that have gotten slightly worse with this patch.

Just reading the patch, I see the following possible opportunities
for improvement:

 * Could the calculation of mask:
        mask = (1ul << (pages - 1));
        mask += mask - 1;
   be simplified to:
	mask = (1UL << pages) - 1;
   (and note that 1UL is easier to read than 1ul)

 * The variable named 'pages' is misnamed.  It happens that the
   current user of this code is using one bit to represent one
   page, but that is not something that this code has any business
   knowing.  For this code, it might better be 'nbits' or some such.

 * With your 'pages > BITS_PER_LONG' patch, this 'pages' variable
   becomes more confused.  Apparently, it is the number of bits
   to consider in each word scanned, and 'scan' is the number of
   words to scan.  Hmmm ... that's not quite right either.  It
   seems that 'pages' is first set (in bitmask_find_free_region)
   to the number of bits total to find, which value is used to
   compute 'scan', the number of words needed to hold that many
   bits; then 'pages' is recomputed to be the number of bits in
   a single word to examine, which value is used to compute the
   'mask'.  This sort of dual use of a poorly named variable is
   confusing.  I'd suggest two variables - 'nbitstotal' and
   'nbitsinword', or some such.  Or short variable names, and
   a comment:
	int bt;		/* total number of bits to find free */
	int bw;		/* how many bits to consider in one word */

 * The block comment states:
	allocate a memory region from a bitmap
   This is another confusion between the user of this code, and
   this current code.  I think we are allocating a sequence of
   consecutive bits of size and allignment some power of two
   ('order' is that power), not allocating a 'memory region.'

 * There is no function block comment for bitmap_allocate_region().

 * The include/linux/bitmap.h header comment is missing the
   three lines specifying these three routines.

-- 
                  I won't rest till it's the best ...
                  Programmer, Linux Scalability
                  Paul Jackson <pj@sgi.com> 1.925.600.0401

  parent reply	other threads:[~2006-01-19  6:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-19  1:48 [PATCH] bitmap: Support for pages > BITS_PER_LONG Paul Mundt
2006-01-19  3:11 ` Paul Jackson
2006-01-20  3:28   ` James Bottomley
2006-01-20  7:28     ` Paul Mundt
2006-01-20  9:10     ` Paul Jackson
2006-01-19  6:07 ` Paul Jackson [this message]
2006-01-19  6:40   ` Paul Jackson

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=20060118220753.3f005b5a.pj@sgi.com \
    --to=pj@sgi.com \
    --cc=James.Bottomley@steeleye.com \
    --cc=akpm@osdl.org \
    --cc=lethal@linux-sh.org \
    --cc=linux-kernel@vger.kernel.org \
    /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