From cd9e707b23980ed568aeddac6eaa2125b651c6cc Mon Sep 17 00:00:00 2001
From: John Kacur <jkacur@redhat.com>
Date: Wed, 3 Mar 2021 10:45:28 -0500
Subject: [PATCH] tuna: Fix tuna --include option breakage
The change to remove the dependency on python-schedutils
broke the --include function.
get_affinity(pid) from python-schedutils returned a list
os.sched_getaffinity(pid) returns a set
In many cases they can be interchanged, but not with the '+' operation
Fix this by changing affinity to a list before concatenation
Reported-by: Mark Simmons <msimmons@redhat.com>
Signed-off-by: John Kacur <jkacur@redhat.com>
---
tuna/tuna.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/tuna/tuna.py b/tuna/tuna.py
index e5122dac1081..614a8250b054 100755
--- a/tuna/tuna.py
+++ b/tuna/tuna.py
@@ -431,9 +431,9 @@ def include_cpus(cpus, nr_cpus):
if err.args[0] == errno.ESRCH:
continue
raise err
- if set(affinity).intersection(set(cpus)) != set(cpus):
+ if affinity.intersection(set(cpus)) != set(cpus):
previous_pid_affinities[pid] = copy.copy(affinity)
- affinity = list(set(affinity + cpus))
+ affinity = list(affinity) + cpus
try:
os.sched_setaffinity(pid, affinity)
except OSError as err:
@@ -453,9 +453,9 @@ def include_cpus(cpus, nr_cpus):
if err.args[0] == errno.ESRCH:
continue
raise err
- if set(affinity).intersection(set(cpus)) != set(cpus):
+ if affinity.intersection(set(cpus)) != set(cpus):
previous_pid_affinities[tid] = copy.copy(affinity)
- affinity = list(set(affinity + cpus))
+ affinity = list(affinity) + cpus
try:
os.sched_setaffinity(tid, affinity)
except OSError as err:
--
2.26.2