All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v7 0/3] Kernel-Shark and libtraceevent plugins
@ 2022-03-12 12:59 Jan Kiszka
  2022-03-12 13:00 ` [PATCH v7 1/3] build: add options to build plugins of kernelshark and libtraceevent Jan Kiszka
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Jan Kiszka @ 2022-03-12 12:59 UTC (permalink / raw)
  To: xenomai

Changes in v7:
 - reworked installation
 - fixed build of kernelshark plugin (missing dep)
 - dropped applied first patch

Jan


CC: Hongzhan Chen <hongzhan.chen@intel.com>

Hongzhan Chen (3):
  build: add options to build plugins of kernelshark and libtraceevent
  KernelShark: Add xenomai_cobalt_switch_events plugin for KernelShark
  libtraceevent: Add xenomai_schedparams plugin for libtraceevent

 Makefile.am                                   |   4 +
 configure.ac                                  |  36 ++++
 tracing/Makefile.am                           |  13 ++
 tracing/README                                |  84 +++++++++
 tracing/kernelshark/CobaltSwitchEvents.cpp    | 156 ++++++++++++++++
 tracing/kernelshark/Makefile.am               |  23 +++
 .../xenomai_cobalt_switch_events.c            | 174 ++++++++++++++++++
 .../xenomai_cobalt_switch_events.h            |  58 ++++++
 tracing/libtraceevent/Makefile.am             |  19 ++
 .../plugin_xenomai_schedparams.c              | 158 ++++++++++++++++
 10 files changed, 725 insertions(+)
 create mode 100644 tracing/Makefile.am
 create mode 100644 tracing/README
 create mode 100644 tracing/kernelshark/CobaltSwitchEvents.cpp
 create mode 100644 tracing/kernelshark/Makefile.am
 create mode 100644 tracing/kernelshark/xenomai_cobalt_switch_events.c
 create mode 100644 tracing/kernelshark/xenomai_cobalt_switch_events.h
 create mode 100644 tracing/libtraceevent/Makefile.am
 create mode 100644 tracing/libtraceevent/plugin_xenomai_schedparams.c

-- 
2.34.1



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

* [PATCH v7 1/3] build: add options to build plugins of kernelshark and libtraceevent
  2022-03-12 12:59 [PATCH v7 0/3] Kernel-Shark and libtraceevent plugins Jan Kiszka
@ 2022-03-12 13:00 ` Jan Kiszka
  2022-03-14  1:27   ` Chen, Hongzhan
  2022-03-12 13:00 ` [PATCH v7 2/3] KernelShark: Add xenomai_cobalt_switch_events plugin for KernelShark Jan Kiszka
  2022-03-12 13:00 ` [PATCH v7 3/3] libtraceevent: Add xenomai_schedparams plugin for libtraceevent Jan Kiszka
  2 siblings, 1 reply; 12+ messages in thread
From: Jan Kiszka @ 2022-03-12 13:00 UTC (permalink / raw)
  To: xenomai

From: Hongzhan Chen <hongzhan.chen@intel.com>

To build plugins of kernelshark and libtraceevent, add options and
do necessary configuration.

Signed-off-by: Hongzhan Chen <hongzhan.chen@intel.com>
[Jan: cleaned up AC_ARG_ENABLE matches, add missing kshark dep, drop INSTALLDIRs]
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 configure.ac | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/configure.ac b/configure.ac
index 16cffd8f81..ef450aa582 100644
--- a/configure.ac
+++ b/configure.ac
@@ -91,6 +91,8 @@ AC_ARG_WITH(cxx,
     ])
 AC_PROG_CXX
 
+PKG_PROG_PKG_CONFIG
+
 # Do not let autoconf set the default value of CFLAGS
 if $XENO_EMPTY_CFLAGS; then
 	CFLAGS=""
@@ -826,6 +828,37 @@ AC_ARG_WITH(demodir,
     ], [XENO_DEMO_DIR=$demodir])
 AC_MSG_RESULT($XENO_DEMO_DIR)
 
+kernelshark_plugin=
+AC_MSG_CHECKING(whether KernelShark plugin should be built)
+AC_ARG_ENABLE(kernelshark_plugin,
+	AS_HELP_STRING([--enable-kernelshark-plugin], [build KernelShark plugin]),
+	[case "$enableval" in
+	y | yes) kernelshark_plugin=y ;;
+	*) unset kernelshark_plugin ;;
+	esac])
+AC_MSG_RESULT(${kernelshark_plugin:-no})
+AM_CONDITIONAL(XENO_KSHARK_PLUGIN, [test x$kernelshark_plugin = xy])
+
+libtraceevent_plugin=
+AC_MSG_CHECKING(whether libtraceevent plugin should be built)
+AC_ARG_ENABLE(libtraceevent_plugin,
+	AS_HELP_STRING([--enable-libtraceevent-plugin], [build libtraceevent plugin]),
+	[case "$enableval" in
+	y | yes) libtraceevent_plugin=y ;;
+	*) unset libtraceevent_plugin ;;
+	esac])
+AC_MSG_RESULT(${libtraceevent_plugin:-no})
+AM_CONDITIONAL(XENO_LIBTRACEEVENT_PLUGIN, [test x$libtraceevent_plugin = xy])
+
+if test x$kernelshark_plugin = xy -o x$libtraceevent_plugin = xy; then
+	PKG_CHECK_MODULES(LIBTRACEEVENT, libtraceevent)
+fi
+
+if test x$kernelshark_plugin = xy; then
+	PKG_CHECK_MODULES(LIBKSHARK, libkshark)
+	PKG_CHECK_MODULES(LIBTRACEFS, libtracefs)
+fi
+
 AC_MSG_CHECKING([for test source generation])
 AC_RUN_IFELSE([AC_LANG_PROGRAM([[ ]], [[ ]])],
     [AC_MSG_RESULT(ok)], [AC_MSG_RESULT(failed)], [AC_MSG_RESULT(untestable)])
-- 
2.34.1



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

* [PATCH v7 2/3] KernelShark: Add xenomai_cobalt_switch_events plugin for KernelShark
  2022-03-12 12:59 [PATCH v7 0/3] Kernel-Shark and libtraceevent plugins Jan Kiszka
  2022-03-12 13:00 ` [PATCH v7 1/3] build: add options to build plugins of kernelshark and libtraceevent Jan Kiszka
@ 2022-03-12 13:00 ` Jan Kiszka
  2022-03-12 13:00 ` [PATCH v7 3/3] libtraceevent: Add xenomai_schedparams plugin for libtraceevent Jan Kiszka
  2 siblings, 0 replies; 12+ messages in thread
From: Jan Kiszka @ 2022-03-12 13:00 UTC (permalink / raw)
  To: xenomai

From: Hongzhan Chen <hongzhan.chen@intel.com>

For 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.

Signed-off-by: Hongzhan Chen <hongzhan.chen@intel.com>
[Jan: add further CFLAGS and LIBS, rework installation]
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 Makefile.am                                   |   4 +
 configure.ac                                  |   2 +
 tracing/Makefile.am                           |   8 +
 tracing/kernelshark/CobaltSwitchEvents.cpp    | 156 ++++++++++++++++
 tracing/kernelshark/Makefile.am               |  23 +++
 .../xenomai_cobalt_switch_events.c            | 174 ++++++++++++++++++
 .../xenomai_cobalt_switch_events.h            |  58 ++++++
 7 files changed, 425 insertions(+)
 create mode 100644 tracing/Makefile.am
 create mode 100644 tracing/kernelshark/CobaltSwitchEvents.cpp
 create mode 100644 tracing/kernelshark/Makefile.am
 create mode 100644 tracing/kernelshark/xenomai_cobalt_switch_events.c
 create mode 100644 tracing/kernelshark/xenomai_cobalt_switch_events.h

diff --git a/Makefile.am b/Makefile.am
index 604644277e..bd3e4bfb18 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -18,6 +18,9 @@ SUBDIRS += 		\
 	testsuite
 endif
 
+SUBDIRS +=		\
+	tracing
+
 EXTRA_DIST = kernel debian
 
 DIST_SUBDIRS =		\
@@ -26,6 +29,7 @@ DIST_SUBDIRS =		\
 	doc		\
 	include		\
 	lib 		\
+	tracing		\
 	scripts		\
 	testsuite	\
 	utils
