Linux - KernelThis forum is for all discussion relating to the Linux kernel.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
, you don't have to write /sbin etc. with insmod and this has to be done from Root and before that you need to run make on the makefile which you have written! Does make result in successful compilation?
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,516
Rep:
Welcome to LQ.
1) su , 2) /sbin/insmode ( or better /sbin/modprobe )
Please read 'man insmode' and 'man modprobe'.
'insmod' is a basic primitive tool.
'modprobe' : The advanced tool, takes also care of dependencies.
I.e. if you depend on some other module to be inserted,
insmod will not work.
In Redhat ( Fedora, CentOS, etc.) based OS, /usr/sbin , /sbin/
are not in the path for users.
But 'su -' ( su, space, hyphen ) will get you "roots path".
..
"" Dec 21 04:02:40 localhost kernel:
insmod: page allocation failure. order:9, mode:0xd0 ""
Sorry, I don't know, what your error means.
..
Hi,
Viewing the above error I think that you are trying to allocate free pages from the kernel module and you are getting error there. If you could show the code, it would be easy to say about the error.
And using "su -" command you switch to the root user from the login so the path variable is set as of the root user and you don't have to give the absolute path.
Hi all,
thanks for ur replies, am doing kernal insertion as root user and this module doesn't depend on any other module.And my OS is Redhad linux.From the log i observed that, while inserting the kernal module, it is unable to allocate pages which am doing in my code... the code is...
for(i=0; i<(TABLESZ/SLOT); i++)
{
arrMasterNode[i] = (NODE)__get_free_pages(GFP_KERNEL,9);
if(!arrMasterNode[i])
{
printk(KERN_INFO "NFNL Unable to initialize slot %ld\n",i);
status = 0;
}
else
{
p = virt_to_page(arrMasterNode[i]);
for(j=0; j<512; j++)
{
SetPageReserved(p);
p++;
}
p = NULL;
}
}
Hi,
You are trying to allocate 2^9 pages and iterating over that using get_free_pages() from the kernel. This function internally calls alloc_pages which calls alloc_pages_current(). This function checks for the current process memory policy. If it is not set, it uses default policy. Using that policy, it calls alloc_pages_nodemask() which is called when Memory Interleaving is not set in memory policy. It first tries to allocate pages from the free list of pages and then if it does not find free pages, it calls __alloc_pages_slowpath(). This function agains tries to allocate pages by swapping out some pages. If does not succeeds in allocating pages, it prints the process name, order(2^9 pages) and mode(policy) and shows the memory.
You should try to allocate pages in small chunks and then check at which limit you are getting error.
Hi All,
Thanks for your replies. I have one doubt, even it is a stupid one, i want to know indetail.Is there any difference between in executing the command as 1. #/sbin/insmod, 2. #insmod. While inserting my kernalmodule(which includes allocating huge memroy) using 1st command, it is working fine(i tried 4-5 times), where as in 2nd case ($insmod), for while inserting 2nd time, i observed the log saying failed(failed to allocate memory). Please help me...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.