mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: linux-kernel@vger.kernel.org
Cc: Andrew Morton <akpm@osdl.org>,
	Wolfgang Erig <Wolfgang.Erig@fujitsu-siemens.com>,
	Andreas Friedrich <andreas.friedrich@fujitsu-siemens.com>,
	Adrian Bunk <bunk@stusta.de>, Greg Kroah-Hartman <gregkh@suse.de>,
	Linus Torvalds <torvalds@osdl.org>
Subject: [patch] i386/x86_64: ACPI cpu_idle_wait() fix
Date: Fri, 17 Nov 2006 14:26:18 +0100	[thread overview]
Message-ID: <20061117132618.GA14411@elte.hu> (raw)
In-Reply-To: <20061117124913.GA24893@upset.pdb.fsc.net>

Subject: [patch] i386/x86_64: ACPI cpu_idle_wait() fix
From: Ingo Molnar <mingo@elte.hu>

The scheduler on Andreas Friedrich's hyperthreading system
stopped working properly as of 2.6.18: the scheduler would
never move tasks to another CPU!

after a couple of attempts to corner the bug, the following
smoking gun was found:

BIOS reported wrong ACPI idfor the processor
CPU#1: set_cpus_allowed(), swapper:1, 3 -> 2
 [<c0103bbe>] show_trace_log_lvl+0x34/0x4a
 [<c0103ceb>] show_trace+0x2c/0x2e
 [<c01045f8>] dump_stack+0x2b/0x2d
 [<c0116a77>] set_cpus_allowed+0x52/0xec
 [<c0101d86>] cpu_idle_wait+0x2e/0x100
 [<c0259c57>] acpi_processor_power_exit+0x45/0x58
 [<c0259752>] acpi_processor_remove+0x46/0xea
 [<c025c6fb>] acpi_start_single_object+0x47/0x54
 [<c025cee5>] acpi_bus_register_driver+0xa4/0xd3
 [<c04ab2d7>] acpi_processor_init+0x57/0x77
 [<c01004d7>] init+0x146/0x2fd
 [<c0103a87>] kernel_thread_helper+0x7/0x10

a quick look at cpu_idle_wait() shows how broken that code is
on i386: it changes the init task's affinity map but never
restores it ...

and because all userspace tasks get forked by init, they all
inherited that single-CPU affinity mask. x86_64 cloned this
bug too.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 arch/i386/kernel/process.c   |    4 +++-
 arch/x86_64/kernel/process.c |    4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

Index: linux/arch/i386/kernel/process.c
===================================================================
--- linux.orig/arch/i386/kernel/process.c
+++ linux/arch/i386/kernel/process.c
@@ -205,7 +205,7 @@ void cpu_idle(void)
 void cpu_idle_wait(void)
 {
 	unsigned int cpu, this_cpu = get_cpu();
-	cpumask_t map;
+	cpumask_t map, tmp = current->cpus_allowed;
 
 	set_cpus_allowed(current, cpumask_of_cpu(this_cpu));
 	put_cpu();
@@ -227,6 +227,8 @@ void cpu_idle_wait(void)
 		}
 		cpus_and(map, map, cpu_online_map);
 	} while (!cpus_empty(map));
+
+	set_cpus_allowed(current, tmp);
 }
 EXPORT_SYMBOL_GPL(cpu_idle_wait);
 
Index: linux/arch/x86_64/kernel/process.c
===================================================================
--- linux.orig/arch/x86_64/kernel/process.c
+++ linux/arch/x86_64/kernel/process.c
@@ -144,7 +144,7 @@ static void poll_idle (void)
 void cpu_idle_wait(void)
 {
 	unsigned int cpu, this_cpu = get_cpu();
-	cpumask_t map;
+	cpumask_t map, tmp = current->cpus_allowed;
 
 	set_cpus_allowed(current, cpumask_of_cpu(this_cpu));
 	put_cpu();
@@ -167,6 +167,8 @@ void cpu_idle_wait(void)
 		}
 		cpus_and(map, map, cpu_online_map);
 	} while (!cpus_empty(map));
+
+	set_cpus_allowed(current, tmp);
 }
 EXPORT_SYMBOL_GPL(cpu_idle_wait);
 

       reply	other threads:[~2006-11-17 13:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20061116110558.GB14245@elte.hu>
     [not found] ` <20061116122820.GA2718@upset.pdb.fsc.net>
     [not found]   ` <20061116123335.GA1392@elte.hu>
     [not found]     ` <20061116124132.GA9048@upset.pdb.fsc.net>
     [not found]       ` <20061116131842.GA12961@elte.hu>
     [not found]         ` <20061116133019.GA14546@upset.pdb.fsc.net>
     [not found]           ` <20061116144356.GA4891@elte.hu>
     [not found]             ` <20061117090356.GA26013@upset.pdb.fsc.net>
     [not found]               ` <20061117112237.GA26270@elte.hu>
     [not found]                 ` <20061117124913.GA24893@upset.pdb.fsc.net>
2006-11-17 13:26                   ` Ingo Molnar [this message]
2006-11-17 13:31                     ` Ingo Molnar
2006-11-17 19:18                       ` Andrew Morton
2006-11-17 19:26                         ` Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20061117132618.GA14411@elte.hu \
    --to=mingo@elte.hu \
    --cc=Wolfgang.Erig@fujitsu-siemens.com \
    --cc=akpm@osdl.org \
    --cc=andreas.friedrich@fujitsu-siemens.com \
    --cc=bunk@stusta.de \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®