[PATCH linux-next] ipc: Avoid sleeping inside RCU.

From: Tetsuo Handa
Date: Mon Jun 17 2013 - 07:55:34 EST


I got this.

===============================
[ INFO: suspicious RCU usage. ]
3.10.0-rc6-next-20130617 #7 Not tainted
-------------------------------
include/linux/rcupdate.h:475 Illegal context switch in RCU read-side critical section!

other info that might help us debug this:


rcu_scheduler_active = 1, debug_locks = 1
2 locks held by udevd/1909:
#0: (&ids->rw_mutex){+.+.+.}, at: [<c038c4b5>] ipcget+0x45/0x70
#1: (rcu_read_lock){.+.+..}, at: [<c038df60>] rcu_read_lock+0x0/0x80

stack backtrace:
CPU: 0 PID: 1909 Comm: udevd Not tainted 3.10.0-rc6-next-20130617 #7
Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 08/15/2008
00000001 da591e94 c0677931 00000001 da591ebc c0199606 c07f690d c07f83fa
00000001 00000001 c07e7904 00000000 000001a8 c081e5f7 da591ee4 c0176231
00000246 00000002 00000001 00000000 00000000 000000d0 deee0f0c ffffffe4
Call Trace:
[<c0677931>] dump_stack+0x4c/0x6b
[<c0199606>] lockdep_rcu_suspicious+0xc6/0x100
[<c0176231>] __might_sleep+0xb1/0x200
[<c04098f1>] idr_preload+0xa1/0xd0
[<c038b4d2>] ipc_addid+0x52/0x190
[<c038dfbd>] ? rcu_read_lock+0x5d/0x80
[<c038e7aa>] newary+0xba/0x1a0
[<c038c4be>] ipcget+0x4e/0x70
[<c019d7a2>] ? __lock_release+0x72/0x1b0
[<c038e6cf>] SyS_semget+0x6f/0x80
[<c038e6f0>] ? sem_security+0x10/0x10
[<c038e6e0>] ? SyS_semget+0x80/0x80
[<c038dd80>] ? SyS_msgctl+0xb0/0xb0
[<c0392ab3>] SyS_ipc+0xa3/0x250
[<c0235426>] ? vm_munmap+0x46/0x60
[<c067c89a>] sysenter_do_call+0x12/0x32
BUG: sleeping function called from invalid context at lib/idr.c:424
in_atomic(): 1, irqs_disabled(): 0, pid: 1909, name: udevd
2 locks held by udevd/1909:
#0: (&ids->rw_mutex){+.+.+.}, at: [<c038c4b5>] ipcget+0x45/0x70
#1: (rcu_read_lock){.+.+..}, at: [<c038df60>] rcu_read_lock+0x0/0x80
CPU: 0 PID: 1909 Comm: udevd Not tainted 3.10.0-rc6-next-20130617 #7
Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 08/15/2008
000001a8 da591ebc c0677931 da594260 da591ee4 c01762dd c07e79fc 00000001
00000000 00000775 da594518 000000d0 deee0f0c ffffffe4 da591ef0 c04098f1
c08e2b84 da591f10 c038b4d2 da591f10 c038dfbd ffffffff 00000001 c08e2b80
Call Trace:
[<c0677931>] dump_stack+0x4c/0x6b
[<c01762dd>] __might_sleep+0x15d/0x200
[<c04098f1>] idr_preload+0xa1/0xd0
[<c038b4d2>] ipc_addid+0x52/0x190
[<c038dfbd>] ? rcu_read_lock+0x5d/0x80
[<c038e7aa>] newary+0xba/0x1a0
[<c038c4be>] ipcget+0x4e/0x70
[<c019d7a2>] ? __lock_release+0x72/0x1b0
[<c038e6cf>] SyS_semget+0x6f/0x80
[<c038e6f0>] ? sem_security+0x10/0x10
[<c038e6e0>] ? SyS_semget+0x80/0x80
[<c038dd80>] ? SyS_msgctl+0xb0/0xb0
[<c0392ab3>] SyS_ipc+0xa3/0x250
[<c0235426>] ? vm_munmap+0x46/0x60
[<c067c89a>] sysenter_do_call+0x12/0x32

----------
>From da6fbd77764e01cd611bd488666f349c11e1d4f3 Mon Sep 17 00:00:00 2001
From: Tetsuo Handa <penguin-kernel@xxxxxxxxxxxxxxxxxxx>
Date: Mon, 17 Jun 2013 20:49:25 +0900
Subject: [PATCH linux-next] ipc: Avoid sleeping inside RCU.

Commit 4964214b "ipc: move rcu lock out of ipc_addid" moved
idr_preload(GFP_KERNEL) into RCU read-side critical section.

Signed-off-by: Tetsuo Handa <penguin-kernel@xxxxxxxxxxxxxxxxxxx>
---
ipc/util.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/ipc/util.c b/ipc/util.c
index a746abb..00aca85 100644
--- a/ipc/util.c
+++ b/ipc/util.c
@@ -261,7 +261,7 @@ int ipc_addid(struct ipc_ids* ids, struct kern_ipc_perm* new, int size)
if (ids->in_use >= size)
return -ENOSPC;

- idr_preload(GFP_KERNEL);
+ idr_preload(GFP_ATOMIC);

spin_lock_init(&new->lock);
new->deleted = 0;
--
1.7.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/