|
|
2ba5aa |
From b5aa3a33bc770714f8a68954c05ea362fcfd4d47 Mon Sep 17 00:00:00 2001
|
|
|
2ba5aa |
Message-Id: <b5aa3a33bc770714f8a68954c05ea362fcfd4d47@dist-git>
|
|
|
2ba5aa |
From: Daniel Henrique Barboza <danielhb413@gmail.com>
|
|
|
2ba5aa |
Date: Mon, 5 Oct 2020 10:25:30 -0400
|
|
|
2ba5aa |
Subject: [PATCH] virhostcpu.c: fix 'die_id' parsing for Power hosts
|
|
|
2ba5aa |
|
|
|
2ba5aa |
Commit 7b79ee2f78 makes assumptions about die_id parsing in
|
|
|
2ba5aa |
the sysfs that aren't true for Power hosts. In both Power8
|
|
|
2ba5aa |
and Power9, running 5.6 and 4.18 kernel respectively,
|
|
|
2ba5aa |
'die_id' is set to -1:
|
|
|
2ba5aa |
|
|
|
2ba5aa |
$ cat /sys/devices/system/cpu/cpu0/topology/die_id
|
|
|
2ba5aa |
-1
|
|
|
2ba5aa |
|
|
|
2ba5aa |
This breaks virHostCPUGetDie() parsing because it is trying to
|
|
|
2ba5aa |
retrieve an unsigned integer, causing problems during VM start:
|
|
|
2ba5aa |
|
|
|
2ba5aa |
virFileReadValueUint:4128 : internal error: Invalid unsigned integer
|
|
|
2ba5aa |
value '-1' in file '/sys/devices/system/cpu/cpu0/topology/die_id'
|
|
|
2ba5aa |
|
|
|
2ba5aa |
This isn't necessarily a PowerPC only behavior. Linux kernel commit
|
|
|
2ba5aa |
0e344d8c70 added in the former Documentation/cputopology.txt, now
|
|
|
2ba5aa |
Documentation/admin-guide/cputopology.rst, that:
|
|
|
2ba5aa |
|
|
|
2ba5aa |
To be consistent on all architectures, include/linux/topology.h
|
|
|
2ba5aa |
provides default definitions for any of the above macros that are
|
|
|
2ba5aa |
not defined by include/asm-XXX/topology.h:
|
|
|
2ba5aa |
|
|
|
2ba5aa |
1) topology_physical_package_id: -1
|
|
|
2ba5aa |
2) topology_die_id: -1
|
|
|
2ba5aa |
(...)
|
|
|
2ba5aa |
|
|
|
2ba5aa |
This means that it might be expected that an architecture that
|
|
|
2ba5aa |
does not implement the die_id element will mark it as -1 in
|
|
|
2ba5aa |
sysfs.
|
|
|
2ba5aa |
|
|
|
2ba5aa |
It is not required to change die_id implementation from uInt to
|
|
|
2ba5aa |
Int because of that. Instead, let's change the parsing of the
|
|
|
2ba5aa |
die_id in virHostCPUGetDie() to read an integer value and, in
|
|
|
2ba5aa |
case it's -1, default it to zero like in case of file not found.
|
|
|
2ba5aa |
This is enough to solve the issue Power hosts are experiencing.
|
|
|
2ba5aa |
|
|
|
2ba5aa |
Fixes: 7b79ee2f78bbf2af76df2f6466919e19ae05aeeb
|
|
|
2ba5aa |
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
|
|
|
2ba5aa |
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
2ba5aa |
(cherry picked from commit 0137bf0dab2738d5443e2f407239856e2aa25bb3)
|
|
|
2ba5aa |
|
|
|
2ba5aa |
https://bugzilla.redhat.com/show_bug.cgi?id=1876742
|
|
|
2ba5aa |
|
|
|
2ba5aa |
Signed-off-by: Daniel Henrique Barboza <dbarboza@redhat.com>
|
|
|
2ba5aa |
Message-Id: <20201005142530.3961036-1-dbarboza@redhat.com>
|
|
|
2ba5aa |
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
2ba5aa |
---
|
|
|
2ba5aa |
src/util/virhostcpu.c | 21 ++++++++++++++-------
|
|
|
2ba5aa |
1 file changed, 14 insertions(+), 7 deletions(-)
|
|
|
2ba5aa |
|
|
|
2ba5aa |
diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c
|
|
|
2ba5aa |
index 09c959cd25..218272d7ec 100644
|
|
|
2ba5aa |
--- a/src/util/virhostcpu.c
|
|
|
2ba5aa |
+++ b/src/util/virhostcpu.c
|
|
|
2ba5aa |
@@ -221,16 +221,23 @@ virHostCPUGetSocket(unsigned int cpu, unsigned int *socket)
|
|
|
2ba5aa |
int
|
|
|
2ba5aa |
virHostCPUGetDie(unsigned int cpu, unsigned int *die)
|
|
|
2ba5aa |
{
|
|
|
2ba5aa |
- int ret = virFileReadValueUint(die,
|
|
|
2ba5aa |
- "%s/cpu/cpu%u/topology/die_id",
|
|
|
2ba5aa |
- SYSFS_SYSTEM_PATH, cpu);
|
|
|
2ba5aa |
+ int die_id;
|
|
|
2ba5aa |
+ int ret = virFileReadValueInt(&die_id,
|
|
|
2ba5aa |
+ "%s/cpu/cpu%u/topology/die_id",
|
|
|
2ba5aa |
+ SYSFS_SYSTEM_PATH, cpu);
|
|
|
2ba5aa |
|
|
|
2ba5aa |
- /* If the file is not there, it's 0 */
|
|
|
2ba5aa |
- if (ret == -2)
|
|
|
2ba5aa |
- *die = 0;
|
|
|
2ba5aa |
- else if (ret < 0)
|
|
|
2ba5aa |
+ if (ret == -1)
|
|
|
2ba5aa |
return -1;
|
|
|
2ba5aa |
|
|
|
2ba5aa |
+ /* If the file is not there, it's 0.
|
|
|
2ba5aa |
+ * Another alternative is die_id set to -1, meaning that
|
|
|
2ba5aa |
+ * the arch does not have die_id support. Set @die to
|
|
|
2ba5aa |
+ * 0 in this case too. */
|
|
|
2ba5aa |
+ if (ret == -2 || die_id < 0)
|
|
|
2ba5aa |
+ *die = 0;
|
|
|
2ba5aa |
+ else
|
|
|
2ba5aa |
+ *die = die_id;
|
|
|
2ba5aa |
+
|
|
|
2ba5aa |
return 0;
|
|
|
2ba5aa |
}
|
|
|
2ba5aa |
|
|
|
2ba5aa |
--
|
|
|
2ba5aa |
2.28.0
|
|
|
2ba5aa |
|