Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

softirqs: focus CPU as disector #1130

Merged
merged 1 commit into from
Nov 1, 2017
Merged

softirqs: focus CPU as disector #1130

merged 1 commit into from
Nov 1, 2017

Conversation

cherusk
Copy link
Contributor

@cherusk cherusk commented Apr 23, 2017

With having in mind that softirq processing is happeing in
ksoftirqd/ context, which is associated with a specific cpu over
the whole dynamic life time of a system, focussing on CPus as the
disector appears more sensical.

Quite helpful is this alternative angle of view on the softirqs
processing especially for surveilling the effectiveness of net stack
tunings, as this is highly dynamic depending on the actual net stack
configuration, e.g. scaling or steering.

Signed-off-by: Matthias Tafelmeier matthias.tafelmeier@gmx.net

@brendangregg
Copy link
Member

Do you think it makes sense to update tools/softirq.py to key on the CPU id as well?

Note for others: to test tools/old/softirq.py on newer kernels, I had to delete the blk_iopoll_softirq kprobe.

So the output is now:

# ./softirqs.py.1
warning: unknown warning option '-Wno-pragma-once-outside-header'; did you mean '-Wno-private-header'? [-Wunknown-warning-option]
1 warning generated.
Tracing soft irq event time... Hit Ctrl-C to end.
^C
SOFTIRQ                            CPU TOTAL_usecs
net_tx_action                        7          69
run_rebalance_domains                3         235
run_rebalance_domains                2         248
run_rebalance_domains                4         257
run_rebalance_domains                0         271
run_rebalance_domains                6         274
run_rebalance_domains                1         342
run_rebalance_domains                7         355
run_rebalance_domains                5         366
rcu_process_callbacks                5         804
rcu_process_callbacks                3         820
rcu_process_callbacks                2         822
rcu_process_callbacks                0         828
rcu_process_callbacks                1         912
rcu_process_callbacks                6         930
rcu_process_callbacks                4        1319
rcu_process_callbacks                7        1404
net_rx_action                        7        1451
run_timer_softirq                    6        2536
run_timer_softirq                    2        2554
run_timer_softirq                    3        2599
run_timer_softirq                    0        2642
run_timer_softirq                    1        2893
run_timer_softirq                    4        2901
run_timer_softirq                    7        2951
run_timer_softirq                    5        3269

I'd make this per-CPU breakdown an option, like -C. I do want the per-softirq summaries by default, especially as my larger systems have 64 CPUs and the output is going to get long.

An example of an optional breakdown is biolatency's -D.

I haven't encountered the word "dissector" for this feature, we usually use "breakdown", but I can see that dissector is more specific, so I think I like it. :)

@cherusk
Copy link
Contributor Author

cherusk commented Apr 25, 2017 via email

@cherusk
Copy link
Contributor Author

cherusk commented Apr 26, 2017

Right, seems legit now ...

Copy link
Collaborator

@goldshtn goldshtn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a couple of comments below, and also a bigger question: why does this PR only update tools/old/softirqs.py, and not the new tool that uses tracepoints? That's the one most people will be using by default (on 4.7+ anyway).

@@ -33,6 +33,8 @@
help="output in nanoseconds")
parser.add_argument("-d", "--dist", action="store_true",
help="show distributions as histograms")
parser.add_argument("-C", "--CPUidx", action="store_true",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest a somewhat clearer long option name, perhaps --by-cpu?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No preferences, can do so ...

if (tsp == 0 || ipp == 0) {
return 0; // missed start
bpf_text = ""
if args.CPUidx:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a lot of shared code across the two alternatives, which makes me worried about duplication and potential maintenance problems if we add more "dissectors". What we typically do in other tools is one of two options:

  1. Embed string markers (like REPLACEME) in the C code string and then conditionally replace them with the appropriate code, kind of like you did with COMMON here but in the other direction
  2. Use conditional compilation (#ifdef ...) in the C code and conditionally prepend the relevant macro definition

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, technically, I agree, though, I was refraining from making the replacement section a mess. So I had a tradeoff between readability and code duplication in mind.

@@ -115,11 +166,18 @@
"rcu_process_callbacks", "run_rebalance_domains", "tasklet_action",
"tasklet_hi_action", "run_timer_softirq", "net_tx_action",
"net_rx_action"):
b.attach_kprobe(event=softirqfunc, fn_name="trace_start")
b.attach_kretprobe(event=softirqfunc, fn_name="trace_completion")
if args.CPUidx:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, there's no need for this duplication if we give the C functions the same names in both cases. I don't know why not.

@goldshtn
Copy link
Collaborator

[buildbot, add to whitelist]

@cherusk
Copy link
Contributor Author

cherusk commented Apr 27, 2017 via email

@brendangregg
Copy link
Member

# ./softirqs.py 
Traceback (most recent call last):
  File "./softirqs.py", line 54, in <module>
    if args.by-cpu:
AttributeError: 'Namespace' object has no attribute 'by'

Seems that my versions of argparse doesn't like that. I found s/by-cpu/bycpu/ fixed it. (How come our test system didn't pick it up?).

-C also doesn't work with -d:

# softirqs.py -C -d
warning: unknown warning option '-Wno-pragma-once-outside-header'; did you mean '-Wno-private-header'? [-Wunknown-warning-option]
1 warning generated.
Tracing soft irq event time... Hit Ctrl-C to end.
^C
Traceback (most recent call last):
  File "./softirqs.py", line 197, in <module>
    dist.print_log2_hist(label, "softirq", section_print_fn=distr_sec_fn)
  File "/usr/lib/python2.7/dist-packages/bcc/table.py", line 311, in print_log2_hist
    vals[slot] = v.value
IndexError: cannot fit 'long' into an index-sized integer

I filed #1146 for updating tools/softirqs.

@goldshtn
Copy link
Collaborator

goldshtn commented May 1, 2017

@brendangregg Our smoke tests only run the tools in tools/, not in tools/old/.

I generally think of the tools in tools/old/ as unmaintained.

With having in mind that softirq processing is happeing in
ksoftirqd/<cpu> context, which is associated with a specific cpu over
the whole dynamic life time of a system, focussing on CPus as the
dissector appears more sensical.

Quite helpful is this alternative angle of view on the softirqs
processing especially for surveilling the effectiveness of net stack
tunings, as this is highly dynamic depending on the actual net stack
configuration, e.g. scaling or steering.

Signed-off-by: Matthias Tafelmeier <matthias.tafelmeier@gmx.net>
@cherusk
Copy link
Contributor Author

cherusk commented Jul 5, 2017

Amended things, also the general Softirq per CPU breakdown is working now, though, I don't deem this as very helpful. It might need a nested breakdown per CPU-softirq on top - feel free to add that later. Cheers!

@4ast
Copy link
Member

4ast commented Oct 26, 2017

have been pending for too long. Please resubmit if it's still relevant.

@4ast 4ast closed this Oct 26, 2017
@cherusk
Copy link
Contributor Author

cherusk commented Oct 31, 2017

It is ... pls, reopen in order not to splinter the context. I've not procrastinated it.

@4ast 4ast reopened this Oct 31, 2017
Copy link
Member

@4ast 4ast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rebase needed?

@cherusk
Copy link
Contributor Author

cherusk commented Nov 1, 2017

I don't think so., seemingly, it hasn't been touched on master ever since.

@yonghong-song
Copy link
Collaborator

@cherusk This still only changes tools/old/softirqs.py. Did any situation change in your side so you could make a change in tools/softirqs.py instead? As mentioned in the above, tools/old/... are considered unmaintained and hence will not be tested in bcc testing framework and will not be used by most people.

@cherusk
Copy link
Contributor Author

cherusk commented Nov 1, 2017

@yonghong-song I am prepared to align the tools/softirqs.py to the 'old' symmetrically. Though, landscapes on older kernels (enough out there for stability) will use this one, so please merge it in.

@yonghong-song
Copy link
Collaborator

@4ast could you merge since you requested the change? Note that the code is using kprobe and it will not work on 4.14 kernel as some functions are already gone.

@4ast 4ast merged commit 8c0e4b9 into iovisor:master Nov 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants