From: tip-bot for Ingo Molnar <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: mingo@kernel.org, kernel@kolivas.org,
linux-kernel@vger.kernel.org, tglx@linutronix.de,
peterz@infradead.org, xiaolong.ye@intel.com, cchalpha@gmail.com,
hpa@zytor.com
Subject: [tip:sched/urgent] Revert "sched/core: Do not use smp_processor_id() with preempt enabled in smpboot_thread_fn()"
Date: Tue, 4 Oct 2016 01:06:56 -0700 [thread overview]
Message-ID: <tip-be6a2e4c46cc122ba9113ba569fbc50fad075fff@git.kernel.org> (raw)
In-Reply-To: <20160930015102.GB20189@yexl-desktop>
Commit-ID: be6a2e4c46cc122ba9113ba569fbc50fad075fff
Gitweb: http://git.kernel.org/tip/be6a2e4c46cc122ba9113ba569fbc50fad075fff
Author: Ingo Molnar <mingo@kernel.org>
AuthorDate: Tue, 4 Oct 2016 09:55:57 +0200
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Tue, 4 Oct 2016 09:55:57 +0200
Revert "sched/core: Do not use smp_processor_id() with preempt enabled in smpboot_thread_fn()"
This reverts commit 4fa5cd5245b627db88c9ca08ae442373b02596b4.
The original change widens a preempt-off section, to avoid a seemingly unsafe
smp_processor_id() use.
During review I overlooked two facts:
- The code to calls a non-trivial function callback:
ht->park(td->cpu);
... which might (and does occasionally) sleep, triggering the warning.
- More importantly, as pointed out by Peter Zijlstra, using
smp_processor_id() in that context is safe, if it's done from
a kernel thread that is pinned to a single CPU - which is the
case here.
So revert to the original code that enables preemption sooner.
Reported-by: kernel test robot <xiaolong.ye@intel.com>
Acked-by: Peter Zijlstra <peterz@infradead.org>
Cc: Con Kolivas <kernel@kolivas.org>
Cc: Alfred Chen <cchalpha@gmail.com>
Link: http://lkml.kernel.org/r/20160930015102.GB20189@yexl-desktop
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
kernel/smpboot.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/smpboot.c b/kernel/smpboot.c
index fc0d8270..13bc43d 100644
--- a/kernel/smpboot.c
+++ b/kernel/smpboot.c
@@ -122,12 +122,12 @@ static int smpboot_thread_fn(void *data)
if (kthread_should_park()) {
__set_current_state(TASK_RUNNING);
+ preempt_enable();
if (ht->park && td->status == HP_THREAD_ACTIVE) {
BUG_ON(td->cpu != smp_processor_id());
ht->park(td->cpu);
td->status = HP_THREAD_PARKED;
}
- preempt_enable();
kthread_parkme();
/* We might have been woken for stop */
continue;
next prev parent reply other threads:[~2016-10-04 8:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-30 1:51 [lkp] [sched/core] 4fa5cd5245: BUG: sleeping function called from invalid context at kernel/locking/mutex.c:97 kernel test robot
2016-09-30 10:35 ` Peter Zijlstra
2016-10-04 8:06 ` tip-bot for Ingo Molnar [this message]
2016-10-04 8:22 ` [tip:sched/urgent] Revert "sched/core: Do not use smp_processor_id() with preempt enabled in smpboot_thread_fn()" Thomas Gleixner
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=tip-be6a2e4c46cc122ba9113ba569fbc50fad075fff@git.kernel.org \
--to=tipbot@zytor.com \
--cc=cchalpha@gmail.com \
--cc=hpa@zytor.com \
--cc=kernel@kolivas.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=xiaolong.ye@intel.com \
/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