diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2008-09-13 16:37:56 -0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2008-09-13 16:37:56 -0300 |
commit | 0beb1235163caea9f4a9755668bf6c271f4cccd9 (patch) | |
tree | e03d6e343ce43e01d2525b5cb969e7ec87b2a267 | |
parent | eed2071f28f5637fcd29d8ce89c07d5c5eac8b13 (diff) | |
download | tuna-0beb1235163caea9f4a9755668bf6c271f4cccd9.tar.gz |
tuna: Allow passing a custom warning routine to move_threads_to_cpu
This fixes a long standing bug that was uncovered when an unsorted list of cpus
was passed to this routine: the set_affinity_warning was moved to tuna_gui when
the gui code moved from tuna.py, but move_threads_to_cpu called it when it
compared the new affinity, and as it was unsorted...
So now just print to the standard output if it fails setting the new affinity
or call the provided routine, that will be what tuna_gui will do.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rwxr-xr-x | tuna/tuna.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/tuna/tuna.py b/tuna/tuna.py index ccab6f2..c021873 100755 --- a/tuna/tuna.py +++ b/tuna/tuna.py @@ -142,7 +142,7 @@ def list_to_cpustring(l): prev = i return ",".join(strings) -def move_threads_to_cpu(new_affinity, pid_list): +def move_threads_to_cpu(new_affinity, pid_list, set_affinity_warning = None): changed = False ps = procfs.pidstats() @@ -154,8 +154,10 @@ def move_threads_to_cpu(new_affinity, pid_list): curr_affinity = schedutils.get_affinity(pid) if set(curr_affinity) == set(new_affinity): changed = True - else: + elif set_affinity_warning: set_affinity_warning(pid, new_affinity) + else: + print "move_threads_to_cpu: could not change pid %d affinity to %s" % (pid, new_affinity) # See if this is the thread group leader if not ps.has_key(pid): @@ -169,8 +171,10 @@ def move_threads_to_cpu(new_affinity, pid_list): curr_affinity = schedutils.get_affinity(tid) if set(curr_affinity) == set(new_affinity): changed = True - else: + elif set_affinity_warning: set_affinity_warning(tid, new_affinity) + else: + print "move_threads_to_cpu: could not change pid %d affinity to %s" % (pid, new_affinity) except SystemError: # process died continue |