Messages in this thread | | | Date | Fri, 6 Dec 2002 12:58:06 -0500 | Subject | Re: [PATCH] Make `hash_long' function work if bits parameter is 0. | From | Miles Bader <> |
| |
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] - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |