Bug 1375507

Summary: "threads" option is overwritten if both "sockets" and "cores" is set on -smp
Product: Red Hat Enterprise Linux 7 Reporter: Guo, Zhiyi <zhguo>
Component: qemu-kvmAssignee: Eduardo Habkost <ehabkost>
Status: CLOSED ERRATA QA Contact: Guo, Zhiyi <zhguo>
Severity: medium Docs Contact: Jiri Herrmann <jherrman>
Priority: unspecified    
Version: 7.3CC: chayang, juzhang, knoel, michen, rbalakri, virt-maint, xfu, zhguo
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: All   
Whiteboard:
Fixed In Version: qemu-kvm-1.5.3-129.el7 Doc Type: Known Issue
Doc Text:
Cause: 1) The "sockets" command-line option in qemu-kvm-1.5.3 is ambiguous when maxcpus is used. 2) The "threads" command-line argument is ignored and overwritten when all both "sockets" and "cores" are set. Consequence: 1) The "threads" argument in -smp may be set to an unexpected value if using both "sockets" and "maxcpus" in the command-line. 2) QEMU won't print a warning when overwriting the "threads" value set on the command-line. Workaround (if any): Two possible workarounds: 1) Setting only the "cores" and "threads" arguments on the command-line. 2) Setting the "sockets" option to match the number of boot VCPUs ("-smp [cpus=]X[,...]"), not hotplug VCPUs ("-smp [...]maxcpus=X") Result: The "threads" argument won't be overwritten in the configuration.
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-08-01 17:46:48 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Guo, Zhiyi 2016-09-13 09:31:36 UTC
Description of problem:
ht flag is missing when there is sockets option in smp

Version-Release number of selected component (if applicable):
qemu-kvm:
qemu-kvm-1.5.3-123.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1.Boot guest with qemu cli:
/usr/libexec/qemu-kvm -name rhel7.3 -m 2048 \
        -cpu Skylake-Client,check\
        -smp 1,threads=2,cores=1,sockets=3,maxcpus=6 \
         -vga qxl\
        -spice port=3003,disable-ticketing \
        -device virtio-serial -chardev spicevmc,id=vdagent,debug=0,name=vdagent \
        -serial unix:/tmp/m,server,nowait \
        -device virtserialport,chardev=vdagent,name=com.redhat.spice.0 \
        -drive file=ss1rhel73.qcow2,if=none,id=drive-scsi-disk0,format=qcow2,cache=none,werror=stop,rerror=stop -device virtio-scsi-pci,id=scsi0 -device scsi-hd,drive=drive-scsi-disk0,bus=scsi0.0,scsi-id=0,lun=0,id=scsi-disk0,bootindex=1 \
        -monitor stdio \
        -usb -device usb-kbd,id=input0 \
        -netdev tap,id=idinWyYp,vhost=on -device virtio-net-pci,mac=42:ce:a9:d2:4d:d7,id=idlbq7eA,netdev=idinWyYp \
        -qmp tcp:localhost:4444,server,nowait \
2. get flags by cat /proc/cpuinfo inside guest
3.

Actual results:
ht flag is missing
# cat /proc/cpuinfo 
processor	: 0
vendor_id	: GenuineIntel
cpu family	: 6
model		: 94
model name	: Intel Core Processor (Skylake)
stepping	: 3
microcode	: 0x1
cpu MHz		: 3695.996
cache size	: 4096 KB
physical id	: 0
siblings	: 1
core id		: 0
cpu cores	: 1
apicid		: 0
initial apicid	: 0
fpu		: yes
fpu_exception	: yes
cpuid level	: 13
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx rdtscp lm constant_tsc rep_good nopl eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch fsgsbase bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx rdseed adx smap xsaveopt xsavec xgetbv1

Expected results:
ht flag presents

Additional info:
After remove sockets=.. option, ht flag presents. ht flag presents in qemu-kvm-rhev with same smp config:-smp 1,threads=2,cores=1,sockets=3,maxcpus=6

Comment 1 Guo, Zhiyi 2016-09-13 09:33:12 UTC
Bug is reported according to ht flag description of https://bugzilla.redhat.com/show_bug.cgi?id=1371619#c2

Comment 3 Eduardo Habkost 2016-12-27 20:03:42 UTC
There are two issues with the command-line on comment #0:

1) The number of boot CPUs (1) is smaller than the number of threads per socket (2).

2) The "sockets" option is ambiguous on qemu-kvm-1.5. On QEMU 1.5, "maxcpus" is not used when parsing -smp. As threads*cores*sockets = 2*1*3 don't match the requested CPU count (1), the "threads" argument will be overwritten and set to 1. I recommend to _not_ use the "sockets" argument at all and set only "threads" and "cores".

Recent QEMU versions print warnings on those cases and will refuse to override "threads" if it was set explicitly. I am updating Doc Text to document this known issue and recommend workarounds.

Comment 5 Miroslav Rezanina 2017-01-18 12:11:04 UTC
Fix included in qemu-kvm-1.5.3-129.el7

Comment 7 Guo, Zhiyi 2017-03-30 08:26:15 UTC
Verify against qemu-kvm-1.5.3-134.el7.x86_64

qemu cli used:
/usr/libexec/qemu-kvm -name cve -m 8G -machine pc,accel=kvm\
        -S \
        -cpu IvyBridge,check,enforce\
	-smp 1,threads=2,cores=1,sockets=3,maxcpus=6 \
        -vnc :3 \
        -drive file=/home/nfs/image/rhel74-64-virtio-scsi.qcow2,if=none,id=drive-scsi-disk0,format=qcow2,cache=none,werror=stop,rerror=stop -device virtio-scsi-pci,id=scsi0 -device scsi-hd,drive=drive-scsi-disk0,bus=scsi0.0,scsi-id=0,lun=0,id=scsi-disk0,bootindex=1 \
        -netdev tap,id=idinWyYp,vhost=on -device virtio-net-pci,mac=42:ce:a9:d2:4d:d7,id=idlbq7eA,netdev=idinWyYp \
        -monitor stdio \
        -device cirrus-vga \

Check ht flags inside guest:
# cat /proc/cpuinfo
processor	: 0
vendor_id	: GenuineIntel
cpu family	: 6
model		: 58
model name	: Intel Xeon E3-12xx v2 (Ivy Bridge)
stepping	: 9
microcode	: 0x1
cpu MHz		: 1899.998
cache size	: 4096 KB
physical id	: 0
siblings	: 1
core id		: 0
cpu cores	: 1
apicid		: 0
initial apicid	: 0
fpu		: yes
fpu_exception	: yes
cpuid level	: 13
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx rdtscp lm constant_tsc rep_good nopl pni pclmulqdq ssse3 cx16 sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm fsgsbase smep erms xsaveopt
bugs		:
bogomips	: 3799.99
clflush size	: 64
cache_alignment	: 64
address sizes	: 46 bits physical, 48 bits virtual
power management:

ht found now

Comment 8 Guo, Zhiyi 2017-03-30 08:26:55 UTC
Verified per comment 7

Comment 9 errata-xmlrpc 2017-08-01 17:46:48 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2017:1856