Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Sarvani_C_
Beginner
141 Views

LKM cleanup_module() not called

Hi,

We are cross-building a loadable kernel module for Wind River Linux (gcc 4.4.1).  We can modprobe (load) our module, but it's marked as permanent.  We can remove the module (rmmod -f) and lsmod will no longer list it, but in that case our cleanup_module() function is not called.  We tried several possible fixes mentioned in the tech forums such as defining CC_HAVE_GOTO_ASM and USE_IMMEDIATE.  Modinfo vermagic shows:

   2.6.34.10-WR4.3.0.0_standard SMP preempt mod_unload

The only impact of this seems to be:

  -when we load the module again, the major assigned is decremented; i.e. the system appears to have "lost" an available major number

  -a kfree() that we need is not being done

For debug purposes, is there any other impact?  Can we continue to test the module, unload, rebuild, reload?  For production the permanent marking would need to be fixed, but that's not currently a concern.

--
Thanks!

Regards,
Sarvani Chadalapaka
HPC Systems Engineer
Signalogic Inc.

0 Kudos
4 Replies
Yang_W_Intel
Employee
141 Views

cleanup_module function should be called when your rmmod the module. Did you try the hello_world kernel module for your develop environment and see if it works? http://en.wikibooks.org/wiki/The_Linux_Kernel/Modules . This could help to narrow down if it is your specific module issue or the OS kernel issue. You may add printk in your source and use "dmesg" command to check the output to see if a specific function is called.

thanks.

-Yang

 

 

 

Sukruth_H_Intel
Employee
141 Views

Hi,

     As Yang suggested the rmmod has to call the cleanup module.

You may also refer to this article for the solution :- http://pritambankar.blogspot.com/2012/10/solution-to-problem-of-module-getting.html . Please let us know if this resolves the issue of permanent loading of kernel module.

Regarding your question about the debugging, I think this should not affect debugging using ITP-XDP, You may first need to load the xdbntf.ko module and then the add the module of interest in the watchlist. Now you should be able to "insmod " and see the kernel module being loaded in the debugger watchlist.

You may follow the video here :- https://software.intel.com/en-us/videos/kernel-module-debug-on-minnowboard-max .

Please do let us know if you have any issues in debugging using XDB/Intel JTAG debugger.

Regards,

Sukruth H V

Sarvani_C_
Beginner
141 Views

Hi Yang,

Thank you for your response. We have not tried hello world kernel module yet. However, we added printks in our source code to verify that rmmod is not being called.  Also we have run our driver on other Linux (e.g. Ubuntu) to verify the module open and cleanup functions are called, and that we can repeatedly modprobe and rmmod our driver.

--
Thanks!

Regards,
Sarvani Chadalapaka
HPC Systems Engineer
Signalogic Inc.

 

 

Sarvani_C_
Beginner
141 Views

Hi Sukruth,

Thank you for your response. We tried defining CC_HAVE_ASM_GOTO flag in our Make file as I already mentioned in my thread.

--
Thanks!

Regards,
Sarvani Chadalapaka
HPC Systems Engineer
Signalogic Inc.

Reply