Per-cpu patches on top of PDA stuff...
Hi Jeremy, all,
Sorry this took so long, spent last week in Japan at OSDL conf then
netconf. After several false starts, I ended up with a very simple implementation, which clashes significantly with your work since then 8(. I've pushed the patches anyway, but it's going to be significant work for me to re-merge them, so I wanted your feedback first.
The first patch simply changes the GDTs to be a straight per-cpu
variable. I notice that you did a similar thing with your patches, but this is simpler and avoids wasting space in the UP case. It's a bit tricky since we've never referred to per-cpu vars from asm before, but since we're only referring to the pre-setup versions, it's ok.
The second patch changes gs to be the per-cpu offset, and by
implication, avoids using it altogether on UP. This avoids a special "pda" structure, instead allowing all per-cpu variables to be accessed this way. It avoids __thread, which I gave up after creating a horribly complicated patch which still didn't quite work, and was no more efficient if we want the kernel to run under Xen anyway.
I really think this is the way to go, and I'll start work on merging now.
Cheers!
Rusty.
Signature · 1 line
Help! Save Australia from the worst of the DMCA: http://linux.org.au/law
Quoted 7 lines · Rusty Russell
Hi Jeremy, all,
Sorry this took so long, spent last week in Japan at OSDL conf then
netconf. After several false starts, I ended up with a very simple implementation, which clashes significantly with your work since then 8(. I've pushed the patches anyway, but it's going to be significant work for me to re-merge them, so I wanted your feedback first.
OK, here's a patch against 2.6.18-rc6-mm2. Tested on UP and SMP. Crashes on hotplugging CPU, but crashes in same way as before the patch 8).
Replace PDA with per-cpu section, and put GDT in per-cpu section.
This patch uses the "gs" segment register which Jeremy Fitzhardinge freed up for kernel use, for the per-cpu section. This means that instead of having a special per-cpu struct which we can access in a single instruction, any per-cpu variable can be accessed in a single instruction. In addition, it avoids introducing the concept of a "pda" into the kernel, in favour of the well-known "percpu" concept.
So, arch-specific code (eg. smp_processor_id()) can use x86_write_percpu()/x86_read_percpu() directly. Generic code expects an lvalue from __get_cpu_var(), but it takes two instruction to get the address of a per-cpu variable (still not bad). Ideally, we could use the __thread extension, and GCC would then generate optimal code when an lvalue isn't needed, however, the linker wants to use a negative offset within the gs register, which cannot be used with Xen (or any similar hypervisor), because it requires a 4GB segment, which would allow the OS to access the hypervisor memory.
As an additional simplification, the GDT is placed directly in a per-cpu variable, rather than allocated dynamically. This is optimal for the UP case (previously, we made a copy even here), and signficantly simplfies the code. It's a little unusual to have asm access a per-cpu var, but it is only done early at boot, where the per-cpu GDT is sitting in the to-be-discarded section.
More cleanups/optimizations are possible:
1) Don't save/restore %gs on UP. The cost is measurable, and we don't use it.
2) Remove early_smp_processor_id(), by setting up the per-cpu processor_id field correctly before starting a CPU.
3) Similarly, get rid of early_current().
4) Implement cpu_local_* in terms of x86_read_percpu etc.
arch/i386/kernel/cpu/common.c +18 -141
@@ -19,18 +19,14 @@#include <asm/apic.h> #include <mach_apic.h> #endif -#include <asm/pda.h> #include "cpu.h" -DEFINE_PER_CPU(struct Xgt_desc_struct, cpu_gdt_descr); -EXPORT_PER_CPU_SYMBOL (cpu_gdt_descr); - DEFINE_PER_CPU(unsigned char, cpu_16bit_stack[CPU_16BIT_STACK_SIZE]);EXPORT_PER_CPU_SYMBOL (cpu_16bit_stack); -struct i386_pda *_cpu_pda[NR_CPUS ]__read_mostly ; -EXPORT_SYMBOL (_cpu_pda); +DEFINE_PER_CPU(struct task_struct *, current_task) = &init_task; +EXPORT_PER_CPU_SYMBOL (current_task);static int cachesize_override__cpuinitdata =-1 ;static int disable_x86_fxsr__cpuinitdata ;
@@ -592,141 +587,10 @@ void __init early_cpu_init(void)struct pt_regs *__devinit idle_regs (struct pt_regs *regs) {memset (regs,0 ,sizeof (struct pt_regs )); - regs->xgs = __KERNEL_PDA; + regs->xgs = __KERNEL_PERCPU;return regs; } -__cpuinit int alloc_gdt (int cpu) -{ -struct Xgt_desc_struct *cpu_gdt_descr = &per_cpu (cpu_gdt_descr, cpu); -struct desc_struct *gdt; -struct i386_pda *pda; - - gdt = (struct desc_struct *)cpu_gdt_descr->address; - pda =cpu_pda (cpu); - -/* -* This is a horrible hack to allocate the GDT. The problem -* is that cpu_init() is called really early for the boot CPU -* (and hence needs bootmem) but much later for the secondary -* CPUs, when bootmem will have gone away -*/ -if (NODE_DATA (0 )->bdata->node_bootmem_map) { -BUG_ON (gdt !=NULL || pda !=NULL ); - - gdt =alloc_bootmem_pages (PAGE_SIZE ); - pda =alloc_bootmem (sizeof (*pda)); -/* alloc_bootmem(_pages) panics on failure, so no check */ - -memset (gdt,0 ,PAGE_SIZE ); -memset (pda,0 ,sizeof (*pda)); - }else { -/* GDT and PDA might already have been allocated if -this is a CPU hotplug re-insertion. */ -if (gdt ==NULL ) - gdt = (struct desc_struct *)get_zeroed_page (GFP_KERNEL ); - -if (pda ==NULL ) - pda =kmalloc_node (sizeof (*pda),GFP_KERNEL ,cpu_to_node (cpu)); - -if (unlikely (!gdt || !pda)) { -free_pages ((unsigned long )gdt,0 ); -kfree (pda); -return 0 ; - } - } - - cpu_gdt_descr->address = (unsigned long )gdt; -cpu_pda (cpu) = pda; - -return 1 ; -} - -static __cpuinit void pda_init (int cpu,struct task_struct *curr) -{ -struct i386_pda *pda =cpu_pda (cpu); - -memset (pda,0 ,sizeof (*pda)); - - pda->cpu_number = cpu; - pda->pcurrent = curr; - -printk ("cpu %d current %p\n" , cpu, curr); -} - -static inline void set_kernel_gs (void ) -{ -/* Set %gs for this CPU's PDA. Memory clobber is to create a -barrier with respect to any PDA operations, so the compiler -doesn't move any before here. */ - asmvolatile ("mov %0, %%gs" : :"r" (__KERNEL_PDA) :"memory" ); -} - -/* Initialize the CPU's GDT and PDA */ -static __cpuinit void init_gdt (void ) -{ -int cpu =early_smp_processor_id (); -struct task_struct *curr =early_current (); -struct Xgt_desc_struct *cpu_gdt_descr = &per_cpu (cpu_gdt_descr, cpu); -__u32 stk16_off = (__u32)&per_cpu (cpu_16bit_stack, cpu); -struct desc_struct *gdt; -struct i386_pda *pda; - -/* For non-boot CPUs, the GDT and PDA should already have been -allocated. */ -if (!alloc_gdt (cpu)) { -printk (KERN_CRIT "CPU%d failed to allocate GDT or PDA\n" , cpu); -for (;;) -local_irq_enable (); - } - - gdt = (struct desc_struct *)cpu_gdt_descr->address; - pda =cpu_pda (cpu); - -BUG_ON (gdt ==NULL || pda ==NULL ); - -/* -* Initialize the per-CPU GDT with the boot GDT, -* and set up the GDT descriptor: -*/ -memcpy (gdt, cpu_gdt_table,GDT_SIZE ); - cpu_gdt_descr->size =GDT_SIZE -1 ; - -/* Set up GDT entry for 16bit stack */ - *(__u64 *)(&gdt[GDT_ENTRY_ESPFIX_SS ]) |= - ((((__u64 )stk16_off) <<16 ) &0x000000ffffff0000ULL ) | - ((((__u64 )stk16_off) <<32 ) &0xff00000000000000ULL ) | - (CPU_16BIT_STACK_SIZE -1 ); - -pack_descriptor ((u32 *)&gdt[GDT_ENTRY_PDA ].a, - (u32 *)&gdt[GDT_ENTRY_PDA ].b, - (unsigned long )pda,sizeof (*pda) -1 , -0x80 |DESCTYPE_S |0x2 ,0 );/* present read-write data segment */ - -load_gdt (cpu_gdt_descr); -set_kernel_gs (); - -/* Do this once everything GDT-related has been set up. */ -pda_init (cpu, curr); -} - -/* Set up a very early PDA for the boot CPU so that smp_processor_id() -and current will work. */ -void __init smp_setup_processor_id (void ) -{ -static __initdata struct i386_pda boot_pda; - -pack_descriptor ((u32 *)&cpu_gdt_table[GDT_ENTRY_PDA ].a, - (u32 *)&cpu_gdt_table[GDT_ENTRY_PDA ].b, - (unsigned long )&boot_pda,sizeof (struct i386_pda ) -1 , -0x80 |DESCTYPE_S |0x2 ,0 );/* present read-write data segment */ - - boot_pda.pcurrent =early_current (); - -/* Set %gs for this CPU's PDA */ -set_kernel_gs (); -} -/* * cpu_init() initializes state that is per-CPU. Some data is already * initialized (naturally) in the bootstrap process, such as the GDT
@@ -740,15 +604,27 @@ void __cpuinit cpu_init(void)struct tss_struct * t = &per_cpu (init_tss, cpu);struct thread_struct *thread = &curr->thread; +struct desc_struct *gdt; +u32 stk16_off;if (cpu_test_and_set (cpu, cpu_initialized)) {printk (KERN_WARNING "CPU#%d already initialized!\n" , cpu);for (;;)local_irq_enable (); } -/* Init the GDT and PDA early, before calling printk(), -since it may end up using the PDA indirectly. */ -init_gdt (); +/* Complete percpu area setup early, before calling printk(), +since it may end up using it indirectly. */ +setup_percpu_for_this_cpu (cpu); +/* FIXME: Always the idle thread, can get rid of early_current. */ +__get_cpu_var (current_task) = curr; + +/* Set up GDT entry for 16bit stack */ + stk16_off = (u32)&__get_cpu_var (cpu_16bit_stack); + gdt =__get_cpu_var (cpu_gdt_table); + *(__u64 *)(&gdt[GDT_ENTRY_ESPFIX_SS ]) |= + ((((__u64 )stk16_off) <<16 ) &0x000000ffffff0000ULL ) | + ((((__u64 )stk16_off) <<32 ) &0xff00000000000000ULL ) | + (CPU_16BIT_STACK_SIZE -1 );printk (KERN_INFO "Initializing CPU#%d\n" , cpu);
arch/i386/kernel/entry.S +2 -2
@@ -125,7 +125,7 @@ VM_MASK = 0x00020000 movl $(__USER_DS), %edx; \ movl %edx, %ds; \ movl %edx, %es; \ - movl $(__KERNEL_PDA), %edx; \ + movl $(__KERNEL_PERCPU), %edx; \ movl %edx, %gs #define RESTORE_INT_REGS \
@@ -638,7 +638,7 @@ error_code: movl $(__USER_DS), %ecx movl %ecx, %ds movl %ecx, %es - movl $(__KERNEL_PDA), %ecx + movl $(__KERNEL_PERCPU), %ecx movl %ecx, %gs movl %esp,%eax # pt_regs pointer call *%edi
arch/i386/kernel/head.S +1 -59
75 lines not on this page · raw message
arch/i386/kernel/process.c +3 -3
@@ -38,6 +38,7 @@#include <linux/ptrace.h> #include <linux/random.h> #include <linux/personality.h> +#include <linux/percpu.h> #include <asm/uaccess.h> #include <asm/pgtable.h>
@@ -56,7 +57,6 @@#include <asm/tlbflush.h> #include <asm/cpu.h> -#include <asm/pda.h> asmlinkage void ret_from_fork(void) __asm__("ret_from_fork");
@@ -345,7 +345,7 @@ int kernel_thread(int (*fn)(void *), voi regs.xds = __USER_DS; regs.xes = __USER_DS; - regs.xgs = __KERNEL_PDA; + regs.xgs = __KERNEL_PERCPU; regs.orig_eax =-1 ; regs.eip = (unsigned long ) kernel_thread_helper; regs.xcs = __KERNEL_CS |get_kernel_rpl ();
@@ -684,7 +684,7 @@ struct task_struct fastcall * __switch_tif (unlikely (prev->fs | next->fs))loadsegment (fs, next->fs); -write_pda (pcurrent, next_p); +x86_write_percpu (current_task, next_p);/* * Restore IOPL if needed.
arch/i386/kernel/setup.c +46 -0
52 lines not on this page · raw message
arch/i386/kernel/smpboot.c +55 -21
120 lines not on this page · raw message
include/asm-i386/current.h +3 -7
@@ -2,7 +2,7 @@#define _I386_CURRENT_H#include <linux/thread_info.h> -#include <asm/pda.h> +#include <asm/percpu.h> struct task_struct ;
@@ -11,11 +11,7 @@ static __always_inline struct task_strucreturn current_thread_info ()->task; } -static __always_inline struct task_struct *get_current(void) -{ -return read_pda (pcurrent); -} - -#define current get_current() +DECLARE_PER_CPU(struct task_struct *, current_task); +#define current x86_read_percpu(current_task)#endif /* !(_I386_CURRENT_H) */
include/asm-i386/desc.h +2 -4
@@ -14,8 +14,8 @@#include <asm/mmu.h> -extern struct desc_struct cpu_gdt_table[GDT_ENTRIES ]; - +DECLARE_PER_CPU(struct desc_struct, cpu_gdt_table[GDT_ENTRIES]); +DECLARE_PER_CPU(struct Xgt_desc_struct, cpu_gdt_descr); DECLARE_PER_CPU(unsigned char, cpu_16bit_stack[CPU_16BIT_STACK_SIZE]);struct Xgt_desc_struct {
@@ -25,8 +25,6 @@ struct Xgt_desc_struct { } __attribute__ ((packed));extern struct Xgt_desc_struct idt_descr; -DECLARE_PER_CPU(struct Xgt_desc_struct, cpu_gdt_descr); -static inline struct desc_struct *get_cpu_gdt_table (unsigned int cpu) {
include/asm-i386/pda.h +0 -68
68 lines not on this page · raw message
include/asm-i386/percpu.h +101 -0
107 lines not on this page · raw message
include/asm-i386/processor.h +1 -2
@@ -473,7 +473,7 @@ struct thread_struct { .vm86_info = NULL, \ .sysenter_cs = __KERNEL_CS, \ .io_bitmap_ptr = NULL, \ - .gs = __KERNEL_PDA, \ + .gs = __KERNEL_PERCPU, \ }/*
@@ -728,6 +728,5 @@ extern void select_idle_routine(const stextern unsigned long boot_option_idle_override;extern void enable_sep_cpu (void );extern int sysenter_setup (void ); -extern int alloc_gdt (int cpu);#endif /* __ASM_I386_PROCESSOR_H */
include/asm-i386/segment.h +3 -3
@@ -39,7 +39,7 @@* 25 - APM BIOS support * * 26 - ESPFIX small SS -* 27 - PDA [ per-cpu private data area ] +* 27 - PERCPU [ offset segment for per-cpu area ] * 28 - unused * 29 - unused * 30 - unused
@@ -74,8 +74,8 @@#define GDT_ENTRY_ESPFIX_SS (GDT_ENTRY_KERNEL_BASE + 14)#define __ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8) -#define GDT_ENTRY_PDA (GDT_ENTRY_KERNEL_BASE + 15) -#define __KERNEL_PDA (GDT_ENTRY_PDA * 8) +#define GDT_ENTRY_PERCPU (GDT_ENTRY_KERNEL_BASE + 15) +#define __KERNEL_PERCPU (GDT_ENTRY_PERCPU * 8)#define GDT_ENTRY_DOUBLEFAULT_TSS 31
include/asm-i386/smp.h +6 -2
@@ -8,7 +8,7 @@#include <linux/kernel.h> #include <linux/threads.h> #include <linux/cpumask.h> -#include <asm/pda.h> +#include <asm/percpu.h> #endif #ifdef CONFIG_X86_LOCAL_APIC
@@ -59,7 +59,8 @@ extern void cpu_uninit(void);* from the initial startup. We map APIC_BASE very early in page_setup(), * so this is correct in the x86 case. */ -#define raw_smp_processor_id () (read_pda(cpu_number)) +DECLARE_PER_CPU(unsigned int, processor_id); +#define raw_smp_processor_id () (x86_read_percpu(processor_id))/* This is valid from the very earliest point in boot that we care about. */ #define early_smp_processor_id () (current_thread_info()->cpu)
@@ -93,6 +94,8 @@ extern int __cpu_disable(void);extern void __cpu_die (unsigned int cpu);extern unsigned int num_processors; +void setup_percpu_for_this_cpu (unsigned int cpu); +#endif /* !__ASSEMBLY__ */ #else /* CONFIG_SMP */
@@ -100,6 +103,7 @@ extern unsigned int num_processors;#define safe_smp_processor_id () 0#define cpu_physical_id (cpu) boot_cpu_physical_apicid#define early_smp_processor_id () 0 +#define setup_percpu_for_this_cpu (cpu)#define NO_PROC_ID 0xFF/* No processor magic marker */
include/asm-i386/unwind.h +1 -1
@@ -65,7 +65,7 @@ static inline void arch_unw_init_blocked info->regs.xss = __KERNEL_DS; info->regs.xds = __USER_DS; info->regs.xes = __USER_DS; - info->regs.xgs = __KERNEL_PDA; + info->regs.xgs = __KERNEL_PERCPU; } extern asmlinkage int arch_unwind_init_running(struct unwind_frame_info *,
Signature · 1 line
Help! Save Australia from the worst of the DMCA: http://linux.org.au/law
Quoted 6 lines · Rusty Russell
The first patch simply changes the GDTs to be a straight per-cpu
variable. I notice that you did a similar thing with your patches, but this is simpler and avoids wasting space in the UP case. It's a bit tricky since we've never referred to per-cpu vars from asm before, but since we're only referring to the pre-setup versions, it's ok.
The current mechanism was specifically introduced by James Bottomley a while back; I guess to deal with Voyager strangeness.
As far as setting up the PDA in head.S goes, it turns out to be very easy without having to access any per-cpu data, since the whole CPU bringup stuff depends on static variables anyway.
Quoted 9 lines
The second patch changes gs to be the per-cpu offset, and by
implication, avoids using it altogether on UP. This avoids a special "pda" structure, instead allowing all per-cpu variables to be accessed this way. It avoids__thread, which I gave up after creating a horribly complicated patch which still didn't quite work, and was no more efficient if we want the kernel to run under Xen anyway.I really think this is the way to go, and I'll start work on merging now.
Hm, now is not really a good time. I'm still trying to get Xen basically working, and the percpu PDA stuff isn't really necessary for that. The PDA stuff was enough of a problem in itself...
Also, the PDA patches are in -mm, so that's probably a better base for your patches.
J
Quoted 9 lines · Rusty Russell
Quoted 7 lines · Rusty Russell
Hi Jeremy, all,
Sorry this took so long, spent last week in Japan at OSDL conf then
netconf. After several false starts, I ended up with a very simple implementation, which clashes significantly with your work since then 8(. I've pushed the patches anyway, but it's going to be significant work for me to re-merge them, so I wanted your feedback first.
Quoted 3 lines
OK, here's a patch against 2.6.18-rc6-mm2. Tested on UP and SMP. Crashes on hotplugging CPU, but crashes in same way as before the patch 8).
The incremental patches are madness and unmergeable. Can you please just do fresh patches with PDA stuff dropped first?
-Andi
Quoted 2 lines · * Rusty Russell ([email protected]) wrote:
8(. I've pushed the patches anyway, but it's going to be significant work for me to re-merge them, so I wanted your feedback first.
Seems you or Jeremy pushed an unmerged head to the queue. Please don't do that, it makes life going forward a mess. I'm merging it, will push the result so best double check it.
thanks,
-chris
Quoted 7 lines · Rusty Russell
This patch uses the "gs" segment register which Jeremy Fitzhardinge freed up for kernel use, for the per-cpu section. This means that instead of having a special per-cpu struct which we can access in a single instruction, any per-cpu variable can be accessed in a single instruction. In addition, it avoids introducing the concept of a "pda" into the kernel, in favour of the well-known "percpu" concept.
The PDA is well established in the x86-64 tree; one of the reasons for having an x86-32 PDA was to make the trees a bit more similar.
Quoted 3 lines
More cleanups/optimizations are possible:
1) Don't save/restore %gs on UP. The cost is measurable, and we don't use it.
You need to make sure the userspace %gs gets saved/restored for context switch. If you don't do it in entry.S, you need to have two versions of the %gs-handling code in a number of places around the kernel (__switch_to, vm86, ptrace).
Quoted 4 lines
2) Remove
early_smp_processor_id(), by setting up the per-cpuprocessor_idfield correctly before starting a CPU.
3) Similarly, get rid ofearly_current().
I've already submitted a patch to do this. In fact, it would help if you could rebase against my most recent patches (which I think Andrew has queued for the next -mm, and are in the paravirt patch queue).
Also, does this patch address the problem of percpu module variables? That was the only real sticking point with my previous percpu-in-pda patch.
I can't say this patch fills me with joy.
J
Quoted 4 lines · Chris Wright
Seems you or Jeremy pushed an unmerged head to the queue. Please don't do that, it makes life going forward a mess. I'm merging it, will push the result so best double check it.
I don't think we should merge it now. There are enough other things broken before adding more complexity.
J
Quoted 9 lines · * Jeremy Fitzhardinge ([email protected]) wrote:
Quoted 5 lines · Rusty Russell
The first patch simply changes the GDTs to be a straight per-cpu
variable. I notice that you did a similar thing with your patches, but this is simpler and avoids wasting space in the UP case. It's a bit tricky since we've never referred to per-cpu vars from asm before, but since we're only referring to the pre-setup versions, it's ok.The current mechanism was specifically introduced by James Bottomley a while back; I guess to deal with Voyager strangeness.
Yes, he reverted some changes because voyager boot cpu may not be cpu 0.
Quoted 11 lines
As far as setting up the PDA in
head.Sgoes, it turns out to be very easy without having to access any per-cpu data, since the whole CPU bringup stuff depends on static variables anyway.Quoted 7 lines
The second patch changes gs to be the per-cpu offset, and by
implication, avoids using it altogether on UP. This avoids a special "pda" structure, instead allowing all per-cpu variables to be accessed this way. It avoids__thread, which I gave up after creating a horribly complicated patch which still didn't quite work, and was no more efficient if we want the kernel to run under Xen anyway.
Quoted 6 lines
Quoted 2 lines
I really think this is the way to go, and I'll start work on merging now.
Hm, now is not really a good time. I'm still trying to get Xen basically working, and the percpu PDA stuff isn't really necessary for that. The PDA stuff was enough of a problem in itself...
I agree. We're right in the middle of the last bit of Xen bring up. PDA is not strictly needed, and destabilizing for this would be counter productive.
thanks,
-chris
Quoted 7 lines · * Jeremy Fitzhardinge ([email protected]) wrote:
Quoted 3 lines · Chris Wright
Seems you or Jeremy pushed an unmerged head to the queue. Please don't do that, it makes life going forward a mess. I'm merging it, will push the result so best double check it.
I don't think we should merge it now. There are enough other things broken before adding more complexity.
No, I just mean merge in the queue (which means I'll drop the series changes that Rusty made, otherwise it should have zero overlap). Otherwise mercurial gets unhappy with unmerged heads.
thanks,
-chris
Quoted 4 lines · Chris Wright
I agree. We're right in the middle of the last bit of Xen bring up. PDA is not strictly needed, and destabilizing for this would be counter productive.
Well, the basic PDA stuff is already in there, and seems OK now. I don't want to revisit it until everything else looks sound though.
J
Quoted 10 lines · Jeremy Fitzhardinge
Quoted 6 lines · Rusty Russell
The first patch simply changes the GDTs to be a straight per-cpu
variable. I notice that you did a similar thing with your patches, but this is simpler and avoids wasting space in the UP case. It's a bit tricky since we've never referred to per-cpu vars from asm before, but since we're only referring to the pre-setup versions, it's ok.The current mechanism was specifically introduced by James Bottomley a while back; I guess to deal with Voyager strangeness.
(James CC'd). I dislike the gratuitous copy: we have three gdts, the boot GDT, the master GDT (cpu_gdt_table), then the per-cpu GDT. Using the per-cpu mechanisms already in place makes it simple, avoids manual allocation, and the extra master GDT. The extra GDT is particularly embarrassing on UP, which doesn't want a per-cpu GDT anyway...
Seems that we can't assume boot CPU == 0. I think I've removed the two places where I assumed that, but will need testing.
Quoted 6 lines
Hm, now is not really a good time. I'm still trying to get Xen basically working, and the percpu PDA stuff isn't really necessary for that. The PDA stuff was enough of a problem in itself...
Also, the PDA patches are in -mm, so that's probably a better base for your patches.
Yes, it turned out to be easier to go straight to -mm anyway. I'll redo them as Andi requested....
Rusty.
Signature · 1 line
Help! Save Australia from the worst of the DMCA: http://linux.org.au/law
Quoted 3 lines
Seems that we can't assume boot CPU == 0. I think I've removed the two places where I assumed that, but will need testing.
boot CPU == 0 should be true. You just can't assume anything about its APIC ID, but we decouple APIC ID and logical processor id anyways.
Another issue is that with CPU hotunplug CPU #0 might disappear at some point later.
-Andi
Quoted 2 lines · Andi Kleen
boot CPU == 0 should be true. You just can't assume anything about its APIC ID, but we decouple APIC ID and logical processor id anyways.
No, it is not. Voyager has fixed and immutable CPU IDs dependent on CPU position in the system. If CPU 0 is missing or logically deconfigured, the boot CPU is definitely non zero.
James
Quoted 7 lines · James Bottomley
Quoted 2 lines · Andi Kleen
boot CPU == 0 should be true. You just can't assume anything about its APIC ID, but we decouple APIC ID and logical processor id anyways.
No, it is not. Voyager has fixed and immutable CPU IDs dependent on CPU position in the system. If CPU 0 is missing or logically deconfigured, the boot CPU is definitely non zero.
As APIC ID (hard_smp_processor_id()) possible, but surely not as linux logical
processor id (smp_processor_id()). That always starts with 0 and goes up.
-Andi
Quoted 2 lines · Andi Kleen
As APIC ID (
hard_smp_processor_id()) possible, but surely not as linux logical
processor id (smp_processor_id()). That always starts with 0 and goes up.
Voyager is not APIC based. The SMP hal is constructed so there's no such thing as processor translation. hard and soft processor IDs return the same thing.
James
Quoted 7 lines · James Bottomley
Quoted 2 lines · Andi Kleen
As APIC ID (
hard_smp_processor_id()) possible, but surely not as linux logical
processor id (smp_processor_id()). That always starts with 0 and goes up.Voyager is not APIC based. The SMP hal is constructed so there's no such thing as processor translation. hard and soft processor IDs return the same thing.
Well that's your problem then. Just add the remapping array.
-Andi
Quoted 1 line · Andi Kleen
Well that's your problem then. Just add the remapping array.
I don't see why I should be the one to add unnecessary obfuscation. Using the current ID scheme, the user always knows exactly where to find CPU<n> in the chassis (and they are separately installable and removable). Why should I make up a new identity scheme that would have no relation to the hardware?
James
Quoted 8 lines · James Bottomley
Quoted 1 line · Andi Kleen
Well that's your problem then. Just add the remapping array.
I don't see why I should be the one to add unnecessary obfuscation. Using the current ID scheme, the user always knows exactly where to find CPU<n> in the chassis (and they are separately installable and removable). Why should I make up a new identity scheme that would have no relation to the hardware?
Because it makes it easier to write other code? We don't really want any unnecessary limiting assumptions in arch/i386 just because of some obscure machine with one user.
-Andi
Quoted 3 lines · Andi Kleen
Because it makes it easier to write other code? We don't really want any unnecessary limiting assumptions in
arch/i386just because of some obscure machine with one user.
Really? I don't see it that way. I did a lot of work back in 2000/2001 to break x86 of its remapped CPU assumptions ... it's been operating nicely for 6 years, I don't see a reason to break it now.
Also, as we enter the era of hotplug CPUs, when a non voyager x86 system tells you CPU3 is overheating, how to you find out exactly which CPU to hot unplug?
James
Quoted 8 lines · James Bottomley
Quoted 3 lines · Andi Kleen
Because it makes it easier to write other code? We don't really want any unnecessary limiting assumptions in
arch/i386just because of some obscure machine with one user.Really? I don't see it that way. I did a lot of work back in 2000/2001 to break x86 of its remapped CPU assumptions ... it's been operating nicely for 6 years, I don't see a reason to break it now.
There are already CPU #0 assumptions in various paths, although they might not affect you.
Quoted 4 lines
Also, as we enter the era of hotplug CPUs, when a non voyager x86 system tells you CPU3 is overheating, how to you find out exactly which CPU to hot unplug?
Right now you can't anyways, but at some point I would expect this information to be in the SMBIOS (mapped from APIC-ID) and giving some label that is printed on the motherboard.
We already support this for DIMMs BTW (although it doesn't work everywhere due to very creative spec interpretation of some vendors)
-Andi
Quoted 8 lines · James Bottomley
Quoted 3 lines · Andi Kleen
Because it makes it easier to write other code? We don't really want any unnecessary limiting assumptions in
arch/i386just because of some obscure machine with one user.Really? I don't see it that way. I did a lot of work back in 2000/2001 to break x86 of its remapped CPU assumptions ... it's been operating nicely for 6 years, I don't see a reason to break it now.
I agree with James, it's just that I can't test it. I'll send you my patch set when I'm done, please test...
Thanks!
Rusty.
Signature · 1 line
Help! Save Australia from the worst of the DMCA: http://linux.org.au/law