LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 12-20-2010, 01:48 AM   #1
a.murali
LQ Newbie
 
Registered: Dec 2010
Posts: 5

Rep: Reputation: 0
Unable to insert my kernal module


Hi, am new to kernalprogramming.plz help me.I am trying to insert my kernal module with "/sbin/insmod mymodule", am getting the following log...

Dec 21 04:02:40 localhost kernel: Node 0 Normal: empty
Dec 21 04:02:40 localhost kernel: Node 0 HighMem: empty
Dec 21 04:02:40 localhost kernel: Swap cache: add 96032, delete 90864, find 31257/35546, race 0+2
Dec 21 04:02:40 localhost kernel: Free swap = 1969796kB
Dec 21 04:02:40 localhost kernel: Total swap = 2031608kB
Dec 21 04:02:40 localhost kernel: Free swap: 1969796kB
Dec 21 04:02:40 localhost kernel: 260016 pages of RAM
Dec 21 04:02:40 localhost kernel: 41719 reserved pages
Dec 21 04:02:40 localhost kernel: 136610 pages shared
Dec 21 04:02:40 localhost kernel: 5170 pages swap cached
Dec 21 04:02:40 localhost kernel: NFNL Unable to initialize slot 2
Dec 21 04:02:40 localhost kernel: insmod: page allocation failure. order:9, mode:0xd0
Dec 21 04:02:40 localhost kernel:
Dec 21 04:02:40 localhost kernel: Call Trace:
Dec 21 04:02:40 localhost kernel: [<ffffffff8000f0e1>] __alloc_pages+0x29b/0x2b4
Dec 21 04:02:40 localhost kernel: [<ffffffff8003bba6>] __get_free_pages+0xe/0x71
Dec 21 04:02:40 localhost kernel: [<ffffffff88580330>] :btg:allocateRule+0x1c/0x1a0
Dec 21 04:02:40 localhost kernel: [<ffffffff881b4055>] :btg:btg_nf_init+0x55/0x148
Dec 21 04:02:40 localhost kernel: [<ffffffff800a29da>] sys_init_module+0x16a6/0x1857
Dec 21 04:02:40 localhost kernel: [<ffffffff8000c1a5>] _atomic_dec_and_lock+0x39/0x57
Dec 21 04:02:40 localhost kernel: [<ffffffff8005b28d>] tracesys+0xd5/0xe0
Dec 21 04:02:40 localhost kernel:
Dec 21 04:02:40 localhost kernel: Mem-info:
Dec 21 04:02:40 localhost kernel: Node 0 DMA per-cpu:
 
Old 12-20-2010, 02:28 AM   #2
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
The command is
Code:
insmod mymodule.ko
, 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?
 
Old 12-20-2010, 03:46 AM   #3
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
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.
..

Last edited by knudfl; 12-20-2010 at 03:49 AM.
 
Old 12-20-2010, 04:59 AM   #4
Deep Narayan Dubey
LQ Newbie
 
Registered: Dec 2010
Location: Allahabad, India
Posts: 11

Rep: Reputation: 8
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.
 
Old 12-21-2010, 12:04 AM   #5
a.murali
LQ Newbie
 
Registered: Dec 2010
Posts: 5

Original Poster
Rep: Reputation: 0
Re. unable to insert kernal module

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;
}
}
 
Old 12-21-2010, 03:53 AM   #6
Deep Narayan Dubey
LQ Newbie
 
Registered: Dec 2010
Location: Allahabad, India
Posts: 11

Rep: Reputation: 8
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.
 
Old 01-27-2011, 04:56 AM   #7
a.murali
LQ Newbie
 
Registered: Dec 2010
Posts: 5

Original Poster
Rep: Reputation: 0
Difference between /sbin/insmod and insmod

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...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Invalid module format. Unable to insert tg3.ko!! Please help ravichandran_swamy Linux - Newbie 4 01-29-2009 06:35 AM
Unable to insert lodable module pathak_ashish Linux - Newbie 1 01-13-2008 07:19 AM
unable to insert oss module linuxmandrake Debian 1 09-30-2005 06:29 PM
Cisco VPN Client unable to insert kernel module cuco76 Linux - Networking 2 04-14-2005 03:36 PM
Can't insert module into kernel swamysk Linux - Newbie 14 08-22-2003 05:27 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 12:06 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration