On Fri, Dec 13, 2013 at 02:10:20AM +0800, lijun wrote: > Hi all, > > when set "-smp" more than 160, qemu will give the following warning: > Warning: Number of SMP cpus requested (161) exceeds the recommended > cpus supported by KVM (160) > As the above warning, when set "-smp > 160,sockets=2,cores=3,threads=2", but find that > apic_id(hw/i386/acpi-build.c) is 259 not 159 and id(hw/acpi/piix4.c) > is 259 not 159. > > As the above warning, when set "-smp > 254,sockets=2,cores=3,threads=2", but find that > apic_id(hw/i386/acpi-build.c) is 513 not 253 and id(hw/acpi/piix4.c) > is 513 not 253.
"-smp 254,sockets=2,cores=3,threads=2" is invalid because you can't fit 254 VCPUs in 2 cores having 2*3 threads each. Setting both sockets and cores makes QEMU ignore the "threads" value and set it to smp/(cores*sockets) (42). (42 is also an invalid value because two (42*3)-core can have only 252 VCPUs, but that's another bug.) Anyway, your crash should be also reproducible if you simply run: "-smp 254,sockets=2,cores=3". But in that case, the APIC ID is right because: * With threads=42, we need 6 bits for thread ID * With cores=3, we need 2 bits for core ID * Bit offset of core ID is 6 * Bit offset of socket ID is 6+2 = 8 * CPU index #253 will thread #1 on core #0 on socket #2 (253 = 2*42*3 + 0*3 + 1) * APIC ID for socket #2 core #0 thread #1 is: (2<<8) | (0<<6) | 1 = 513 What we need to do to avoid this crash is to reject configurations where apic_id(max_cpus-1) or apic_id(smp_cpus-1) is too large. I believe this is what you mean on item 2 below (except that you will need to do that outside vl.c because the restriction is x86-specific) > > Based on above reasons, we have two methods to fix this issue. > 1, Delete "assert(apic_id <= MAX_CPUMASK_BITS)" in file > "hw/i386/acpi-build.c" and delete "g_assert((id / 8) < > PIIX4_PROC_LEN)" in file "hw/acpi/piix4.c". > 2, Detect the values of "sockets,cores,threads" when get them from > command line. And modify smp_parse function in file vl.c to do some > restrictions on these parameters when boot qemu. > > I will submit the code patch later. > > Best Regards, > Jun Li > -- Eduardo