What heap algorithm is Linux using?

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
Post Reply
LIC
Member
Member
Posts: 44
Joined: Mon Jun 04, 2018 8:10 am
Libera.chat IRC: lic

What heap algorithm is Linux using?

Post by LIC »

I have seen that there are several kernel heap algorithms with their pros and cons. What about Linux? What is the heap algorithm that the Linux Kernel is using?

Thanks for your answers
User avatar
iansjack
Member
Member
Posts: 4685
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: What heap algorithm is Linux using?

Post by iansjack »

If only the source code wad available to answer this sort of question.

If only someone had written a book describing the workings of the Linux kernel.

Seriously - without wishing to appear rude - there is a wealth of information available on the web and in print about the Linux kernel. You will learn far more by doing your own research than by asking someone else to do it for you. Amongst other publications let me recommend: https://www.amazon.com/Professional-Ker ... 0470343435
User avatar
bzt
Member
Member
Posts: 1584
Joined: Thu Oct 13, 2016 4:55 pm
Contact:

Re: What heap algorithm is Linux using?

Post by bzt »

Hi
LIC wrote:I have seen that there are several kernel heap algorithms with their pros and cons. What about Linux? What is the heap algorithm that the Linux Kernel is using?

Thanks for your answers
A quick google search reveals that Linux is using the buddy allocator for page allocation and slab allocator for heap, which algorithm originates from Solaris' allocator.

https://www.kernel.org/doc/gorman/html/ ... nd009.html
https://en.wikipedia.org/wiki/Buddy_memory_allocation
https://www.kernel.org/doc/gorman/html/ ... nd011.html
https://en.wikipedia.org/wiki/Slab_allocation

Cheers,
bzt
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: What heap algorithm is Linux using?

Post by Solar »

iansjack wrote:If only the source code wad available to answer this sort of question.
Source code tells you lots about the "how". Unless there are comments, figuring out the "what" can be somewhat of a stretch, especially in a code base of that magnitude. And even then you usually get the "what" on a rather too-fine-grained level. Usually we rely on documentation to tell us the high-level "what" and "why".
Every good solution is obvious once you've found it.
User avatar
iansjack
Member
Member
Posts: 4685
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: What heap algorithm is Linux using?

Post by iansjack »

Solar wrote:
iansjack wrote:If only the source code wad available to answer this sort of question.
Source code tells you lots about the "how". Unless there are comments, figuring out the "what" can be somewhat of a stretch, especially in a code base of that magnitude. And even then you usually get the "what" on a rather too-fine-grained level. Usually we rely on documentation to tell us the high-level "what" and "why".
Which - of course - is why I also recommended books.

A combination of the two is - IMO - better than relying upon inaccurate generalisations such as " it uses the buddy allocator".
LIC
Member
Member
Posts: 44
Joined: Mon Jun 04, 2018 8:10 am
Libera.chat IRC: lic

Re: What heap algorithm is Linux using?

Post by LIC »

Thank you for your replies, I tried to check the answer by myself with the Linux kernel code but with all the files, I could not find out a clue on where to look for this part of the kernel first.

Thank you for the links !
Post Reply