linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/6]sep initializing rework
@ 2005-04-12  5:30 Li Shaohua
  2005-04-12 12:07 ` Zwane Mwaikambo
  2005-04-30 12:06 ` Benoit Boissinot
  0 siblings, 2 replies; 5+ messages in thread
From: Li Shaohua @ 2005-04-12  5:30 UTC (permalink / raw)
  To: lkml, ACPI-DEV; +Cc: Len Brown, Pavel Machek, Zwane Mwaikambo, Andrew Morton

Hi,
These patches (together with 5 patches followed this one) are updated
suspend/resume SMP patches. The patches fixed some bugs and do clean up
as suggested. Now they work for both suspend-to-ram and suspend-to-disk.
Patches are against 2.6.12-rc2-mm3.

Thanks,
Shaohua

---
Make SEP init per-cpu, so it is hotplug safed.

Signed-off-by: Li Shaohua<shaohua.li@intel.com>

---

 linux-2.6.11-root/arch/i386/kernel/smpboot.c           |    6 ++++++
 linux-2.6.11-root/arch/i386/kernel/sysenter.c          |   12 +++++++-----
 linux-2.6.11-root/arch/i386/mach-voyager/voyager_smp.c |    4 ++++
 linux-2.6.11-root/arch/i386/power/cpu.c                |    4 +---
 linux-2.6.11-root/include/asm-i386/smp.h               |    3 +++
 5 files changed, 21 insertions(+), 8 deletions(-)

