softirqs fails to print histogram of distributions
I encountered the following err with bcc v0.8.0:
root@debian:~/bcc/tools# ./softirqs.py -d
Tracing soft irq event time... Hit Ctrl-C to end.
^C
Traceback (most recent call last):
File "./softirqs.py", line 144, in <module>
dist.print_log2_hist(label, "softirq", section_print_fn=vec_to_name)
File "/usr/local/lib/python2.7/dist-packages/bcc/table.py", line 326, in print_log2_hist
vals[slot] = v.value
TypeError: list indices must be integers, not str
I looked through softirqs.py and found no obvious bug. Maybe a bug in table.py?
If a struct S is used as key to a BPF_HISTOGRAM, table.py expects the second member of S is holding the slot.
But when S is converted to python from bpf C, a padding may be inserted as a second member of S. table.py doesn't check the possible padding so print_log2_hist() is broken.
A quick fix https://github.com/boat0/bcc/commit/9e81daada749598422866a401e45199dd47b7ae1 by skipping the possible padding member in tables.py. I am just wondering if it is better not to generate the padding in the first place.
Thanks. I looked at the fix. The change looks good to me. The padding are bcc internals and fixing/working around in the library is the right thing. Checking __pad_1 is also right since there will at most one padding between field 1 and field 2.
Could you add a little comment in the code itself to describe the reason of fix so later checking code alone will be able to understand why? Could you submit a pull request? Thanks!
#2155