2005-03-09 14:45:28

by Srinivas G.

[permalink] [raw]
Subject: badness in interruptible_sleep_on_timeout FC-3 (source code and Makefile attached)

Dear All,

I have developed a small module in Fedora Core 3 with 2.6.9-1.667 kernel
version. This module uses the interruptible_sleep_on_timeout call and
one proc entry in it. After inserting the module when I try to cat the
/proc entry I got the following messages on the screen.

<jit_init> invoked!
Badness in interruptible_sleep_on_timeout at kernel/sched.c:3005
[<02302989>] interruptible_sleep_on_timeout+0x5d/0x23a
[<0211b919>] default_wake_function+0x0/0xc
[<0aa120f9>] jit_read_queue+0x48/0x60 [badness_test]
[<021a515f>] proc_file_read+0xd1/0x1ee
[<0216554f>] vfs_read+0xb6/0xe2
[<02165762>] sys_read+0x3c/0x62
Badness in interruptible_sleep_on_timeout at kernel/sched.c:3005
[<02302989>] interruptible_sleep_on_timeout+0x5d/0x23a
[<0211b919>] default_wake_function+0x0/0xc
[<0aa120f9>] jit_read_queue+0x48/0x60 [badness_test]
[<021a515f>] proc_file_read+0xd1/0x1ee
[<0216554f>] vfs_read+0xb6/0xe2
[<02165762>] sys_read+0x3c/0x62

I tried with spinlocks also. Even though, I got the same messages.
Here is the source code for the *.c file and Makefile.

badness_test.c file
-------------------
#include <linux/config.h>
#include <linux/module.h>
#include <linux/sched.h>
#include <linux/kernel.h> /* printk() */
#include <linux/fs.h> /* everything... */
#include <linux/proc_fs.h>
#include <linux/errno.h> /* error codes */
#include <linux/types.h> /* size_t */

/*
* This module is a silly one: it only embeds short code fragments
* that show how time delays can be handled in the kernel.
*/

int jit_delay = 1; /* the default delay in read() */
char *jit_spoke = "Sample string to test various delay options.\n";

MODULE_PARM(jit_delay, "i");
MODULE_PARM(jit_spoke, "s");
MODULE_LICENSE("GPL");

#define LIMIT (PAGE_SIZE-128) /* don't print any more after this size */

static int jit_print(char *buf)
{
int len = 0;
len = sprintf(buf+len,"%s",jit_spoke);
return len;
}

int jit_read_queue(char *buf, char **start, off_t offset,
int len, int *eof, void *data)
{
wait_queue_head_t wait;

init_waitqueue_head (&wait);
interruptible_sleep_on_timeout(&wait, jit_delay*HZ);

*eof = 1;
return jit_print(buf);
}

int jit_init(void)
{
printk("<%s> invoked!\n",__FUNCTION__);

create_proc_read_entry("jitqueue", 0, NULL, jit_read_queue, NULL);

return 0; /* succeed */
}

void jit_cleanup(void)
{
printk("<%s> invoked!\n",__FUNCTION__);

remove_proc_entry ("jitqueue", 0);
}

module_init(jit_init);
module_exit(jit_cleanup);

-----------------------------------------------------------------------

Makefile
--------
#
# Makefile for badness_test.c file
#
KDIR:=/lib/modules/$(shell uname -r)/build
TRGT:=badness_testing
OBJS:=badness_test.o

obj-m += $(TRGT).o
$(TRGT)-objs := $(OBJS)

default:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
clean:
$(RM) .*.cmd *.mod.c *.ko *.o -r .tmp*

------------------------------------------------------------------------
---

Please give some advices on this issue.

Thanks and Regards,
Srinivas G


2005-03-09 16:04:52

by Arjan van de Ven

[permalink] [raw]
Subject: Re: badness in interruptible_sleep_on_timeout FC-3 (source code and Makefile attached)

On Wed, 2005-03-09 at 20:12 +0530, Srinivas G. wrote:
>
>
> I have developed a small module in Fedora Core 3 with 2.6.9-1.667
> kernel
> version. This module uses the interruptible_sleep_on_timeout call and

don't use interruptible_sleep_on_timeout() !!!!
really.

(and if you want to use the sleep_on() family of apis even when you
shouldn't, you HAVE to hold the big kernel lock for them!)