Skip to contentSkip to conversation

initialize some more cpuinfo fields

PATCH In review Jan Beulich 2 participants 6 messages May 8, 2006 1 message not in the archive Xen hypervisor interface

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 initialize some more cpuinfo fields

Namely preventing systems to look like single-socket ones with many cores (because all CPUs show physical ID being zero).

drivers/xen/core/smpboot.c +15 -0
Index: head-2006-05-03/drivers/xen/core/smpboot.c
===================================================================
@@ -148,9 +148,23 @@ static void xen_smp_intr_exit(unsigned i
 
 static void cpu_bringup(void)
 {
+	unsigned cpu;
+	struct cpuinfo_x86 *c;
+
 	cpu_init();
 	touch_softlockup_watchdog();
 	preempt_disable();
+
+	cpu = smp_processor_id();
+	c = cpu_data + cpu;
+	*c = boot_cpu_data;
+	identify_cpu(c);
+	/* We fake a single-core, single-thread configuration, short of
+	   knowing the real setup. c->booted_cores is always 1 (inherited
+	   from boot_cpu_data). */
+	phys_proc_id[cpu] = cpu;
+	print_cpu_info(c);
+
 	local_irq_enable();
 	cpu_idle();
 }
@@ -230,6 +244,7 @@ void __init smp_prepare_cpus(unsigned in
 	struct Xgt_desc_struct *gdt_descr;
 #endif
 
+	boot_cpu_data.booted_cores = 1;
 	cpu_data[0] = boot_cpu_data;
 
 	cpu_2_logical_apicid[0] = 0;

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw
Quoted 2 lines · Jan Beulich

Namely preventing systems to look like single-socket ones with many cores (because all CPUs show physical ID being zero).

Is it a problem to look like a many-core processor? Given that VCPUS can get moved around between physical CPUs to load-balance, it doesn't make much sense to take the physical IDs of CPUs that VCPUs happen to run on when they boot.

If the many-core appearance is a problem then we could synthesise different physical IDs for VCPUs (probably by forcing physical ID to VCPU number).

The only exception to this 'lie' could perhaps be domain0 in some situations, if we guarantee to run a dom0 VCPU on every physical CPU and never change the pinning. Then calling identify_cpu() for each VCPU makes sense, as does parsing SRAT data or otherwise obtaining NUMA info via a Xen hypercall.

-- Keir

#2 lore raw
Quoted 4 lines
Quoted 1 line
Quoted 1 line

Keir Fraser <[email protected]> 08.05.06 15:46 >>>

On 8 May 2006, at 14:10, Jan Beulich wrote:

Quoted 8 lines
Quoted 3 lines

Namely preventing systems to look like single-socket ones with many cores (because all CPUs show physical ID being
zero).

Is it a problem to look like a many-core processor? Given that VCPUS can get moved around between physical CPUs to load-balance, it doesn't make much sense to take the physical IDs of CPUs that VCPUs happen to run on when they boot.

Yes, we have an irqbalance userland package that is, as I'm told, supposed to run only on multi-socket systems.

Quoted 3 lines

If the many-core appearance is a problem then we could synthesise different physical IDs for VCPUs (probably by forcing physical ID to VCPU number).

This is what the patch does (it simply overrides whatever identify_cpu() provided).

Quoted 5 lines

The only exception to this 'lie' could perhaps be domain0 in some situations, if we guarantee to run a dom0 VCPU on every physical CPU and never change the pinning. Then calling identify_cpu() for each VCPU makes sense, as does parsing SRAT data or otherwise obtaining NUMA info via a Xen hypercall.

Yes, if such a guarantee was made, then dom0 should behave like native (and should specifically also have/call set_cpu_sibling_map()), provided there are not currently any implications on cpu_sibling_map or cpu_core_map in the Xen specific code.

Jan

#3 lore raw
Quoted 5 lines · Jan Beulich
Quoted 3 lines

If the many-core appearance is a problem then we could synthesise different physical IDs for VCPUs (probably by forcing physical ID to VCPU number).

This is what the patch does (it simply overrides whatever identify_cpu() provided).

Why add the copy from boot_cpu_data, or the call to identify_cpu(), at all? We already initialise the cpu_data in smp_prepare_cpus(), and we set up the cpu_to_apicid array at the same time. Why not lie about cpu_data->apicid, and set phys_proc_id[cpu], at the same time in the same function?

That would be a one- or two-liner, plus maybe your modification of booted_cores if that's still needed.

-- Keir

A message that is not in the archive (sent off-list or not yet received): [email protected]

#5 lore raw
Quoted 6 lines · Jan Beulich
Quoted 3 lines

set up the cpu_to_apicid array at the same time. Why not lie about cpu_data->apicid, and set phys_proc_id[cpu], at the same time in the same function?

Certainly an option, but keeping it in cpu_bringup() will allow easier change once the dom0 special casing you talked about would be wanted/needed (because then you clearly *want* to call identify_cpu() and not lie about anything).

How early during boot do these things need to be set up? We may also want to support static NUMA topologies for domU guests as well, under some circumstances. Is it okay to set that up in cpu_bringup() even though the CPUs may be brought online only after the OS is fully booted? Or is it better to set up the mapping arrays and so on early in smp_prepare_cpus()? The latter is possible since vcpu0 could interrogate Xen via a new vcpu_op sub-hypercall.

I think I'd rather keep the code where it is for now, and simply add identify_cpu() to cpu_bringup() later when we support that for domain0. That will simply act as a dynamic reconfiguration of the mappings and relationships that get simply statically initialised in smp_prepare_cpus().

-- Keir

#6 lore raw
Quoted 5 lines

I think I'd rather keep the code where it is for now, and simply add identify_cpu() to cpu_bringup() later when we support that for domain0. That will simply act as a dynamic reconfiguration of the mappings and relationships that get simply statically initialised in smp_prepare_cpus().

I think I'm fine with that.

Jan