Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Memory allocation during linux booting?

I have tried to search this topic on google and this site but I can't find a proper answer.

I am trying to allocate a big continuous block of memory (a few MB) at a set physical address during the Linux booting process. But I am still not clear where I should place my "alloc_bootmem" function. I am running Linux on an ARM processor.

  1. AFAIK, there is a way to create a driver which contains a call to "alloc_bootmem" and then compile that driver directly to into the kernel.

  2. Another method is to add "alloc_bootmem" somewhere in the Linux kernel source.

  3. The last method that I think exists is to create a settings file like boot.rc?(not sure) so that during booting Linux will reserve the memory I want allocated.

If there is a clear way or a link to an answer to this question, I really would appreciate everyone's help. The basic question is "where should I call "alloc_bootmem" so it will work during booting?"

Thanks, Shahril

like image 497
Shahril Avatar asked Sep 04 '13 10:09

Shahril


1 Answers

Take a look at: http://lwn.net/Kernel/LDD3/ chapter 8 it explains the memory allocation for early booting stages.

Further information about booting memory allocation can be found here:

https://www.kernel.org/doc/gorman/html/understand/understand022.html

This feature is used for allocating large memory chunks during the system boot up and it uses the physical rather than virtual memory. After MMU is up and running there is no possible way of accessing the memory AFAIK

If you are looking for a large continues memory allocation you should probably use different allocator take a look at:

http://lwn.net/Articles/396702/

like image 118
cerkiewny Avatar answered Sep 16 '22 15:09

cerkiewny