LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
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-18-2013, 09:11 AM   #1
aasthakm
LQ Newbie
 
Registered: Mar 2013
Posts: 3

Rep: Reputation: Disabled
cpu hung after doing insmod


Hello,

I am trying to write a block driver module in which I create a kernel thread for doing the actual job of servicing the I/O requests. I create the thread as part of module_init and make it wait until there is a request to be served. However, sometimes I see a cpu hung panic while doing insmod or right after doing insmod. The dump looks like the following:

Code:
kernel: [  159.893591] NMI backtrace for cpu 3
kernel: [  159.893591] CPU 3
kernel: [  159.893591] Call Trace:
kernel: [  159.893591]  [<ffffffff8159d776>] wait_for_common+0x26/0x150
kernel: [  159.893591]  [<ffffffff8159d908>] wait_for_completion_interruptible+0x18/0x30
kernel: [  159.893591]  [<ffffffffa00ed4be>] tsdd_worker_thread+0x4e/0x1e0 [tsdd]
kernel: [  159.893591]  [<ffffffff81075eee>] kthread+0x7e/0x90

[  280.033982] BUG: soft lockup - CPU#0 stuck for 22s! [blkid:1672]
[  280.034009] CPU 0
[  280.034027]
[  280.034032] Pid: 1672, comm: blkid Tainted: G        W 
[  280.034034] Process blkid (pid: 1672, threadinfo ffff880037ade000, task ffff880037a4a7c0)
[  280.034034] Stack:
[  280.034034]  0000000000000000 01ff880037adfbc0 ffff880037adfbc0 ffff880037ade000
[  280.034034]  ffff880037adffd8 000000000000101d ffff88011b1ed098 ffff880116ac0800
[  280.034034]  ffff8801050d1490 ffffffff8108d3e3 ffff88011b1ed2a0 ffffffff81183180
[  280.034034] Call Trace:
[  280.034034]  [<ffffffff8108d3e3>] smp_call_function+0x33/0x60
[  280.034034]  [<ffffffff8108d443>] on_each_cpu+0x33/0xa0
[  280.034034]  [<ffffffff81189e95>] __blkdev_put+0x185/0x1f0
[  280.034034]  [<ffffffff8115570a>] __fput+0xaa/0x200
[  280.034034]  [<ffffffff81151f3f>] filp_close+0x5f/0x90
[  280.034034]  [<ffffffff810562b6>] put_files_struct.part.11+0x76/0xe0
[  280.034034]  [<ffffffff8105800f>] do_exit+0x17f/0x450
[  280.034034]  [<ffffffff81058471>] do_group_exit+0x41/0xb0
[  280.034034]  [<ffffffff810695bc>] get_signal_to_deliver+0x20c/0x480
[  280.034034]  [<ffffffff81002775>] do_signal+0x35/0x110
[  280.034034]  [<ffffffff81002a05>] do_notify_resume+0x65/0x90
[  280.034034]  [<ffffffff815a75e0>] int_signal+0x12/0x17
rtkit-daemon[1468]: The canary thread is apparently starving. Taking action.
rtkit-daemon[1468]: Demoting known real-time threads.
rtkit-daemon[1468]: Demoted 0 threads.
udevd[432]: timeout: killing '/sbin/blkid -o udev -p /dev/tsdd0' [1672]
Below is a rough sketch of my code for module init and the worker thread:

Code:
struct completion *start = NULL;
struct completion *done = NULL;
struct request *sch_req;
my_module_init() {
	start = kzalloc();
	done = kzalloc();

	struct task_struct *task = kthread_create(my_worker_thread);
	if (task)
		wake_up_process(task);
	wait_for_completion(start);
	...
}

int my_worker_thread() {
	complete(start);
	allow_signal(SIGINT);
	while (!kthread_should_stop()) {
		if (wait_for_completion_interruptible(done)) {
			continue;
		}
		...
		while (sch_req) {
			// process request
			// check for new request
		}
		init_completion(done);
	}
}

// function which first gets the request and hands over to the worker thread
void transfer_request() {
	// fetch request
	served = 0;
	while (!served) {
		if (completion_done(done)) {
			continue;
		}
		sch_req = req;
		served = 1;
		complete(done);
	}
}
Could someone help me figure out what is wrong with this code that leads to the above mentioned panic?
Thanks in advance.

Last edited by aasthakm; 03-18-2013 at 09:12 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Computer Hung kokotx1981 Red Hat 3 12-07-2007 04:51 AM
Suse 9.3 Hung up sparton Suse/Novell 2 04-11-2006 03:41 PM
Kernel hung up pacman Linux - Software 2 02-11-2006 04:45 PM
Help with insmod. I have a problem with insmod. RJARRRPCGP Linux - Newbie 5 08-24-2004 08:23 PM
Hung up on boot Thanatos Linux - Newbie 1 07-28-2004 12:13 PM


All times are GMT -5. The time now is 07:16 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration