I attached a test module to reproduce this bug. Does I miss something in my code or is there a bug?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Unable to handle kernel paging request at kthread_should_stop

Hello,

In a kernel module which used to work on previous kernel versions I tried to
start a kernel thread (kthread). In the threads mainloop I poll the method
kthread_should_stop which seems to fail.

[   65.531778] BUG: unable to handle kernel paging request at fffffffc
[   65.532011] IP: [<c103bf7c>] kthread_should_stop+0x10/0x14
[   65.532011] *pde = 01551067 *pte = 00000000
[   65.532011] Oops: 0000 [#1] SMP
[   65.532011] last sysfs file: /sys/devices/virtual/dmi/id/board_asset_tag
[   65.532011] Modules linked in: testmod [last unloaded: scsi_wait_scan]
[   65.532011]
[   65.532011] Pid: 3392, comm: test-module Not tainted 2.6.33.2-rt13 #1 E243/
E243
[   65.532011] EIP: 0060:[<c103bf7c>] EFLAGS: 00010206 CPU: 0
[   65.532011] EIP is at kthread_should_stop+0x10/0x14
[   65.532011] EAX: 00000000 EBX: dd9e8430 ECX: 00006161 EDX: 00000286
[   65.532011] ESI: 00000000 EDI: e00d8000 EBP: dc8e1fbc ESP: dc8e1fb0
[   65.532011]  DS: 007b ES: 007b FS: 00d8 GS: 0000 SS: 0068 preempt:00000000
[   65.532011] Process test-module (pid: 3392, ti=dc8e0000 task=dd9e8430
task.ti=dc8e0000)
[   65.535828] Stack:
[   65.535828]  e00d808c 00000000 d3945f50 dc8e1fe4 c103bfe1 00000000 00000001
00000101
[   65.535828] <0> dc8e1fd0 dc8e1fd0 00000000 c103bf80 d3945f44 00000000
c1002e36 00000000
[   65.535828] <0> 00000000 00000000 00000000 00000000
[   65.535828] Call Trace:
[   65.535828]  [<e00d808c>] ? runloop+0x8c/0xa4 [testmod]
[   65.535828]  [<c103bfe1>] ? kthread+0x61/0x66
[   65.535828]  [<c103bf80>] ? kthread+0x0/0x66
[   65.535828]  [<c1002e36>] ? kernel_thread_helper+0x6/0x10
[ 65.535828] Code: 8b 47 18 01 46 10 8b 55 f0 8d 47 08 e8 b1 a9 32 00 8d 65 f4 5b 5e 5f 5d c3 90 90 55 64 a1 7c 34 54 c1 8b 80 8c 01 00 00 89 e5 5d <8b> 40 fc
c3 55 ba a4 f6 59 c1 89 e5 57 56 53 89 c3 83 ec 14 8b
[   65.535828] EIP: [<c103bf7c>] kthread_should_stop+0x10/0x14 SS:ESP
0068:dc8e1fb0
[   65.535828] CR2: 00000000fffffffc
[   65.535828] ---[ end trace 6b0fc9b05d23e589 ]---

My platform is an Intel Atom CPU N270.
# uname -a
Linux systemmanager 2.6.33.2-rt13 #1 SMP Sat Apr 10 00:12:20 CEST 2010 i686
GNU/Linux

I attached a test module to reproduce this bug.  Does I miss something in my
code or is there a bug?

Thanks for any help

--
Stefan Agner


----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
#include <linux/module.h>
#include <linux/kthread.h>
#include <linux/hrtimer.h>

#define THREAD_PRIORITY (80)
#define THREAD_SCHEDULER SCHED_FIFO
#define MODULE_NAME "test-module"
#define KLOG_PREFIX MODULE_NAME ": "

struct task_struct *thread;
static ktime_t thread_next;
static ktime_t now;

/*
 * Threaded Runloop
 */
static int runloop(void *unused)
{

	int ret;

	/* Daemonize */
	daemonize(MODULE_NAME);

	/* Allow SIGTERM signal */
	allow_signal(SIGTERM);

	/* Calculate first shot */
	now = ktime_get();
	thread_next = ktime_add_us(now, 500);

	do {
		set_current_state(TASK_UNINTERRUPTIBLE);
		ret = schedule_hrtimeout(&thread_next, HRTIMER_MODE_ABS);
		if(ret == -EINTR)
		{
			printk(KERN_INFO KLOG_PREFIX "Signal received\n");
			continue;
		}

		thread_next = ktime_add_us(thread_next, 500);
	} while (!kthread_should_stop());

	printk(KERN_INFO KLOG_PREFIX "Thread exited\n");
	return 0;
}

int __init init_test_module(void)
{
	struct sched_param param = { .sched_priority = THREAD_PRIORITY };

	/* Kernel Thread erzeugen */
	if(thread == NULL)
		thread = kthread_create((void *)&runloop, NULL, "testthread");

	// Realtime scheduler
	sched_setscheduler(thread, THREAD_SCHEDULER, &param);
	wake_up_process(thread);
	return 0;
}

void __exit cleanup_test_module(void)
{
        if(thread != NULL)
                kthread_stop(thread);
        thread = NULL;
}

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Stefan Agner <stefan@xxxxxxxx");
MODULE_DESCRIPTION("kthread test module");

module_init(init_test_module);
module_exit(cleanup_test_module);

Attachment: Makefile
Description: Binary data

Attachment: .config
Description: Binary data


[Index of Archives]     [RT Stable]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux