Hi Matteo, On 9/7/22 11:08, Matteo Bertolino wrote:
If that doesn't annoy you too much, may you give me some hints about writing a Kernelshark's plugin?
As I already mentioned, we have a plugin for sched events, so you can use this plugin as starting point, despite that your plugin will be by far simpler.
Have a look here https://git.kernel.org/pub/scm/utils/trace-cmd/kernel-shark.git/tree/src/plugins/sched_events.h and here https://git.kernel.org/pub/scm/utils/trace-cmd/kernel-shark.git/tree/src/plugins/sched_events.cand see how you can define a context object for your plugin and how you can register a plugin action that will be executed over each entry in the data that is event of a given type. Example of such action for sched_switch events:
https://git.kernel.org/pub/scm/utils/trace-cmd/kernel-shark.git/tree/src/plugins/sched_events.c#n102As a first step, try to register a plugin action for the 'funcgraph_exit' event that will set the 'pid' of the entry to 'idle'
entry->pid = stream->idle_pid This will be enough to have half of the work done. You can build your plugin, using the 'BUILD_PLUGIN' macro here: https://git.kernel.org/pub/scm/utils/trace-cmd/kernel-shark.git/tree/src/plugins/CMakeLists.txtLet me know when you are ready with this and we will figure out how to implement the other features that you want.
cheers, Yordan