Skip to contentSkip to conversation

smpboot: Use preempt_enable_no_resched() before schedule()

PATCH In review Kirill Tkhai 2 participants 2 messages Feb 12, 2014 CPU hotplug

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 smpboot: Use preempt_enable_no_resched() before schedule()

CC Thomas Gleixner <[email protected]>
---
 kernel/smpboot.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/smpboot.c +1 -1
index eb89e18..c6e1c56 100644
@@ -152,7 +152,7 @@ static int smpboot_thread_fn(void *data)
 		}
 
 		if (!ht->thread_should_run(td->cpu)) {
-			preempt_enable();
+			preempt_enable_no_resched();
 			schedule();
 		} else {
 			set_current_state(TASK_RUNNING);
#1 lore raw

On Wed, 12 Feb 2014, Kirill Tkhai wrote:

No, preempt_enable_no_resched() should just die. If you want to get rid of the preempt_enable() / schedule() sequence just use schedule_preempt_disabled(). See below.

Thanks,

tglx

kernel/smpboot.c +4 -3
@@ -106,9 +106,9 @@ static int smpboot_thread_fn(void *data)
 	struct smpboot_thread_data *td = data;
 	struct smp_hotplug_thread *ht = td->ht;
 
+	preempt_disable();
 	while (1) {
 		set_current_state(TASK_INTERRUPTIBLE);
-		preempt_disable();
 		if (kthread_should_stop()) {
 			set_current_state(TASK_RUNNING);
 			preempt_enable();
@@ -128,6 +128,7 @@ static int smpboot_thread_fn(void *data)
 			}
 			kthread_parkme();
 			/* We might have been woken for stop */
+			preempt_disable();
 			continue;
 		}
 
@@ -152,12 +153,12 @@ static int smpboot_thread_fn(void *data)
 		}
 
 		if (!ht->thread_should_run(td->cpu)) {
-			preempt_enable();
-			schedule();
+			schedule_preempt_disabled();
 		} else {
 			set_current_state(TASK_RUNNING);
 			preempt_enable();
 			ht->thread_fn(td->cpu);
+			preempt_disable();
 		}
 	}
 }