CPU sockets calculation is inconsistent with physical sockets when
Host machine has more than one node. It only calculate the maximum
socket number of all CPU nodes instead of summing up.
For example:
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 32
On-line CPU(s) list: 0-31
Thread(s) per core: 2
Core(s) per socket: 8
Socket(s): 2 <------ Host machine has 2 sockets
NUMA node(s): 2
Vendor ID: GenuineIntel
CPU family: 6
Model: 62
Model name: Intel(R) Xeon(R) CPU E5-2650 v2 @ 2.60GHz
Stepping: 4
CPU MHz: 3074.296
BogoMIPS: 5205.76
Virtualization: VT-x
L1d cache: 32K
L1i cache: 32K
L2 cache: 256K
L3 cache: 20480K
NUMA node0 CPU(s): 0-7,16-23
NUMA node1 CPU(s): 8-15,24-31
CPU model: x86_64
CPU(s): 32
CPU frequency: 3021 MHz
CPU socket(s): 1 <----- Should be 2 sockets
Core(s) per socket: 8
Thread(s) per core: 2
NUMA cell(s): 2
Memory size: 131833636 KiB
"lscpu" shows host machine has 2 sockets, however "virsh nodeinfo"
only calculate the maximum socket number of all CPU nodes,
This patch fix it by summing sockets in all nodes up.
Signed-off-by: Zhang Zhuoyu <zhangzhuoyu(a)cmss.chinamobile.com>
Signed-off-by: Xiubo Li <lixiubo(a)cmss.chinamobile.com>
---
src/util/virhostcpu.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c
index 42a52ca..f2e3b8c 100644
--- a/src/util/virhostcpu.c
+++ b/src/util/virhostcpu.c
@@ -699,9 +699,7 @@ virHostCPUGetInfoPopulateLinux(FILE *cpuinfo,
VIR_FREE(sysfs_cpudir);
*cpus += nodecpus;
-
- if (nodesockets > *sockets)
- *sockets = nodesockets;
+ *sockets += nodesockets;
if (nodecores > *cores)
*cores = nodecores;
@@ -760,8 +758,7 @@ virHostCPUGetInfoPopulateLinux(FILE *cpuinfo,
* the nodeinfo structure isn't designed to carry the full topology so
* we're going to lie about the detected topology to notify the user
* to check the host capabilities for the actual topology. */
- if ((*nodes *
- *sockets *
+ if ((*sockets *
*cores *
*threads) != (*cpus + offline)) {
*nodes = 1;
--
1.8.3.1