Re: [PATCH] smpboot: Use preempt_enable_no_resched() before schedule()

From: Thomas Gleixner
Date: Wed Feb 12 2014 - 06:38:56 EST


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


--- linux-2.6.orig/kernel/smpboot.c
+++ linux-2.6/kernel/smpboot.c
@@ -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();
}
}
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/