What do we need from our memory manager ?
- allocate/free areas of memory
- ability to kick areas
- ability to specify unkickable areas (pinned areas)
- no need for single-use chunks, better hide them internally in the drm and expose higher level functionality like "notifier"
- a way to allocate either VIDEO or AGP memory, or any of those as available
Choices of implementation
- we only allocate (and optionally map) page-aligned chunks and have offsets in pages
- this leaves room for AGP memory allocation GL extensions, since this makes it possible to map areas into the process space selectively
- this is much more future-proof than using 32 bits for memory sizes/offsets
- this ensures a cache-friendly behaviour of the memory blocks
- the DDX can use a proxy memory manager to avoid doing lots of small allocations (some kind of slab allocator). this also avoids a trip to the kernel for all those small allocations
- each memory chunk must have its usage tracked for use by the memory eviction policy. that information must find its way back to the kernel somehow
- use a bitmap allocator, which seems faster under load
- each allocation is a structure containing :
- int flags (can be FRAMEBUFFER, AGP, PINNED, MAPPED_TO_USER,...)
- int offset (in pages)
- int size (in pages)
- the filp of the owner
Possible improvements
- try to use a linked list of blocks instead of a bitmap allocator
- try to put large areas at the beggining, small at the end. that will help avoiding fragmentation (would be messy with a linked list, though)

