OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Dec 12, 2019 11:07 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: What heap algorithm is Linux using?
PostPosted: Thu Apr 04, 2019 2:13 am 
Offline
Member
Member

Joined: Mon Jun 04, 2018 8:10 am
Posts: 44
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


Top
 Profile  
 
 Post subject: Re: What heap algorithm is Linux using?
PostPosted: Thu Apr 04, 2019 3:03 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 3593
Location: Chichester, UK
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


Top
 Profile  
 
 Post subject: Re: What heap algorithm is Linux using?
PostPosted: Thu Apr 04, 2019 4:01 am 
Offline
Member
Member
User avatar

Joined: Thu Oct 13, 2016 4:55 pm
Posts: 416
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/understand/understand009.html
https://en.wikipedia.org/wiki/Buddy_memory_allocation
https://www.kernel.org/doc/gorman/html/understand/understand011.html
https://en.wikipedia.org/wiki/Slab_allocation

Cheers,
bzt


Top
 Profile  
 
 Post subject: Re: What heap algorithm is Linux using?
PostPosted: Thu Apr 04, 2019 7:45 am 
Offline
Member
Member
User avatar

Joined: Thu Nov 16, 2006 12:01 pm
Posts: 7431
Location: Germany
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.


Top
 Profile  
 
 Post subject: Re: What heap algorithm is Linux using?
PostPosted: Thu Apr 04, 2019 8:48 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 3593
Location: Chichester, UK
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".


Top
 Profile  
 
 Post subject: Re: What heap algorithm is Linux using?
PostPosted: Thu Apr 04, 2019 2:39 pm 
Offline
Member
Member

Joined: Mon Jun 04, 2018 8:10 am
Posts: 44
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 !


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: reapersms and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group