kernel-shark: Handle traces with sched_wakeup but not sched_waking
PATCH 1/1 kernel-shark: Handle traces with sched_wakeup but not sched_waking
If sched_wakeup or sched_wakeup_new is avaiable but sched_waking is not, then define_wakeup_event() returns true even though waking_event_ptr is null.
Change find_wakeup_event() to avoid overwriting the output parameter on error so that the define_wakeup_event() returns true iff *waking_event_ptr is non-null.
--- src/libkshark-tepdata.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
src/libkshark-tepdata.c +7 -2
@@ -1868,9 +1868,14 @@ int kshark_tep_find_top_stream(struct kshark_context *kshark_ctx,static bool find_wakeup_event (struct tep_handle *tep,const char *wakeup_name,struct tep_event **waking_event_ptr) { - *waking_event_ptr =tep_find_event_by_name (tep,"sched" , wakeup_name); +struct tep_event *event; + + event =tep_find_event_by_name (tep,"sched" , wakeup_name); + +if (event) + *waking_event_ptr = event; -return (*waking_event_ptr)? true : false; +return !!event; }/**
Signature · 1 line
2.33.0
Quoted 9 lines · John Keeping
If
sched_wakeuporsched_wakeup_newis avaiable butsched_wakingis not, thendefine_wakeup_event()returns true even thoughwaking_event_ptris null.Change
find_wakeup_event()to avoid overwriting the output parameter on error so that thedefine_wakeup_event()returns true iff*waking_event_ptris non-null.Signed-off-by John Keeping <[email protected]>
Thanks a lot for helping us to improve KernelShark!
It seems that you are interested in analyzing wakeup latency and you are keen of digging into code, so I would like to point you to something new that may be interesting for you.
We are trying to develop Python bindings for the tracing libraries, including libkshark. Here is one very simple example script that plots the distribution of the latency and generates a description of a KernelShark session directly showing the largest latency:
https://github.com/vmware/trace-cruncher/blob/master/examples/sched_wakeup.py
Note that this example is supposed to demonstrate the Python APIs, not to do something that is particularly useful on its own. But you should be able to easily adapt it to your own needs. The installation of the Python module is very simple. See the README here:
https://github.com/vmware/trace-cruncher
Please let me know if this is something interesting for you. I will be vary happy to receive patches from you for this project as well. I am pretty sure you will find bugs ;-)
Once again, thanks a lot for the KernelShark patches! Cheers,
Yordan
Quoted 26 lines
--- src/libkshark-tepdata.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)src/libkshark-tepdata.c +7
-2@@ -1868,9 +1868,14 @@ int kshark_tep_find_top_stream(struct kshark_context *kshark_ctx,static bool find_wakeup_event (struct tep_handle *tep,const char *wakeup_name,struct tep_event **waking_event_ptr) { - *waking_event_ptr =tep_find_event_by_name (tep,"sched" , wakeup_name); +struct tep_event *event; + + event =tep_find_event_by_name (tep,"sched" , wakeup_name); + +if (event) + *waking_event_ptr = event; -return (*waking_event_ptr)? true : false; +return !!event; }/**