diff options
author | Rogan Kyuseok Lee <kyulee@redhat.com> | 2011-06-06 14:12:22 -0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-06-06 14:12:22 -0300 |
commit | 4de71441b51a6a9b9d394023df9ebb43e9ced226 (patch) | |
tree | f02bcf375f6c80f321e5198b5ab0e100c90e6cbb | |
parent | 40bc92dc04aaf35661cf3ba55e1eff565b094fb9 (diff) | |
download | tuna-4de71441b51a6a9b9d394023df9ebb43e9ced226.tar.gz |
cmdline: Fix IRQ affinity setting
Description of problem:
tuna skips some IRQ threads when applying CPU IRQ affinity with --move
option.
Version-Release number of selected component (if applicable):
tuna-0.9.4-1.el5rt
How reproducible:
always
Steps to Reproduce:
# users affinity
.... snip ....
64 eth0-0 0xffff bnx2
65 eth0-1 0xffff bnx2
66 eth0-2 0xffff bnx2
67 eth0-3 0xffff bnx2
68 eth0-4 0xffff bnx2
69 eth0-5 0xffff bnx2
70 eth0-6 0xffff bnx2
71 eth0-7 0xffff bnx2
Actual results:
.... snip ....
64 eth0-0 0xffff bnx2
65 eth0-1 0xff bnx2
66 eth0-2 0xffff bnx2
67 eth0-3 0xff bnx2
68 eth0-4 0xffff bnx2
69 eth0-5 0xff bnx2
70 eth0-6 0xffff bnx2
71 eth0-7 0xff bnx2
Expected results:
.... snip ....
64 eth0-0 0xff bnx2
65 eth0-1 0xff bnx2
66 eth0-2 0xff bnx2
67 eth0-3 0xff bnx2
68 eth0-4 0xff bnx2
69 eth0-5 0xff bnx2
70 eth0-6 0xff bnx2
71 eth0-7 0xff bnx2
Additional info:
tuna GUI can set IRQ affinity correctly.
Comment 1 Rogan Kyuseok Lee 2010-12-23 21:41:19 EST
elif o in ("-q", "--irqs"):
(op, a) = pick_op(a)
op_list = reduce(lambda i, j: i + j,
map(irq_mapper, list(set(a.split(",")))))
irq_list = do_list_op(op, irq_list, op_list)
# See comment above about thread_list_str
if not op_list and type(a) == type(''):
irq_list_str = do_list_op(op, irq_list_str,
a.split(","))
if not op:
thread_list = []
if not ps:
ps = procfs.pidstats()
if tuna.has_threaded_irqs(ps):
for irq in irq_list:
irq_re = tuna.threaded_irq_re(irq)
irq_threads = ps.find_by_regex(irq_re)
if irq_threads:
thread_list += irq_threads
irq_list.remove(irq)
The given irqs from command-line are stored in irq_list variable. If
there is a relevant threaded irq of an IRQ, put the thread into
thread_list and remove the IRQ from irq_list. However, it
unintentionally makes skipping an element because an index in the for
statement has been already moved to a next element.
64 eth0-0 0xffff bnx2
65 eth0-1 0xff bnx2
66 eth0-2 0xffff bnx2
67 eth0-3 0xff bnx2
68 eth0-4 0xffff bnx2
69 eth0-5 0xff bnx2
70 eth0-6 0xffff bnx2
71 eth0-7 0xff bnx2
As a result, threads_list contains IRQ threads for 64, 66, 68, 70. The
rest of IRQs are remained in irq_list. So, CPU affinity only apply to
irq_list.
elif o in ("-m", "--move", "-x", "--spread"):
if not cpu_list:
print "tuna: --move " + _("requires a cpu list!")
sys.exit(2)
if not (thread_list or irq_list):
print "tuna: --move " + _("requires a list of threads/irqs!")
sys.exit(2)
spread = o in ("-x", "--spread")
if thread_list:
tuna.move_threads_to_cpu(cpu_list, thread_list,
spread = spread)
if irq_list:
tuna.move_irqs_to_cpu(cpu_list, irq_list,
spread = spread)
move_irqs_to_cpu calls set_irq_affinity to set IRQ's CPU affinity on a
given IRQ.
In case of move_threads_to_cpu, it sets process's CPU affinity mask on a
given thread using schedutils.set_affinity which is a wrapper for
sched_setaffinity(2). But it doesn't generally set IRQ's CPU affinity.
So, I've proposed a patch which basically makes IRQs remaining in
irq_list.
Reported on BZ: 665483
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rwxr-xr-x | tuna-cmd.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/tuna-cmd.py b/tuna-cmd.py index aafd2e4..a3b0aff 100755 --- a/tuna-cmd.py +++ b/tuna-cmd.py @@ -552,8 +552,12 @@ def main(): irq_re = tuna.threaded_irq_re(irq) irq_threads = ps.find_by_regex(irq_re) if irq_threads: + # Change the affinity of the thread too + # as we can't rely on changing the irq + # affinity changing the affinity of the + # thread or vice versa. We need to change + # both. thread_list += irq_threads - irq_list.remove(irq) elif o in ("-U", "--no_uthreads"): uthreads = False |