kernel-shark:add new plugin for xenomai cobalt_switch_context events
v2 cover kernel-shark:add new plugin for xenomai cobalt_switch_context events
1. To avoid code duplication, move some common APIs and definitions out to create new files and share with other plugins.
2. add new plugin for handling xenomai cobalt_switch_context events to visualize OOB state of RT tasks.
I tried to move common APIs and definitions to KsPlugins.cpp/hpp but found these definitions finally depend on KsMainWindow object used by _doubleClick of LatencyBox assigned by plugin_set_gui_ptr via KSHARK_MENU_PLUGIN_INITIALIZER.
I do not know how to remove this dependency so I create new files to avoid code duplication. Please suggest if there is better way.
Hongzhan Chen (2):
kernel-shark: Move common APIs and definitions out to avoid
duplication
kernel-shark: Add plugin for handling Xenomai cobalt_context_switch
src/libkshark-tepdata.c | 1 + src/plugins/CMakeLists.txt | 6 +- src/plugins/CobaltSwitchEvents.cpp | 125 +++++++++++++++ src/plugins/CommonSched.hpp | 99 ++++++++++++ src/plugins/SchedEvents.cpp | 87 +---------- src/plugins/common_sched.c | 37 +++++ src/plugins/common_sched.h | 50 ++++++ src/plugins/sched_events.c | 37 +---- src/plugins/sched_events.h | 12 +- src/plugins/xenomai_cobalt_switch_events.c | 169 +++++++++++++++++++++ src/plugins/xenomai_cobalt_switch_events.h | 54 +++++++ 11 files changed, 545 insertions(+), 132 deletions(-) create mode 100644 src/plugins/CobaltSwitchEvents.cpp create mode 100644 src/plugins/CommonSched.hpp create mode 100644 src/plugins/common_sched.c create mode 100644 src/plugins/common_sched.h create mode 100644 src/plugins/xenomai_cobalt_switch_events.c create mode 100644 src/plugins/xenomai_cobalt_switch_events.h
Signature · 1 line
2.17.1
PATCH v2 1/2 kernel-shark: Move common APIs and definitions out to avoid duplication
To avoid code duplication, move some common APIs and definitions out to create new files and share with other plugins.
--- src/plugins/CMakeLists.txt | 2 +- src/plugins/CommonSched.hpp | 99 +++++++++++++++++++++++++++++++++++++ src/plugins/SchedEvents.cpp | 87 +------------------------------- src/plugins/common_sched.c | 37 ++++++++++++++ src/plugins/common_sched.h | 50 +++++++++++++++++++ src/plugins/sched_events.c | 37 +------------- src/plugins/sched_events.h | 12 ++--- 7 files changed, 192 insertions(+), 132 deletions(-) create mode 100644 src/plugins/CommonSched.hpp create mode 100644 src/plugins/common_sched.c create mode 100644 src/plugins/common_sched.h
src/plugins/CMakeLists.txt +1 -1
@@ -41,7 +41,7 @@ set(PLUGIN_LIST "") if (Qt5Widgets_FOUND AND TT_FONT_FILE) BUILD_GUI_PLUGIN(NAME sched_events - SOURCE sched_events.c SchedEvents.cpp) + SOURCE common_sched.c sched_events.c SchedEvents.cpp) list(APPEND PLUGIN_LIST "sched_events") BUILD_GUI_PLUGIN(NAME event_field_plot
src/plugins/CommonSched.hpp new file +99 -0
99 lines not on this page · raw message
src/plugins/SchedEvents.cpp +1 -86
95 lines not on this page · raw message
src/plugins/common_sched.c new file +37 -0
@@ -0,0 +1,37 @@ +// SPDX-License-Identifier: LGPL-2.1 + +/* +* Copyright (C) 2021 Intel Inc, Hongzhan Chen <[email protected]> +*/ + +/** +* @file common_sched.c +* @brief +*/ + +// KernelShark +#include "plugins/common_sched.h" + +void plugin_sched_set_pid (ks_num_field_t *field, +tep_num_field_t pid) +{ + *field &= ~PID_MASK ; + *field = pid &PID_MASK ; +} + +/** +* @brief Retrieve the PID value from the data field stored in the +* kshark_data_container object. +* +* @param field: Input location for the data field. +*/ +__hidden int plugin_sched_get_pid(ks_num_field_t field) +{ +return field &PID_MASK ; +} + +/** Initialize the control interface of the plugin. */ +void *KSHARK_MENU_PLUGIN_INITIALIZER (void *gui_ptr) +{ +return plugin_set_gui_ptr (gui_ptr); +}
src/plugins/common_sched.h new file +50 -0
50 lines not on this page · raw message
src/plugins/sched_events.c +1 -36
@@ -17,41 +17,12 @@#include <trace-cmd.h> // KernelShark +#include "plugins/common_sched.h" #include "plugins/sched_events.h" #include "libkshark-tepdata.h" /** Plugin context instance. */ -//! @cond Doxygen_Suppress - -typedef unsigned long long tep_num_field_t ; - -#define PREV_STATE_SHIFT ((int) ((sizeof(ks_num_field_t) - 1) * 8)) - -#define PREV_STATE_MASK (((ks_num_field_t) 1 << 8) - 1) - -#define PID_MASK (((ks_num_field_t) 1 << PREV_STATE_SHIFT) - 1) - -//! @endcond - -static void plugin_sched_set_pid (ks_num_field_t *field, -tep_num_field_t pid) -{ - *field &= ~PID_MASK ; - *field = pid &PID_MASK ; -} - -/** -* @brief Retrieve the PID value from the data field stored in the -* kshark_data_container object. -* -* @param field: Input location for the data field. -*/ -__hidden int plugin_sched_get_pid(ks_num_field_t field) -{ -return field &PID_MASK ; -} -/* Use the most significant byte to store the value of "prev_state". */ static void plugin_sched_set_prev_state (ks_num_field_t *field,tep_num_field_t prev_state)
@@ -230,9 +201,3 @@ int KSHARK_PLOT_PLUGIN_DEINITIALIZER(struct kshark_data_stream *stream)return ret; } - -/** Initialize the control interface of the plugin. */ -void *KSHARK_MENU_PLUGIN_INITIALIZER (void *gui_ptr) -{ -return plugin_set_gui_ptr (gui_ptr); -}
src/plugins/sched_events.h +3 -9
@@ -9,12 +9,12 @@* @brief Plugin for Sched events. */ -#ifndef _KS_PLUGIN_SHED_H -#define _KS_PLUGIN_SHED_H +#ifndef _KS_PLUGIN_SCHED_H +#define _KS_PLUGIN_SCHED_H // KernelShark #include "libkshark.h" -#include "libkshark-plugin.h" +#include "plugins/common_sched.h" #ifdef __cplusplus extern "C" {
@@ -55,18 +55,12 @@ struct plugin_sched_context {KS_DECLARE_PLUGIN_CONTEXT_METHODS (struct plugin_sched_context ) -/** The type of the data field stored in the kshark_data_container object. */ -typedef int64_t ks_num_field_t; - -int plugin_sched_get_pid (ks_num_field_t field); int plugin_sched_get_prev_state(ks_num_field_t field);void plugin_draw (struct kshark_cpp_argv *argv,int sd,int pid,int draw_action); -void *plugin_set_gui_ptr (void *gui_ptr); - #ifdef __cplusplus }#endif
Signature · 1 line
2.17.1
PATCH v2 2/2 kernel-shark: Add plugin for handling Xenomai cobalt_context_switch
In reply to Hongzhan ChenFor Xenomai-cobalt enabled system, cobalt_switch_context means that there is schedule and context switch in companion core(realtime core), which we may need to do special treatment and take correct action as main kernel sched_switch to visualize out-of-band state of realtime tasks running in cobalt core. To achive our target, we implement following:
1. store corresponding cobalt_switch_context events into container data.
2. modify pid stored in entry to be equal to next_pid to show correct color in cpu bar when cobalt_switch_context event happen.
3. show blue hollow box to mark out-of-band state according to cobalt_switch_context events.
4. clickable cobalt_switch_context plugin shapes.
--- src/libkshark-tepdata.c | 1 + src/plugins/CMakeLists.txt | 4 + src/plugins/CobaltSwitchEvents.cpp | 125 +++++++++++++++ src/plugins/xenomai_cobalt_switch_events.c | 169 +++++++++++++++++++++ src/plugins/xenomai_cobalt_switch_events.h | 54 +++++++ 5 files changed, 353 insertions(+) create mode 100644 src/plugins/CobaltSwitchEvents.cpp create mode 100644 src/plugins/xenomai_cobalt_switch_events.c create mode 100644 src/plugins/xenomai_cobalt_switch_events.h
src/libkshark-tepdata.c +1 -0
@@ -1208,6 +1208,7 @@ static void kshark_tep_init_methods(struct kshark_generic_stream_interface *inte/** A list of built in default plugins for FTRACE (trace-cmd) data. */ const char *tep_plugin_names[] = {"sched_events" , +"xenomai_cobalt_switch_events" ,"missed_events" ,"kvm_combo" , };
src/plugins/CMakeLists.txt +4 -0
@@ -44,6 +44,10 @@ if (Qt5Widgets_FOUND AND TT_FONT_FILE) SOURCE common_sched.c sched_events.c SchedEvents.cpp) list(APPEND PLUGIN_LIST "sched_events") + BUILD_GUI_PLUGIN(NAME xenomai_cobalt_switch_events + SOURCE common_sched.c xenomai_cobalt_switch_events.c CobaltSwitchEvents.cpp) + list(APPEND PLUGIN_LIST "xenomai_cobalt_switch_events") + BUILD_GUI_PLUGIN(NAME event_field_plot MOC EventFieldDialog.hpp SOURCE event_field_plot.c EventFieldDialog.cpp EventFieldPlot.cpp)
src/plugins/CobaltSwitchEvents.cpp new file +125 -0
125 lines not on this page · raw message
src/plugins/xenomai_cobalt_switch_events.c new file +169 -0
169 lines not on this page · raw message
src/plugins/xenomai_cobalt_switch_events.h new file +54 -0
54 lines not on this page · raw message
Signature · 1 line
2.17.1
Quoted 11 lines · Hongzhan Chen
1. To avoid code duplication, move some common APIs and definitions out to create new files and share with other plugins.
2. add new plugin for handling xenomaicobalt_switch_contextevents to visualize OOB state of RT tasks.I tried to move common APIs and definitions to KsPlugins.cpp/hpp but found these definitions finally depend on KsMainWindow object used by
_doubleClickof LatencyBox assigned byplugin_set_gui_ptrviaKSHARK_MENU_PLUGIN_INITIALIZER.
I do not know how to remove this dependency so I create new files to avoid code duplication. Please suggest if there is better way.
Hi Hongzhan,
Indeed, this turns to be a bit trickier than I expected, but it is possible. I will comment in the patch.
thanks,
Yordan
Quoted 25 lines
Hongzhan Chen (2):
kernel-shark: Move common APIs and definitions out to avoid
duplication
kernel-shark: Add plugin for handling Xenomaicobalt_context_switchsrc/libkshark-tepdata.c | 1 + src/plugins/CMakeLists.txt | 6 +- src/plugins/CobaltSwitchEvents.cpp | 125 +++++++++++++++ src/plugins/CommonSched.hpp | 99 ++++++++++++ src/plugins/SchedEvents.cpp | 87 +---------- src/plugins/common_sched.c | 37 +++++ src/plugins/common_sched.h | 50 ++++++ src/plugins/sched_events.c | 37 +---- src/plugins/sched_events.h | 12 +- src/plugins/xenomai_cobalt_switch_events.c | 169 +++++++++++++++++++++ src/plugins/xenomai_cobalt_switch_events.h | 54 +++++++ 11 files changed, 545 insertions(+), 132 deletions(-)create mode 100644 src/plugins/CobaltSwitchEvents.cpp create mode 100644 src/plugins/CommonSched.hpp create mode 100644
src/plugins/common_sched.ccreate mode 100644src/plugins/common_sched.hcreate mode 100644src/plugins/xenomai_cobalt_switch_events.ccreate mode 100644src/plugins/xenomai_cobalt_switch_events.h
Re: [PATCH v2 1/2] kernel-shark: Move common APIs and definitions out to avoid duplication
In reply to Hongzhan ChenQuoted 61 lines · Hongzhan Chen
To avoid code duplication, move some common APIs and definitions out to create new files and share with other plugins.
Signed-off-by Hongzhan Chen <[email protected]>--- src/plugins/CMakeLists.txt | 2 +- src/plugins/CommonSched.hpp | 99 +++++++++++++++++++++++++++++++++++++ src/plugins/SchedEvents.cpp | 87 +------------------------------- src/plugins/common_sched.c | 37 ++++++++++++++ src/plugins/common_sched.h | 50 +++++++++++++++++++ src/plugins/sched_events.c | 37 +------------- src/plugins/sched_events.h | 12 ++--- 7 files changed, 192 insertions(+), 132 deletions(-)create mode 100644 src/plugins/CommonSched.hpp
create mode 100644src/plugins/common_sched.c
create mode 100644src/plugins/common_sched.hsrc/plugins/CMakeLists.txt +1
-1@@ -41,7 +41,7 @@ set(PLUGIN_LIST "") if (Qt5Widgets_FOUND AND TT_FONT_FILE) BUILD_GUI_PLUGIN(NAME sched_events - SOURCE sched_events.c SchedEvents.cpp) + SOURCE common_sched.c sched_events.c SchedEvents.cpp) list(APPEND PLUGIN_LIST "sched_events") BUILD_GUI_PLUGIN(NAME event_field_plotsrc/plugins/CommonSched.hpp new file +25
-0@@ -0,0 +1,99 @@ +/* SPDX-License-Identifier: LGPL-2.1 */ + +/* + * Copyright (C) 2021 Intel Inc, Hongzhan Chen <[email protected]> + */ + +/** + * @file CommonSched.hpp + * @brief Tools for plot common sched. + */ + +// C++ +#include <vector> + +// KernelShark +#include "libkshark.h" +#include "libkshark-plugin.h" +#include "KsPlotTools.hpp" +#include "KsPlugins.hpp" +#include "KsMainWindow.hpp" + +using namespace KsPlot; + +static KsMainWindow *ks_ptr; +
src/plugins/CommonSched.hpp line 35
Quoted 10 lines
src/plugins/CommonSched.hpp new file +10
-0+/** + * @brief Provide the plugin with a pointer to the KsMainWindow object (the GUI + * itself) such that the plugin can manipulate the GUI. + */ +__hidden void *plugin_set_gui_ptr(void *gui_ptr) +{ + ks_ptr = static_cast<KsMainWindow *>(gui_ptr); + return nullptr; +} +
I would prefer the global variable above and the function to set this global variable to stay within the plugin. Also make sure that these global variable have different names in the two plugins.
Quoted 4 lines
src/plugins/CommonSched.hpp new file +4
-0+/** + * This class represents the graphical element visualizing the latency between + * two events such as sched_waking and sched_switch events for common Linux + * kernel or cobalt_switch_contexts for Xenomai.
src/plugins/CommonSched.hpp line 49
Quoted 10 lines
src/plugins/CommonSched.hpp new file +10
-0+ */ +class LatencyBox : public Rectangle +{ + /** On double click do. */ + void _doubleClick() const override + { + ks_ptr->markEntry(_data[1]->entry, DualMarkerState::B); + ks_ptr->markEntry(_data[0]->entry, DualMarkerState::A); + } +
So, here comes the problem of depending on some KS GUI definitions that are not available in KsPlugins.cpp/hpp. This is a C++ code so let's do it the C++(OOP) way. In KsPlugins you will provide a generic (dummy) version of the double-click function
void _doubleClick() const override {}
all the rest is the same.
Quoted 22 lines
src/plugins/CommonSched.hpp new file +22
-0+public: + /** The trace record data that corresponds to this LatencyBox. */ + std::vector<kshark_data_field_int64 *> _data; + + /** + * @brief Distance between the click and the shape. Used to decide if + * the double click action must be executed. + * + * @param x: X coordinate of the click. + * @param y: Y coordinate of the click. + * + * @returns If the click is inside the box, the distance is zero. + * Otherwise infinity. + */ + double distance(int x, int y) const override + { + if (x < pointX(0) || x > pointX(2)) + return std::numeric_limits<double>::max(); + + if (y < pointY(0) || y > pointY(1)) + return std::numeric_limits<double>::max(); +
src/plugins/CommonSched.hpp line 81
Quoted 10 lines
src/plugins/CommonSched.hpp new file +10
-0+ return 0; + } +}; + +static PlotObject *makeShape(std::vector<const Graph *> graph, + std::vector<int> bins, + std::vector<kshark_data_field_int64 *> data, + Color col, float size) +{ + LatencyBox *rec = new LatencyBox;
This function can also be in KsPlugins.hpp, if you change the definition to something like this
template<class T> KsPlot::PlotObject * makeLatencyBox(std::vector<const KsPlot::Graph *> graph,
std::vector<int> bins, std::vector<kshark_data_field_int64 *> data, KsPlot::Color col, float size)
{
LatencyBox *rec = new T;Quoted 80 lines
src/plugins/CommonSched.hpp new file +18
-0+ rec->_data = data; + + Point p0 = graph[0]->bin(bins[0])._base; + Point p1 = graph[0]->bin(bins[1])._base; + int height = graph[0]->height() * .3; + + rec->setFill(false); + rec->setPoint(0, p0.x() - 1, p0.y() - height); + rec->setPoint(1, p0.x() - 1, p0.y() - 1); + + rec->setPoint(3, p1.x() - 1, p1.y() - height); + rec->setPoint(2, p1.x() - 1, p1.y() - 1); + + rec->_size = size; + rec->_color = col; + + return rec; +}src/plugins/SchedEvents.cpp +0
-52@@ -11,94 +11,9 @@ * preempted by another task. */ -// C++ -#include <vector> - // KernelShark -#include "libkshark.h" -#include "libkshark-plugin.h" #include "plugins/sched_events.h" -#include "KsPlotTools.hpp" -#include "KsPlugins.hpp" -#include "KsMainWindow.hpp" - -using namespace KsPlot; - -static KsMainWindow *ks_ptr; - -/** - * @brief Provide the plugin with a pointer to the KsMainWindow object (the GUI - * itself) such that the plugin can manipulate the GUI. - */ -__hidden void *plugin_set_gui_ptr(void *gui_ptr) -{ - ks_ptr = static_cast<KsMainWindow *>(gui_ptr); - return nullptr; -} - -/** - * This class represents the graphical element visualizing the latency between - * sched_waking and sched_switch events. - */ -class LatencyBox : public Rectangle -{ - /** On double click do. */ - void _doubleClick() const override - { - ks_ptr->markEntry(_data[1]->entry, DualMarkerState::B); - ks_ptr->markEntry(_data[0]->entry, DualMarkerState::A); - } - -public: - /** The trace record data that corresponds to this LatencyBox. */ - std::vector<kshark_data_field_int64 *> _data; - - /** - * @brief Distance between the click and the shape. Used to decide if - * the double click action must be executed. - * - * @param x: X coordinate of the click. - * @param y: Y coordinate of the click. - * - * @returns If the click is inside the box, the distance is zero. - * Otherwise infinity. - */ - double distance(int x, int y) const override - {
src/plugins/SchedEvents.cpp line 77
Quoted 10 lines
src/plugins/SchedEvents.cpp +0
-10- if (x < pointX(0) || x > pointX(2)) - return std::numeric_limits<double>::max(); - - if (y < pointY(0) || y > pointY(1)) - return std::numeric_limits<double>::max(); - - return 0; - } -}; -
Here you will have a child class that implements only the double-click function
class SchedLatencyBox : public LatencyBox
{
/** On double click do. */
void _doubleClick() const override
{
ks_ptr->markEntry(_data[1]->entry, DualMarkerState::B);
ks_ptr->markEntry(_data[0]->entry, DualMarkerState::A);
}
};Again, make sure that the child classes have different names in the two plugins. This will prevent any funny things that can potentially happen during linking.
Quoted 14 lines
src/plugins/SchedEvents.cpp +0
-14-static PlotObject *makeShape(std::vector<const Graph *> graph, - std::vector<int> bins, - std::vector<kshark_data_field_int64 *> data, - Color col, float size) -{ - LatencyBox *rec = new LatencyBox; - rec->_data = data; - - Point p0 = graph[0]->bin(bins[0])._base; - Point p1 = graph[0]->bin(bins[1])._base; - int height = graph[0]->height() * .3; - - rec->setFill(false); - rec->setPoint(0, p0.x() - 1, p0.y() - height);
src/plugins/SchedEvents.cpp line 101
Quoted 10 lines
src/plugins/SchedEvents.cpp +0
-10- rec->setPoint(1, p0.x() - 1, p0.y() - 1); - - rec->setPoint(3, p1.x() - 1, p1.y() - height); - rec->setPoint(2, p1.x() - 1, p1.y() - 1); - - rec->_size = size; - rec->_color = col; - - return rec; -};
and you don't need a local definition of makeShape. You can use makeLatencyBox<SchedLatencyBox>
Note that I haven't tested this at all, so do not copy-paste my code blindly.
Quoted 32 lines
src/plugins/SchedEvents.cpp +1
-0+#include "plugins/CommonSched.hpp" /* * Ideally, the sched_switch has to be the last trace event recorded before thesrc/plugins/common_sched.c new file +22
-0@@ -0,0 +1,37 @@ +// SPDX-License-Identifier: LGPL-2.1 + +/* +* Copyright (C) 2021 Intel Inc, Hongzhan Chen <[email protected]> +*/ + +/** +* @file common_sched.c +* @brief +*/ + +// KernelShark +#include "plugins/common_sched.h" + +void plugin_sched_set_pid (ks_num_field_t *field, +tep_num_field_t pid) +{ + *field &= ~PID_MASK ; + *field = pid &PID_MASK ; +} + +/**
src/plugins/common_sched.c line 32
Quoted 10 lines
src/plugins/common_sched.c new file +10
-0+* @brief Retrieve the PID value from the data field stored in the +* kshark_data_container object. +* +* @param field: Input location for the data field. +*/ +__hidden int plugin_sched_get_pid(ks_num_field_t field) +{ +return field &PID_MASK ; +} +
No need to have this file. All functions above can stay in the header as 'static inline' the one below must stay within the plugin.
cheers,
Yordan
Quoted 158 lines
src/plugins/common_sched.c new file +5
-0+/** Initialize the control interface of the plugin. */ +void *KSHARK_MENU_PLUGIN_INITIALIZER (void *gui_ptr) +{ +return plugin_set_gui_ptr (gui_ptr); +}src/plugins/common_sched.h new file +50
-0@@ -0,0 +1,50 @@ +/* SPDX-License-Identifier: LGPL-2.1 */ + +/* +* Copyright (C) 2021 Intel Inc, Hongzhan Chen<[email protected]> +*/ + +/** +* @file common_sched.h +* @brief Plugin for common sched. +*/ + +#ifndef _KS_PLUGIN_COMMON_SCHED_H +#define _KS_PLUGIN_COMMON_SCHED_H + +// KernelShark +#include "libkshark-plugin.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef unsigned long long tep_num_field_t ; + +/** The type of the data field stored in the kshark_data_container object. */ +typedef int64_t ks_num_field_t ; + +#define PREV_STATE_SHIFT ((int) ((sizeof(ks_num_field_t) - 1) * 8)) + +#define PREV_STATE_MASK (((ks_num_field_t) 1 << 8) - 1) + +#define PID_MASK (((ks_num_field_t) 1 << PREV_STATE_SHIFT) - 1) + +void plugin_sched_set_pid (ks_num_field_t *field, +tep_num_field_t pid); + +/** +* @brief Retrieve the PID value from the data field stored in the +* kshark_data_container object. +* +* @param field: Input location for the data field. +*/ +int plugin_sched_get_pid (ks_num_field_t field); + +void *plugin_set_gui_ptr (void *gui_ptr); + +#ifdef __cplusplus +} +#endif + +#endif src/plugins/sched_events.c +1
-36@@ -17,41 +17,12 @@#include <trace-cmd.h> // KernelShark +#include "plugins/common_sched.h" #include "plugins/sched_events.h" #include "libkshark-tepdata.h" /** Plugin context instance. */ -//! @cond Doxygen_Suppress - -typedef unsigned long long tep_num_field_t ; - -#define PREV_STATE_SHIFT ((int) ((sizeof(ks_num_field_t) - 1) * 8)) - -#define PREV_STATE_MASK (((ks_num_field_t) 1 << 8) - 1) - -#define PID_MASK (((ks_num_field_t) 1 << PREV_STATE_SHIFT) - 1) - -//! @endcond - -static void plugin_sched_set_pid (ks_num_field_t *field, -tep_num_field_t pid) -{ - *field &= ~PID_MASK ; - *field = pid &PID_MASK ; -} - -/** -* @brief Retrieve the PID value from the data field stored in the -* kshark_data_container object. -* -* @param field: Input location for the data field. -*/ -__hidden int plugin_sched_get_pid(ks_num_field_t field) -{ -return field &PID_MASK ; -} -/* Use the most significant byte to store the value of "prev_state". */ static void plugin_sched_set_prev_state (ks_num_field_t *field,tep_num_field_t prev_state)@@ -230,9 +201,3 @@ int KSHARK_PLOT_PLUGIN_DEINITIALIZER(struct kshark_data_stream *stream)return ret; } - -/** Initialize the control interface of the plugin. */ -void *KSHARK_MENU_PLUGIN_INITIALIZER (void *gui_ptr) -{ -return plugin_set_gui_ptr (gui_ptr); -}src/plugins/sched_events.h +3
-9@@ -9,12 +9,12 @@* @brief Plugin for Sched events. */ -#ifndef _KS_PLUGIN_SHED_H -#define _KS_PLUGIN_SHED_H +#ifndef _KS_PLUGIN_SCHED_H +#define _KS_PLUGIN_SCHED_H // KernelShark #include "libkshark.h" -#include "libkshark-plugin.h" +#include "plugins/common_sched.h" #ifdef __cplusplus extern "C" {@@ -55,18 +55,12 @@ struct plugin_sched_context {KS_DECLARE_PLUGIN_CONTEXT_METHODS (struct plugin_sched_context ) -/** The type of the data field stored in the kshark_data_container object. */ -typedef int64_t ks_num_field_t; - -int plugin_sched_get_pid (ks_num_field_t field); int plugin_sched_get_prev_state(ks_num_field_t field);void plugin_draw (struct kshark_cpp_argv *argv,int sd,int pid,int draw_action); -void *plugin_set_gui_ptr (void *gui_ptr); - #ifdef __cplusplus }#endif
This was sent during the Christmas vacation. I don't want it to be forgotten about.
Yordan, what's your thoughts on this?
-- Steve
Quoted 36 lines · On Wed, 22 Dec 2021 01:40:12 -0500 Hongzhan Chen <[email protected]>…
1. To avoid code duplication, move some common APIs and definitions out to create new files and share with other plugins.
2. add new plugin for handling xenomaicobalt_switch_contextevents to visualize OOB state of RT tasks.I tried to move common APIs and definitions to KsPlugins.cpp/hpp but found these definitions finally depend on KsMainWindow object used by
_doubleClickof LatencyBox assigned byplugin_set_gui_ptrviaKSHARK_MENU_PLUGIN_INITIALIZER.
I do not know how to remove this dependency so I create new files to avoid code duplication. Please suggest if there is better way.Hongzhan Chen (2):
kernel-shark: Move common APIs and definitions out to avoid
duplication
kernel-shark: Add plugin for handling Xenomaicobalt_context_switchsrc/libkshark-tepdata.c | 1 + src/plugins/CMakeLists.txt | 6 +- src/plugins/CobaltSwitchEvents.cpp | 125 +++++++++++++++ src/plugins/CommonSched.hpp | 99 ++++++++++++ src/plugins/SchedEvents.cpp | 87 +---------- src/plugins/common_sched.c | 37 +++++ src/plugins/common_sched.h | 50 ++++++ src/plugins/sched_events.c | 37 +---- src/plugins/sched_events.h | 12 +- src/plugins/xenomai_cobalt_switch_events.c | 169 +++++++++++++++++++++ src/plugins/xenomai_cobalt_switch_events.h | 54 +++++++ 11 files changed, 545 insertions(+), 132 deletions(-) create mode 100644 src/plugins/CobaltSwitchEvents.cpp create mode 100644 src/plugins/CommonSched.hpp create mode 100644 src/plugins/common_sched.c create mode 100644 src/plugins/common_sched.h create mode 100644 src/plugins/xenomai_cobalt_switch_events.c create mode 100644 src/plugins/xenomai_cobalt_switch_events.h
Hi Steven,
Happy New Year!
I already replayed, asking for some minor corrections.
https://lore.kernel.org/all/[email protected]/
I think the plugin is almost ready.
BTW have you finished the renovation of your office? If yes, I will send you a review for your trace-cruncher patch.
cheers,
Yordan
Quoted 49 lines · Steven Rostedt
This was sent during the Christmas vacation. I don't want it to be forgotten about.
Yordan, what's your thoughts on this?
-- Steve
Quoted 36 lines · On Wed, 22 Dec 2021 01:40:12 -0500 Hongzhan Chen <[email protected]>…
1. To avoid code duplication, move some common APIs and definitions out to create new files and share with other plugins.
2. add new plugin for handling xenomaicobalt_switch_contextevents to visualize OOB state of RT tasks.I tried to move common APIs and definitions to KsPlugins.cpp/hpp but found these definitions finally depend on KsMainWindow object used by
_doubleClickof LatencyBox assigned byplugin_set_gui_ptrviaKSHARK_MENU_PLUGIN_INITIALIZER.
I do not know how to remove this dependency so I create new files to avoid code duplication. Please suggest if there is better way.Hongzhan Chen (2):
kernel-shark: Move common APIs and definitions out to avoid
duplication
kernel-shark: Add plugin for handling Xenomaicobalt_context_switchsrc/libkshark-tepdata.c | 1 + src/plugins/CMakeLists.txt | 6 +- src/plugins/CobaltSwitchEvents.cpp | 125 +++++++++++++++ src/plugins/CommonSched.hpp | 99 ++++++++++++ src/plugins/SchedEvents.cpp | 87 +---------- src/plugins/common_sched.c | 37 +++++ src/plugins/common_sched.h | 50 ++++++ src/plugins/sched_events.c | 37 +---- src/plugins/sched_events.h | 12 +- src/plugins/xenomai_cobalt_switch_events.c | 169 +++++++++++++++++++++ src/plugins/xenomai_cobalt_switch_events.h | 54 +++++++ 11 files changed, 545 insertions(+), 132 deletions(-)create mode 100644 src/plugins/CobaltSwitchEvents.cpp create mode 100644 src/plugins/CommonSched.hpp create mode 100644
src/plugins/common_sched.ccreate mode 100644src/plugins/common_sched.hcreate mode 100644src/plugins/xenomai_cobalt_switch_events.ccreate mode 100644src/plugins/xenomai_cobalt_switch_events.h
Quoted 2 lines · On Thu, 6 Jan 2022 19:32:56 +0200 Yordan Karadzhov <[email protected]> wrote:
Hi Steven,
Happy New Year!
Happy New Year to you too Yordan!
Quoted 4 lines
I already replayed, asking for some minor corrections.
https://lore.kernel.org/all/[email protected]/
I think the plugin is almost ready.
Strange, I didn't receive it. I wonder if I got booted from the email lists because I had my mail server offline for too long (/me goes check).
Quoted 3 lines
BTW have you finished the renovation of your office? If yes, I will send you a review for your trace-cruncher patch.
Yes, I just finished. Now I'm trying to catch up on everything and also work on some things that I may not be able to work on when I start working again.
Cheers,
-- Steve