Bug 1456793

Summary: virsh nodecpumap shows wrong cpus present output
Product: Red Hat Enterprise Linux 7 Reporter: Peter Krempa <pkrempa>
Component: libvirtAssignee: Peter Krempa <pkrempa>
Status: CLOSED ERRATA QA Contact: Luyao Huang <lhuang>
Severity: low Docs Contact:
Priority: high    
Version: 7.4CC: bugproxy, dyuan, hannsj_uhl, jkachuck, lhuang, libvirt-maint, mzhan, pkrempa, rbalakri, xuzhang, yalzhang
Target Milestone: rcKeywords: Patch
Target Release: 7.4   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-3.2.0-7.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-08-02 01:34:35 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:
Bug Depends On:    
Bug Blocks: 1446211    

Description Peter Krempa 2017-05-30 11:41:15 UTC
+++ This bug was initially created as a clone of Bug #1455284 +++

Description of problem:
virsh nodecpumap ignores the last cores offline cpus and shows wrong value for cpus present and map field

Actual:
# virsh nodecpumap
CPUs present:   153
CPUs online:    20
CPU map:        y-------y-------y-------y-------y-------y-------y-------y-------y-------y-------y-------y-------y-------y-------y-------y-------y-------y-------y-------y

Expected:
CPUs present:   160
CPUs online:    20
CPU map:        y-------y-------y-------y-------y-------y-------y-------y-------y-------y-------y-------y-------y-------y-------y-------y-------y-------y-------y-------y-------

# lscpu
Architecture:          ppc64le
Byte Order:            Little Endian
CPU(s):                160
On-line CPU(s) list:   0,8,16,24,32,40,48,56,64,72,80,88,96,104,112,120,128,136,144,152
Off-line CPU(s) list:  1-7,9-15,17-23,25-31,33-39,41-47,49-55,57-63,65-71,73-79,81-87,89-95,97-103,105-111,113-119,121-127,129-135,137-143,145-151,153-159
Thread(s) per core:    1
Core(s) per socket:    5
Socket(s):             4
NUMA node(s):          4
Model:                 2.1 (pvr 004b 0201)
Model name:            POWER8E (raw), altivec supported
L1d cache:             64K
L1i cache:             32K
L2 cache:              512K
L3 cache:              8192K
NUMA node0 CPU(s):     0,8,16,24,32
NUMA node1 CPU(s):     40,48,56,64,72
NUMA node16 CPU(s):    80,88,96,104,112
NUMA node17 CPU(s):    120,128,136,144,152


Version-Release number of selected component (if applicable):
# virsh version
Compiled against library: libvirt 3.4.0
Using library: libvirt 3.4.0
Using API: QEMU 3.4.0
Running hypervisor: QEMU 2.9.50


How reproducible:
Always

Steps to Reproduce:
1.# virsh nodecpumap

Actual results:
CPUs present:   153
CPUs online:    20
CPU map:        y-------y-------y-------y-------y-------y-------y-------y-------y-------y-------y-------y-------y-------y-------y-------y-------y-------y-------y-------y


Expected results:
CPUs present:   160
CPUs online:    20
CPU map:        y-------y-------y-------y-------y-------y-------y-------y-------y-------y-------y-------y-------y-------y-------y-------y-------y-------y-------y-------y-------


Additional info:

--- Additional comment from Peter Krempa on 2017-05-30 10:43:53 CEST ---

Fixed upstream:

commit 4ae0f65669a6672a408e08698678ed2958a77fde
Author: Nitesh Konkar <niteshkonkar.libvirt>
Date:   Thu May 25 15:47:43 2017 +0530

    util: hostcpu: Correctly report total number of vcpus in virHostCPUGetMap
    
    Callers expect the return value to be the total number of vcpus in the
    host (including offline vcpus). The refactor in c67e04e25fa58104e0fae41
    broke this assumption by using virHostCPUGetOnlineBitmap which only
    creates a bitmap long enough to hold the last online vcpu.
    
    Report the full number of host vcpus by returning value from
    virHostCPUGetCount().

Comment 4 Luyao Huang 2017-06-01 09:18:34 UTC
I can reproduce this issue on libvirt-3.2.0-6.el7.x86_64:

# virsh nodecpumap
CPUs present:   16
CPUs online:    16
CPU map:        yyyyyyyyyyyyyyyy

# echo 0 > /sys/devices/system/cpu/cpu15/online

# lscpu
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                16
On-line CPU(s) list:   0-14
Off-line CPU(s) list:  15
Thread(s) per core:    1
Core(s) per socket:    4
Socket(s):             2
NUMA node(s):          4
Vendor ID:             AuthenticAMD
CPU family:            21
Model:                 2
Model name:            AMD Opteron(tm) Processor 6320
Stepping:              0
CPU MHz:               2800.000
CPU max MHz:           2800.0000
CPU min MHz:           1400.0000
BogoMIPS:              5586.17
Virtualization:        AMD-V
L1d cache:             16K
L1i cache:             64K
L2 cache:              2048K
L3 cache:              6144K
NUMA node0 CPU(s):     0,2,4,6
NUMA node1 CPU(s):     8,10,12,14
NUMA node2 CPU(s):     1,3,5,7
NUMA node3 CPU(s):     9,11,13

# virsh nodecpumap
CPUs present:   15
CPUs online:    15
CPU map:        yyyyyyyyyyyyyyy


And verify this issue on libvirt-3.2.0-7.el7.x86_64:

1. # echo 0 > /sys/devices/system/cpu/cpu15/online 

2. # virsh nodecpumap
CPUs present:   16
CPUs online:    15
CPU map:        yyyyyyyyyyyyyyy-

Comment 5 Peter Krempa 2017-06-06 07:54:04 UTC
*** Bug 1459050 has been marked as a duplicate of this bug. ***

Comment 6 IBM Bug Proxy 2017-07-14 04:40:23 UTC
------- Comment From satheera.com 2017-07-14 00:39 EDT-------
Verified on libvirt-3.2.0-15.el7a.ppc64le
and working fine.
Closing.

# virsh nodecpumap --pretty
CPUs online:    16
CPU map:        0-15

[root@ltc-boston8 ~]# virsh nodecpumap --pretty
CPUs present:   16
CPU map:        0-14

#echo 1 > /sys/devices/system/cpu/cpu15/online
# virsh nodecpumap --pretty
CPUs present:   16
CPUs online:    16
CPU map:        0-15

# rpm -qa|grep libvirt-[0-9]
libvirt-3.2.0-15.el7a.ppc64le

Comment 7 errata-xmlrpc 2017-08-02 01:34:35 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/RHEA-2017:1846