Problem in using Kernel Timers: Sleeping function called from invalid context

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

 



Hi i am facing the following problem while running my kernel module:

The code is:
--------------
struct timer_list myTimer;
void gen_sig(void){
    struct task_struct *p=NULL;
    p=kmalloc(sizeof(struct task_struct), GFP_KERNEL);

    p = find_task_by_pid(pid); /*Received from a user program through ioctl()*/

    if (p == NULL) {
        printk("Unable to find task for process id %d\n",pid);
        return;
    }

    if ( send_sig(SIG_NO,p,0) != 0 ) {     /* SIG_NO=51 */
        printk("Sending signal failed . . .\n");
}

    myTimer.function = (void*)gen_sig;
    myTimer.expires = jiffies + TIMER_REFRESH_SUBSCRIBED_TABLE;
    add_timer (&myTimer);
        return;
}    
static int watchdog_init (void) {
     myTimer.function = (void*)gen_sig;
     myTimer.expires = TIMER_REFRESH_SUBSCRIBED_TABLE;  /*Value is 1*/
     add_timer (&myTimer);
return 0;
 }
int init_module(void){
    init_timer (&myTimer);
    watchdog_init();
 }

The code is working fine but it's giving the following message in "dmesg"
----------------------------------------------------------------------
Debug: sleeping function called from invalid context at mm/slab.c:2055
in_atomic():1, irqs_disabled():0
 [<c011d475>] __might_sleep+0x95/0xb0
 [<c0158820>] kmem_cache_alloc+0x50/0x60
 [<d02bc000>] gen_sig+0x0/0xc0 [sighnd]
 [<d02bc012>] generate_signal+0x12/0xc0 [sighnd]
 [<c013f0b0>] autoremove_wake_function+0x0/0x50
 [<c012c57c>] run_timer_softirq+0xfc/0x3e0
 [<c014a592>] handle_IRQ_event+0x32/0x70
 [<c0179454>] vfs_read+0xe4/0x130
 [<c0127842>] __do_softirq+0x42/0x90
 [<c01278b7>] do_softirq+0x27/0x30
 [<c010568b>] do_IRQ+0x3b/0x70
 [<c0103ae2>] common_interrupt+0x1a/0x20
---------------------------------------------------------------------
This message comes on repeatedly and after some times the module hangs up.

Same error occurs for every function that is being called through the timer.
Is it wrong to call functions through timer in kernel?. Please give me suggestions to solve this problem.
Thanks
Ganesh
ganesh.p7[at]gmail.com


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux