All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 0/2] cobalt_switch_context plugin
@ 2021-12-14  3:15 Hongzhan Chen
  2021-12-14  3:15 ` [RFC PATCH 1/2] kernel-shark: add plugin for handling xenomai cobalt context switch event Hongzhan Chen
  2021-12-14  3:15 ` [RFC PATCH 2/2] kernelshark: shape blue hollow box to show OOB state of task Hongzhan Chen
  0 siblings, 2 replies; 14+ messages in thread
From: Hongzhan Chen @ 2021-12-14  3:15 UTC (permalink / raw)
  To: xenomai, jan.kiszka

1. add plugin to take correct action to show correct color for
   cobalt_switch_context in cpu plot
2. show hollow blue box underneath baseline of task plot to mark
   oob state task is runing on.

steps to show hollow blue box
1. loading trace-cmd data, please note that it would check if there
    is cobalt_switch_context event in data. If does not exist ,the
    cobalt_switch_context plugin would fail to init.
2. click menu plots-> tasks and then choose RT tasks that you want to
   show and then apply.
3. In RT tasks plot shape you may find the hollow blue box that indicating that 
   it is running on OOB underneath the baseline of plot.

Please help check if it meet our requirement and comments.


Hongzhan Chen (2):
  kernel-shark: add plugin for handling xenomai cobalt context switch
    event
  kernelshark: shape blue hollow box to show OOB state of task

 src/libkshark-tepdata.c                    |   1 +
 src/plugins/CMakeLists.txt                 |   4 +
 src/plugins/CobaltSwitchEvents.cpp         | 204 +++++++++++++++++++++
 src/plugins/xenomai_cobalt_switch_events.c | 196 ++++++++++++++++++++
 src/plugins/xenomai_cobalt_switch_events.h |  64 +++++++
 5 files changed, 469 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

-- 
2.17.1



^ permalink raw reply	[flat|nested] 14+ messages in thread

* [RFC PATCH 1/2] kernel-shark: add plugin for handling xenomai cobalt context switch event
  2021-12-14  3:15 [RFC PATCH 0/2] cobalt_switch_context plugin Hongzhan Chen
@ 2021-12-14  3:15 ` Hongzhan Chen
  2021-12-14  6:37   ` Jan Kiszka
  2021-12-14  3:15 ` [RFC PATCH 2/2] kernelshark: shape blue hollow box to show OOB state of task Hongzhan Chen
  1 sibling, 1 reply; 14+ messages in thread
From: Hongzhan Chen @ 2021-12-14  3:15 UTC (permalink / raw)
  To: xenomai, jan.kiszka

For Xenomai-cobalt enabled system, cobalt_switch_context means that there
is context switch in companion core(realtime core), which we may need
to do special treatment and take correct action as main kernel sched_switch.
We need to update cpu bar regarding cobalt_switch_context event to correct
color as switching-in task.

Signed-off-by: Hongzhan Chen <hongzhan.chen@intel.com>
---
 src/libkshark-tepdata.c                    |   1 +
 src/plugins/CMakeLists.txt                 |   4 +
 src/plugins/xenomai_cobalt_switch_events.c | 116 +++++++++++++++++++++
 src/plugins/xenomai_cobalt_switch_events.h |  45 ++++++++
 4 files changed, 166 insertions(+)
 create mode 100644 src/plugins/xenomai_cobalt_switch_events.c
 create mode 100644 src/plugins/xenomai_cobalt_switch_events.h

diff --git a/src/libkshark-tepdata.c b/src/libkshark-tepdata.c
index 9740ed9..e933b39 100644
--- a/src/libkshark-tepdata.c
+++ b/src/libkshark-tepdata.c
@@ -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",
 };
diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt
index 3e170fa..276eaaa 100644
--- a/src/plugins/CMakeLists.txt
+++ b/src/plugins/CMakeLists.txt
@@ -44,6 +44,10 @@ if (Qt5Widgets_FOUND AND TT_FONT_FILE)
                      SOURCE sched_events.c SchedEvents.cpp)
     list(APPEND PLUGIN_LIST "sched_events")
 
+    BUILD_GUI_PLUGIN(NAME xenomai_cobalt_switch_events
+                     SOURCE xenomai_cobalt_switch_events.c)
+    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)
diff --git a/src/plugins/xenomai_cobalt_switch_events.c b/src/plugins/xenomai_cobalt_switch_events.c
new file mode 100644
index 0000000..4639d24
--- /dev/null
+++ b/src/plugins/xenomai_cobalt_switch_events.c
@@ -0,0 +1,116 @@
+// SPDX-License-Identifier: LGPL-2.1
+
+/*
+ * Copyright (C) 2021 Intel Inc, Hongzhan Chen <hongzhan.chen@intel.com>
+ */
+
+/**
+ *  @file    xenomai_cobalt_switch_events.c
+ *  @brief   handle xenomai cobalt switch context event
+ */
+
+// C
+#include <stdlib.h>
+#include <stdio.h>
+
+// trace-cmd
+#include <trace-cmd.h>
+
+// KernelShark
+#include "plugins/xenomai_cobalt_switch_events.h"
+#include "libkshark-tepdata.h"
+
+/** Plugin context instance. */
+
+static void cobalt_free_context(struct plugin_cobalt_context *plugin_ctx)
+{
+	return;
+}
+
+/** A general purpose macro is used to define plugin context. */
+KS_DEFINE_PLUGIN_CONTEXT(struct plugin_cobalt_context, cobalt_free_context);
+
+static bool plugin_cobalt_init_context(struct kshark_data_stream *stream,
+				      struct plugin_cobalt_context *plugin_ctx)
+{
+	struct tep_event *event;
+
+	if (!kshark_is_tep(stream))
+		return false;
+
+	plugin_ctx->tep = kshark_get_tep(stream);
+
+	event = tep_find_event_by_name(plugin_ctx->tep,
+					"cobalt_core", "cobalt_switch_context");
+	if (!event)
+		return false;
+
+	plugin_ctx->cobalt_switch_event = event;
+	plugin_ctx->cobalt_switch_next_field =
+		tep_find_any_field(event, "next_pid");
+
+	plugin_ctx->cobalt_switch_prev_state_field =
+		tep_find_field(event, "prev_state");
+
+	return true;
+}
+
+static void plugin_cobalt_switch_action(struct kshark_data_stream *stream,
+				      void *rec, struct kshark_entry *entry)
+{
+	struct tep_record *record = (struct tep_record *) rec;
+	struct plugin_cobalt_context *plugin_ctx;
+	unsigned long long next_pid;
+	int ret;
+
+	plugin_ctx = __get_context(stream->stream_id);
+	if (!plugin_ctx)
+		return;
+
+	ret = tep_read_number_field(plugin_ctx->cobalt_switch_next_field,
+				    record->data, &next_pid);
+
+	if (ret == 0 && next_pid >= 0)
+		entry->pid = next_pid;
+}
+
+/** Load this plugin. */
+int KSHARK_PLOT_PLUGIN_INITIALIZER(struct kshark_data_stream *stream)
+{
+	struct plugin_cobalt_context *plugin_ctx;
+
+	plugin_ctx = __init(stream->stream_id);
+	if (!plugin_ctx || !plugin_cobalt_init_context(stream, plugin_ctx)) {
+		__close(stream->stream_id);
+		return 0;
+	}
+
+	if (plugin_ctx->cobalt_switch_event) {
+		kshark_register_event_handler(stream,
+						plugin_ctx->cobalt_switch_event->id,
+						plugin_cobalt_switch_action);
+	}
+
+	return 1;
+}
+
+/** Unload this plugin. */
+int KSHARK_PLOT_PLUGIN_DEINITIALIZER(struct kshark_data_stream *stream)
+{
+	struct plugin_cobalt_context *plugin_ctx = __get_context(stream->stream_id);
+	int ret = 0;
+
+	if (plugin_ctx) {
+		if (plugin_ctx->cobalt_switch_event) {
+			kshark_unregister_event_handler(stream,
+							plugin_ctx->cobalt_switch_event->id,
+							plugin_cobalt_switch_action);
+		}
+
+		ret = 1;
+	}
+
+	__close(stream->stream_id);
+
+	return ret;
+}
diff --git a/src/plugins/xenomai_cobalt_switch_events.h b/src/plugins/xenomai_cobalt_switch_events.h
new file mode 100644
index 0000000..4a3bc66
--- /dev/null
+++ b/src/plugins/xenomai_cobalt_switch_events.h
@@ -0,0 +1,45 @@
+/* SPDX-License-Identifier: LGPL-2.1 */
+
+/*
+ * Copyright (C) 2021 Intel Inc, Hongzhan Chen<hongzhan.chen@intel.com>
+ */
+
+/**
+ *  @file    xenomai_cobalt_switch_events.h
+ *  @brief   Plugin for xenomai cobalt switch context event
+ */
+
+#ifndef _KS_PLUGIN_SHED_H
+#define _KS_PLUGIN_SHED_H
+
+// KernelShark
+#include "libkshark.h"
+#include "libkshark-plugin.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** Structure representing a plugin-specific context. */
+struct plugin_cobalt_context {
+	/** Page event used to parse the page. */
+	struct tep_handle	*tep;
+
+	/** Pointer to the cobalt_switch_event object. */
+	struct tep_event	*cobalt_switch_event;
+
+	 /** Pointer to the cobalt_switch_next_field format descriptor. */
+	struct tep_format_field *cobalt_switch_next_field;
+
+	/** Pointer to the cobalt_switch_prev_state_field format descriptor. */
+	struct tep_format_field *cobalt_switch_prev_state_field;
+
+};
+
+KS_DECLARE_PLUGIN_CONTEXT_METHODS(struct plugin_cobalt_context)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [RFC PATCH 2/2] kernelshark: shape blue hollow box to show OOB state of task
  2021-12-14  3:15 [RFC PATCH 0/2] cobalt_switch_context plugin Hongzhan Chen
  2021-12-14  3:15 ` [RFC PATCH 1/2] kernel-shark: add plugin for handling xenomai cobalt context switch event Hongzhan Chen
@ 2021-12-14  3:15 ` Hongzhan Chen
  2021-12-14  6:40   ` Jan Kiszka
  1 sibling, 1 reply; 14+ messages in thread
From: Hongzhan Chen @ 2021-12-14  3:15 UTC (permalink / raw)
  To: xenomai, jan.kiszka

1. store cobalt_switch_contexts event to data container.
2. show blue hollow box to mark out-of-band state under the
   basedline of task plot according to cobalt_switch_context
   events.
3. clickable cobalt_switch_context plugin shapes.

Signed-off-by: Hongzhan Chen <hongzhan.chen@intel.com>
---
 src/plugins/CMakeLists.txt                 |   2 +-
 src/plugins/CobaltSwitchEvents.cpp         | 204 +++++++++++++++++++++
 src/plugins/xenomai_cobalt_switch_events.c |  86 ++++++++-
 src/plugins/xenomai_cobalt_switch_events.h |  19 ++
 4 files changed, 307 insertions(+), 4 deletions(-)
 create mode 100644 src/plugins/CobaltSwitchEvents.cpp

diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt
index 276eaaa..16f080b 100644
--- a/src/plugins/CMakeLists.txt
+++ b/src/plugins/CMakeLists.txt
@@ -45,7 +45,7 @@ if (Qt5Widgets_FOUND AND TT_FONT_FILE)
     list(APPEND PLUGIN_LIST "sched_events")
 
     BUILD_GUI_PLUGIN(NAME xenomai_cobalt_switch_events
-                     SOURCE xenomai_cobalt_switch_events.c)
+                     SOURCE xenomai_cobalt_switch_events.c CobaltSwitchEvents.cpp)
     list(APPEND PLUGIN_LIST "xenomai_cobalt_switch_events")
 
     BUILD_GUI_PLUGIN(NAME event_field_plot
diff --git a/src/plugins/CobaltSwitchEvents.cpp b/src/plugins/CobaltSwitchEvents.cpp
new file mode 100644
index 0000000..cfe82dd
--- /dev/null
+++ b/src/plugins/CobaltSwitchEvents.cpp
@@ -0,0 +1,204 @@
+// SPDX-License-Identifier: LGPL-2.1
+
+/*
+ * Copyright (C) 2018 Intel Inc, Hongzhan Chen<hongzhan.chen@intel.com>
+ */
+
+/**
+ *  @file    CobaltSwitchEvents.cpp
+ *  @brief   Defines a callback function for Xenomai Cobalt context switch
+ *           events used to plot in blue the out-of-band state of the task
+ */
+
+// C++
+#include <vector>
+
+// KernelShark
+#include "libkshark.h"
+#include "libkshark-plugin.h"
+#include "plugins/xenomai_cobalt_switch_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_cobalt_set_gui_ptr(void *gui_ptr)
+{
+	ks_ptr = static_cast<KsMainWindow *>(gui_ptr);
+	return nullptr;
+}
+
+/**
+ * This class represents the graphical element visualizing out-of-band state
+ * that the task is running on
+ */
+class CobaltOobBox : 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 CobaltOobBox. */
+	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();
+
+		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)
+{
+	CobaltOobBox *rec = new CobaltOobBox;
+	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;
+};
+
+/*
+ * Ideally, the cobalt_switch_context has to be the last trace event recorded before
+ * the task is preempted. Because of this, when the data is loaded (the first pass),
+ * the "pid" field of the cobalt_switch_context entries gets edited by this plugin
+ * to be equal to the "next pid" of the cobalt_switch_context event. However, in
+ * reality the cobalt_switch_context event may be followed by some trailing events
+ * from the same task (printk events for example). This has the effect of extending
+ * the graph of the task outside of the actual duration of the task. The "second
+ * pass" over the data is used to fix this problem. It takes advantage of the
+ * "next" field of the entry (this field is set during the first pass) to search
+ * for trailing events after the "cobalt_switch_context". In addition, when 
+ * we find that it try to switch in-band because next-pid is zero, we prefer to
+ * skip this event because it try to leave oob not enterring.
+ */
+static void secondPass(plugin_cobalt_context *plugin_ctx)
+{
+	kshark_data_container *cSS;
+	kshark_entry *e;
+	int pid_rec, switch_inband;
+
+	cSS = plugin_ctx->cs_data;
+	for (ssize_t i = 0; i < cSS->size; ++i) {
+		switch_inband = plugin_cobalt_check_switch_inband(
+				cSS->data[i]->field);
+		if (switch_inband)
+			continue;
+		pid_rec = plugin_cobalt_get_pid(cSS->data[i]->field);
+		e = cSS->data[i]->entry;
+		if (!e->next || e->pid == 0 ||
+		    e->event_id == e->next->event_id ||
+		    pid_rec != e->next->pid)
+			continue;
+
+		e = e->next;
+		/* Find the very last trailing event. */
+		for (; e->next; e = e->next) {
+			if (e->pid == plugin_cobalt_get_pid(
+						cSS->data[i]->field)) {
+				/*
+				 * Change the "pid" to be equal to the "next
+				 * pid" of the cobalt_switch_context event
+				 * and leave a sign that you edited this
+				 * entry.
+				 */
+				e->pid = cSS->data[i]->entry->pid;
+				e->visible &= ~KS_PLUGIN_UNTOUCHED_MASK;
+			}
+			/*  This is the last trailing event, we finish
+			 *  this round.
+			 */
+			if (e->next->pid != plugin_cobalt_get_pid(
+						cSS->data[i]->field))
+				break;
+		}
+	}
+}
+
+/**
+ * @brief Plugin's draw function.
+ *
+ * @param argv_c: A C pointer to be converted to KsCppArgV (C++ struct).
+ * @param sd: Data stream identifier.
+ * @param pid: Process Id.
+ * @param draw_action: Draw action identifier.
+ */
+__hidden void plugin_cobalt_draw(kshark_cpp_argv *argv_c,
+			  int sd, int pid, int draw_action)
+{
+	plugin_cobalt_context *plugin_ctx;
+
+	if (!(draw_action & KSHARK_TASK_DRAW) || pid == 0)
+		return;
+
+	plugin_ctx = __get_context(sd);
+	if (!plugin_ctx)
+		return;
+
+	KsCppArgV *argvCpp = KS_ARGV_TO_CPP(argv_c);
+
+	if (!plugin_ctx->second_pass_done) {
+		/* The second pass is not done yet. */
+		secondPass(plugin_ctx);
+		plugin_ctx->second_pass_done = true;
+	}
+
+	IsApplicableFunc checkFieldCS = [=] (kshark_data_container *d,
+					     ssize_t i) {
+		return !(plugin_cobalt_check_switch_inband(d->data[i]->field)) &&
+			d->data[i]->entry->pid == pid;
+	};
+
+	IsApplicableFunc checkEntryPid = [=] (kshark_data_container *d,
+					      ssize_t i) {
+		return plugin_cobalt_get_pid(d->data[i]->field) == pid;
+	};
+
+	eventFieldIntervalPlot(argvCpp,
+			       plugin_ctx->cs_data, checkFieldCS,
+			       plugin_ctx->cs_data, checkEntryPid,
+			       makeShape,
+			       {0, 0, 255}, // Blue
+			       -1);         // Default size
+}
diff --git a/src/plugins/xenomai_cobalt_switch_events.c b/src/plugins/xenomai_cobalt_switch_events.c
index 4639d24..9349529 100644
--- a/src/plugins/xenomai_cobalt_switch_events.c
+++ b/src/plugins/xenomai_cobalt_switch_events.c
@@ -21,10 +21,61 @@
 #include "libkshark-tepdata.h"
 
 /** Plugin context instance. */
+typedef unsigned long long tep_num_field_t;
+
+#define SWITCH_INBAND_SHIFT	((int) ((sizeof(ks_num_field_t) - 1) * 8))
+
+#define SWITCH_INBAND_MASK		(((ks_num_field_t) 1 << 8) - 1)
+
+#define PID_MASK	(((ks_num_field_t) 1 << SWITCH_INBAND_SHIFT) - 1)
+
+//! @endcond
+
+static void plugin_cobalt_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_cobalt_get_pid(ks_num_field_t field)
+{
+	return field & PID_MASK;
+}
 
 static void cobalt_free_context(struct plugin_cobalt_context *plugin_ctx)
 {
-	return;
+	if (!plugin_ctx)
+		return;
+
+	kshark_free_data_container(plugin_ctx->cs_data);
+}
+
+/* Use the most significant byte to store state marking switch in-band. */
+static void plugin_cobalt_set_switch_inband_state(ks_num_field_t *field,
+					tep_num_field_t inband_state)
+{
+	tep_num_field_t mask = SWITCH_INBAND_MASK << SWITCH_INBAND_SHIFT;
+	*field &= ~mask;
+	*field |= (inband_state & SWITCH_INBAND_MASK) << SWITCH_INBAND_SHIFT;
+}
+
+/**
+ * @brief Retrieve the state of switch-in-band from the data field stored in
+ * 	the kshark_data_container object.
+ *
+ * @param field: Input location for the data field.
+ */
+__hidden int plugin_cobalt_check_switch_inband(ks_num_field_t field)
+{
+	tep_num_field_t mask = SWITCH_INBAND_MASK << SWITCH_INBAND_SHIFT;
+	return (field & mask) >> SWITCH_INBAND_SHIFT;
 }
 
 /** A general purpose macro is used to define plugin context. */
@@ -52,6 +103,13 @@ static bool plugin_cobalt_init_context(struct kshark_data_stream *stream,
 	plugin_ctx->cobalt_switch_prev_state_field =
 		tep_find_field(event, "prev_state");
 
+	plugin_ctx->second_pass_done = false;
+
+	plugin_ctx->cs_data = kshark_init_data_container();
+	if (!plugin_ctx->cs_data)
+		return false;
+
+
 	return true;
 }
 
@@ -61,6 +119,7 @@ static void plugin_cobalt_switch_action(struct kshark_data_stream *stream,
 	struct tep_record *record = (struct tep_record *) rec;
 	struct plugin_cobalt_context *plugin_ctx;
 	unsigned long long next_pid;
+	ks_num_field_t ks_field;
 	int ret;
 
 	plugin_ctx = __get_context(stream->stream_id);
@@ -70,8 +129,21 @@ static void plugin_cobalt_switch_action(struct kshark_data_stream *stream,
 	ret = tep_read_number_field(plugin_ctx->cobalt_switch_next_field,
 				    record->data, &next_pid);
 
-	if (ret == 0 && next_pid >= 0)
-		entry->pid = next_pid;
+	if (ret == 0 && next_pid >= 0) {
+		plugin_cobalt_set_pid(&ks_field, entry->pid);
+		if (next_pid == 0) {
+			plugin_cobalt_set_switch_inband_state(&ks_field,
+					SWITCH_INBAND_STATE);
+		}
+
+		kshark_data_container_append(plugin_ctx->cs_data,
+				entry, ks_field);
+
+		if (next_pid > 0)
+			entry->pid = next_pid;
+
+
+	}
 }
 
 /** Load this plugin. */
@@ -91,6 +163,8 @@ int KSHARK_PLOT_PLUGIN_INITIALIZER(struct kshark_data_stream *stream)
 						plugin_cobalt_switch_action);
 	}
 
+	kshark_register_draw_handler(stream, plugin_cobalt_draw);
+
 	return 1;
 }
 
@@ -114,3 +188,9 @@ 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_cobalt_set_gui_ptr(gui_ptr);
+}
diff --git a/src/plugins/xenomai_cobalt_switch_events.h b/src/plugins/xenomai_cobalt_switch_events.h
index 4a3bc66..9e1e030 100644
--- a/src/plugins/xenomai_cobalt_switch_events.h
+++ b/src/plugins/xenomai_cobalt_switch_events.h
@@ -20,6 +20,7 @@
 extern "C" {
 #endif
 
+#define SWITCH_INBAND_STATE	1
 /** Structure representing a plugin-specific context. */
 struct plugin_cobalt_context {
 	/** Page event used to parse the page. */
@@ -34,10 +35,28 @@ struct plugin_cobalt_context {
 	/** Pointer to the cobalt_switch_prev_state_field format descriptor. */
 	struct tep_format_field *cobalt_switch_prev_state_field;
 
+	/** True if the second pass is already done. */
+	bool	second_pass_done;
+
+	/** Data container for cobalt_switch_context data. */
+	struct kshark_data_container	*cs_data;
+
 };
 
 KS_DECLARE_PLUGIN_CONTEXT_METHODS(struct plugin_cobalt_context)
 
+/** The type of the data field stored in the kshark_data_container object. */
+typedef int64_t ks_num_field_t;
+
+int plugin_cobalt_get_pid(ks_num_field_t field);
+
+int plugin_cobalt_check_switch_inband(ks_num_field_t field);
+
+void plugin_cobalt_draw(struct kshark_cpp_argv *argv, int sd, int pid,
+		 int draw_action);
+
+void *plugin_cobalt_set_gui_ptr(void *gui_ptr);
+
 #ifdef __cplusplus
 }
 #endif
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [RFC PATCH 1/2] kernel-shark: add plugin for handling xenomai cobalt context switch event
  2021-12-14  3:15 ` [RFC PATCH 1/2] kernel-shark: add plugin for handling xenomai cobalt context switch event Hongzhan Chen
@ 2021-12-14  6:37   ` Jan Kiszka
  2021-12-14  6:44     ` Chen, Hongzhan
  0 siblings, 1 reply; 14+ messages in thread
From: Jan Kiszka @ 2021-12-14  6:37 UTC (permalink / raw)
  To: Hongzhan Chen, xenomai

On 14.12.21 04:15, Hongzhan Chen wrote:
> For Xenomai-cobalt enabled system, cobalt_switch_context means that there
> is context switch in companion core(realtime core), which we may need
> to do special treatment and take correct action as main kernel sched_switch.
> We need to update cpu bar regarding cobalt_switch_context event to correct
> color as switching-in task.

It's tricker... I have trace with the following sequence here:

             gdb-898   [000]   753.944137: cobalt_switch_context: prev_name=ROOT/0 prev_pid=0 prev_prio=-1 prev_state=0x218008 ==> next_name=pthelper next_pid=912 next_prio=3
             gdb-898   [000]   753.944142: cobalt_timer_start:   timer=0xef7e8200([watchdog]) value=4000000000 interval=0 mode=0x0
        pthelper-912   [000]   753.944172: cobalt_shadow_hardened: state=0x240840 info=0x0

Your plugin correctly switches colors on cobalt_switch_context, but that
cobalt_timer_start is still running under the previous pid, causing a
color switch-back and than forth on cobalt_shadow_hardened. We need to
understand why and possibly fix that or rethink the visualization.

Jan

-- 
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [RFC PATCH 2/2] kernelshark: shape blue hollow box to show OOB state of task
  2021-12-14  3:15 ` [RFC PATCH 2/2] kernelshark: shape blue hollow box to show OOB state of task Hongzhan Chen
@ 2021-12-14  6:40   ` Jan Kiszka
  2021-12-14  6:58     ` Chen, Hongzhan
  0 siblings, 1 reply; 14+ messages in thread
From: Jan Kiszka @ 2021-12-14  6:40 UTC (permalink / raw)
  To: Hongzhan Chen, xenomai

On 14.12.21 04:15, Hongzhan Chen wrote:
> 1. store cobalt_switch_contexts event to data container.
> 2. show blue hollow box to mark out-of-band state under the
>    basedline of task plot according to cobalt_switch_context
>    events.
> 3. clickable cobalt_switch_context plugin shapes.
> 

How do I activate this? I have the plugin built and apparently loaded,
but I'm not seeing that new boxes in the CPU or task plots.

Jan

-- 
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux


^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: [RFC PATCH 1/2] kernel-shark: add plugin for handling xenomai cobalt context switch event
  2021-12-14  6:37   ` Jan Kiszka
@ 2021-12-14  6:44     ` Chen, Hongzhan
  2021-12-14  6:49       ` Jan Kiszka
  0 siblings, 1 reply; 14+ messages in thread
From: Chen, Hongzhan @ 2021-12-14  6:44 UTC (permalink / raw)
  To: Kiszka, Jan, xenomai

>
>
>-----Original Message-----
>From: Jan Kiszka <jan.kiszka@siemens.com> 
>Sent: Tuesday, December 14, 2021 2:38 PM
>To: Chen, Hongzhan <hongzhan.chen@intel.com>; xenomai@xenomai.org
>Subject: Re: [RFC PATCH 1/2] kernel-shark: add plugin for handling xenomai cobalt context switch event
>
>On 14.12.21 04:15, Hongzhan Chen wrote:
>> For Xenomai-cobalt enabled system, cobalt_switch_context means that there
>> is context switch in companion core(realtime core), which we may need
>> to do special treatment and take correct action as main kernel sched_switch.
>> We need to update cpu bar regarding cobalt_switch_context event to correct
>> color as switching-in task.
>
>It's tricker... I have trace with the following sequence here:
>
>             gdb-898   [000]   753.944137: cobalt_switch_context: prev_name=ROOT/0 prev_pid=0 prev_prio=-1 prev_state=0x218008 ==> next_name=pthelper next_pid=912 next_prio=3
>             gdb-898   [000]   753.944142: cobalt_timer_start:   timer=0xef7e8200([watchdog]) value=4000000000 interval=0 mode=0x0
>        pthelper-912   [000]   753.944172: cobalt_shadow_hardened: state=0x240840 info=0x0
>
>Your plugin correctly switches colors on cobalt_switch_context, but that
>cobalt_timer_start is still running under the previous pid, causing a
>color switch-back and than forth on cobalt_shadow_hardened. We need to
>understand why and possibly fix that or rethink the visualization.

You need to click menu Plots->tasks and then select RT tasks and then apply. It would tigger plugin shape to redraw
and then the issue you observed would be fixed by plugin. 

>
>Jan
>
>-- 
>Siemens AG, T RDA IOT
>Corporate Competence Center Embedded Linux

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [RFC PATCH 1/2] kernel-shark: add plugin for handling xenomai cobalt context switch event
  2021-12-14  6:44     ` Chen, Hongzhan
@ 2021-12-14  6:49       ` Jan Kiszka
  2021-12-14  7:02         ` Jan Kiszka
  0 siblings, 1 reply; 14+ messages in thread
From: Jan Kiszka @ 2021-12-14  6:49 UTC (permalink / raw)
  To: Chen, Hongzhan, xenomai

On 14.12.21 07:44, Chen, Hongzhan wrote:
>>
>>
>> -----Original Message-----
>> From: Jan Kiszka <jan.kiszka@siemens.com> 
>> Sent: Tuesday, December 14, 2021 2:38 PM
>> To: Chen, Hongzhan <hongzhan.chen@intel.com>; xenomai@xenomai.org
>> Subject: Re: [RFC PATCH 1/2] kernel-shark: add plugin for handling xenomai cobalt context switch event
>>
>> On 14.12.21 04:15, Hongzhan Chen wrote:
>>> For Xenomai-cobalt enabled system, cobalt_switch_context means that there
>>> is context switch in companion core(realtime core), which we may need
>>> to do special treatment and take correct action as main kernel sched_switch.
>>> We need to update cpu bar regarding cobalt_switch_context event to correct
>>> color as switching-in task.
>>
>> It's tricker... I have trace with the following sequence here:
>>
>>             gdb-898   [000]   753.944137: cobalt_switch_context: prev_name=ROOT/0 prev_pid=0 prev_prio=-1 prev_state=0x218008 ==> next_name=pthelper next_pid=912 next_prio=3
>>             gdb-898   [000]   753.944142: cobalt_timer_start:   timer=0xef7e8200([watchdog]) value=4000000000 interval=0 mode=0x0
>>        pthelper-912   [000]   753.944172: cobalt_shadow_hardened: state=0x240840 info=0x0
>>
>> Your plugin correctly switches colors on cobalt_switch_context, but that
>> cobalt_timer_start is still running under the previous pid, causing a
>> color switch-back and than forth on cobalt_shadow_hardened. We need to
>> understand why and possibly fix that or rethink the visualization.
> 
> You need to click menu Plots->tasks and then select RT tasks and then apply. It would tigger plugin shape to redraw
> and then the issue you observed would be fixed by plugin. 

OK, now I also see that blue "OOB" box under the RT task.

But the that does not affect the CPU graph, it continues to jump back
and forth. And it has no RT mode visualization.

BTW, is that blue hollow box exclusive for our plugin? Or can this be
customized? Is it explained somewhere in Kernelshark what hollow boxes mean?

Jan

-- 
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux


^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: [RFC PATCH 2/2] kernelshark: shape blue hollow box to show OOB state of task
  2021-12-14  6:40   ` Jan Kiszka
@ 2021-12-14  6:58     ` Chen, Hongzhan
  0 siblings, 0 replies; 14+ messages in thread
From: Chen, Hongzhan @ 2021-12-14  6:58 UTC (permalink / raw)
  To: Kiszka, Jan, xenomai


>-----Original Message-----
>From: Jan Kiszka <jan.kiszka@siemens.com> 
>Sent: Tuesday, December 14, 2021 2:49 PM
>To: Chen, Hongzhan <hongzhan.chen@intel.com>; xenomai@xenomai.org
>Subject: Re: [RFC PATCH 1/2] kernel-shark: add plugin for handling xenomai cobalt context switch event
>
>On 14.12.21 07:44, Chen, Hongzhan wrote:
>>>
>>>
>>> -----Original Message-----
>>> From: Jan Kiszka <jan.kiszka@siemens.com> 
>>> Sent: Tuesday, December 14, 2021 2:38 PM
>>> To: Chen, Hongzhan <hongzhan.chen@intel.com>; xenomai@xenomai.org
>>> Subject: Re: [RFC PATCH 1/2] kernel-shark: add plugin for handling xenomai cobalt context switch event
>>>
>>> On 14.12.21 04:15, Hongzhan Chen wrote:
>>>> For Xenomai-cobalt enabled system, cobalt_switch_context means that there
>>>> is context switch in companion core(realtime core), which we may need
>>>> to do special treatment and take correct action as main kernel sched_switch.
>>>> We need to update cpu bar regarding cobalt_switch_context event to correct
>>>> color as switching-in task.
>>>
>>> It's tricker... I have trace with the following sequence here:
>>>
>>>             gdb-898   [000]   753.944137: cobalt_switch_context: prev_name=ROOT/0 prev_pid=0 prev_prio=-1 prev_state=0x218008 ==> next_name=pthelper next_pid=912 next_prio=3
>>>             gdb-898   [000]   753.944142: cobalt_timer_start:   timer=0xef7e8200([watchdog]) value=4000000000 interval=0 mode=0x0
>>>        pthelper-912   [000]   753.944172: cobalt_shadow_hardened: state=0x240840 info=0x0
>>>
>>> Your plugin correctly switches colors on cobalt_switch_context, but that
>>> cobalt_timer_start is still running under the previous pid, causing a
>>> color switch-back and than forth on cobalt_shadow_hardened. We need to
>>> understand why and possibly fix that or rethink the visualization.
>> 
>> You need to click menu Plots->tasks and then select RT tasks and then apply. It would tigger plugin shape to redraw
>> and then the issue you observed would be fixed by plugin. 
>
>OK, now I also see that blue "OOB" box under the RT task.
>
>But the that does not affect the CPU graph, it continues to jump back
>and forth. And it has no RT mode visualization.

Yes, it does not affect CPU.  What does means jump back and forth now?

>
>BTW, is that blue hollow box exclusive for our plugin? Or can this be

Currently there is other two hollow box as described in page 15 of [1].
Blue hollow box should be exclusive if we want to upstream if it upstream.


[1]: https://elinux.org/images/6/64/Elc2011_rostedt.pdf

>customized? Is it explained somewhere in Kernelshark what hollow boxes mean?

Yes, we can customize it.  But once we finalize it and upstream , it should be exclusive 
and try not to confuse user per my understanding. I just refer to available design about hollow box usage
in kernelshark as described in page 15 of [1]..


>
>Jan
>
>-- 
>Siemens AG, T RDA IOT
>Corporate Competence Center Embedded Linux

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [RFC PATCH 1/2] kernel-shark: add plugin for handling xenomai cobalt context switch event
  2021-12-14  6:49       ` Jan Kiszka
@ 2021-12-14  7:02         ` Jan Kiszka
  2021-12-14  7:14           ` Chen, Hongzhan
  0 siblings, 1 reply; 14+ messages in thread
From: Jan Kiszka @ 2021-12-14  7:02 UTC (permalink / raw)
  To: Chen, Hongzhan, xenomai

On 14.12.21 07:49, Jan Kiszka via Xenomai wrote:
> On 14.12.21 07:44, Chen, Hongzhan wrote:
>>>
>>>
>>> -----Original Message-----
>>> From: Jan Kiszka <jan.kiszka@siemens.com> 
>>> Sent: Tuesday, December 14, 2021 2:38 PM
>>> To: Chen, Hongzhan <hongzhan.chen@intel.com>; xenomai@xenomai.org
>>> Subject: Re: [RFC PATCH 1/2] kernel-shark: add plugin for handling xenomai cobalt context switch event
>>>
>>> On 14.12.21 04:15, Hongzhan Chen wrote:
>>>> For Xenomai-cobalt enabled system, cobalt_switch_context means that there
>>>> is context switch in companion core(realtime core), which we may need
>>>> to do special treatment and take correct action as main kernel sched_switch.
>>>> We need to update cpu bar regarding cobalt_switch_context event to correct
>>>> color as switching-in task.
>>>
>>> It's tricker... I have trace with the following sequence here:
>>>
>>>             gdb-898   [000]   753.944137: cobalt_switch_context: prev_name=ROOT/0 prev_pid=0 prev_prio=-1 prev_state=0x218008 ==> next_name=pthelper next_pid=912 next_prio=3
>>>             gdb-898   [000]   753.944142: cobalt_timer_start:   timer=0xef7e8200([watchdog]) value=4000000000 interval=0 mode=0x0
>>>        pthelper-912   [000]   753.944172: cobalt_shadow_hardened: state=0x240840 info=0x0
>>>
>>> Your plugin correctly switches colors on cobalt_switch_context, but that
>>> cobalt_timer_start is still running under the previous pid, causing a
>>> color switch-back and than forth on cobalt_shadow_hardened. We need to
>>> understand why and possibly fix that or rethink the visualization.
>>
>> You need to click menu Plots->tasks and then select RT tasks and then apply. It would tigger plugin shape to redraw
>> and then the issue you observed would be fixed by plugin. 
> 
> OK, now I also see that blue "OOB" box under the RT task.
> 
> But the that does not affect the CPU graph, it continues to jump back
> and forth. And it has no RT mode visualization.

Correction: The CPU graph is fine now as well. Still confusing that you
have to enable task plots first, but that might be a generic KernelShark
issue.

> 
> BTW, is that blue hollow box exclusive for our plugin? Or can this be
> customized? Is it explained somewhere in Kernelshark what hollow boxes mean?
> 

Some visualization issue:

        pthelper-912   [000]   753.948271: cobalt_schedule:      status=0x10000000
        pthelper-912   [000]   753.948275: cobalt_switch_context: prev_name=pthelper prev_pid=912 prev_prio=3 prev_state=0xa40042 ==> next_name=hi-thread next_pid=913 next_prio=2
       hi-thread-913   [000]   753.948285: cobalt_shadow_hardened: state=0x240040 info=0x0
       hi-thread-913   [000]   753.948423: cobalt_thread_fault:  ip=0xb6e34e20 type=0x8
       hi-thread-913   [000]   753.948737: cobalt_shadow_gorelax: reason=syscall

In this case, the task plot of hi-thread-919 does no show the blue box 
between hardened and fault.

Jan

-- 
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux


^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: [RFC PATCH 1/2] kernel-shark: add plugin for handling xenomai cobalt context switch event
  2021-12-14  7:02         ` Jan Kiszka
@ 2021-12-14  7:14           ` Chen, Hongzhan
  2021-12-14  7:29             ` Jan Kiszka
  0 siblings, 1 reply; 14+ messages in thread
From: Chen, Hongzhan @ 2021-12-14  7:14 UTC (permalink / raw)
  To: Kiszka, Jan, xenomai


 
>-----Original Message-----
>From: Jan Kiszka <jan.kiszka@siemens.com> 
>Sent: Tuesday, December 14, 2021 3:02 PM
>To: Chen, Hongzhan <hongzhan.chen@intel.com>; xenomai@xenomai.org
>Subject: Re: [RFC PATCH 1/2] kernel-shark: add plugin for handling xenomai cobalt context switch event
>
>On 14.12.21 07:49, Jan Kiszka via Xenomai wrote:
>> On 14.12.21 07:44, Chen, Hongzhan wrote:
>>>>
>>>>
>>>> -----Original Message-----
>>>> From: Jan Kiszka <jan.kiszka@siemens.com> 
>>>> Sent: Tuesday, December 14, 2021 2:38 PM
>>>> To: Chen, Hongzhan <hongzhan.chen@intel.com>; xenomai@xenomai.org
>>>> Subject: Re: [RFC PATCH 1/2] kernel-shark: add plugin for handling xenomai cobalt context switch event
>>>>
>>>> On 14.12.21 04:15, Hongzhan Chen wrote:
>>>>> For Xenomai-cobalt enabled system, cobalt_switch_context means that there
>>>>> is context switch in companion core(realtime core), which we may need
>>>>> to do special treatment and take correct action as main kernel sched_switch.
>>>>> We need to update cpu bar regarding cobalt_switch_context event to correct
>>>>> color as switching-in task.
>>>>
>>>> It's tricker... I have trace with the following sequence here:
>>>>
>>>>             gdb-898   [000]   753.944137: cobalt_switch_context: prev_name=ROOT/0 prev_pid=0 prev_prio=-1 prev_state=0x218008 ==> next_name=pthelper next_pid=912 next_prio=3
>>>>             gdb-898   [000]   753.944142: cobalt_timer_start:   timer=0xef7e8200([watchdog]) value=4000000000 interval=0 mode=0x0
>>>>        pthelper-912   [000]   753.944172: cobalt_shadow_hardened: state=0x240840 info=0x0
>>>>
>>>> Your plugin correctly switches colors on cobalt_switch_context, but that
>>>> cobalt_timer_start is still running under the previous pid, causing a
>>>> color switch-back and than forth on cobalt_shadow_hardened. We need to
>>>> understand why and possibly fix that or rethink the visualization.
>>>
>>> You need to click menu Plots->tasks and then select RT tasks and then apply. It would tigger plugin shape to redraw
>>> and then the issue you observed would be fixed by plugin. 
>> 
>> OK, now I also see that blue "OOB" box under the RT task.
>> 
>> But the that does not affect the CPU graph, it continues to jump back
>> and forth. And it has no RT mode visualization.
>
>Correction: The CPU graph is fine now as well. Still confusing that you
>have to enable task plots first, but that might be a generic KernelShark
>issue.

Yes, this is kernelshark issue. Kernel shark have to depend on redraw of plugin after activation
to correct them.

>
>> 
>> BTW, is that blue hollow box exclusive for our plugin? Or can this be
>> customized? Is it explained somewhere in Kernelshark what hollow boxes mean?
>> 
>
>Some visualization issue:
>
>        pthelper-912   [000]   753.948271: cobalt_schedule:      status=0x10000000
>        pthelper-912   [000]   753.948275: cobalt_switch_context: prev_name=pthelper prev_pid=912 prev_prio=3 prev_state=0xa40042 ==> next_name=hi-thread next_pid=913 next_prio=2
>       hi-thread-913   [000]   753.948285: cobalt_shadow_hardened: state=0x240040 info=0x0
>       hi-thread-913   [000]   753.948423: cobalt_thread_fault:  ip=0xb6e34e20 type=0x8
>       hi-thread-913   [000]   753.948737: cobalt_shadow_gorelax: reason=syscall
>
>In this case, the task plot of hi-thread-919 does no show the blue box 
>between hardened and fault.

Could you zoom out (click "-" in the top left button) to check if blue box would be reshowing?
Could you paste more trailing log in your log to check if there another cobalt_switch_context. Current logic is create hollow box between two cobalt_switch_context. If there is only cobalt switch_context event matching, it would not create hollow box correctly.

Regards

Hongzhan Chen

>
>Jan
>
>-- 
>Siemens AG, T RDA IOT
>Corporate Competence Center Embedded Linux

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [RFC PATCH 1/2] kernel-shark: add plugin for handling xenomai cobalt context switch event
  2021-12-14  7:14           ` Chen, Hongzhan
@ 2021-12-14  7:29             ` Jan Kiszka
  2021-12-14  7:46               ` Chen, Hongzhan
  0 siblings, 1 reply; 14+ messages in thread
From: Jan Kiszka @ 2021-12-14  7:29 UTC (permalink / raw)
  To: Chen, Hongzhan, xenomai

On 14.12.21 08:14, Chen, Hongzhan wrote:
> 
>  
>> -----Original Message-----
>> From: Jan Kiszka <jan.kiszka@siemens.com> 
>> Sent: Tuesday, December 14, 2021 3:02 PM
>> To: Chen, Hongzhan <hongzhan.chen@intel.com>; xenomai@xenomai.org
>> Subject: Re: [RFC PATCH 1/2] kernel-shark: add plugin for handling xenomai cobalt context switch event
>>
>> On 14.12.21 07:49, Jan Kiszka via Xenomai wrote:
>>> On 14.12.21 07:44, Chen, Hongzhan wrote:
>>>>>
>>>>>
>>>>> -----Original Message-----
>>>>> From: Jan Kiszka <jan.kiszka@siemens.com> 
>>>>> Sent: Tuesday, December 14, 2021 2:38 PM
>>>>> To: Chen, Hongzhan <hongzhan.chen@intel.com>; xenomai@xenomai.org
>>>>> Subject: Re: [RFC PATCH 1/2] kernel-shark: add plugin for handling xenomai cobalt context switch event
>>>>>
>>>>> On 14.12.21 04:15, Hongzhan Chen wrote:
>>>>>> For Xenomai-cobalt enabled system, cobalt_switch_context means that there
>>>>>> is context switch in companion core(realtime core), which we may need
>>>>>> to do special treatment and take correct action as main kernel sched_switch.
>>>>>> We need to update cpu bar regarding cobalt_switch_context event to correct
>>>>>> color as switching-in task.
>>>>>
>>>>> It's tricker... I have trace with the following sequence here:
>>>>>
>>>>>             gdb-898   [000]   753.944137: cobalt_switch_context: prev_name=ROOT/0 prev_pid=0 prev_prio=-1 prev_state=0x218008 ==> next_name=pthelper next_pid=912 next_prio=3
>>>>>             gdb-898   [000]   753.944142: cobalt_timer_start:   timer=0xef7e8200([watchdog]) value=4000000000 interval=0 mode=0x0
>>>>>        pthelper-912   [000]   753.944172: cobalt_shadow_hardened: state=0x240840 info=0x0
>>>>>
>>>>> Your plugin correctly switches colors on cobalt_switch_context, but that
>>>>> cobalt_timer_start is still running under the previous pid, causing a
>>>>> color switch-back and than forth on cobalt_shadow_hardened. We need to
>>>>> understand why and possibly fix that or rethink the visualization.
>>>>
>>>> You need to click menu Plots->tasks and then select RT tasks and then apply. It would tigger plugin shape to redraw
>>>> and then the issue you observed would be fixed by plugin. 
>>>
>>> OK, now I also see that blue "OOB" box under the RT task.
>>>
>>> But the that does not affect the CPU graph, it continues to jump back
>>> and forth. And it has no RT mode visualization.
>>
>> Correction: The CPU graph is fine now as well. Still confusing that you
>> have to enable task plots first, but that might be a generic KernelShark
>> issue.
> 
> Yes, this is kernelshark issue. Kernel shark have to depend on redraw of plugin after activation
> to correct them.
> 
>>
>>>
>>> BTW, is that blue hollow box exclusive for our plugin? Or can this be
>>> customized? Is it explained somewhere in Kernelshark what hollow boxes mean?
>>>
>>
>> Some visualization issue:
>>
>>        pthelper-912   [000]   753.948271: cobalt_schedule:      status=0x10000000
>>        pthelper-912   [000]   753.948275: cobalt_switch_context: prev_name=pthelper prev_pid=912 prev_prio=3 prev_state=0xa40042 ==> next_name=hi-thread next_pid=913 next_prio=2
>>       hi-thread-913   [000]   753.948285: cobalt_shadow_hardened: state=0x240040 info=0x0
>>       hi-thread-913   [000]   753.948423: cobalt_thread_fault:  ip=0xb6e34e20 type=0x8
>>       hi-thread-913   [000]   753.948737: cobalt_shadow_gorelax: reason=syscall
>>
>> In this case, the task plot of hi-thread-919 does no show the blue box 
>> between hardened and fault.
> 
> Could you zoom out (click "-" in the top left button) to check if blue box would be reshowing?
> Could you paste more trailing log in your log to check if there another cobalt_switch_context. Current logic is create hollow box between two cobalt_switch_context. If there is only cobalt switch_context event matching, it would not create hollow box correctly.
> 

Yeah, the problem is indeed that the bar is only drawn if beg AND end
points are visible - that is sure not useful. Does the drawing concept
of kernelshark imposes this limitation?

Jan

-- 
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux


^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: [RFC PATCH 1/2] kernel-shark: add plugin for handling xenomai cobalt context switch event
  2021-12-14  7:29             ` Jan Kiszka
@ 2021-12-14  7:46               ` Chen, Hongzhan
  2021-12-14  7:50                 ` Jan Kiszka
  0 siblings, 1 reply; 14+ messages in thread
From: Chen, Hongzhan @ 2021-12-14  7:46 UTC (permalink / raw)
  To: Kiszka, Jan, xenomai


>>>>
>>>> BTW, is that blue hollow box exclusive for our plugin? Or can this be
>>>> customized? Is it explained somewhere in Kernelshark what hollow boxes mean?
>>>>
>>>
>>> Some visualization issue:
>>>
>>>        pthelper-912   [000]   753.948271: cobalt_schedule:      status=0x10000000
>>>        pthelper-912   [000]   753.948275: cobalt_switch_context: prev_name=pthelper prev_pid=912 prev_prio=3 prev_state=0xa40042 ==> next_name=hi-thread next_pid=913 next_prio=2
>>>       hi-thread-913   [000]   753.948285: cobalt_shadow_hardened: state=0x240040 info=0x0
>>>       hi-thread-913   [000]   753.948423: cobalt_thread_fault:  ip=0xb6e34e20 type=0x8
>>>       hi-thread-913   [000]   753.948737: cobalt_shadow_gorelax: reason=syscall
>>>
>>> In this case, the task plot of hi-thread-919 does no show the blue box 
>>> between hardened and fault.
>> 
>> Could you zoom out (click "-" in the top left button) to check if blue box would be reshowing?
>> Could you paste more trailing log in your log to check if there another cobalt_switch_context. Current logic is create hollow box between two cobalt_switch_context. If there is only cobalt switch_context event matching, it would not create hollow box correctly.
>> 
>
>Yeah, the problem is indeed that the bar is only drawn if beg AND end
>points are visible - that is sure not useful. Does the drawing concept
>of kernelshark imposes this limitation?

This should be common issue in kernelshark. I also observed same 
issue on hollow red box for preempt latency implementation.

Regards

Hongzhan Chen
>
>Jan
>
>-- 
>Siemens AG, T RDA IOT
>Corporate Competence Center Embedded Linux

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [RFC PATCH 1/2] kernel-shark: add plugin for handling xenomai cobalt context switch event
  2021-12-14  7:46               ` Chen, Hongzhan
@ 2021-12-14  7:50                 ` Jan Kiszka
  2021-12-15  2:43                   ` Chen, Hongzhan
  0 siblings, 1 reply; 14+ messages in thread
From: Jan Kiszka @ 2021-12-14  7:50 UTC (permalink / raw)
  To: Chen, Hongzhan, xenomai

On 14.12.21 08:46, Chen, Hongzhan wrote:
> 
>>>>>
>>>>> BTW, is that blue hollow box exclusive for our plugin? Or can this be
>>>>> customized? Is it explained somewhere in Kernelshark what hollow boxes mean?
>>>>>
>>>>
>>>> Some visualization issue:
>>>>
>>>>        pthelper-912   [000]   753.948271: cobalt_schedule:      status=0x10000000
>>>>        pthelper-912   [000]   753.948275: cobalt_switch_context: prev_name=pthelper prev_pid=912 prev_prio=3 prev_state=0xa40042 ==> next_name=hi-thread next_pid=913 next_prio=2
>>>>       hi-thread-913   [000]   753.948285: cobalt_shadow_hardened: state=0x240040 info=0x0
>>>>       hi-thread-913   [000]   753.948423: cobalt_thread_fault:  ip=0xb6e34e20 type=0x8
>>>>       hi-thread-913   [000]   753.948737: cobalt_shadow_gorelax: reason=syscall
>>>>
>>>> In this case, the task plot of hi-thread-919 does no show the blue box 
>>>> between hardened and fault.
>>>
>>> Could you zoom out (click "-" in the top left button) to check if blue box would be reshowing?
>>> Could you paste more trailing log in your log to check if there another cobalt_switch_context. Current logic is create hollow box between two cobalt_switch_context. If there is only cobalt switch_context event matching, it would not create hollow box correctly.
>>>
>>
>> Yeah, the problem is indeed that the bar is only drawn if beg AND end
>> points are visible - that is sure not useful. Does the drawing concept
>> of kernelshark imposes this limitation?
> 
> This should be common issue in kernelshark. I also observed same 
> issue on hollow red box for preempt latency implementation.
> 

Ok, another topic to discuss with their community :)

Jan

-- 
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux


^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: [RFC PATCH 1/2] kernel-shark: add plugin for handling xenomai cobalt context switch event
  2021-12-14  7:50                 ` Jan Kiszka
@ 2021-12-15  2:43                   ` Chen, Hongzhan
  0 siblings, 0 replies; 14+ messages in thread
From: Chen, Hongzhan @ 2021-12-15  2:43 UTC (permalink / raw)
  To: Kiszka, Jan, xenomai



>-----Original Message-----
>From: Jan Kiszka <jan.kiszka@siemens.com> 
>Sent: Tuesday, December 14, 2021 3:51 PM
>To: Chen, Hongzhan <hongzhan.chen@intel.com>; xenomai@xenomai.org
>Subject: Re: [RFC PATCH 1/2] kernel-shark: add plugin for handling xenomai cobalt context switch event
>
>On 14.12.21 08:46, Chen, Hongzhan wrote:
>> 
>>>>>>
>>>>>> BTW, is that blue hollow box exclusive for our plugin? Or can this be
>>>>>> customized? Is it explained somewhere in Kernelshark what hollow boxes mean?
>>>>>>
>>>>>
>>>>> Some visualization issue:
>>>>>
>>>>>        pthelper-912   [000]   753.948271: cobalt_schedule:      status=0x10000000
>>>>>        pthelper-912   [000]   753.948275: cobalt_switch_context: prev_name=pthelper prev_pid=912 prev_prio=3 prev_state=0xa40042 ==> next_name=hi-thread next_pid=913 next_prio=2
>>>>>       hi-thread-913   [000]   753.948285: cobalt_shadow_hardened: state=0x240040 info=0x0
>>>>>       hi-thread-913   [000]   753.948423: cobalt_thread_fault:  ip=0xb6e34e20 type=0x8
>>>>>       hi-thread-913   [000]   753.948737: cobalt_shadow_gorelax: reason=syscall
>>>>>
>>>>> In this case, the task plot of hi-thread-919 does no show the blue box 
>>>>> between hardened and fault.
>>>>
>>>> Could you zoom out (click "-" in the top left button) to check if blue box would be reshowing?
>>>> Could you paste more trailing log in your log to check if there another cobalt_switch_context. Current logic is create hollow box between two cobalt_switch_context. If there is only cobalt switch_context event matching, it would not create hollow box correctly.
>>>>
>>>
>>> Yeah, the problem is indeed that the bar is only drawn if beg AND end
>>> points are visible - that is sure not useful. Does the drawing concept
>>> of kernelshark imposes this limitation?
>> 
>> This should be common issue in kernelshark. I also observed same 
>> issue on hollow red box for preempt latency implementation.
>> 
>
>Ok, another topic to discuss with their community :)

It is OK to submit this patch set to kernel-shark community to review if it meet our requirement? 😊

Regards

Hongzhan Chen

>
>Jan
>
>-- 
>Siemens AG, T RDA IOT
>Corporate Competence Center Embedded Linux

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2021-12-15  2:43 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-14  3:15 [RFC PATCH 0/2] cobalt_switch_context plugin Hongzhan Chen
2021-12-14  3:15 ` [RFC PATCH 1/2] kernel-shark: add plugin for handling xenomai cobalt context switch event Hongzhan Chen
2021-12-14  6:37   ` Jan Kiszka
2021-12-14  6:44     ` Chen, Hongzhan
2021-12-14  6:49       ` Jan Kiszka
2021-12-14  7:02         ` Jan Kiszka
2021-12-14  7:14           ` Chen, Hongzhan
2021-12-14  7:29             ` Jan Kiszka
2021-12-14  7:46               ` Chen, Hongzhan
2021-12-14  7:50                 ` Jan Kiszka
2021-12-15  2:43                   ` Chen, Hongzhan
2021-12-14  3:15 ` [RFC PATCH 2/2] kernelshark: shape blue hollow box to show OOB state of task Hongzhan Chen
2021-12-14  6:40   ` Jan Kiszka
2021-12-14  6:58     ` Chen, Hongzhan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.