diff options
author | Paul E. McKenney <paulmck@linux.vnet.ibm.com> | 2012-11-07 16:35:32 -0500 |
---|---|---|
committer | Paul E. McKenney <paulmck@linux.vnet.ibm.com> | 2012-11-16 13:05:58 -0500 |
commit | 4e79752c25ec221ac1e28f8875b539ed7631a0db (patch) | |
tree | 3ea71973fadee2363004c1d4bea10b632c9fd922 /kernel | |
parent | c635a4e1c24e9396db10ed7424b2084908b32252 (diff) |
sched: Mark RCU reader in sched_show_task()
When sched_show_task() is invoked from try_to_freeze_tasks(), there is
no RCU read-side critical section, resulting in the following splat:
[ 125.780730] ===============================
[ 125.780766] [ INFO: suspicious RCU usage. ]
[ 125.780804] 3.7.0-rc3+ #988 Not tainted
[ 125.780838] -------------------------------
[ 125.780875] /home/rafael/src/linux/kernel/sched/core.c:4497 suspicious rcu_dereference_check() usage!
[ 125.780946]
[ 125.780946] other info that might help us debug this:
[ 125.780946]
[ 125.781031]
[ 125.781031] rcu_scheduler_active = 1, debug_locks = 0
[ 125.781087] 4 locks held by s2ram/4211:
[ 125.781120] #0: (&buffer->mutex){+.+.+.}, at: [<ffffffff811e2acf>] sysfs_write_file+0x3f/0x160
[ 125.781233] #1: (s_active#94){.+.+.+}, at: [<ffffffff811e2b58>] sysfs_write_file+0xc8/0x160
[ 125.781339] #2: (pm_mutex){+.+.+.}, at: [<ffffffff81090a81>] pm_suspend+0x81/0x230
[ 125.781439] #3: (tasklist_lock){.?.?..}, at: [<ffffffff8108feed>] try_to_freeze_tasks+0x2cd/0x3f0
[ 125.781543]
[ 125.781543] stack backtrace:
[ 125.781584] Pid: 4211, comm: s2ram Not tainted 3.7.0-rc3+ #988
[ 125.781632] Call Trace:
[ 125.781662] [<ffffffff810a3c73>] lockdep_rcu_suspicious+0x103/0x140
[ 125.781719] [<ffffffff8107cf21>] sched_show_task+0x121/0x180
[ 125.781770] [<ffffffff8108ffb4>] try_to_freeze_tasks+0x394/0x3f0
[ 125.781823] [<ffffffff810903b5>] freeze_kernel_threads+0x25/0x80
[ 125.781876] [<ffffffff81090b65>] pm_suspend+0x165/0x230
[ 125.781924] [<ffffffff8108fa29>] state_store+0x99/0x100
[ 125.781975] [<ffffffff812f5867>] kobj_attr_store+0x17/0x20
[ 125.782038] [<ffffffff811e2b71>] sysfs_write_file+0xe1/0x160
[ 125.782091] [<ffffffff811667a6>] vfs_write+0xc6/0x180
[ 125.782138] [<ffffffff81166ada>] sys_write+0x5a/0xa0
[ 125.782185] [<ffffffff812ff6ae>] ? trace_hardirqs_on_thunk+0x3a/0x3f
[ 125.782242] [<ffffffff81669dd2>] system_call_fastpath+0x16/0x1b
This commit therefore adds the needed RCU read-side critical section.
Reported-by: "Rafael J. Wysocki" <rjw@sisk.pl>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/sched/core.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 6d4569e0924d..36f260864f65 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c | |||
@@ -4474,6 +4474,7 @@ static const char stat_nam[] = TASK_STATE_TO_CHAR_STR; | |||
4474 | void sched_show_task(struct task_struct *p) | 4474 | void sched_show_task(struct task_struct *p) |
4475 | { | 4475 | { |
4476 | unsigned long free = 0; | 4476 | unsigned long free = 0; |
4477 | int ppid; | ||
4477 | unsigned state; | 4478 | unsigned state; |
4478 | 4479 | ||
4479 | state = p->state ? __ffs(p->state) + 1 : 0; | 4480 | state = p->state ? __ffs(p->state) + 1 : 0; |
@@ -4493,8 +4494,11 @@ void sched_show_task(struct task_struct *p) | |||
4493 | #ifdef CONFIG_DEBUG_STACK_USAGE | 4494 | #ifdef CONFIG_DEBUG_STACK_USAGE |
4494 | free = stack_not_used(p); | 4495 | free = stack_not_used(p); |
4495 | #endif | 4496 | #endif |
4497 | rcu_read_lock(); | ||
4498 | ppid = task_pid_nr(rcu_dereference(p->real_parent)); | ||
4499 | rcu_read_unlock(); | ||
4496 | printk(KERN_CONT "%5lu %5d %6d 0x%08lx\n", free, | 4500 | printk(KERN_CONT "%5lu %5d %6d 0x%08lx\n", free, |
4497 | task_pid_nr(p), task_pid_nr(rcu_dereference(p->real_parent)), | 4501 | task_pid_nr(p), ppid, |
4498 | (unsigned long)task_thread_info(p)->flags); | 4502 | (unsigned long)task_thread_info(p)->flags); |
4499 | 4503 | ||
4500 | show_stack(p, NULL); | 4504 | show_stack(p, NULL); |