diff -puN arch/i386/kernel/smpboot.c~sep_init_cleanup arch/i386/kernel/smpboot.c
--- linux-2.6.11/arch/i386/kernel/smpboot.c~sep_init_cleanup	2005-04-12 10:36:00.164171464 +0800
+++ linux-2.6.11-root/arch/i386/kernel/smpboot.c	2005-04-12 10:36:00.174169944 +0800
@@ -443,6 +443,9 @@ static void __init start_secondary(void 
 	 * the local TLBs too.
 	 */
 	local_flush_tlb();
+
+	/* Note: this must be done before __cpu_up finish */
+	enable_sep_cpu();
 	cpu_set(smp_processor_id(), cpu_online_map);
 
 	/* We can take interrupts now: we're officially "up". */
@@ -920,6 +923,9 @@ static void __init smp_boot_cpus(unsigne
 	cpus_clear(cpu_core_map[0]);
 	cpu_set(0, cpu_core_map[0]);
 
+	sysenter_setup();
+	enable_sep_cpu();
+
 	/*
 	 * If we couldn't find an SMP configuration at boot time,
 	 * get out of here now!
diff -puN arch/i386/kernel/sysenter.c~sep_init_cleanup arch/i386/kernel/sysenter.c
--- linux-2.6.11/arch/i386/kernel/sysenter.c~sep_init_cleanup	2005-04-12 10:36:00.165171312 +0800
+++ linux-2.6.11-root/arch/i386/kernel/sysenter.c	2005-04-12 10:36:00.174169944 +0800
@@ -21,11 +21,16 @@
 
 extern asmlinkage void sysenter_entry(void);
 
-void enable_sep_cpu(void *info)
+void enable_sep_cpu(void)
 {
 	int cpu = get_cpu();
 	struct tss_struct *tss = &per_cpu(init_tss, cpu);
 
+	if (!boot_cpu_has(X86_FEATURE_SEP)) {
+		put_cpu();
+		return;
+	}
+
 	tss->ss1 = __KERNEL_CS;
 	tss->esp1 = sizeof(struct tss_struct) + (unsigned long) tss;
 	wrmsr(MSR_IA32_SYSENTER_CS, __KERNEL_CS, 0);
@@ -41,7 +46,7 @@ void enable_sep_cpu(void *info)
 extern const char vsyscall_int80_start, vsyscall_int80_end;
 extern const char vsyscall_sysenter_start, vsyscall_sysenter_end;
 
-static int __init sysenter_setup(void)
+int __init sysenter_setup(void)
 {
 	void *page = (void *)get_zeroed_page(GFP_ATOMIC);
 
@@ -58,8 +63,5 @@ static int __init sysenter_setup(void)
 	       &vsyscall_sysenter_start,
 	       &vsyscall_sysenter_end - &vsyscall_sysenter_start);
 
-	on_each_cpu(enable_sep_cpu, NULL, 1, 1);
 	return 0;
 }
-
-__initcall(sysenter_setup);
diff -puN arch/i386/mach-voyager/voyager_smp.c~sep_init_cleanup arch/i386/mach-voyager/voyager_smp.c
--- linux-2.6.11/arch/i386/mach-voyager/voyager_smp.c~sep_init_cleanup	2005-04-12 10:36:00.167171008 +0800
+++ linux-2.6.11-root/arch/i386/mach-voyager/voyager_smp.c	2005-04-12 10:36:00.175169792 +0800
@@ -499,6 +499,7 @@ start_secondary(void *unused)
 	while (!cpu_isset(cpuid, smp_commenced_mask))
 		rep_nop();
 	local_irq_enable();
+	enable_sep_cpu();
 
 	local_flush_tlb();
 
@@ -696,6 +697,9 @@ smp_boot_cpus(void)
 	printk("CPU%d: ", boot_cpu_id);
 	print_cpu_info(&cpu_data[boot_cpu_id]);
 
+	sysenter_setup();
+	enable_sep_cpu();
+
 	if(is_cpu_quad()) {
 		/* booting on a Quad CPU */
 		printk("VOYAGER SMP: Boot CPU is Quad\n");
diff -puN arch/i386/power/cpu.c~sep_init_cleanup arch/i386/power/cpu.c
--- linux-2.6.11/arch/i386/power/cpu.c~sep_init_cleanup	2005-04-12 10:36:00.168170856 +0800
+++ linux-2.6.11-root/arch/i386/power/cpu.c	2005-04-12 10:36:00.175169792 +0800
@@ -33,8 +33,6 @@ unsigned long saved_context_esp, saved_c
 unsigned long saved_context_esi, saved_context_edi;
 unsigned long saved_context_eflags;
 
-extern void enable_sep_cpu(void *);
-
 void __save_processor_state(struct saved_context *ctxt)
 {
 	kernel_fpu_begin();
@@ -136,7 +134,7 @@ void __restore_processor_state(struct sa
 	 * sysenter MSRs
 	 */
 	if (boot_cpu_has(X86_FEATURE_SEP))
-		enable_sep_cpu(NULL);
+		enable_sep_cpu();
 
 	fix_processor_context();
 	do_fpu_end();
diff -puN include/asm-i386/smp.h~sep_init_cleanup include/asm-i386/smp.h
--- linux-2.6.11/include/asm-i386/smp.h~sep_init_cleanup	2005-04-12 10:36:00.170170552 +0800
+++ linux-2.6.11-root/include/asm-i386/smp.h	2005-04-12 10:36:00.176169640 +0800
@@ -37,6 +37,9 @@ extern int smp_num_siblings;
 extern cpumask_t cpu_sibling_map[];
 extern cpumask_t cpu_core_map[];
 
+extern int sysenter_setup(void);
+extern void enable_sep_cpu(void);
+
 extern void smp_flush_tlb(void);
 extern void smp_message_irq(int cpl, void *dev_id, struct pt_regs *regs);
 extern void smp_invalidate_rcv(void);		/* Process an NMI */
_



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/6]sep initializing rework
  2005-04-12  5:30 [PATCH 1/6]sep initializing rework Li Shaohua
@ 2005-04-12 12:07 ` Zwane Mwaikambo
  2005-04-30 12:06 ` Benoit Boissinot
  1 sibling, 0 replies; 5+ messages in thread
From: Zwane Mwaikambo @ 2005-04-12 12:07 UTC (permalink / raw)
  To: Li Shaohua
  Cc: lkml, ACPI-DEV, Len Brown, Pavel Machek, Andrew Morton,
	Protasevich, Natalie, Ryan Harper

Hello Shaohua,

On Tue, 12 Apr 2005, Li Shaohua wrote:

> These patches (together with 5 patches followed this one) are updated
> suspend/resume SMP patches. The patches fixed some bugs and do clean up
> as suggested. Now they work for both suspend-to-ram and suspend-to-disk.
> Patches are against 2.6.12-rc2-mm3.

These patches look good and i think we should go ahead with them. I've 
also cross checked with physical hotplug cpu patches for ES7xxx from 
Natalie (added to Cc) and it does indeed look like a lot of the code will 
work for her too, but i'd appreciate it if she also does a double check. 
Obviously this won't work for other upcoming users of hotplug cpu like Xen 
(Ryan added to Cc) but i think we can abstract things later on to cover 
other special users.

Thanks Shaohua,
	Zwane


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/6]sep initializing rework
  2005-04-12  5:30 [PATCH 1/6]sep initializing rework Li Shaohua
  2005-04-12 12:07 ` Zwane Mwaikambo
@ 2005-04-30 12:06 ` Benoit Boissinot
  1 sibling, 0 replies; 5+ messages in thread
From: Benoit Boissinot @ 2005-04-30 12:06 UTC (permalink / raw)
  To: Li Shaohua
  Cc: lkml, ACPI-DEV, Len Brown, Pavel Machek, Zwane Mwaikambo, Andrew Morton

On 4/12/05, Li Shaohua <shaohua.li@intel.com> wrote:
> Hi,
> These patches (together with 5 patches followed this one) are updated
> suspend/resume SMP patches. The patches fixed some bugs and do clean up
> as suggested. Now they work for both suspend-to-ram and suspend-to-disk.
> Patches are against 2.6.12-rc2-mm3.
> 
> Thanks,
> Shaohua
> 
> ---
> Make SEP init per-cpu, so it is hotplug safed.
> 
> Signed-off-by: Li Shaohua<shaohua.li@intel.com>
> 
> ---
> +++ linux-2.6.11-root/arch/i386/power/cpu.c     2005-04-12 10:36:00.175169792 +0800
> @@ -33,8 +33,6 @@ unsigned long saved_context_esp, saved_c
>  unsigned long saved_context_esi, saved_context_edi;
>  unsigned long saved_context_eflags;
> 
> -extern void enable_sep_cpu(void *);
> -
>  void __save_processor_state(struct saved_context *ctxt)
>  {
>         kernel_fpu_begin();


> diff -puN include/asm-i386/smp.h~sep_init_cleanup include/asm-i386/smp.h
> --- linux-2.6.11/include/asm-i386/smp.h~sep_init_cleanup        2005-04-12 10:36:00.170170552 +0800
> +++ linux-2.6.11-root/include/asm-i386/smp.h    2005-04-12 10:36:00.176169640 +0800
> @@ -37,6 +37,9 @@ extern int smp_num_siblings;
>  extern cpumask_t cpu_sibling_map[];
>  extern cpumask_t cpu_core_map[];
> 
> +extern int sysenter_setup(void);
> +extern void enable_sep_cpu(void);
> +
>  extern void smp_flush_tlb(void);
>  extern void smp_message_irq(int cpl, void *dev_id, struct pt_regs *regs);
>  extern void smp_invalidate_rcv(void);          /* Process an NMI */
> _

This change adds a warning when CONFIG_SMP is not set:

arch/i386/power/cpu.c: In function '__restore_processor_state':
arch/i386/power/cpu.c:137: warning: implicit declaration of function
'enable_sep_cpu'
Maybe those functions should be defined somewhere else.

regards,

Benoit

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH 1/6]sep initializing rework
  2005-04-12 17:57 Protasevich, Natalie
@ 2005-04-13  1:39 ` Li Shaohua
  0 siblings, 0 replies; 5+ messages in thread
From: Li Shaohua @ 2005-04-13  1:39 UTC (permalink / raw)
  To: Protasevich, Natalie
  Cc: Zwane Mwaikambo, lkml, ACPI-DEV, Len Brown, Pavel Machek,
	Andrew Morton, Ryan Harper, hotplug_sig, Joel Schopp, Ashok Raj,
	Andi Kleen

On Wed, 2005-04-13 at 01:57, Protasevich, Natalie wrote:
> Hello,
> This is a hotplug CPU patch for i386, done against 2.6.12-rc2-mm3.
> Somewhat alternative to the one posted by Li Shaohua, but not really
> (and I didn't mean that :). If you look closer, our patches are
> different and can complement each other I think. Li did great job on
> sep, after-offline cleanup, __devinit etc., and I have some radical
> changes in the AP bringup mechanism. I left alone __init to __devinit
> part (I was going through it lately, but I think even though I had few
> more than Li did, he covered it sufficiently perhaps). I started
> having
> doubts in free_initmem() vs __devinit because look how many of
> __init's
> left! just a few :). 
Looks quite smart, but people will argue it will keep all __init
sections in this way. I'd like we keep the default behavior of __init. 

> I got rid of do_boot_cpu loop in smpboot.c because
> the loop
> static void __init smp_init(void)
> {
>         unsigned int i;
> 
>         /* FIXME: This should be done in userspace --RR */
>         for_each_present_cpu(i) {
>                 if (num_online_cpus() >= max_cpus)
>                         break;
>                 if (!cpu_online(i))
>                         cpu_up(i);
>         }
> ...
> does it again so why leave it in smpboot.c to boot AP's twice. 
This is what IA64 does. In this way, you must clean up the bogomips
message, TSC synchronization. And CPU_UP could be called in user
context, so fork_idle possibly should be in workqueue. And please make
sure it doesn't break other things like check_nmi_watchdog. I just
select an easy way (add smp_prepare_cpu) and it doesn't break anything. 

> I also
> found that my system fails sooner or later when I try not to synch
> runtime booted processor with others, so I changed tsc synchronization
> to only sync between booting CPU and the one that boots it. 
IA64 also does like this. It synchronizes one AP's ITC against BP's one
time. But in IA32, TSC's upper 32 bits can be written only on prescott
and above. In earlier CPU, upper 32 bits will become 0 after any write.

> The patch
> works for me on Intel 8x generic box, and on ES7000. I was asked to
> separate my patch into smaller ones by the theme, but I'm posting the
> entire patch for now, because I think it is probably not the final
> one.
> I think (I hope) I will sync up with Li later on.
> My idea was that if we find a CPU core in ACPI (enabled or disabled),
> we
> encounter for it in sibling map and create a sysfs node accordingly,
> and
> cpu_possible_map will reflect that. We take processors up/down
> depending
> on physical presence using the existing node. That's the scenario
> implemented on ES7000 that reports all possible cores in ACPI marking
> absent processors as disabled. Runtime enablement/disablement depends
> on
> sysfs only and the driving agent can be anything (ACPI or user) that
> triggers sysfs node for this processor.
You possibly can refer to IA64's implementation. The goal of my patches
are to support suspend/resume, which actually doesn't really hotremove a
CPU, so I just ignored the sysfs/ACPI issues.

Thanks,
Shaohua

> 
> -----Original Message-----
> From: Zwane Mwaikambo [mailto:zwane@arm.linux.org.uk] 
> Sent: Tuesday, April 12, 2005 6:08 AM
> To: Li Shaohua
> Cc: lkml; ACPI-DEV; Len Brown; Pavel Machek; Andrew Morton;
> Protasevich,
> Natalie; Ryan Harper
> Subject: Re: [PATCH 1/6]sep initializing rework
> 
> Hello Shaohua,
> 
> On Tue, 12 Apr 2005, Li Shaohua wrote:
> 
> > These patches (together with 5 patches followed this one) are
> updated 
> > suspend/resume SMP patches. The patches fixed some bugs and do clean
> > up as suggested. Now they work for both suspend-to-ram and
> suspend-to-disk.
> > Patches are against 2.6.12-rc2-mm3.
> 
> These patches look good and i think we should go ahead with them. I've
> also cross checked with physical hotplug cpu patches for ES7xxx from
> Natalie (added to Cc) and it does indeed look like a lot of the code
> will work for her too, but i'd appreciate it if she also does a double
> check. 
> Obviously this won't work for other upcoming users of hotplug cpu like
> Xen (Ryan added to Cc) but i think we can abstract things later on to
> cover other special users.
> 
> Thanks Shaohua,
>         Zwane
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH 1/6]sep initializing rework
@ 2005-04-12 17:57 Protasevich, Natalie
  2005-04-13  1:39 ` Li Shaohua
  0 siblings, 1 reply; 5+ messages in thread
From: Protasevich, Natalie @ 2005-04-12 17:57 UTC (permalink / raw)
  To: Zwane Mwaikambo, Li Shaohua
  Cc: lkml, ACPI-DEV, Len Brown, Pavel Machek, Andrew Morton,
	Ryan Harper, hotplug_sig, Joel Schopp, Ashok Raj, Andi Kleen

[-- Attachment #1: Type: text/plain, Size: 3275 bytes --]

Hello,
This is a hotplug CPU patch for i386, done against 2.6.12-rc2-mm3.
Somewhat alternative to the one posted by Li Shaohua, but not really
(and I didn't mean that :). If you look closer, our patches are
different and can complement each other I think. Li did great job on
sep, after-offline cleanup, __devinit etc., and I have some radical
changes in the AP bringup mechanism. I left alone __init to __devinit
part (I was going through it lately, but I think even though I had few
more than Li did, he covered it sufficiently perhaps). I started having
doubts in free_initmem() vs __devinit because look how many of __init's
left! just a few :). I got rid of do_boot_cpu loop in smpboot.c because
the loop
static void __init smp_init(void)
{
        unsigned int i;

        /* FIXME: This should be done in userspace --RR */
        for_each_present_cpu(i) {
                if (num_online_cpus() >= max_cpus)
                        break;
                if (!cpu_online(i))
                        cpu_up(i);
        }
...
does it again so why leave it in smpboot.c to boot AP's twice. I also
found that my system fails sooner or later when I try not to synch
runtime booted processor with others, so I changed tsc synchronization
to only sync between booting CPU and the one that boots it. The patch
works for me on Intel 8x generic box, and on ES7000. I was asked to
separate my patch into smaller ones by the theme, but I'm posting the
entire patch for now, because I think it is probably not the final one.
I think (I hope) I will sync up with Li later on.
My idea was that if we find a CPU core in ACPI (enabled or disabled), we
encounter for it in sibling map and create a sysfs node accordingly, and
cpu_possible_map will reflect that. We take processors up/down depending
on physical presence using the existing node. That's the scenario
implemented on ES7000 that reports all possible cores in ACPI marking
absent processors as disabled. Runtime enablement/disablement depends on
sysfs only and the driving agent can be anything (ACPI or user) that
triggers sysfs node for this processor.
Thanks,
--Natalie

-----Original Message-----
From: Zwane Mwaikambo [mailto:zwane@arm.linux.org.uk] 
Sent: Tuesday, April 12, 2005 6:08 AM
To: Li Shaohua
Cc: lkml; ACPI-DEV; Len Brown; Pavel Machek; Andrew Morton; Protasevich,
Natalie; Ryan Harper
Subject: Re: [PATCH 1/6]sep initializing rework

Hello Shaohua,

On Tue, 12 Apr 2005, Li Shaohua wrote:

> These patches (together with 5 patches followed this one) are updated 
> suspend/resume SMP patches. The patches fixed some bugs and do clean 
> up as suggested. Now they work for both suspend-to-ram and
suspend-to-disk.
> Patches are against 2.6.12-rc2-mm3.

These patches look good and i think we should go ahead with them. I've
also cross checked with physical hotplug cpu patches for ES7xxx from
Natalie (added to Cc) and it does indeed look like a lot of the code
will work for her too, but i'd appreciate it if she also does a double
check. 
Obviously this won't work for other upcoming users of hotplug cpu like
Xen (Ryan added to Cc) but i think we can abstract things later on to
cover other special users.

Thanks Shaohua,
	Zwane


[-- Attachment #2: hotcpu-2.6.11.diff --]
[-- Type: application/octet-stream, Size: 10321 bytes --]

diff -Naurp linux-2.6.11.6-mm/arch/i386/kernel/acpi/boot.c linux-2.6.11.6-HC/arch/i386/kernel/acpi/boot.c
--- linux-2.6.11.6-mm/arch/i386/kernel/acpi/boot.c	2005-04-06 23:08:11.000000000 -0400
+++ linux-2.6.11.6-HC/arch/i386/kernel/acpi/boot.c	2005-04-12 08:08:28.000000000 -0400
@@ -229,7 +229,7 @@ acpi_parse_lapic (
 
 	/* no utility in registering a disabled processor */
 	if (processor->flags.enabled == 0)
-		return 0;
+		printk(KERN_DEBUG "apic %d is disabled\n", processor->id);
 
 	x86_acpiid_to_apicid[processor->acpi_id] = processor->id;
 
@@ -689,6 +689,9 @@ acpi_parse_madt_lapic_entries(void)
 		return count;
 	}
 
+	for (i = 0; i < count; i++)
+		cpu_set(i, cpu_possible_map);
+
 	count = acpi_table_parse_madt(ACPI_MADT_LAPIC_NMI, acpi_parse_lapic_nmi, 0);
 	if (count < 0) {
 		printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n");
diff -Naurp linux-2.6.11.6-mm/arch/i386/kernel/cpu/common.c linux-2.6.11.6-HC/arch/i386/kernel/cpu/common.c
--- linux-2.6.11.6-mm/arch/i386/kernel/cpu/common.c	2005-04-06 23:08:11.000000000 -0400
+++ linux-2.6.11.6-HC/arch/i386/kernel/cpu/common.c	2005-04-12 07:44:54.000000000 -0400
@@ -615,7 +615,11 @@ void __init cpu_init (void)
 	atomic_inc(&init_mm.mm_count);
 	current->active_mm = &init_mm;
 	if (current->mm)
+#ifdef CONFIG_HOTPLUG_CPU
+		current->mm = NULL;
+#else
 		BUG();
+#endif
 	enter_lazy_tlb(&init_mm, current);
 
 	load_esp0(t, thread);
diff -Naurp linux-2.6.11.6-mm/arch/i386/kernel/mpparse.c linux-2.6.11.6-HC/arch/i386/kernel/mpparse.c
--- linux-2.6.11.6-mm/arch/i386/kernel/mpparse.c	2005-04-06 23:08:12.000000000 -0400
+++ linux-2.6.11.6-HC/arch/i386/kernel/mpparse.c	2005-04-12 08:16:57.000000000 -0400
@@ -125,7 +125,7 @@ static void __init MP_processor_info (st
 	physid_mask_t tmp;
  	
 	if (!(m->mpc_cpuflag & CPU_ENABLED))
-		return;
+		printk(KERN_DEBUG "apicid %x was disabled\n",m->mpc_apicid);
 
 	apicid = mpc_apic_id(m, translation_table[mpc_record]);
 
@@ -189,11 +189,13 @@ static void __init MP_processor_info (st
 		return;
 	}
 
+#ifndef CONFIG_HOTPLUG_CPU
 	if (num_processors >= maxcpus) {
 		printk(KERN_WARNING "WARNING: maxcpus limit of %i reached."
 			" Processor ignored.\n", maxcpus); 
 		return;
 	}
+#endif
 	num_processors++;
 	ver = m->mpc_apicver;
 
diff -Naurp linux-2.6.11.6-mm/arch/i386/kernel/smpboot.c linux-2.6.11.6-HC/arch/i386/kernel/smpboot.c
--- linux-2.6.11.6-mm/arch/i386/kernel/smpboot.c	2005-04-06 23:08:12.000000000 -0400
+++ linux-2.6.11.6-HC/arch/i386/kernel/smpboot.c	2005-04-12 08:40:08.000000000 -0400
@@ -73,6 +73,7 @@ cpumask_t cpu_online_map __cacheline_ali
 
 cpumask_t cpu_callin_map;
 cpumask_t cpu_callout_map;
+cpumask_t cpu_possible_map;
 static cpumask_t smp_commenced_mask;
 
 /* Per CPU bogomips and other parameters */
@@ -195,7 +196,13 @@ valid_k7:
 static atomic_t tsc_start_flag = ATOMIC_INIT(0);
 static atomic_t tsc_count_start = ATOMIC_INIT(0);
 static atomic_t tsc_count_stop = ATOMIC_INIT(0);
-static unsigned long long tsc_values[NR_CPUS];
+union _tsc_values {
+	unsigned long long _tsc_value;
+	struct {
+		unsigned long tsc_value_high;
+		unsigned long tsc_value_low;
+	} _part;
+} tsc_values[NR_CPUS];
 
 #define NR_LOOPS 5
 
@@ -241,12 +248,6 @@ static void __init synchronize_tsc_bp (v
 
 		rdtscll(tsc_values[smp_processor_id()]);
 		/*
-		 * We clear the TSC in the last loop:
-		 */
-		if (i == NR_LOOPS-1)
-			write_tsc(0, 0);
-
-		/*
 		 * Wait for all APs to leave the synchronization point:
 		 */
 		while (atomic_read(&tsc_count_stop) != num_booting_cpus()-1)
@@ -259,7 +260,7 @@ static void __init synchronize_tsc_bp (v
 	sum = 0;
 	for (i = 0; i < NR_CPUS; i++) {
 		if (cpu_isset(i, cpu_callout_map)) {
-			t0 = tsc_values[i];
+			t0 = tsc_values[i]._tsc_value;
 			sum += t0;
 		}
 	}
@@ -270,7 +271,7 @@ static void __init synchronize_tsc_bp (v
 	for (i = 0; i < NR_CPUS; i++) {
 		if (!cpu_isset(i, cpu_callout_map))
 			continue;
-		delta = tsc_values[i] - avg;
+		delta = tsc_values[i]._tsc_value - avg;
 		if (delta < 0)
 			delta = -delta;
 		/*
@@ -284,7 +285,7 @@ static void __init synchronize_tsc_bp (v
 			}
 			realdelta = delta;
 			do_div(realdelta, one_usec);
-			if (tsc_values[i] < avg)
+			if (tsc_values[i]._tsc_value < avg)
 				realdelta = -realdelta;
 
 			printk(KERN_INFO "CPU#%d had %ld usecs TSC skew, fixed it up.\n", i, realdelta);
@@ -312,9 +313,10 @@ static void __init synchronize_tsc_ap (v
 		while (atomic_read(&tsc_count_start) != num_booting_cpus())
 			mb();
 
-		rdtscll(tsc_values[smp_processor_id()]);
+		rdtscll(tsc_values[smp_processor_id()]._tsc_value);
 		if (i == NR_LOOPS-1)
-			write_tsc(0, 0);
+			write_tsc(tsc_values[master]._part.tsc_value_high,
+				tsc_values[master]._part.tsc_value_low);
 
 		atomic_inc(&tsc_count_stop);
 		while (atomic_read(&tsc_count_stop) != num_booting_cpus()) mb();
@@ -449,6 +451,7 @@ static void __init start_secondary(void 
 	local_irq_enable();
 
 	wmb();
+	enable_sep_cpu(0);
 	cpu_idle();
 }
 
@@ -843,7 +846,9 @@ static int __init do_boot_cpu(int apicid
 	x86_cpu_to_apicid[cpu] = apicid;
 	if (boot_error) {
 		/* Try to put things back the way they were before ... */
+#ifndef CONFIG_HOTPLUG_CPU
 		unmap_cpu_to_logical_apicid(cpu);
+#endif
 		cpu_clear(cpu, cpu_callout_map); /* was set here (do_boot_cpu()) */
 		cpu_clear(cpu, cpu_initialized); /* was set by cpu_init() */
 		cpucount--;
@@ -852,6 +857,8 @@ static int __init do_boot_cpu(int apicid
 	/* mark "stuck" area as not stuck */
 	*((volatile unsigned long *)trampoline_base) = 0;
 
+	if (cpu_has_tsc && cpu_khz)
+		synchronize_tsc_bp();
 	return boot_error;
 }
 
@@ -987,27 +994,6 @@ static void __init smp_boot_cpus(unsigne
 	 */
 	Dprintk("CPU present map: %lx\n", physids_coerce(phys_cpu_present_map));
 
-	kicked = 1;
-	for (bit = 0; kicked < NR_CPUS && bit < MAX_APICS; bit++) {
-		apicid = cpu_present_to_apicid(bit);
-		/*
-		 * Don't even attempt to start the boot CPU!
-		 */
-		if ((apicid == boot_cpu_apicid) || (apicid == BAD_APICID))
-			continue;
-
-		if (!check_apicid_present(bit))
-			continue;
-		if (max_cpus <= cpucount+1)
-			continue;
-
-		if (do_boot_cpu(apicid))
-			printk("CPU #%d not responding - cannot use it.\n",
-								apicid);
-		else
-			++kicked;
-	}
-
 	/*
 	 * Cleanup possible dangling ends...
 	 */
@@ -1057,13 +1043,17 @@ static void __init smp_boot_cpus(unsigne
 		struct cpuinfo_x86 *c = cpu_data + cpu;
 		int siblings = 0;
 		int i;
+#ifndef CONFIG_HOTPLUG_CPU
 		if (!cpu_isset(cpu, cpu_callout_map))
 			continue;
+#endif
 
 		if (smp_num_siblings > 1) {
 			for (i = 0; i < NR_CPUS; i++) {
+#ifndef CONFIG_HOTPLUG_CPU
 				if (!cpu_isset(i, cpu_callout_map))
 					continue;
+#endif
 				if (cpu_core_id[cpu] == cpu_core_id[i]) {
 					siblings++;
 					cpu_set(i, cpu_sibling_map[cpu]);
@@ -1094,6 +1084,7 @@ static void __init smp_boot_cpus(unsigne
 
 	setup_boot_APIC_clock();
 
+	enable_sep_cpu(0);
 	/*
 	 * Synchronize the TSC with the AP
 	 */
@@ -1195,13 +1186,6 @@ void __cpu_die(unsigned int cpu)
 
 int __devinit __cpu_up(unsigned int cpu)
 {
-	/* In case one didn't come up */
-	if (!cpu_isset(cpu, cpu_callin_map)) {
-		printk(KERN_DEBUG "skipping cpu%d, didn't come online\n", cpu);
-		local_irq_enable();
-		return -EIO;
-	}
-
 #ifdef CONFIG_HOTPLUG_CPU
 	/* Already up, and in cpu_quiescent now? */
 	if (cpu_isset(cpu, smp_commenced_mask)) {
@@ -1210,11 +1194,19 @@ int __devinit __cpu_up(unsigned int cpu)
 	}
 #endif
 
+	for (i = 0; i < NR_CPUS; i++)
+	cpu_clear(i, cpu_callout_map);
+	cpu_set(smp_processor_id(), cpu_callout_map);
+	apicid = cpu_present_to_apicid(cpu);
+	do_boot_cpu(apicid, cpu);
 	local_irq_enable();
 	/* Unleash the CPU! */
 	cpu_set(cpu, smp_commenced_mask);
 	while (!cpu_isset(cpu, cpu_online_map))
 		mb();
+	cpu_enable(cpu);
+	cpu_clear(cpu, cpu_callout_map);
+	cpu_clear(smp_processor_id(), cpu_callout_map);
 	return 0;
 }
 
@@ -1223,11 +1215,13 @@ void __init smp_cpus_done(unsigned int m
 #ifdef CONFIG_X86_IO_APIC
 	setup_ioapic_dest();
 #endif
+#ifndef CONFIG_HOTPLUG_CPU
 	zap_low_mappings();
 	/*
 	 * Disable executability of the SMP trampoline:
 	 */
 	set_kernel_exec((unsigned long)trampoline_base, trampoline_exec);
+#endif
 }
 
 void __init smp_intr_init(void)
diff -Naurp linux-2.6.11.6-mm/arch/i386/kernel/sysenter.c linux-2.6.11.6-HC/arch/i386/kernel/sysenter.c
--- linux-2.6.11.6-mm/arch/i386/kernel/sysenter.c	2005-04-06 23:08:12.000000000 -0400
+++ linux-2.6.11.6-HC/arch/i386/kernel/sysenter.c	2005-04-12 07:59:36.000000000 -0400
@@ -58,7 +58,6 @@ static int __init sysenter_setup(void)
 	       &vsyscall_sysenter_start,
 	       &vsyscall_sysenter_end - &vsyscall_sysenter_start);
 
-	on_each_cpu(enable_sep_cpu, NULL, 1, 1);
 	return 0;
 }
 
diff -Naurp linux-2.6.11.6-mm/include/asm/smp.h linux-2.6.11.6-HC/include/asm/smp.h
--- linux-2.6.11.6-mm/include/asm/smp.h	2005-04-06 23:09:26.000000000 -0400
+++ linux-2.6.11.6-HC/include/asm/smp.h	2005-04-12 08:06:48.000000000 -0400
@@ -55,7 +55,7 @@ extern u8 x86_cpu_to_apicid[];
 
 extern cpumask_t cpu_callout_map;
 extern cpumask_t cpu_callin_map;
-#define cpu_possible_map cpu_callout_map
+extern cpumask_t cpu_possible_map;
 
 /* We don't mark CPUs online until __cpu_up(), so we need another measure */
 static inline int num_booting_cpus(void)
diff -Naurp linux-2.6.11.6-mm/include/asm-i386/smp.h linux-2.6.11.6-HC/include/asm-i386/smp.h
--- linux-2.6.11.6-mm/include/asm-i386/smp.h	2005-04-06 23:09:26.000000000 -0400
+++ linux-2.6.11.6-HC/include/asm-i386/smp.h	2005-04-12 08:06:48.000000000 -0400
@@ -55,7 +55,7 @@ extern u8 x86_cpu_to_apicid[];
 
 extern cpumask_t cpu_callout_map;
 extern cpumask_t cpu_callin_map;
-#define cpu_possible_map cpu_callout_map
+extern cpumask_t cpu_possible_map;
 
 /* We don't mark CPUs online until __cpu_up(), so we need another measure */
 static inline int num_booting_cpus(void)
diff -Naurp linux-2.6.11.6-mm/init/main.c linux-2.6.11.6-HC/init/main.c
--- linux-2.6.11.6-mm/init/main.c	2005-04-06 23:08:21.000000000 -0400
+++ linux-2.6.11.6-HC/init/main.c	2005-04-12 08:46:54.000000000 -0400
@@ -684,7 +684,9 @@ static int init(void * unused)
 	 * we're essentially up and running. Get rid of the
 	 * initmem segments and start the user-mode stuff..
 	 */
+#infdef CONFIG_HOTPLUG_CPU
 	free_initmem();
+#endif
 	unlock_kernel();
 	system_state = SYSTEM_RUNNING;
 	numa_default_policy();

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2005-04-30 12:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-12  5:30 [PATCH 1/6]sep initializing rework Li Shaohua
2005-04-12 12:07 ` Zwane Mwaikambo
2005-04-30 12:06 ` Benoit Boissinot
2005-04-12 17:57 Protasevich, Natalie
2005-04-13  1:39 ` Li Shaohua

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).