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 03-23-2011, 04:12 AM   #1
Sakthi_Selvam
LQ Newbie
 
Registered: Mar 2011
Posts: 4

Rep: Reputation: 0
Unable to remove kernel module


Need your assistance:

Currently I am using Wind River Linux distribution OS with kernel version 2.6.27.39 and Wind River version pne-3. After loading of my kernel module, I found it was permanent in the kernel using lsmod (for ex see below Ref 1). When I tried to remove, it was displaying as “ERROR: Removing 'hsl_module': Device or resource busy”. For your information, the same module is working fine with the Wind River pne-2 Linux Distribution OS with kernel version 2.6.21.

From the kernel source, I came to know that only possibility of showing permanent is “if there is non-availability of cleanup_module with the availability of init_module”.

But in my case, cleanup module also available in memory, after loading the module. I used to check using the file in /proc/kallsyms for the availability of cleanup module in memory.

Thanks for reading. Prompt reply is expected to identify the root cause.

Ref 1:
Module Size Used by
hsl_module 530454 0 [permanent]

Regards,
Sakthi
 
Old 03-23-2011, 09:21 PM   #2
quanta
Member
 
Registered: Aug 2007
Location: Vietnam
Distribution: RedHat based, Debian based, Slackware, Gentoo
Posts: 724

Rep: Reputation: 101Reputation: 101
Please give us the output of `lsmod | grep hsl`? I think there are some kernel modules depend on it.
 
Old 03-24-2011, 01:41 PM   #3
kalloc
LQ Newbie
 
Registered: Feb 2011
Posts: 20

Rep: Reputation: 0
ENABLE force unloadiung in kernel and recompile ur kernel. use make menuconfig to go this option.
Quote:
Originally Posted by quanta View Post
Please give us the output of `lsmod | grep hsl`? I think there are some kernel modules depend on it.
 
Old 03-25-2011, 12:19 AM   #4
Sakthi_Selvam
LQ Newbie
 
Registered: Mar 2011
Posts: 4

Original Poster
Rep: Reputation: 0
Doubting of compiler flags regarding memory optimizations

hsl module has some dependency on another modules. But, I am sure that there is no problem with dependency because I have done a sample module having the same instructions used in hsl init and cleanup module and its working fine. Currently I have doubts on Makefile and the compiler flags used. I had the thought that some optimization was done during compilation which lead to discarding of the cleanup module from the memory.
 
Old 04-01-2011, 03:09 AM   #5
Sakthi_Selvam
LQ Newbie
 
Registered: Mar 2011
Posts: 4

Original Poster
Rep: Reputation: 0
Identified the reason but not solution still - need your assistance

After more debugging, I have identified root cause for the problem. The problem is, in the executable file(.ko) created, does not have ".rela.init.text and .rela.exit.text" in section headers which are responsible for starting address of init module and cleanup module correspondingly, used by the kernel for linking and relocation during loading of kernel module. But still I am searching for solution because I don't know the exact flag to be specified during compilation to get those section headers.

For your information, I have used the command 'readelf -a <file>.ko' to get the headers and symbol table of the executable created.
 
Old 04-17-2011, 01:06 AM   #6
Sakthi_Selvam
LQ Newbie
 
Registered: Mar 2011
Posts: 4

Original Poster
Rep: Reputation: 0
Define 'USE_IMMEDIATE' to get rid of this permanent issue

Thanks for your suggestion. Finally, I identified the solution for the permanent issued I faced after loading my kernel module. The solution is the kernel macro; 'USE_IMMEDIATE' has to be defined (to be given as -DUSE_IMMEDIATE along with compiler flags) during compilation of my module. Actually, I don't know much deep about the usage of this kernel macro and how it resolves the issue, but one thing I came to know that it was used during module relocation while inserting the module. If anyone help me to get know much about it, then it will be fine. Also, for your information, I have used my own Makefile for compilation of kernel loadable modules. So, I have to add myself this macro to get rid of this permanent issue. Another fine solution is, you can make use of kernel build Makefile itself (if linux kernel version is above 2.4) to build your kernel loadable modules. Because it itself include all default macros and flags needed for compilation of your module. I have specified below the sample Makefile for compiling kernel loadable modules with kernel build Makefile.
Reference:
obj-m += hello.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean

Regards,
Sakthi Selvam
 
  


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
How do you permanently remove a module from the kernel? edomingox Linux - Server 14 06-15-2010 06:29 AM
Unable to remove module from Ubuntu 8.04 JockVSJock Ubuntu 4 07-20-2009 04:05 PM
how to remove a module from kernel htamayo Debian 1 06-18-2008 11:31 AM
unable to remove kernel module........ dogslayer Linux - Software 6 03-27-2006 12:26 AM
How to remove module from kernel without recompile? Stoic Linux - Software 10 09-23-2003 06:17 PM

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

All times are GMT -5. The time now is 09:17 AM.

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