Skip to contentSkip to conversation

Various minor modifications and fixes toward KS 1.0

PATCH Superseded Yordan Karadzhov 1 participant 5 messages Mar 7, 2019

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Various minor modifications and fixes toward KS 1.0

Yordan Karadzhov (4):
kernel-shark: Specify the OpenGL interface used by KernelShark
kernel-shark: Fix a bug in ksmodel_zoom
kernel-shark: Fix Doxygen warning from sched_events
kernel-shark: Fix a bug in KsPluginManager

 kernel-shark/CMakeLists.txt             | 1 +
 kernel-shark/src/KsUtils.cpp            | 4 ++--
 kernel-shark/src/libkshark-model.c      | 4 ++--
 kernel-shark/src/plugins/sched_events.c | 2 +-
 4 files changed, 6 insertions(+), 5 deletions(-)
Signature · 1 line
2.19.1
#1 lore raw

PATCH 1/4 kernel-shark: Specify the OpenGL interface used by KernelShark

We instruct CMAKE to prefer using the legacy libGL library, if available. Although this is the default choice, the latest versions of CMAKE are printing a warning message in the case when no explicit preference is provided.

---
 kernel-shark/CMakeLists.txt | 1 +
 1 file changed, 1 insertion(+)
kernel-shark/CMakeLists.txt +1 -0
index 9460026..20ced14 100644
@@ -22,6 +22,7 @@ include(${KS_DIR}/build/FindJSONC.cmake)
 
 find_package(Doxygen)
 
+set(OpenGL_GL_PREFERENCE LEGACY)
 find_package(OpenGL)
 find_package(GLUT)
 
Signature · 1 line
2.19.1
#2 lore raw

PATCH 2/4 kernel-shark: Fix a bug in ksmodel_zoom

In reply to Yordan Karadzhov

When zooming-in the model is supposed to avoid over-zooming by recalculation the Scale factor. The new value of the Scale factor is supposed to be such that the size of the bin cannot be smaller than 5 ns. This patch fixes a naive bug in the way the new scale value is calculated. The bug was introduced in

f97e31f00 ("kernel-shark-qt: Introduce the visualization model used by the Qt-based KS")

but had no effect until

94efea960 ("kernel-shark-qt: Handle the case when the range of the model is too small")

because the ridiculous value of the Scale factor resulted in a very small model range and because of this such modification of the model was always rejected.

Fixes f97e31f00 ("kernel-shark-qt: Introduce the visualization model used by the Qt-based KS")
---
 kernel-shark/src/libkshark-model.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel-shark/src/libkshark-model.c +2 -2
index 4bd1e2c..7574cbe 100644
@@ -648,8 +648,8 @@ static void ksmodel_zoom(struct kshark_trace_histo *histo,
 	 * Avoid overzooming. If needed, adjust the Scale factor to a the value
 	 * which provides bin_size >= 5.
 	 */
-	if (zoom_in && range * (1 - r) < histo->n_bins * 5)
-		r = 1 - (histo->n_bins * 5) / range;
+	if (zoom_in && int (range * (1. - r)) < histo->n_bins * 5)
+		r = 1. - (histo->n_bins * 5.) / range;
 
 	/*
 	 * Now calculate the new range of the histo. Use the bin of the marker
Signature · 1 line
2.19.1
#3 lore raw

PATCH 3/4 kernel-shark: Fix Doxygen warning from sched_events

In reply to Yordan Karadzhov

There is no reason for find_wakeup_pid being non-static. In the same time, because it is non-static, Doxygen complains about missing documentation for this function.

---
 kernel-shark/src/plugins/sched_events.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel-shark/src/plugins/sched_events.c +1 -1
index c52fb29..724aa19 100644
@@ -148,7 +148,7 @@ static void plugin_register_command(struct kshark_context *kshark_ctx,
 			tep_register_comm(kshark_ctx->pevent, comm, pid);
 }
 
-int find_wakeup_pid(struct kshark_context *kshark_ctx, struct kshark_entry *e,
+static int find_wakeup_pid(struct kshark_context *kshark_ctx, struct kshark_entry *e,
 		    struct tep_event *wakeup_event, struct tep_format_field *pid_field)
 {
 	struct tep_record *record;
Signature · 1 line
2.19.1
#4 lore raw

PATCH 4/4 kernel-shark: Fix a bug in KsPluginManager

In reply to Yordan Karadzhov

const char *lib = plugin.toStdString().c_str();

This line is a bad idea because the returned array may (will) be invalidated when the destructor of std::string is called.

Fixes 18cf94f485("kernel-shark-qt: Add KernalShark Utils")
---
 kernel-shark/src/KsUtils.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel-shark/src/KsUtils.cpp +2 -2
index 34b2e2d..d7b1753 100644
@@ -439,7 +439,7 @@ void KsPluginManager::registerFromList(kshark_context *kshark_ctx)
 
 	auto lamRegUser = [&kshark_ctx](const QString &plugin)
 	{
-		const char *lib = plugin.toStdString().c_str();
+		const char *lib = plugin.toLocal8Bit().data();
 		kshark_register_plugin(kshark_ctx, lib);
 	};
 
@@ -474,7 +474,7 @@ void KsPluginManager::unregisterFromList(kshark_context *kshark_ctx)
 
 	auto lamUregUser = [&kshark_ctx](const QString &plugin)
 	{
-		const char *lib = plugin.toStdString().c_str();
+		const char *lib = plugin.toLocal8Bit().data();
 		kshark_unregister_plugin(kshark_ctx, lib);
 	};
 
Signature · 1 line
2.19.1