patch hand edited. Message-Id: <20011031.101742.65195491.davem@redhat.com> To: torvalds@transmeta.com Cc: andrea@suse.de Subject: [PATCH] Fix ksoftirqd startup logic From: "David S. Miller" X-Mailer: Mew version 2.0 on Emacs 21.0 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Right after kernel_thread() is called, nothing prevents gcc from incrementing the stack copy of "cpu" and just using a "cpu - 1" value in a local register for the rest of that loop body. This would lead to ksoftirqd seeing a corrupt cpu number. I've actually had a report of gcc doing this on sparc32. Andrea, is might even explain those weird reports of ksoftirqd eating all the cpu on sparc64 systems but this is unlikely. The fix is really easy luckily :-) Please apply, thanks. --- linux/kernel/softirq.c.~1~ Sun Oct 21 02:47:54 2001 +++ linux/kernel/softirq.c Wed Oct 31 10:02:21 2001 @@ -361,7 +361,7 @@ void __run_task_queue(task_queue *list) static int ksoftirqd(void * __bind_cpu) { - int bind_cpu = *(int *) __bind_cpu; + int bind_cpu = (int) (long) __bind_cpu; int cpu = cpu_logical_map(bind_cpu); daemonize(); @@ -401,7 +401,7 @@ static __init int spawn_ksoftirqd(void) int cpu; for (cpu = 0; cpu < smp_num_cpus; cpu++) { - if (kernel_thread(ksoftirqd, (void *) &cpu, + if (kernel_thread(ksoftirqd, (void *) (long) cpu, CLONE_FS | CLONE_FILES | CLONE_SIGNAL) < 0) printk("spawn_ksoftirqd() failed for cpu %d\n", cpu); else {