[PATCH 0/2] Make affinity setting a bit more debug friendly

*** BLURB HERE *** Michal Prívozník (2): qemu_process: Issue an info message when subtracting isolcpus virprocess: Debug affinity map in virProcessSetAffinity() src/qemu/qemu_process.c | 6 ++++++ src/util/virprocess.c | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-) -- 2.43.2

In one of my previous commits I've made us substract isolcpus from all online CPUs when setting affinity on QEMU threads. See commit below for more info on that. Nevertheless, this is something that surely deserves an entry in log. I've chosen INFO priority for now. We can promote that to a regular WARN if users complain. Fixes: da95bcb6b2d9b04958e0f2603202801dd29debb8 Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/qemu/qemu_process.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 7ef7040a85..2c33ac3bf7 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -2348,6 +2348,12 @@ qemuProcessGetAllCpuAffinity(virBitmap **cpumapRet) return -1; if (isolCpus) { + g_autofree char *isolCpusStr = virBitmapFormat(isolCpus); + g_autofree char *cpumapRetStr = virBitmapFormat(*cpumapRet); + + VIR_INFO("Subtracting isolated CPUs %1$s from online CPUs %2$s", + isolCpusStr, cpumapRetStr); + virBitmapSubtract(*cpumapRet, isolCpus); } -- 2.43.2

The aim of virProcessSetAffinity() is to set affinity of given process to given CPUs. While we currently print the PID into logs, the CPU map is not printed. It may help when debugging weird scenarios. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/util/virprocess.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/util/virprocess.c b/src/util/virprocess.c index 5cdf3e3eb9..f1e5e4decd 100644 --- a/src/util/virprocess.c +++ b/src/util/virprocess.c @@ -452,8 +452,9 @@ int virProcessSetAffinity(pid_t pid, { size_t i; cpuset_t mask; + g_autofree char *mapStr = virBitmapFormat(map); - VIR_DEBUG("Set process affinity on %lld", (long long)pid); + VIR_DEBUG("Set process affinity on %1$lld to %2$s", (long long)pid, mapStr); CPU_ZERO(&mask); for (i = 0; i < virBitmapSize(map); i++) { @@ -509,8 +510,9 @@ int virProcessSetAffinity(pid_t pid, virBitmap *map, bool quiet) size_t masklen; cpu_set_t *mask; int rv = -1; + g_autofree char *mapStr = virBitmapFormat(map); - VIR_DEBUG("Set process affinity on %lld", (long long)pid); + VIR_DEBUG("Set process affinity on %1$lld to %2$s", (long long)pid, mapStr); /* Not only may the statically allocated cpu_set_t be too small, * but there is no way to ask the kernel what size is large enough. -- 2.43.2

On 5/16/24 14:48, Michal Privoznik wrote:
*** BLURB HERE ***
Michal Prívozník (2): qemu_process: Issue an info message when subtracting isolcpus virprocess: Debug affinity map in virProcessSetAffinity()
src/qemu/qemu_process.c | 6 ++++++ src/util/virprocess.c | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-)
ping Michal

On a Thursday in 2024, Michal Privoznik wrote:
*** BLURB HERE ***
Michal Prívozník (2): qemu_process: Issue an info message when subtracting isolcpus virprocess: Debug affinity map in virProcessSetAffinity()
src/qemu/qemu_process.c | 6 ++++++ src/util/virprocess.c | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano
participants (3)
-
Ján Tomko
-
Michal Privoznik
-
Michal Prívozník