[PATCH] revert "kthread: convert stop_machine into a kthread"

Jiri reports that the stop_machin kthread conversion caused his machine to
hang when suspending. Hyperthreading is apparently involved.

I don't see why that would be and I can't reproduce it. Revert to the 2.6.17
code.

Cc: "Serge E. Hallyn" <serue@us.ibm.com>
Cc: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by Andrew Morton and committed by Linus Torvalds d8cb7c1d 38c54ee8

+6 -11
+6 -11
kernel/stop_machine.c
··· 4 #include <linux/cpu.h> 5 #include <linux/err.h> 6 #include <linux/syscalls.h> 7 - #include <linux/kthread.h> 8 #include <asm/atomic.h> 9 #include <asm/semaphore.h> 10 #include <asm/uaccess.h> ··· 25 static atomic_t stopmachine_thread_ack; 26 static DECLARE_MUTEX(stopmachine_mutex); 27 28 - static int stopmachine(void *unused) 29 { 30 int irqs_disabled = 0; 31 int prepared = 0; 32 33 /* Ack: we are alive */ 34 smp_mb(); /* Theoretically the ack = 0 might not be on this CPU yet. */ ··· 85 86 static int stop_machine(void) 87 { 88 - int ret = 0; 89 - unsigned int i; 90 struct sched_param param = { .sched_priority = MAX_RT_PRIO-1 }; 91 92 /* One high-prio thread per cpu. We'll do this one. */ ··· 96 stopmachine_state = STOPMACHINE_WAIT; 97 98 for_each_online_cpu(i) { 99 - struct task_struct *tsk; 100 if (i == raw_smp_processor_id()) 101 continue; 102 - tsk = kthread_create(stopmachine, NULL, "stopmachine"); 103 - if (IS_ERR(tsk)) { 104 - ret = PTR_ERR(tsk); 105 break; 106 - } 107 - kthread_bind(tsk, i); 108 - wake_up_process(tsk); 109 stopmachine_num_threads++; 110 } 111
··· 4 #include <linux/cpu.h> 5 #include <linux/err.h> 6 #include <linux/syscalls.h> 7 #include <asm/atomic.h> 8 #include <asm/semaphore.h> 9 #include <asm/uaccess.h> ··· 26 static atomic_t stopmachine_thread_ack; 27 static DECLARE_MUTEX(stopmachine_mutex); 28 29 + static int stopmachine(void *cpu) 30 { 31 int irqs_disabled = 0; 32 int prepared = 0; 33 + 34 + set_cpus_allowed(current, cpumask_of_cpu((int)(long)cpu)); 35 36 /* Ack: we are alive */ 37 smp_mb(); /* Theoretically the ack = 0 might not be on this CPU yet. */ ··· 84 85 static int stop_machine(void) 86 { 87 + int i, ret = 0; 88 struct sched_param param = { .sched_priority = MAX_RT_PRIO-1 }; 89 90 /* One high-prio thread per cpu. We'll do this one. */ ··· 96 stopmachine_state = STOPMACHINE_WAIT; 97 98 for_each_online_cpu(i) { 99 if (i == raw_smp_processor_id()) 100 continue; 101 + ret = kernel_thread(stopmachine, (void *)(long)i,CLONE_KERNEL); 102 + if (ret < 0) 103 break; 104 stopmachine_num_threads++; 105 } 106