lkml.org 
[lkml]   [2003]   [Nov]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: hash table sizes
On Tue, Nov 25, 2003 at 05:25:07PM +0100, Thomas Schlichter wrote:
> Hi Jens,
>
> I was wondering about you funny formula, too. (especially because it was 23 -
> (PAGE_SHIFT -1) and not 24 - PAGE_SHIFT ;-) So I wanted to find out why this:
> 1: mempages >>= (23 - (PAGE_SHIFT - 1));
> 2: order = max(2, fls(mempages));
> 3: order = min(12, order);
>
> should be similar to this original code:
> 4: mempages >>= (14 - PAGE_SHIFT);
> 5: mempages *= sizeof(struct hlist_head);
> 6: for (order = 0; ((1UL << order) << PAGE_SHIFT) < mempages; order++)
> 7: ;
>
> Well, first I saw that lines 2 and 3 make order to be between 2 and 12. OK
> this is new, and I like it ;-) Then I saw you tried to convert the ugly lines
> 6 + 7 into a fls() call. Fine! (I like that, too) Line 6 + 7 can be converted

is fls(x) sort-of log2(x) via some "find-highest-bit-set"?
I recall discussing something related with Jesse Barnes
last 5 november (search for "[DMESG] cpumask_t in action" in lkml).

[SNIP]

Greets, Antonio Vargas

1. Dado un programa, siempre tiene al menos un fallo.
2. Dadas varias lineas de codigo, siempre se pueden acortar a menos lineas.
3. Por induccion, todos los programas se pueden
reducir a una linea que no funciona.
-
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/

\
 
 \ /
  Last update: 2005-03-22 13:58    [from the cache]
©2003-2014 Jasper Spaans. Advertise on this site