All of lore.kernel.org
 help / color / mirror / Atom feed
From: Miles Bader <miles@gnu.org>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH]  Make `hash_long' function work if bits parameter is 0.
Date: Fri, 6 Dec 2002 12:58:06 -0500	[thread overview]
Message-ID: <20021206175806.GB15923@gnu.org> (raw)
In-Reply-To: <Pine.LNX.4.44.0212060836170.23118-100000@home.transmeta.com>

On Fri, Dec 06, 2002 at 08:37:26AM -0800, Linus Torvalds wrote:
> > If the bits parameter of hash_long (in <linux/hash.h>) is 0, then it
> > ends up right-shifting by BITS_PER_LONG, which is undefined in C (and
> > often is a nop).
> 
> I would much rather just add a comment saying that "bits" had better be in
> a valid range. There are no valid uses for a 0-bit hash table that I can
> see, and undefined behaviour for undefined operations is fine with me.

The reason I sent the patch is because I ran into a case where the return
value _should_ be zero -- on a machine with very little memory (1MB), the
page wait-queue hash-table ends up having only one bucket (it has 256 pages,
and the code tries to make a wait-queue for every 256 pages....).  The 0 is
returned by the `wait_table_bits' function in mm/page_alloc.c.

I suppose an alternative in this case is to special-case above calculation to
peg the minimum at 1.

-Miles
-- 
`...the Soviet Union was sliding in to an economic collapse so comprehensive
 that in the end its factories produced not goods but bads: finished products
 less valuable than the raw materials they were made from.'  [The Economist]

  reply	other threads:[~2002-12-06 17:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-06  9:33 [PATCH] Make `hash_long' function work if bits parameter is 0 Miles Bader
2002-12-06 16:37 ` Linus Torvalds
2002-12-06 17:58   ` Miles Bader [this message]
2002-12-06 18:16     ` Linus Torvalds
2002-12-08 17:23   ` Rogier Wolff

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=20021206175806.GB15923@gnu.org \
    --to=miles@gnu.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@transmeta.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 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.