diff --git a/configure.ac b/configure.ac
index ef450aa582..034368e5a5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -976,6 +976,8 @@ AC_CONFIG_FILES([ \
 	scripts/Makefile \
 	scripts/xeno-config:scripts/xeno-config-$rtcore_type.in \
 	scripts/xeno \
+	tracing/Makefile \
+	tracing/kernelshark/Makefile \
 	lib/Makefile \
 	lib/boilerplate/Makefile \
 	lib/boilerplate/init/Makefile \
diff --git a/tracing/Makefile.am b/tracing/Makefile.am
new file mode 100644
index 0000000000..885a9497f7
--- /dev/null
+++ b/tracing/Makefile.am
@@ -0,0 +1,8 @@
+SUBDIRS =
+
+if XENO_KSHARK_PLUGIN
+SUBDIRS += kernelshark
+endif
+
+DIST_SUBDIRS = 		\
+	kernelshark
diff --git a/tracing/kernelshark/CobaltSwitchEvents.cpp b/tracing/kernelshark/CobaltSwitchEvents.cpp
new file mode 100644
index 0000000000..3a521bdfc0
--- /dev/null
+++ b/tracing/kernelshark/CobaltSwitchEvents.cpp
@@ -0,0 +1,156 @@
+// SPDX-License-Identifier: LGPL-2.1
+
+/*
+ * Copyright (C) 2021 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 cobalt blue the out-of-band state of
+ *           the task
+ */
+
+// KernelShark
+#include "libkshark.h"
+#include "libkshark-plugin.h"
+#include "xenomai_cobalt_switch_events.h"
+#include "KsPlotTools.hpp"
+#include "KsPlugins.hpp"
+#include "KsPluginsGUI.hpp"
+
+static void *ks4xenomai_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)
+{
+	ks4xenomai_ptr = gui_ptr;
+	return nullptr;
+}
+
+/**
+ * This class represents the graphical element visualizing OOB state between
+ *  two cobalt_switch_context events.
+ */
+class XenomaiSwitchBox : public LatencyBox
+{
+	/** On double click do. */
+	void _doubleClick() const override
+	{
+		markEntryB(ks4xenomai_ptr, _data[1]->entry);
+		markEntryA(ks4xenomai_ptr, _data[0]->entry);
+	}
+};
+
+/*
+ * 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);
+
+		/* we skip cobalt_switch_context that try to
+		 * switch into in-band state because we just handle
+		 * out-of-band
+		 */
+		if (switch_inband)
+			continue;
+		pid_rec = plugin_sched_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 all trailing events. */
+		for (; e->next; e = e->next) {
+			if (e->pid == plugin_sched_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_sched_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_sched_get_pid(d->data[i]->field) == pid;
+	};
+
+	eventFieldIntervalPlot(argvCpp,
+			       plugin_ctx->cs_data, checkFieldCS,
+			       plugin_ctx->cs_data, checkEntryPid,
+			       makeLatencyBox<XenomaiSwitchBox>,
+			       {0, 71, 171}, // Cobalt Blue
+			       -1);         // Default size
+}
diff --git a/tracing/kernelshark/Makefile.am b/tracing/kernelshark/Makefile.am
new file mode 100644
index 0000000000..45c000c1f5
--- /dev/null
+++ b/tracing/kernelshark/Makefile.am
@@ -0,0 +1,23 @@
+libsub_LTLIBRARIES = plugin_xenomai_cobalt_switch_events.la
+
+plugin_xenomai_cobalt_switch_events_la_SOURCES =	\
+	CobaltSwitchEvents.cpp				\
+	xenomai_cobalt_switch_events.c			\
+	xenomai_cobalt_switch_events.h
+
+plugin_xenomai_cobalt_switch_events_la_CPPFLAGS  =	\
+	$(LIBKSHARK_CFLAGS)				\
+	$(LIBTRACEEVENT_CFLAGS)				\
+	$(LIBTRACEFS_CFLAGS)
+
+plugin_xenomai_cobalt_switch_events_la_LDFLAGS =	\
+	$(LIBKSHARK_LIBS)				\
+	$(LIBTRACEEVENT_LIBS)				\
+	-module -avoid-version
+
+AM_LIBTOOLFLAGS = --silent --tag=disable-static
+
+libsubdir := $(libdir)/kernelshark/plugins
+
+install-data-hook:
+	$(RM) $(DESTDIR)$(libsubdir)/$(libsub_LTLIBRARIES)
diff --git a/tracing/kernelshark/xenomai_cobalt_switch_events.c b/tracing/kernelshark/xenomai_cobalt_switch_events.c
new file mode 100644
index 0000000000..758966df74
--- /dev/null
+++ b/tracing/kernelshark/xenomai_cobalt_switch_events.c
@@ -0,0 +1,174 @@
+// 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 "xenomai_cobalt_switch_events.h"
+#include "libkshark-tepdata.h"
+
+/** Plugin context instance. */
+
+//! @cond Doxygen_Suppress
+
+#define SWITCH_INBAND_SHIFT	PREV_STATE_SHIFT
+
+#define SWITCH_INBAND_MASK	PREV_STATE_MASK
+
+//! @endcond
+
+static void cobalt_free_context(struct plugin_cobalt_context *plugin_ctx)
+{
+	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,
+					ks_num_field_t inband_state)
+{
+	unsigned long long 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)
+{
+	unsigned long long mask = SWITCH_INBAND_MASK << SWITCH_INBAND_SHIFT;
+
+	return (field & mask) >> SWITCH_INBAND_SHIFT;
+}
+
+/** 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->second_pass_done = false;
+
+	plugin_ctx->cs_data = kshark_init_data_container();
+	if (!plugin_ctx->cs_data)
+		return false;
+
+	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;
+	ks_num_field_t ks_field = 0;
+	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) {
+		plugin_sched_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. */
+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);
+	}
+
+	kshark_register_draw_handler(stream, plugin_cobalt_draw);
+
+	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);
+		}
+
+		kshark_unregister_draw_handler(stream, plugin_cobalt_draw);
+
+		ret = 1;
+	}
+
+	__close(stream->stream_id);
+
+	return ret;
+}
+
+/** Initialize the control interface of the plugin. */
+void *KSHARK_MENU_PLUGIN_INITIALIZER(void *gui_ptr)
+{
+	return plugin_set_gui_ptr(gui_ptr);
+}
diff --git a/tracing/kernelshark/xenomai_cobalt_switch_events.h b/tracing/kernelshark/xenomai_cobalt_switch_events.h
new file mode 100644
index 0000000000..f7f4593ff9
--- /dev/null
+++ b/tracing/kernelshark/xenomai_cobalt_switch_events.h
@@ -0,0 +1,58 @@
+/* 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_COBALT_SWITCH_H
+#define _KS_PLUGIN_COBALT_SWITCH_H
+
+// KernelShark
+#include "libkshark.h"
+#include "plugins/common_sched.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** cobalt_switch_context is trying to switch in-band. */
+#define SWITCH_INBAND_STATE	1
+
+/** 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;
+
+	/** 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)
+
+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_set_gui_ptr(void *gui_ptr);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
-- 
2.34.1



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

* [PATCH v7 3/3] libtraceevent: Add xenomai_schedparams plugin for libtraceevent
  2022-03-12 12:59 [PATCH v7 0/3] Kernel-Shark and libtraceevent plugins Jan Kiszka
  2022-03-12 13:00 ` [PATCH v7 1/3] build: add options to build plugins of kernelshark and libtraceevent Jan Kiszka
  2022-03-12 13:00 ` [PATCH v7 2/3] KernelShark: Add xenomai_cobalt_switch_events plugin for KernelShark Jan Kiszka
@ 2022-03-12 13:00 ` Jan Kiszka
  2 siblings, 0 replies; 12+ messages in thread
From: Jan Kiszka @ 2022-03-12 13:00 UTC (permalink / raw)
  To: xenomai

From: Hongzhan Chen <hongzhan.chen@intel.com>

For cobalt thread, there is special struct param_ex data stored in
data record, we need to parse and print its content out correctly
to hint user.

Signed-off-by: Hongzhan Chen <hongzhan.chen@intel.com>
[Jan: rework installation]
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 configure.ac                                  |   1 +
 tracing/Makefile.am                           |   7 +-
 tracing/README                                |  84 ++++++++++
 tracing/libtraceevent/Makefile.am             |  19 +++
 .../plugin_xenomai_schedparams.c              | 158 ++++++++++++++++++
 5 files changed, 268 insertions(+), 1 deletion(-)
 create mode 100644 tracing/README
 create mode 100644 tracing/libtraceevent/Makefile.am
 create mode 100644 tracing/libtraceevent/plugin_xenomai_schedparams.c

diff --git a/configure.ac b/configure.ac
index 034368e5a5..e9f46630d4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -978,6 +978,7 @@ AC_CONFIG_FILES([ \
 	scripts/xeno \
 	tracing/Makefile \
 	tracing/kernelshark/Makefile \
+	tracing/libtraceevent/Makefile \
 	lib/Makefile \
 	lib/boilerplate/Makefile \
 	lib/boilerplate/init/Makefile \
diff --git a/tracing/Makefile.am b/tracing/Makefile.am
index 885a9497f7..da7d979f9a 100644
--- a/tracing/Makefile.am
+++ b/tracing/Makefile.am
@@ -4,5 +4,10 @@ if XENO_KSHARK_PLUGIN
 SUBDIRS += kernelshark
 endif
 
+if XENO_LIBTRACEEVENT_PLUGIN
+SUBDIRS += libtraceevent
+endif
+
 DIST_SUBDIRS = 		\
-	kernelshark
+	kernelshark	\
+	libtraceevent
diff --git a/tracing/README b/tracing/README
new file mode 100644
index 0000000000..298797052e
--- /dev/null
+++ b/tracing/README
@@ -0,0 +1,84 @@
+
+What is it?
+=============
+
+  The modules under this folder is plugins implemented for Xenomai tracing.
+  kernelshark subdir includes plugin for KernelShark.
+  libtraceevent subduir includes plugin for libtraceevent.
+
+Dependencies
+================================
+
+  For KernelShark plugin:
+      Building standlone plugin for KernelShark depends on
+      following patchset after kernelshark-v2.1.0:
+         kernel-shark: Install missing headers (commit 5419186f4bbad68aa16849882a8f12fa9adb22c5)
+         kernel-shark: Add KsPluginsGUI.hpp/.cpp (commit 59b5763c7c52b703e3b8e05be801f7c85365c9d3)
+         kernel-shark: Load 'ctrl' interface for user plugins (commit e35970770b71f0cc849870512a806dff96bf19e1)
+
+      If you cannot confirm that your local installed KernelShark include these patches,
+      please refer to https://kernelshark.org/build.html to download updated code
+      and build & install again.
+
+How to build and install plugin?
+====================================
+
+    goto your xenomai folder
+    ./scripts/bootstrap
+    ./configure --enable-xxx-plugin
+    cd tracing/xxx/
+    make
+    sudo make install
+
+    Note: Please replace xxx with your module name that you want to build and install plugin.
+
+How to use plugin?
+====================================
+
+  For KernelShark plugin:
+
+      kernelshark -p your_path_of_libplugin_xenomai_cobalt_switch_events.so your_path_of_trace.dat
+
+  For libtraceevent plugin:
+
+      While libtracevent and its plugins is installed correctly, the plugins
+      would be loaded automatically by other module such as libtracecmd after
+      corresponding tracing tool such as KernelShark or trace-cmd run.
+
+What the difference is after plug works?
+===============================================
+
+  For KernelShark plugin:
+      1. For those trace log which does not include cobalt_switch_context event, you may
+         not expect that there is any difference after Xenomai plugin is loaded.
+
+      2. But when there is cobalt_switch_context event in trace log, the plugin would
+         analysis cobalt_switch_context event and visualize the OOB state.
+
+      3. How to check OOB state with cobalt blue hollow box?
+
+         3.1. Please check if there is cobalt_switch_context events existing in the
+              log using search boxes in the list area of kernelshark GUI.
+
+         3.2. When there is cobalt_switch_context events existing in the log, please goto
+              task plots dialog to choose tasks that you may want to check its OOB state by
+              clicking menu Plots->Tasks and then hit "Apply".
+
+         3.3. Selected tasks would be added to the bottom of the graph area as task plots.
+              You may zoom in to check if there is cobalt blue hollow box showing in
+              the corresponding task bar/plot if the time span is really large and
+              there is too much events.
+
+         3.4. When you double click the hollow box, there is two vertical lines
+              that marked as "Mark A" and "Mark B" which you may use to measure time of
+              running in OOB state between two cobalt_switch_context events.
+
+         Note:
+              Please refer to [1] about introduction of search boxes or task plot or  "Mark A" &
+              "Mark B" on Graph Control Area for more detailed info.
+
+  For libtraceevent plugin:
+
+      It would try to show sched_param_ex param correctly.
+
+[1]: https://kernelshark.org/Documentation.html
diff --git a/tracing/libtraceevent/Makefile.am b/tracing/libtraceevent/Makefile.am
new file mode 100644
index 0000000000..542d71cb6f
--- /dev/null
+++ b/tracing/libtraceevent/Makefile.am
@@ -0,0 +1,19 @@
+libsub_LTLIBRARIES = plugin_xenomai_schedparams.la
+
+plugin_xenomai_schedparams_la_SOURCES =	\
+	plugin_xenomai_schedparams.c
+
+plugin_xenomai_schedparams_la_CPPFLAGS =	\
+	$(LIBTRACEEVENT_CFLAGS)			\
+	-I$(top_srcdir)/include
+
+plugin_xenomai_schedparams_la_LDFLAGS =		\
+	$(LIBTRACEEVENT_LIBS)			\
+	-module -avoid-version -nostartfiles
+
+AM_LIBTOOLFLAGS = --silent --tag=disable-static
+
+libsubdir := $(libdir)/traceevent/plugins
+
+install-data-hook:
+	$(RM) $(DESTDIR)$(libsubdir)/$(libsub_LTLIBRARIES)
diff --git a/tracing/libtraceevent/plugin_xenomai_schedparams.c b/tracing/libtraceevent/plugin_xenomai_schedparams.c
new file mode 100644
index 0000000000..01234fe5f0
--- /dev/null
+++ b/tracing/libtraceevent/plugin_xenomai_schedparams.c
@@ -0,0 +1,158 @@
+// SPDX-License-Identifier: LGPL-2.1
+/*
+ * Copyright (C) 2021 Intel Inc, Hongzhan Chen <hongzhan.chen@intel.com>
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <linux/sched.h>
+#include <cobalt/uapi/sched.h>
+#include <sched.h>
+#include "event-parse.h"
+#include "trace-seq.h"
+
+static void write_policy(struct trace_seq *p, int policy)
+{
+	trace_seq_printf(p, "policy=");
+
+	switch (policy) {
+	case SCHED_QUOTA:
+		trace_seq_printf(p, "quota ");
+		break;
+	case SCHED_TP:
+		trace_seq_printf(p, "tp ");
+		break;
+	case SCHED_NORMAL:
+		trace_seq_printf(p, "normal ");
+		break;
+	case SCHED_SPORADIC:
+		trace_seq_printf(p, "sporadic ");
+		break;
+	case SCHED_RR:
+		trace_seq_printf(p, "rr ");
+		break;
+	case SCHED_FIFO:
+		trace_seq_printf(p, "fifo ");
+		break;
+	case SCHED_COBALT:
+		trace_seq_printf(p, "cobalt ");
+		break;
+	case SCHED_WEAK:
+		trace_seq_printf(p, "weak ");
+		break;
+	default:
+		trace_seq_printf(p, "unknown ");
+		break;
+	}
+}
+
+/* save param */
+static void write_param(struct tep_format_field *field,
+				struct tep_record *record,
+				struct trace_seq *p, int policy)
+{
+	int offset;
+	struct sched_param_ex *params;
+
+	offset = field->offset;
+
+	if (!strncmp(field->type, "__data_loc", 10)) {
+		unsigned long long v;
+
+		if (tep_read_number_field(field, record->data, &v)) {
+			trace_seq_printf(p, "invalid_data_loc");
+			return;
+		}
+		offset = v & 0xffff;
+
+	}
+
+	params = (struct sched_param_ex *)((char *)record->data + offset);
+
+	trace_seq_printf(p, "param: { ");
+
+	switch (policy) {
+	case SCHED_QUOTA:
+		trace_seq_printf(p, "priority=%d, group=%d",
+				 params->sched_priority,
+				 params->sched_quota_group);
+		break;
+	case SCHED_TP:
+		trace_seq_printf(p, "priority=%d, partition=%d",
+				 params->sched_priority,
+				 params->sched_tp_partition);
+		break;
+	case SCHED_NORMAL:
+		break;
+	case SCHED_SPORADIC:
+		trace_seq_printf(p, "priority=%d, low_priority=%d, ",
+				 params->sched_priority,
+				 params->sched_ss_low_priority);
+
+		trace_seq_printf(p, "budget=(%ld.%09ld), period=(%ld.%09ld), ",
+				 params->sched_ss_init_budget.tv_sec,
+				 params->sched_ss_init_budget.tv_nsec);
+
+		trace_seq_printf(p, "maxrepl=%d",
+				 params->sched_ss_max_repl);
+		break;
+	case SCHED_RR:
+	case SCHED_FIFO:
+	case SCHED_COBALT:
+	case SCHED_WEAK:
+	default:
+		trace_seq_printf(p, "priority=%d", params->sched_priority);
+		break;
+	}
+	trace_seq_printf(p, " }");
+	trace_seq_putc(p, '\0');
+
+}
+
+static int cobalt_schedparam_handler(struct trace_seq *s,
+				struct tep_record *record,
+				struct tep_event *event, void *context)
+{
+	struct tep_format_field *field;
+	unsigned long long val;
+
+	if (tep_get_field_val(s, event, "pth", record, &val, 1))
+		return trace_seq_putc(s, '!');
+	trace_seq_puts(s, "pth: ");
+	trace_seq_printf(s, "0x%08llx ", val);
+
+	if (tep_get_field_val(s, event, "policy", record, &val, 1) == 0)
+		write_policy(s, val);
+
+	field = tep_find_field(event, "param_ex");
+	if (field)
+		write_param(field, record, s, val);
+
+	return 0;
+}
+
+int TEP_PLUGIN_LOADER(struct tep_handle *tep)
+{
+	tep_register_event_handler(tep, -1, "cobalt_posix", "cobalt_pthread_setschedparam",
+					cobalt_schedparam_handler, NULL);
+
+	tep_register_event_handler(tep, -1, "cobalt_posix", "cobalt_pthread_getschedparam",
+					cobalt_schedparam_handler, NULL);
+
+	tep_register_event_handler(tep, -1, "cobalt_posix", "cobalt_pthread_create",
+					cobalt_schedparam_handler, NULL);
+
+	return 0;
+}
+
+void TEP_PLUGIN_UNLOADER(struct tep_handle *tep)
+{
+	tep_unregister_event_handler(tep, -1, "cobalt_posix", "cobalt_pthread_setschedparam",
+					cobalt_schedparam_handler, NULL);
+
+	tep_unregister_event_handler(tep, -1, "cobalt_posix", "cobalt_pthread_getschedparam",
+					cobalt_schedparam_handler, NULL);
+
+	tep_unregister_event_handler(tep, -1, "cobalt_posix", "cobalt_pthread_create",
+					cobalt_schedparam_handler, NULL);
+}
-- 
2.34.1



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

* RE: [PATCH v7 1/3] build: add options to build plugins of kernelshark and libtraceevent
  2022-03-12 13:00 ` [PATCH v7 1/3] build: add options to build plugins of kernelshark and libtraceevent Jan Kiszka
@ 2022-03-14  1:27   ` Chen, Hongzhan
  2022-03-14  1:40     ` Chen, Hongzhan
  2022-03-14  6:41     ` Jan Kiszka
  0 siblings, 2 replies; 12+ messages in thread
From: Chen, Hongzhan @ 2022-03-14  1:27 UTC (permalink / raw)
  To: Kiszka, Jan, xenomai

>
>
>-----Original Message-----
>From: Jan Kiszka <jan.kiszka@siemens.com> 
>Sent: Saturday, March 12, 2022 9:00 PM
>To: xenomai@xenomai.org
>Cc: Chen, Hongzhan <hongzhan.chen@intel.com>
>Subject: [PATCH v7 1/3] build: add options to build plugins of kernelshark and libtraceevent
>
>From: Hongzhan Chen <hongzhan.chen@intel.com>
>
>To build plugins of kernelshark and libtraceevent, add options and
>do necessary configuration.
>
>Signed-off-by: Hongzhan Chen <hongzhan.chen@intel.com>
>[Jan: cleaned up AC_ARG_ENABLE matches, add missing kshark dep, drop INSTALLDIRs]
>Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
>---
> configure.ac | 33 +++++++++++++++++++++++++++++++++
> 1 file changed, 33 insertions(+)
>
>diff --git a/configure.ac b/configure.ac
>index 16cffd8f81..ef450aa582 100644
>--- a/configure.ac
>+++ b/configure.ac
>@@ -91,6 +91,8 @@ AC_ARG_WITH(cxx,
>     ])
> AC_PROG_CXX
> 
>+PKG_PROG_PKG_CONFIG
>+
> # Do not let autoconf set the default value of CFLAGS
> if $XENO_EMPTY_CFLAGS; then
> 	CFLAGS=""
>@@ -826,6 +828,37 @@ AC_ARG_WITH(demodir,
>     ], [XENO_DEMO_DIR=$demodir])
> AC_MSG_RESULT($XENO_DEMO_DIR)
> 
>+kernelshark_plugin=
>+AC_MSG_CHECKING(whether KernelShark plugin should be built)
>+AC_ARG_ENABLE(kernelshark_plugin,
>+	AS_HELP_STRING([--enable-kernelshark-plugin], [build KernelShark plugin]),
>+	[case "$enableval" in
>+	y | yes) kernelshark_plugin=y ;;
>+	*) unset kernelshark_plugin ;;
>+	esac])
>+AC_MSG_RESULT(${kernelshark_plugin:-no})
>+AM_CONDITIONAL(XENO_KSHARK_PLUGIN, [test x$kernelshark_plugin = xy])
>+
>+libtraceevent_plugin=
>+AC_MSG_CHECKING(whether libtraceevent plugin should be built)
>+AC_ARG_ENABLE(libtraceevent_plugin,
>+	AS_HELP_STRING([--enable-libtraceevent-plugin], [build libtraceevent plugin]),
>+	[case "$enableval" in
>+	y | yes) libtraceevent_plugin=y ;;
>+	*) unset libtraceevent_plugin ;;
>+	esac])
>+AC_MSG_RESULT(${libtraceevent_plugin:-no})
>+AM_CONDITIONAL(XENO_LIBTRACEEVENT_PLUGIN, [test x$libtraceevent_plugin = xy])
>+
>+if test x$kernelshark_plugin = xy -o x$libtraceevent_plugin = xy; then
>+	PKG_CHECK_MODULES(LIBTRACEEVENT, libtraceevent)
>+fi
>+
>+if test x$kernelshark_plugin = xy; then
>+	PKG_CHECK_MODULES(LIBKSHARK, libkshark)
>+	PKG_CHECK_MODULES(LIBTRACEFS, libtracefs)

I do not quite understand why we check LIBTRAEFS here because kernelshark depend on libtracefs 
as described in [1] which should be handled by kernelshark module itself.
If we have to check libtracefs, why we do not check other dependency module like libtraceevent  for kernelshark_plugin?

Regards

Hongzhan Chen 

[1]: https://git.kernel.org/pub/scm/utils/trace-cmd/kernel-shark.git/tree/README

>+fi
>+
> AC_MSG_CHECKING([for test source generation])
> AC_RUN_IFELSE([AC_LANG_PROGRAM([[ ]], [[ ]])],
>     [AC_MSG_RESULT(ok)], [AC_MSG_RESULT(failed)], [AC_MSG_RESULT(untestable)])
>-- 
>2.34.1
>
>
>
>
>
>
>


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

* RE: [PATCH v7 1/3] build: add options to build plugins of kernelshark and libtraceevent
  2022-03-14  1:27   ` Chen, Hongzhan
@ 2022-03-14  1:40     ` Chen, Hongzhan
  2022-03-14  1:52       ` Chen, Hongzhan
  2022-03-14  6:41     ` Jan Kiszka
  1 sibling, 1 reply; 12+ messages in thread
From: Chen, Hongzhan @ 2022-03-14  1:40 UTC (permalink / raw)
  To: Kiszka, Jan, xenomai

>>-----Original Message-----
>>From: Jan Kiszka <jan.kiszka@siemens.com> 
>>Sent: Saturday, March 12, 2022 9:00 PM
>>To: xenomai@xenomai.org
>>Cc: Chen, Hongzhan <hongzhan.chen@intel.com>
>>Subject: [PATCH v7 1/3] build: add options to build plugins of kernelshark and libtraceevent
>>
>>From: Hongzhan Chen <hongzhan.chen@intel.com>
>>
>>To build plugins of kernelshark and libtraceevent, add options and
>>do necessary configuration.
>>
>>Signed-off-by: Hongzhan Chen <hongzhan.chen@intel.com>
>>[Jan: cleaned up AC_ARG_ENABLE matches, add missing kshark dep, drop INSTALLDIRs]
>>Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
>>---
>> configure.ac | 33 +++++++++++++++++++++++++++++++++
>> 1 file changed, 33 insertions(+)
>>
>>diff --git a/configure.ac b/configure.ac
>>index 16cffd8f81..ef450aa582 100644
>>--- a/configure.ac
>>+++ b/configure.ac
>>@@ -91,6 +91,8 @@ AC_ARG_WITH(cxx,
>>     ])
>> AC_PROG_CXX
>> 
>>+PKG_PROG_PKG_CONFIG
>>+
>> # Do not let autoconf set the default value of CFLAGS
>> if $XENO_EMPTY_CFLAGS; then
>> 	CFLAGS=""
>>@@ -826,6 +828,37 @@ AC_ARG_WITH(demodir,
>>     ], [XENO_DEMO_DIR=$demodir])
>> AC_MSG_RESULT($XENO_DEMO_DIR)
>> 
>>+kernelshark_plugin=
>>+AC_MSG_CHECKING(whether KernelShark plugin should be built)
>>+AC_ARG_ENABLE(kernelshark_plugin,
>>+	AS_HELP_STRING([--enable-kernelshark-plugin], [build KernelShark plugin]),
>>+	[case "$enableval" in
>>+	y | yes) kernelshark_plugin=y ;;
>>+	*) unset kernelshark_plugin ;;
>>+	esac])
>>+AC_MSG_RESULT(${kernelshark_plugin:-no})
>>+AM_CONDITIONAL(XENO_KSHARK_PLUGIN, [test x$kernelshark_plugin = xy])
>>+
>>+libtraceevent_plugin=
>>+AC_MSG_CHECKING(whether libtraceevent plugin should be built)
>>+AC_ARG_ENABLE(libtraceevent_plugin,
>>+	AS_HELP_STRING([--enable-libtraceevent-plugin], [build libtraceevent plugin]),
>>+	[case "$enableval" in
>>+	y | yes) libtraceevent_plugin=y ;;
>>+	*) unset libtraceevent_plugin ;;
>>+	esac])
>>+AC_MSG_RESULT(${libtraceevent_plugin:-no})
>>+AM_CONDITIONAL(XENO_LIBTRACEEVENT_PLUGIN, [test x$libtraceevent_plugin = xy])
>>+
>>+if test x$kernelshark_plugin = xy -o x$libtraceevent_plugin = xy; then
>>+	PKG_CHECK_MODULES(LIBTRACEEVENT, libtraceevent)
>>+fi
>>+
>>+if test x$kernelshark_plugin = xy; then
>>+	PKG_CHECK_MODULES(LIBKSHARK, libkshark)
>>+	PKG_CHECK_MODULES(LIBTRACEFS, libtracefs)
>
>I do not quite understand why we check LIBTRAEFS here because kernelshark depend on libtracefs 
>as described in [1] which should be handled by kernelshark module itself.
>If we have to check libtracefs, why we do not check other dependency module like libtraceevent  for kernelshark_plugin?

I just found libtraceevent module already be checked in previous code. But kernelshark also depends on trace-cmd. Do we need to check it here?

Regards

Hongzhan Chen

>
>Regards
>
>Hongzhan Chen 
>
>[1]: https://git.kernel.org/pub/scm/utils/trace-cmd/kernel-shark.git/tree/README
>
>>+fi
>>+
>> AC_MSG_CHECKING([for test source generation])
>> AC_RUN_IFELSE([AC_LANG_PROGRAM([[ ]], [[ ]])],
>>     [AC_MSG_RESULT(ok)], [AC_MSG_RESULT(failed)], [AC_MSG_RESULT(untestable)])
>>-- 
>>2.34.1
>>


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

* RE: [PATCH v7 1/3] build: add options to build plugins of kernelshark and libtraceevent
  2022-03-14  1:40     ` Chen, Hongzhan
@ 2022-03-14  1:52       ` Chen, Hongzhan
  0 siblings, 0 replies; 12+ messages in thread
From: Chen, Hongzhan @ 2022-03-14  1:52 UTC (permalink / raw)
  To: Kiszka, Jan, xenomai



> Message-----
>From: Chen, Hongzhan 
>Sent: Monday, March 14, 2022 9:40 AM
>To: 'Jan Kiszka' <jan.kiszka@siemens.com>; 'xenomai@xenomai.org' <xenomai@xenomai.org>
>Subject: RE: [PATCH v7 1/3] build: add options to build plugins of kernelshark and libtraceevent
>
>>>-----Original Message-----
>>>From: Jan Kiszka <jan.kiszka@siemens.com> 
>>>Sent: Saturday, March 12, 2022 9:00 PM
>>>To: xenomai@xenomai.org
>>>Cc: Chen, Hongzhan <hongzhan.chen@intel.com>
>>>Subject: [PATCH v7 1/3] build: add options to build plugins of kernelshark and libtraceevent
>>>
>>>From: Hongzhan Chen <hongzhan.chen@intel.com>
>>>
>>>To build plugins of kernelshark and libtraceevent, add options and
>>>do necessary configuration.
>>>
>>>Signed-off-by: Hongzhan Chen <hongzhan.chen@intel.com>
>>>[Jan: cleaned up AC_ARG_ENABLE matches, add missing kshark dep, drop INSTALLDIRs]
>>>Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
>>>---
>>> configure.ac | 33 +++++++++++++++++++++++++++++++++
>>> 1 file changed, 33 insertions(+)
>>>
>>>diff --git a/configure.ac b/configure.ac
>>>index 16cffd8f81..ef450aa582 100644
>>>--- a/configure.ac
>>>+++ b/configure.ac
>>>@@ -91,6 +91,8 @@ AC_ARG_WITH(cxx,
>>>     ])
>>> AC_PROG_CXX
>>> 
>>>+PKG_PROG_PKG_CONFIG
>>>+
>>> # Do not let autoconf set the default value of CFLAGS
>>> if $XENO_EMPTY_CFLAGS; then
>>> 	CFLAGS=""
>>>@@ -826,6 +828,37 @@ AC_ARG_WITH(demodir,
>>>     ], [XENO_DEMO_DIR=$demodir])
>>> AC_MSG_RESULT($XENO_DEMO_DIR)
>>> 
>>>+kernelshark_plugin=
>>>+AC_MSG_CHECKING(whether KernelShark plugin should be built)
>>>+AC_ARG_ENABLE(kernelshark_plugin,
>>>+	AS_HELP_STRING([--enable-kernelshark-plugin], [build KernelShark plugin]),
>>>+	[case "$enableval" in
>>>+	y | yes) kernelshark_plugin=y ;;
>>>+	*) unset kernelshark_plugin ;;
>>>+	esac])
>>>+AC_MSG_RESULT(${kernelshark_plugin:-no})
>>>+AM_CONDITIONAL(XENO_KSHARK_PLUGIN, [test x$kernelshark_plugin = xy])
>>>+
>>>+libtraceevent_plugin=
>>>+AC_MSG_CHECKING(whether libtraceevent plugin should be built)
>>>+AC_ARG_ENABLE(libtraceevent_plugin,
>>>+	AS_HELP_STRING([--enable-libtraceevent-plugin], [build libtraceevent plugin]),
>>>+	[case "$enableval" in
>>>+	y | yes) libtraceevent_plugin=y ;;
>>>+	*) unset libtraceevent_plugin ;;
>>>+	esac])
>>>+AC_MSG_RESULT(${libtraceevent_plugin:-no})
>>>+AM_CONDITIONAL(XENO_LIBTRACEEVENT_PLUGIN, [test x$libtraceevent_plugin = xy])
>>>+
>>>+if test x$kernelshark_plugin = xy -o x$libtraceevent_plugin = xy; then
>>>+	PKG_CHECK_MODULES(LIBTRACEEVENT, libtraceevent)
>>>+fi
>>>+
>>>+if test x$kernelshark_plugin = xy; then
>>>+	PKG_CHECK_MODULES(LIBKSHARK, libkshark)
>>>+	PKG_CHECK_MODULES(LIBTRACEFS, libtracefs)
>>
>>I do not quite understand why we check LIBTRAEFS here because kernelshark depend on libtracefs 
>>as described in [1] which should be handled by kernelshark module itself.
>>If we have to check libtracefs, why we do not check other dependency module like libtraceevent  for kernelshark_plugin?
>
>I just found libtraceevent module already be checked in previous code. But kernelshark also depends on trace-cmd. Do we need to check it here?

Following is error when I remove libtracefs in checking libkshark:

configure: error: Package requirements (libkshark) were not met:

Package 'libtracefs', required by 'libtracecmd', not found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Following is error when remove trace-cmd:

checking for LIBKSHARK... no
configure: error: Package requirements (libkshark) were not met:

Package 'libtracecmd', required by 'libkshark', not found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.


Regards

Hongzhan Chen

>
>Regards
>
>Hongzhan Chen
>
>>
>>Regards
>>
>>Hongzhan Chen 
>>
>>[1]: https://git.kernel.org/pub/scm/utils/trace-cmd/kernel-shark.git/tree/README
>>
>>>+fi
>>>+
>>> AC_MSG_CHECKING([for test source generation])
>>> AC_RUN_IFELSE([AC_LANG_PROGRAM([[ ]], [[ ]])],
>>>     [AC_MSG_RESULT(ok)], [AC_MSG_RESULT(failed)], [AC_MSG_RESULT(untestable)])
>>>-- 
>>>2.34.1
>>>


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

* Re: [PATCH v7 1/3] build: add options to build plugins of kernelshark and libtraceevent
  2022-03-14  1:27   ` Chen, Hongzhan
  2022-03-14  1:40     ` Chen, Hongzhan
@ 2022-03-14  6:41     ` Jan Kiszka
  2022-03-14  6:48       ` Chen, Hongzhan
  1 sibling, 1 reply; 12+ messages in thread
From: Jan Kiszka @ 2022-03-14  6:41 UTC (permalink / raw)
  To: Chen, Hongzhan, xenomai

On 14.03.22 02:27, Chen, Hongzhan wrote:
>>
>>
>> -----Original Message-----
>> From: Jan Kiszka <jan.kiszka@siemens.com> 
>> Sent: Saturday, March 12, 2022 9:00 PM
>> To: xenomai@xenomai.org
>> Cc: Chen, Hongzhan <hongzhan.chen@intel.com>
>> Subject: [PATCH v7 1/3] build: add options to build plugins of kernelshark and libtraceevent
>>
>> From: Hongzhan Chen <hongzhan.chen@intel.com>
>>
>> To build plugins of kernelshark and libtraceevent, add options and
>> do necessary configuration.
>>
>> Signed-off-by: Hongzhan Chen <hongzhan.chen@intel.com>
>> [Jan: cleaned up AC_ARG_ENABLE matches, add missing kshark dep, drop INSTALLDIRs]
>> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
>> ---
>> configure.ac | 33 +++++++++++++++++++++++++++++++++
>> 1 file changed, 33 insertions(+)
>>
>> diff --git a/configure.ac b/configure.ac
>> index 16cffd8f81..ef450aa582 100644
>> --- a/configure.ac
>> +++ b/configure.ac
>> @@ -91,6 +91,8 @@ AC_ARG_WITH(cxx,
>>     ])
>> AC_PROG_CXX
>>
>> +PKG_PROG_PKG_CONFIG
>> +
>> # Do not let autoconf set the default value of CFLAGS
>> if $XENO_EMPTY_CFLAGS; then
>> 	CFLAGS=""
>> @@ -826,6 +828,37 @@ AC_ARG_WITH(demodir,
>>     ], [XENO_DEMO_DIR=$demodir])
>> AC_MSG_RESULT($XENO_DEMO_DIR)
>>
>> +kernelshark_plugin=
>> +AC_MSG_CHECKING(whether KernelShark plugin should be built)
>> +AC_ARG_ENABLE(kernelshark_plugin,
>> +	AS_HELP_STRING([--enable-kernelshark-plugin], [build KernelShark plugin]),
>> +	[case "$enableval" in
>> +	y | yes) kernelshark_plugin=y ;;
>> +	*) unset kernelshark_plugin ;;
>> +	esac])
>> +AC_MSG_RESULT(${kernelshark_plugin:-no})
>> +AM_CONDITIONAL(XENO_KSHARK_PLUGIN, [test x$kernelshark_plugin = xy])
>> +
>> +libtraceevent_plugin=
>> +AC_MSG_CHECKING(whether libtraceevent plugin should be built)
>> +AC_ARG_ENABLE(libtraceevent_plugin,
>> +	AS_HELP_STRING([--enable-libtraceevent-plugin], [build libtraceevent plugin]),
>> +	[case "$enableval" in
>> +	y | yes) libtraceevent_plugin=y ;;
>> +	*) unset libtraceevent_plugin ;;
>> +	esac])
>> +AC_MSG_RESULT(${libtraceevent_plugin:-no})
>> +AM_CONDITIONAL(XENO_LIBTRACEEVENT_PLUGIN, [test x$libtraceevent_plugin = xy])
>> +
>> +if test x$kernelshark_plugin = xy -o x$libtraceevent_plugin = xy; then
>> +	PKG_CHECK_MODULES(LIBTRACEEVENT, libtraceevent)
>> +fi
>> +
>> +if test x$kernelshark_plugin = xy; then
>> +	PKG_CHECK_MODULES(LIBKSHARK, libkshark)
>> +	PKG_CHECK_MODULES(LIBTRACEFS, libtracefs)
> 
> I do not quite understand why we check LIBTRAEFS here because kernelshark depend on libtracefs 
> as described in [1] which should be handled by kernelshark module itself.
> If we have to check libtracefs, why we do not check other dependency module like libtraceevent  for kernelshark_plugin?
> 

Without this inclusion (and the corresponding usage of 
LIBTRACEFS_CFLAGS), you will get

  CC       plugin_xenomai_cobalt_switch_events_la-xenomai_cobalt_switch_events.lo
In file included from ../../../tracing/kernelshark/xenomai_cobalt_switch_events.c:17:0:
/usr/local/include/trace-cmd/trace-cmd.h:10:10: fatal error: tracefs.h: No such file or directory
 #include "tracefs.h"
          ^~~~~~~~~~~
compilation terminated.

I do not have libtracefs installed via my distro, thus everything must 
be explored and properly appended to the search path.

Jan

-- 
Siemens AG, Technology
Competence Center Embedded Linux


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

* RE: [PATCH v7 1/3] build: add options to build plugins of kernelshark and libtraceevent
  2022-03-14  6:41     ` Jan Kiszka
@ 2022-03-14  6:48       ` Chen, Hongzhan
  2022-03-14  7:50         ` Jan Kiszka
  0 siblings, 1 reply; 12+ messages in thread
From: Chen, Hongzhan @ 2022-03-14  6:48 UTC (permalink / raw)
  To: Kiszka, Jan, xenomai

-----Original Message-----
From: Jan Kiszka <jan.kiszka@siemens.com> 
>Sent: Monday, March 14, 2022 2:41 PM
>To: Chen, Hongzhan <hongzhan.chen@intel.com>; xenomai@xenomai.org
>Subject: Re: [PATCH v7 1/3] build: add options to build plugins of kernelshark and libtraceevent
>
>On 14.03.22 02:27, Chen, Hongzhan wrote:
>>>
>>>
>>> -----Original Message-----
>>> From: Jan Kiszka <jan.kiszka@siemens.com> 
>>> Sent: Saturday, March 12, 2022 9:00 PM
>>> To: xenomai@xenomai.org
>>> Cc: Chen, Hongzhan <hongzhan.chen@intel.com>
>>> Subject: [PATCH v7 1/3] build: add options to build plugins of kernelshark and libtraceevent
>>>
>>> From: Hongzhan Chen <hongzhan.chen@intel.com>
>>>
>>> To build plugins of kernelshark and libtraceevent, add options and
>>> do necessary configuration.
>>>
>>> Signed-off-by: Hongzhan Chen <hongzhan.chen@intel.com>
>>> [Jan: cleaned up AC_ARG_ENABLE matches, add missing kshark dep, drop INSTALLDIRs]
>>> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
>>> ---
>>> configure.ac | 33 +++++++++++++++++++++++++++++++++
>>> 1 file changed, 33 insertions(+)
>>>
>>> diff --git a/configure.ac b/configure.ac
>>> index 16cffd8f81..ef450aa582 100644
>>> --- a/configure.ac
>>> +++ b/configure.ac
>>> @@ -91,6 +91,8 @@ AC_ARG_WITH(cxx,
>>>     ])
>>> AC_PROG_CXX
>>>
>>> +PKG_PROG_PKG_CONFIG
>>> +
>>> # Do not let autoconf set the default value of CFLAGS
>>> if $XENO_EMPTY_CFLAGS; then
>>> 	CFLAGS=""
>>> @@ -826,6 +828,37 @@ AC_ARG_WITH(demodir,
>>>     ], [XENO_DEMO_DIR=$demodir])
>>> AC_MSG_RESULT($XENO_DEMO_DIR)
>>>
>>> +kernelshark_plugin=
>>> +AC_MSG_CHECKING(whether KernelShark plugin should be built)
>>> +AC_ARG_ENABLE(kernelshark_plugin,
>>> +	AS_HELP_STRING([--enable-kernelshark-plugin], [build KernelShark plugin]),
>>> +	[case "$enableval" in
>>> +	y | yes) kernelshark_plugin=y ;;
>>> +	*) unset kernelshark_plugin ;;
>>> +	esac])
>>> +AC_MSG_RESULT(${kernelshark_plugin:-no})
>>> +AM_CONDITIONAL(XENO_KSHARK_PLUGIN, [test x$kernelshark_plugin = xy])
>>> +
>>> +libtraceevent_plugin=
>>> +AC_MSG_CHECKING(whether libtraceevent plugin should be built)
>>> +AC_ARG_ENABLE(libtraceevent_plugin,
>>> +	AS_HELP_STRING([--enable-libtraceevent-plugin], [build libtraceevent plugin]),
>>> +	[case "$enableval" in
>>> +	y | yes) libtraceevent_plugin=y ;;
>>> +	*) unset libtraceevent_plugin ;;
>>> +	esac])
>>> +AC_MSG_RESULT(${libtraceevent_plugin:-no})
>>> +AM_CONDITIONAL(XENO_LIBTRACEEVENT_PLUGIN, [test x$libtraceevent_plugin = xy])
>>> +
>>> +if test x$kernelshark_plugin = xy -o x$libtraceevent_plugin = xy; then
>>> +	PKG_CHECK_MODULES(LIBTRACEEVENT, libtraceevent)
>>> +fi
>>> +
>>> +if test x$kernelshark_plugin = xy; then
>>> +	PKG_CHECK_MODULES(LIBKSHARK, libkshark)
>>> +	PKG_CHECK_MODULES(LIBTRACEFS, libtracefs)
>> 
>> I do not quite understand why we check LIBTRAEFS here because kernelshark depend on libtracefs 
>> as described in [1] which should be handled by kernelshark module itself.
>> If we have to check libtracefs, why we do not check other dependency module like libtraceevent  for kernelshark_plugin?
>> 
>
>Without this inclusion (and the corresponding usage of 
>LIBTRACEFS_CFLAGS), you will get
>
>  CC       plugin_xenomai_cobalt_switch_events_la-xenomai_cobalt_switch_events.lo
>In file included from ../../../tracing/kernelshark/xenomai_cobalt_switch_events.c:17:0:
>/usr/local/include/trace-cmd/trace-cmd.h:10:10: fatal error: tracefs.h: No such file or directory
> #include "tracefs.h"
>          ^~~~~~~~~~~
>compilation terminated.
>
>I do not have libtracefs installed via my distro, thus everything must 
>be explored and properly appended to the search path.

According to my test on my platform, if we have not instaledl libtracefs, 
PKG_CHECK_MODULES(LIBKSHARK, libkshark) would fail at first reporting following error.


configure: error: Package requirements (libkshark) were not met:

Package 'libtracefs', required by 'libtracecmd', not found

Regards

Hongzhan Chen
>
>Jan
>
>-- 
>Siemens AG, Technology
>Competence Center Embedded Linux

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

* Re: [PATCH v7 1/3] build: add options to build plugins of kernelshark and libtraceevent
  2022-03-14  6:48       ` Chen, Hongzhan
@ 2022-03-14  7:50         ` Jan Kiszka
  2022-03-14  8:04           ` Chen, Hongzhan
  0 siblings, 1 reply; 12+ messages in thread
From: Jan Kiszka @ 2022-03-14  7:50 UTC (permalink / raw)
  To: Chen, Hongzhan, xenomai

