rk: proc: fix slub warning when call setup_irq
author黄涛 <huangtao@rock-chips.com>
Thu, 20 Feb 2014 11:39:44 +0000 (19:39 +0800)
committer黄涛 <huangtao@rock-chips.com>
Thu, 20 Feb 2014 12:07:14 +0000 (20:07 +0800)
BUG: sleeping function called from invalid context at mm/slub.c:926
in_atomic(): 1, irqs_disabled(): 128, pid: 0, name: swapper/3
INFO: lockdep is turned off.
irq event stamp: 45900
hardirqs last  enabled at (45899): [<c009fe18>] rcu_preempt_note_context_switch+0x174/0x18c
hardirqs last disabled at (45900): [<c0605a64>] _raw_spin_lock_irq+0x18/0x50
softirqs last  enabled at (45744): [<c002c424>] irq_enter+0x50/0x78
softirqs last disabled at (45743): [<c002c418>] irq_enter+0x44/0x78
CPU: 3 PID: 0 Comm: swapper/3 Tainted: G           O 3.10.0 #405
[<c0013fe8>] (unwind_backtrace+0x0/0xe0) from [<c0011930>] (show_stack+0x10/0x14)
[<c0011930>] (show_stack+0x10/0x14) from [<c00fa3dc>] (__kmalloc+0x70/0x228)
[<c00fa3dc>] (__kmalloc+0x70/0x228) from [<c0148d2c>] (__proc_create+0x94/0xf0)
[<c0148d2c>] (__proc_create+0x94/0xf0) from [<c0149000>] (proc_mkdir_data+0x30/0x74)
[<c0149000>] (proc_mkdir_data+0x30/0x74) from [<c009babc>] (register_handler_proc+0xe8/0x114)
[<c009babc>] (register_handler_proc+0xe8/0x114) from [<c00982b0>] (__setup_irq+0x334/0x3fc)
[<c00982b0>] (__setup_irq+0x334/0x3fc) from [<c0098558>] (setup_irq+0x58/0x80)
[<c0098558>] (setup_irq+0x58/0x80) from [<c05ef51c>] (rk_timer_init_clockevent+0x98/0xcc)
[<c05ef51c>] (rk_timer_init_clockevent+0x98/0xcc) from [<c05ed0dc>] (percpu_timer_setup+0x54/0xa8)
[<c05ed0dc>] (percpu_timer_setup+0x54/0xa8) from [<c05ed4d8>] (secondary_start_kernel+0x128/0x160)
[<c05ed4d8>] (secondary_start_kernel+0x128/0x160) from [<600081bc>] (0x600081bc)

fs/proc/generic.c

index a2596afffae6dad430f8cb2727628e162c567876..7adb3272a3e7627d1f2268c9e8c7810aa9bbc76e 100644 (file)
@@ -8,6 +8,7 @@
  * Copyright (C) 1997 Theodore Ts'o
  */
 
+#include <linux/hardirq.h>
 #include <linux/errno.h>
 #include <linux/time.h>
 #include <linux/proc_fs.h>
@@ -134,7 +135,7 @@ int proc_alloc_inum(unsigned int *inum)
        int error;
 
 retry:
-       if (!ida_pre_get(&proc_inum_ida, GFP_KERNEL))
+       if (!ida_pre_get(&proc_inum_ida, (in_atomic() || irqs_disabled()) ? GFP_ATOMIC : GFP_KERNEL))
                return -ENOMEM;
 
        spin_lock_irq(&proc_inum_lock);
@@ -387,7 +388,7 @@ static struct proc_dir_entry *__proc_create(struct proc_dir_entry **parent,
 
        len = strlen(fn);
 
-       ent = kzalloc(sizeof(struct proc_dir_entry) + len + 1, GFP_KERNEL);
+       ent = kzalloc(sizeof(struct proc_dir_entry) + len + 1, (in_atomic() || irqs_disabled()) ? GFP_ATOMIC : GFP_KERNEL);
        if (!ent)
                goto out;