Skip to contentSkip to conversation

sched: Do not use smp_processor_id() with preempt enabled in smpboot_thread_fn

PATCH New Con Kolivas 2 participants 2 messages Sep 13, 2016 – Sep 22, 2016 CPU hotplug

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sched: Do not use smp_processor_id() with preempt enabled in smpboot_thread_fn

We should not be using smp_processor_id() with preempt enabled.

Bug identified and fix provided by Alfred Chen.

---
 kernel/smpboot.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/smpboot.c +1 -1
Index: linux-4.7.3-ck3/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;
#1 lore raw

[tip:sched/core] sched/core: Do not use smp_processor_id() with preempt enabled in smpboot_thread_fn()

sched/core: Do not use smp_processor_id() with preempt enabled in smpboot_thread_fn()
Commit-ID:  4fa5cd5245b627db88c9ca08ae442373b02596b4
Gitweb:     http://git.kernel.org/tip/4fa5cd5245b627db88c9ca08ae442373b02596b4
Author:     Con Kolivas <[email protected]>
AuthorDate: Tue, 13 Sep 2016 16:27:05 +1000
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 22 Sep 2016 12:28:00 +0200

sched/core: Do not use smp_processor_id() with preempt enabled in smpboot_thread_fn()

We should not be using smp_processor_id() with preempt enabled.

Bug identified and fix provided by Alfred Chen.

---
 kernel/smpboot.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/smpboot.c +1 -1
index 13bc43d..fc0d8270 100644
@@ -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;