On 14.03.22 07:48, Chen, Hongzhan wrote:
> -----Original Message-----
> From: Jan Kiszka <jan.kiszka@siemens.com> 
>> Sent: Monday, March 14, 2022 2:41 PM
>> To: Chen, Hongzhan <hongzhan.chen@intel.com>; xenomai@xenomai.org
>> Subject: Re: [PATCH v7 1/3] build: add options to build plugins of kernelshark and libtraceevent
>>
>> On 14.03.22 02:27, Chen, Hongzhan wrote:
>>>>
>>>>
>>>> -----Original Message-----
>>>> From: Jan Kiszka <jan.kiszka@siemens.com> 
>>>> Sent: Saturday, March 12, 2022 9:00 PM
>>>> To: xenomai@xenomai.org
>>>> Cc: Chen, Hongzhan <hongzhan.chen@intel.com>
>>>> Subject: [PATCH v7 1/3] build: add options to build plugins of kernelshark and libtraceevent
>>>>
>>>> From: Hongzhan Chen <hongzhan.chen@intel.com>
>>>>
>>>> To build plugins of kernelshark and libtraceevent, add options and
>>>> do necessary configuration.
>>>>
>>>> Signed-off-by: Hongzhan Chen <hongzhan.chen@intel.com>
>>>> [Jan: cleaned up AC_ARG_ENABLE matches, add missing kshark dep, drop INSTALLDIRs]
>>>> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
>>>> ---
>>>> configure.ac | 33 +++++++++++++++++++++++++++++++++
>>>> 1 file changed, 33 insertions(+)
>>>>
>>>> diff --git a/configure.ac b/configure.ac
>>>> index 16cffd8f81..ef450aa582 100644
>>>> --- a/configure.ac
>>>> +++ b/configure.ac
>>>> @@ -91,6 +91,8 @@ AC_ARG_WITH(cxx,
>>>>     ])
>>>> AC_PROG_CXX
>>>>
>>>> +PKG_PROG_PKG_CONFIG
>>>> +
>>>> # Do not let autoconf set the default value of CFLAGS
>>>> if $XENO_EMPTY_CFLAGS; then
>>>> 	CFLAGS=""
>>>> @@ -826,6 +828,37 @@ AC_ARG_WITH(demodir,
>>>>     ], [XENO_DEMO_DIR=$demodir])
>>>> AC_MSG_RESULT($XENO_DEMO_DIR)
>>>>
>>>> +kernelshark_plugin=
>>>> +AC_MSG_CHECKING(whether KernelShark plugin should be built)
>>>> +AC_ARG_ENABLE(kernelshark_plugin,
>>>> +	AS_HELP_STRING([--enable-kernelshark-plugin], [build KernelShark plugin]),
>>>> +	[case "$enableval" in
>>>> +	y | yes) kernelshark_plugin=y ;;
>>>> +	*) unset kernelshark_plugin ;;
>>>> +	esac])
>>>> +AC_MSG_RESULT(${kernelshark_plugin:-no})
>>>> +AM_CONDITIONAL(XENO_KSHARK_PLUGIN, [test x$kernelshark_plugin = xy])
>>>> +
>>>> +libtraceevent_plugin=
>>>> +AC_MSG_CHECKING(whether libtraceevent plugin should be built)
>>>> +AC_ARG_ENABLE(libtraceevent_plugin,
>>>> +	AS_HELP_STRING([--enable-libtraceevent-plugin], [build libtraceevent plugin]),
>>>> +	[case "$enableval" in
>>>> +	y | yes) libtraceevent_plugin=y ;;
>>>> +	*) unset libtraceevent_plugin ;;
>>>> +	esac])
>>>> +AC_MSG_RESULT(${libtraceevent_plugin:-no})
>>>> +AM_CONDITIONAL(XENO_LIBTRACEEVENT_PLUGIN, [test x$libtraceevent_plugin = xy])
>>>> +
>>>> +if test x$kernelshark_plugin = xy -o x$libtraceevent_plugin = xy; then
>>>> +	PKG_CHECK_MODULES(LIBTRACEEVENT, libtraceevent)
>>>> +fi
>>>> +
>>>> +if test x$kernelshark_plugin = xy; then
>>>> +	PKG_CHECK_MODULES(LIBKSHARK, libkshark)
>>>> +	PKG_CHECK_MODULES(LIBTRACEFS, libtracefs)
>>>
>>> I do not quite understand why we check LIBTRAEFS here because kernelshark depend on libtracefs 
>>> as described in [1] which should be handled by kernelshark module itself.
>>> If we have to check libtracefs, why we do not check other dependency module like libtraceevent  for kernelshark_plugin?
>>>
>>
>> Without this inclusion (and the corresponding usage of 
>> LIBTRACEFS_CFLAGS), you will get
>>
>>  CC       plugin_xenomai_cobalt_switch_events_la-xenomai_cobalt_switch_events.lo
>> In file included from ../../../tracing/kernelshark/xenomai_cobalt_switch_events.c:17:0:
>> /usr/local/include/trace-cmd/trace-cmd.h:10:10: fatal error: tracefs.h: No such file or directory
>> #include "tracefs.h"
>>          ^~~~~~~~~~~
>> compilation terminated.
>>
>> I do not have libtracefs installed via my distro, thus everything must 
>> be explored and properly appended to the search path.
> 
> According to my test on my platform, if we have not instaledl libtracefs, 
> PKG_CHECK_MODULES(LIBKSHARK, libkshark) would fail at first reporting following error.
> 
> 
> configure: error: Package requirements (libkshark) were not met:
> 
> Package 'libtracefs', required by 'libtracecmd', not found
> 

Right, but this alone does not fill and propagate LIBTRACEFS_CFLAGS.

Jan

-- 
Siemens AG, Technology
Competence Center Embedded Linux


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

* RE: [PATCH v7 1/3] build: add options to build plugins of kernelshark and libtraceevent
  2022-03-14  7:50         ` Jan Kiszka
@ 2022-03-14  8:04           ` Chen, Hongzhan
  2022-03-14  9:36             ` Jan Kiszka
  0 siblings, 1 reply; 12+ messages in thread
From: Chen, Hongzhan @ 2022-03-14  8:04 UTC (permalink / raw)
  To: Kiszka, Jan, xenomai

>On 14.03.22 07:48, Chen, Hongzhan wrote:
>> -----Original Message-----
>> From: Jan Kiszka <jan.kiszka@siemens.com> 
>>> Sent: Monday, March 14, 2022 2:41 PM
>>> To: Chen, Hongzhan <hongzhan.chen@intel.com>; xenomai@xenomai.org
>>> Subject: Re: [PATCH v7 1/3] build: add options to build plugins of kernelshark and libtraceevent
>>>
>>> On 14.03.22 02:27, Chen, Hongzhan wrote:
>>>>>
>>>>>
>>>>> -----Original Message-----
>>>>> From: Jan Kiszka <jan.kiszka@siemens.com> 
>>>>> Sent: Saturday, March 12, 2022 9:00 PM
>>>>> To: xenomai@xenomai.org
>>>>> Cc: Chen, Hongzhan <hongzhan.chen@intel.com>
>>>>> Subject: [PATCH v7 1/3] build: add options to build plugins of kernelshark and libtraceevent
>>>>>
>>>>> From: Hongzhan Chen <hongzhan.chen@intel.com>
>>>>>
>>>>> To build plugins of kernelshark and libtraceevent, add options and
>>>>> do necessary configuration.
>>>>>
>>>>> Signed-off-by: Hongzhan Chen <hongzhan.chen@intel.com>
>>>>> [Jan: cleaned up AC_ARG_ENABLE matches, add missing kshark dep, drop INSTALLDIRs]
>>>>> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
>>>>> ---
>>>>> configure.ac | 33 +++++++++++++++++++++++++++++++++
>>>>> 1 file changed, 33 insertions(+)
>>>>>
>>>>> diff --git a/configure.ac b/configure.ac
>>>>> index 16cffd8f81..ef450aa582 100644
>>>>> --- a/configure.ac
>>>>> +++ b/configure.ac
>>>>> @@ -91,6 +91,8 @@ AC_ARG_WITH(cxx,
>>>>>     ])
>>>>> AC_PROG_CXX
>>>>>
>>>>> +PKG_PROG_PKG_CONFIG
>>>>> +
>>>>> # Do not let autoconf set the default value of CFLAGS
>>>>> if $XENO_EMPTY_CFLAGS; then
>>>>> 	CFLAGS=""
>>>>> @@ -826,6 +828,37 @@ AC_ARG_WITH(demodir,
>>>>>     ], [XENO_DEMO_DIR=$demodir])
>>>>> AC_MSG_RESULT($XENO_DEMO_DIR)
>>>>>
>>>>> +kernelshark_plugin=
>>>>> +AC_MSG_CHECKING(whether KernelShark plugin should be built)
>>>>> +AC_ARG_ENABLE(kernelshark_plugin,
>>>>> +	AS_HELP_STRING([--enable-kernelshark-plugin], [build KernelShark plugin]),
>>>>> +	[case "$enableval" in
>>>>> +	y | yes) kernelshark_plugin=y ;;
>>>>> +	*) unset kernelshark_plugin ;;
>>>>> +	esac])
>>>>> +AC_MSG_RESULT(${kernelshark_plugin:-no})
>>>>> +AM_CONDITIONAL(XENO_KSHARK_PLUGIN, [test x$kernelshark_plugin = xy])
>>>>> +
>>>>> +libtraceevent_plugin=
>>>>> +AC_MSG_CHECKING(whether libtraceevent plugin should be built)
>>>>> +AC_ARG_ENABLE(libtraceevent_plugin,
>>>>> +	AS_HELP_STRING([--enable-libtraceevent-plugin], [build libtraceevent plugin]),
>>>>> +	[case "$enableval" in
>>>>> +	y | yes) libtraceevent_plugin=y ;;
>>>>> +	*) unset libtraceevent_plugin ;;
>>>>> +	esac])
>>>>> +AC_MSG_RESULT(${libtraceevent_plugin:-no})
>>>>> +AM_CONDITIONAL(XENO_LIBTRACEEVENT_PLUGIN, [test x$libtraceevent_plugin = xy])
>>>>> +
>>>>> +if test x$kernelshark_plugin = xy -o x$libtraceevent_plugin = xy; then
>>>>> +	PKG_CHECK_MODULES(LIBTRACEEVENT, libtraceevent)
>>>>> +fi
>>>>> +
>>>>> +if test x$kernelshark_plugin = xy; then
>>>>> +	PKG_CHECK_MODULES(LIBKSHARK, libkshark)
>>>>> +	PKG_CHECK_MODULES(LIBTRACEFS, libtracefs)
>>>>
>>>> I do not quite understand why we check LIBTRAEFS here because kernelshark depend on libtracefs 
>>>> as described in [1] which should be handled by kernelshark module itself.
>>>> If we have to check libtracefs, why we do not check other dependency module like libtraceevent  for kernelshark_plugin?
>>>>
>>>
>> Without this inclusion (and the corresponding usage of 
>> LIBTRACEFS_CFLAGS), you will get
>>
>>  CC       plugin_xenomai_cobalt_switch_events_la-xenomai_cobalt_switch_events.lo
>> In file included from ../../../tracing/kernelshark/xenomai_cobalt_switch_events.c:17:0:
>> /usr/local/include/trace-cmd/trace-cmd.h:10:10: fatal error: tracefs.h: No such file or directory
>> #include "tracefs.h"
>>          ^~~~~~~~~~~
>> compilation terminated.
>>
>> I do not have libtracefs installed via my distro, thus everything must 
>> be explored and properly appended to the search path.
> 
> According to my test on my platform, if we have not instaledl libtracefs, 
> PKG_CHECK_MODULES(LIBKSHARK, libkshark) would fail at first reporting following error.
> 
> 
> configure: error: Package requirements (libkshark) were not met:
> 
> Package 'libtracefs', required by 'libtracecmd', not found
> 
>
>Right, but this alone does not fill and propagate LIBTRACEFS_CFLAGS.

Why do we need LIBTRACEFS_CFLAGS? We do not try to compile libtracefs.  when PKG_CHECK_MODULES(LIBKSHARK, libkshark) successfully, 
LIBKSHARK_CFLAGS already include needed tracefs path like following. The cause of the issue you met should be that 
Libtracefs is not installed correctly on you platform? If libtracefs had not been  installed  why configure stage did not report error?

-I/usr/local/include/kernelshark -I/usr/local/include/trace-cmd -I/usr/local/include/tracefs -I/usr/local/include/traceevent -I/usr/include/json-c


Regards

Hongzhan Chen


>
>Jan
>
>-- 
>Siemens AG, Technology
>Competence Center Embedded Linux
>

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

* Re: [PATCH v7 1/3] build: add options to build plugins of kernelshark and libtraceevent
  2022-03-14  8:04           ` Chen, Hongzhan
