Re: [RFC][PATCH] flexible array implementation

From: Andrew Morton
Date: Tue Jul 21 2009 - 18:34:14 EST


On Tue, 21 Jul 2009 14:56:51 -0700
Dave Hansen <dave@xxxxxxxxxxxxxxxxxx> 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.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/