Skip to contentSkip to conversation

kernel-shark: Add KVMCombo plugin

PATCH New Yordan Karadzhov (VMware) 1 participant 1 message May 11, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kernel-shark: Add KVMCombo plugin

The plugin allows the user to visualize the execution flow between the host and guest virtual machines. It exploits the concept of "Combo Plots" that allows to have two normal graphs stacked together (on top of each other). The plugin uses a "combo" between the task in the host that emulates a virtual CPU and the corresponding CPU graph from the VM. The plugin draws additional graphical elements on top of this "combo", helping the user to intuitively interpret the data and see how the execution flow goes from host to guest and back. The core KVM-specific logic that implements the processing of the data and the visualization itself is implemented in:

src/plugins/kvm_combo.h
src/plugins/kvm_combo.c
src/plugins/KVMCombo.cpp

Some general purposes tools for plotting, that in the future can be used to implement similar plugins for other hypervisor are available in:

plugins/VirtComboPlotTools.hpp

The plugin also registers its own dialog, that allows the user to select the "combos" to be visualized. The widget of the dialog gets implemented in:

src/plugins/KVMComboDialog.hpp
src/plugins/KVMComboDialog.cpp

---
 src/libkshark-tepdata.c            |   1 +
 src/plugins/CMakeLists.txt         |   5 +
 src/plugins/KVMCombo.cpp           |  39 ++++
 src/plugins/KVMComboDialog.cpp     | 350 +++++++++++++++++++++++++++++
 src/plugins/KVMComboDialog.hpp     |  89 ++++++++
 src/plugins/VirtComboPlotTools.hpp | 171 ++++++++++++++
 src/plugins/kvm_combo.c            |  72 ++++++
 src/plugins/kvm_combo.h            |  49 ++++
 tests/libkshark-gui-tests.cpp      |   1 +
 9 files changed, 777 insertions(+)
 create mode 100644 src/plugins/KVMCombo.cpp
 create mode 100644 src/plugins/KVMComboDialog.cpp
 create mode 100644 src/plugins/KVMComboDialog.hpp
 create mode 100644 src/plugins/VirtComboPlotTools.hpp
 create mode 100644 src/plugins/kvm_combo.c
 create mode 100644 src/plugins/kvm_combo.h
src/libkshark-tepdata.c +1 -0
index f7cd083..bc5babb 100644
@@ -1210,6 +1210,7 @@ static void kshark_tep_init_methods(struct kshark_generic_stream_interface *inte
 const char *tep_plugin_names[] = {
 	"sched_events",
 	"missed_events",
+	"kvm_combo",
 };
 
 /**
src/plugins/CMakeLists.txt +5 -0
index 2906dd4..3e170fa 100644
@@ -54,6 +54,11 @@ if (Qt5Widgets_FOUND AND TT_FONT_FILE)
                      SOURCE latency_plot.c LatencyPlot.cpp LatencyPlotDialog.cpp)
     list(APPEND PLUGIN_LIST "latency_plot")
 
+    BUILD_GUI_PLUGIN(NAME kvm_combo
+                     MOC KVMComboDialog.hpp
+                     SOURCE kvm_combo.c KVMCombo.cpp KVMComboDialog.cpp)
+    list(APPEND PLUGIN_LIST "kvm_combo")
+
 endif (Qt5Widgets_FOUND AND TT_FONT_FILE)
 
 BUILD_PLUGIN(NAME missed_events
src/plugins/KVMCombo.cpp new file +39 -0
new file mode 100644
index 0000000..c7e89d8
@@ -0,0 +1,39 @@
+// SPDX-License-Identifier: LGPL-2.1
+
+/*
+ * Copyright (C) 2019 VMware Inc, Yordan Karadzhov <[email protected]>
+ */
+
+/**
+ *  @file    KVMCombo.cpp
+ *  @brief   Plugin for visualization of KVM events.
+ */
+
+// KernelShark
+#include "plugins/kvm_combo.h"
+#include "VirtComboPlotTools.hpp"
+#include "KsPlugins.hpp"
+
+/**
+ * @brief Plugin's draw function.
+ *
+ * @param argv_c: A C pointer to be converted to KsCppArgV (C++ struct).
+ * @param sdHost: Data stream identifier of the Host.
+ * @param pidHost: Process Id of the virtual CPU process in the Host.
+ * @param draw_action: Draw action identifier.
+ */
+__hidden void draw_kvm_combos(kshark_cpp_argv *argv_c,
+			      int sdHost, int pidHost,
+			      int draw_action)
+{
+	plugin_kvm_context *plugin_ctx = __get_context(sdHost);
+	if (!plugin_ctx)
+		return;
+
+	drawVirtCombos(argv_c,
+		       sdHost,
+		       pidHost,
+		       plugin_ctx->vm_entry_id,
+		       plugin_ctx->vm_exit_id,
+		       draw_action);
+}
src/plugins/KVMComboDialog.cpp new file +350 -0

350 lines not on this page · raw message

src/plugins/KVMComboDialog.hpp new file +89 -0

89 lines not on this page · raw message

src/plugins/VirtComboPlotTools.hpp new file +171 -0

171 lines not on this page · raw message

src/plugins/kvm_combo.c new file +72 -0

72 lines not on this page · raw message

src/plugins/kvm_combo.h new file +49 -0

49 lines not on this page · raw message

tests/libkshark-gui-tests.cpp +1 -0
index f96b3dd..031e836 100644
@@ -149,6 +149,7 @@ BOOST_AUTO_TEST_CASE(KsUtils_getPluginList)
 	QStringList plugins{"sched_events",
 			    "event_field_plot",
 			    "latency_plot",
+			    "kvm_combo",
 			    "missed_events"
 	};
 
Signature · 1 line
2.27.0