@ 2022-03-14  9:36             ` Jan Kiszka
  0 siblings, 0 replies; 12+ messages in thread
From: Jan Kiszka @ 2022-03-14  9:36 UTC (permalink / raw)
  To: Chen, Hongzhan, xenomai

On 14.03.22 09:04, Chen, Hongzhan wrote:
>> On 14.03.22 07:48, Chen, Hongzhan wrote:
>>> -----Original Message-----
>>> From: Jan Kiszka <jan.kiszka@siemens.com> 
>>>> Sent: Monday, March 14, 2022 2:41 PM
>>>> To: Chen, Hongzhan <hongzhan.chen@intel.com>; xenomai@xenomai.org
>>>> Subject: Re: [PATCH v7 1/3] build: add options to build plugins of kernelshark and libtraceevent
>>>>
>>>> On 14.03.22 02:27, Chen, Hongzhan wrote:
>>>>>>
>>>>>>
>>>>>> -----Original Message-----
>>>>>> From: Jan Kiszka <jan.kiszka@siemens.com> 
>>>>>> Sent: Saturday, March 12, 2022 9:00 PM
>>>>>> To: xenomai@xenomai.org
>>>>>> Cc: Chen, Hongzhan <hongzhan.chen@intel.com>
>>>>>> Subject: [PATCH v7 1/3] build: add options to build plugins of kernelshark and libtraceevent
>>>>>>
>>>>>> From: Hongzhan Chen <hongzhan.chen@intel.com>
>>>>>>
>>>>>> To build plugins of kernelshark and libtraceevent, add options and
>>>>>> do necessary configuration.
>>>>>>
>>>>>> Signed-off-by: Hongzhan Chen <hongzhan.chen@intel.com>
>>>>>> [Jan: cleaned up AC_ARG_ENABLE matches, add missing kshark dep, drop INSTALLDIRs]
>>>>>> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
>>>>>> ---
>>>>>> configure.ac | 33 +++++++++++++++++++++++++++++++++
>>>>>> 1 file changed, 33 insertions(+)
>>>>>>
>>>>>> diff --git a/configure.ac b/configure.ac
>>>>>> index 16cffd8f81..ef450aa582 100644
>>>>>> --- a/configure.ac
>>>>>> +++ b/configure.ac
>>>>>> @@ -91,6 +91,8 @@ AC_ARG_WITH(cxx,
>>>>>>     ])
>>>>>> AC_PROG_CXX
>>>>>>
>>>>>> +PKG_PROG_PKG_CONFIG
>>>>>> +
>>>>>> # Do not let autoconf set the default value of CFLAGS
>>>>>> if $XENO_EMPTY_CFLAGS; then
>>>>>> 	CFLAGS=""
>>>>>> @@ -826,6 +828,37 @@ AC_ARG_WITH(demodir,
>>>>>>     ], [XENO_DEMO_DIR=$demodir])
>>>>>> AC_MSG_RESULT($XENO_DEMO_DIR)
>>>>>>
>>>>>> +kernelshark_plugin=
>>>>>> +AC_MSG_CHECKING(whether KernelShark plugin should be built)
>>>>>> +AC_ARG_ENABLE(kernelshark_plugin,
>>>>>> +	AS_HELP_STRING([--enable-kernelshark-plugin], [build KernelShark plugin]),
>>>>>> +	[case "$enableval" in
>>>>>> +	y | yes) kernelshark_plugin=y ;;
>>>>>> +	*) unset kernelshark_plugin ;;
>>>>>> +	esac])
>>>>>> +AC_MSG_RESULT(${kernelshark_plugin:-no})
>>>>>> +AM_CONDITIONAL(XENO_KSHARK_PLUGIN, [test x$kernelshark_plugin = xy])
>>>>>> +
>>>>>> +libtraceevent_plugin=
>>>>>> +AC_MSG_CHECKING(whether libtraceevent plugin should be built)
>>>>>> +AC_ARG_ENABLE(libtraceevent_plugin,
>>>>>> +	AS_HELP_STRING([--enable-libtraceevent-plugin], [build libtraceevent plugin]),
>>>>>> +	[case "$enableval" in
>>>>>> +	y | yes) libtraceevent_plugin=y ;;
>>>>>> +	*) unset libtraceevent_plugin ;;
>>>>>> +	esac])
>>>>>> +AC_MSG_RESULT(${libtraceevent_plugin:-no})
>>>>>> +AM_CONDITIONAL(XENO_LIBTRACEEVENT_PLUGIN, [test x$libtraceevent_plugin = xy])
>>>>>> +
>>>>>> +if test x$kernelshark_plugin = xy -o x$libtraceevent_plugin = xy; then
>>>>>> +	PKG_CHECK_MODULES(LIBTRACEEVENT, libtraceevent)
>>>>>> +fi
>>>>>> +
>>>>>> +if test x$kernelshark_plugin = xy; then
>>>>>> +	PKG_CHECK_MODULES(LIBKSHARK, libkshark)
>>>>>> +	PKG_CHECK_MODULES(LIBTRACEFS, libtracefs)
>>>>>
>>>>> I do not quite understand why we check LIBTRAEFS here because kernelshark depend on libtracefs 
>>>>> as described in [1] which should be handled by kernelshark module itself.
>>>>> If we have to check libtracefs, why we do not check other dependency module like libtraceevent  for kernelshark_plugin?
>>>>>
>>>>
>>> Without this inclusion (and the corresponding usage of 
>>> LIBTRACEFS_CFLAGS), you will get
>>>
>>>  CC       plugin_xenomai_cobalt_switch_events_la-xenomai_cobalt_switch_events.lo
>>> In file included from ../../../tracing/kernelshark/xenomai_cobalt_switch_events.c:17:0:
>>> /usr/local/include/trace-cmd/trace-cmd.h:10:10: fatal error: tracefs.h: No such file or directory
>>> #include "tracefs.h"
>>>          ^~~~~~~~~~~
>>> compilation terminated.
>>>
>>> I do not have libtracefs installed via my distro, thus everything must 
>>> be explored and properly appended to the search path.
>>
>> According to my test on my platform, if we have not instaledl libtracefs, 
>> PKG_CHECK_MODULES(LIBKSHARK, libkshark) would fail at first reporting following error.
>>
>>
>> configure: error: Package requirements (libkshark) were not met:
>>
>> Package 'libtracefs', required by 'libtracecmd', not found
>>
>>
>> Right, but this alone does not fill and propagate LIBTRACEFS_CFLAGS.
> 
> Why do we need LIBTRACEFS_CFLAGS? We do not try to compile libtracefs.  when PKG_CHECK_MODULES(LIBKSHARK, libkshark) successfully, 
> LIBKSHARK_CFLAGS already include needed tracefs path like following. The cause of the issue you met should be that 
> Libtracefs is not installed correctly on you platform? If libtracefs had not been  installed  why configure stage did not report error?
> 
> -I/usr/local/include/kernelshark -I/usr/local/include/trace-cmd -I/usr/local/include/tracefs -I/usr/local/include/traceevent -I/usr/include/json-c
> 

Not here so far:

$ pkg-config libkshark --cflags
-I/usr/local/include/kernelshark -I/usr/local/include/trace-cmd
-I/usr/include/json-c

I dug deeper and it turned out that my local installation of trace-cmd
was outdated - "make install" vs. "make install_libs"...

OK, we can simplify then again. Let me check...

Jan

-- 
Siemens AG, Technology
Competence Center Embedded Linux


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

end of thread, other threads:[~2022-03-14  9:36 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-12 12:59 [PATCH v7 0/3] Kernel-Shark and libtraceevent plugins Jan Kiszka
2022-03-12 13:00 ` [PATCH v7 1/3] build: add options to build plugins of kernelshark and libtraceevent Jan Kiszka
2022-03-14  1:27   ` Chen, Hongzhan
2022-03-14  1:40     ` Chen, Hongzhan
2022-03-14  1:52       ` Chen, Hongzhan
2022-03-14  6:41     ` Jan Kiszka
2022-03-14  6:48       ` Chen, Hongzhan
2022-03-14  7:50         ` Jan Kiszka
2022-03-14  8:04           ` Chen, Hongzhan
2022-03-14  9:36             ` Jan Kiszka
2022-03-12 13:00 ` [PATCH v7 2/3] KernelShark: Add xenomai_cobalt_switch_events plugin for KernelShark Jan Kiszka
2022-03-12 13:00 ` [PATCH v7 3/3] libtraceevent: Add xenomai_schedparams plugin for libtraceevent Jan Kiszka

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.