mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org
Subject: [PATCH] sched: RCU-protect __set_task_cpu() in set_task_cpu()
Date: Tue, 31 May 2011 20:26:51 +0300	[thread overview]
Message-ID: <20110531172651.GA4478@swordfish.minsk.epam.com> (raw)

Wrap __set_task_cpu() with RCU read-side critical section. 
__set_task_cpu() calls task_group() that performs rcu dereference check in 
task_subsys_state_check(), causing:

 [  152.262791] kernel/sched.c:619 invoked rcu_dereference_check() without protection!
 [  152.262795] 
 [  152.262841] stack backtrace:
 [  152.262846] Pid: 16, comm: watchdog/1 Not tainted 3.0.0-rc1-dbg-00441-g1d5f9cc-dirty #599
 [  152.262851] Call Trace:
 [  152.262860]  [<ffffffff8106e17b>] lockdep_rcu_dereference+0xa7/0xaf
 [  152.262868]  [<ffffffff810369f4>] set_task_cpu+0x1ed/0x3ce
 [  152.262876]  [<ffffffff8123a5d7>] ? plist_check_head+0x94/0x98
 [  152.262883]  [<ffffffff8123a72d>] ? plist_del+0x82/0x89
 [  152.262889]  [<ffffffff8102b139>] ? dequeue_task_rt+0x33/0x38
 [  152.262895]  [<ffffffff8102e3ac>] ? dequeue_task+0x82/0x89
 [  152.262902]  [<ffffffff81036fc0>] push_rt_task.part.131+0x1bb/0x247
 [  152.262909]  [<ffffffff81037138>] post_schedule_rt+0x1b/0x24
 [  152.262918]  [<ffffffff81477c1c>] schedule+0x989/0xa9e
 [  152.262923]  [<ffffffff814775e6>] ? schedule+0x353/0xa9e
 [  152.262931]  [<ffffffff8147de58>] ? sub_preempt_count+0x8f/0xa3
 [  152.262938]  [<ffffffff8109fd2c>] ? watchdog_enable+0x195/0x195
 [  152.262946]  [<ffffffff810072e5>] ? native_sched_clock+0x38/0x65
 [  152.262953]  [<ffffffff81062c0c>] ? cpu_clock+0x4a/0x5f
 [  152.262958]  [<ffffffff8109fd2c>] ? watchdog_enable+0x195/0x195
 [  152.262965]  [<ffffffff81071a15>] ? trace_hardirqs_on_caller+0x10d/0x131
 [  152.262971]  [<ffffffff81071a46>] ? trace_hardirqs_on+0xd/0xf
 [  152.262977]  [<ffffffff8109fd2c>] ? watchdog_enable+0x195/0x195
 [  152.262983]  [<ffffffff8109fd94>] watchdog+0x68/0xab
 [  152.262990]  [<ffffffff8105cb82>] kthread+0x9a/0xa2
 [  152.262999]  [<ffffffff81481e24>] kernel_thread_helper+0x4/0x10
 [  152.263005]  [<ffffffff8102d6bf>] ? finish_task_switch+0x76/0xf0
 [  152.263012]  [<ffffffff8147b258>] ? retint_restore_args+0x13/0x13
 [  152.263019]  [<ffffffff8105cae8>] ? __init_kthread_worker+0x53/0x53
 [  152.263024]  [<ffffffff81481e20>] ? gs_change+0x13/0x13


Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>

---

 kernel/sched.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/kernel/sched.c b/kernel/sched.c
index cbb3a0e..cf0dd8a 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -2212,7 +2212,9 @@ void set_task_cpu(struct task_struct *p, unsigned int new_cpu)
 		perf_sw_event(PERF_COUNT_SW_CPU_MIGRATIONS, 1, 1, NULL, 0);
 	}
 
+	rcu_read_lock();
 	__set_task_cpu(p, new_cpu);
+	rcu_read_unlock();
 }
 
 struct migration_arg {


             reply	other threads:[~2011-05-31 17:27 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-31 17:26 Sergey Senozhatsky [this message]
2011-05-31 19:45 ` Peter Zijlstra
2011-06-03 15:37 ` Peter Zijlstra
2011-06-03 18:16   ` Sergey Senozhatsky
2011-06-03 22:49   ` Sergey Senozhatsky
2011-06-05 19:12   ` Oleg Nesterov
2011-06-06  9:06     ` Peter Zijlstra
2011-06-06 16:46       ` Oleg Nesterov
2011-06-07  9:31         ` Peter Zijlstra
2011-06-07 14:03           ` Oleg Nesterov
2011-06-06 13:43     ` Peter Zijlstra
2011-06-07 12:03   ` [tip:sched/urgent] sched: Fix/clarify set_task_cpu() locking rules tip-bot for Peter Zijlstra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110531172651.GA4478@swordfish.minsk.epam.com \
    --to=sergey.senozhatsky@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome