Skip to contentSkip to conversation

Idea to improve the performance of the Kernel Memory Allocation

DISCUSSION Guilherme Carvalho 2 participants 2 messages May 15, 2000 Memory management

lore
Share & tools
lore
#0 lore raw

Hi,

I had an idea to improve the performance of the Kernel Memory Allocation...
If I am right, the buddy allocation algorithm first searches for blocks of pages of the size requested and follows the chain of free pages that is queued on the list element of the the free_area data structure. If no blocks of pages of the requested size are free, blocks of the next size are looked for...

free_area:

|  4096  | -> |  8  | -> | 1024  | -> | 8192  | -> | 2  | -> | 4  | -> |
2  | -> | 256  | -> | 512  | -> | 4  | -> | 8  | -> | 16  | ->

in this case, if we request 32 pages, the algorithm will scan the chain 4 times to find the right block.
I think this chain isn't the best structure to do it.

the idea is to make a tree of chains as it is in the attach (arv-list.jpg).
this tree should be an AVL tree for better performance.

Each element of the tree would be an chain
Each element of the chain would be

Struct free_area_struct {
struct page *next;
struct page *prev; // <- Free area element
unsigned int *map;
unsigned long count;
// +
struct page *next_in_chain; // <- pointer to the next free
area with the same size
};

the old pointers would remain because the deallocation process need them, to recombine them in larger blocks.

I am a linux code beginner, so I don't know how to put it on linux (and keep it working too).
Are Anyone interested in try it?

Guilherme Carvalho

#1 lore raw

Hi,

Quoted 4 lines · Guilherme Carvalho

If I am right, the buddy allocation algorithm first searches for blocks of pages of the size requested and follows the chain of free pages that is queued on the list element of the the free_area data structure.

No. The free pages are held on linked lists, one list for each size. We never have to follow free page chains looking for pages. We just allocate the first available free 4k page, and if no such page exists, we find an 8k page, split it, and return one of the 4k subpages (the other one is placed on the 4k free page list).

We never have to walk over more than one page of any given size.

--Stephen
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/