lkml.org 
[lkml]   [2009]   [Jul]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC][PATCH] flexible array implementation
On Tue, 21 Jul 2009 14:56:51 -0700
Dave Hansen <dave@linux.vnet.ibm.com> wrote:

> I've added some comments in the kerneldoc for the (newly renamed) alloc
> function:
>
> * The maximum number of elements is currently the number of elements
> * that can be stored in a page times the number of page pointers
> * that we can fit in the base structure or (using integer math):
> *
> * (PAGE_SIZE/element_size) * (PAGE_SIZE-8)/sizeof(void *)
> *
> * Here's a table showing example capacities. Note that the maximum
> * index that the get/put() functions is just nr_objects-1.
> *
> * Element size | Objects | Objects |
> * PAGE_SIZE=4k | 32-bit | 64-bit |
> * ----------------------------------|
> * 1 byte | 4186112 | 2093056 |
> * 2 bytes | 2093056 | 1046528 |
> * 3 bytes | 1395030 | 697515 |
> * 4 bytes | 1046528 | 523264 |
> * 32 bytes | 130816 | 65408 |
> * 33 bytes | 126728 | 63364 |
> * 2048 bytes | 2044 | 10228 |
> * 2049 bytes | 1022 | 511 |
> * void * | 1046528 | 261632 |

4-bytes on 32-bit and 8-bytes on 64-bit are the most interesting ones
(IMO). So what we're basically saying is "2MB on 64-bit".

I wonder if that's enough for known likely callers. Hopefully it is.



\
 
 \ /
  Last update: 2009-07-22 00:37    [from the cache]
©2003-2011 Jasper Spaans