diff mbox series

[3/8] kernel-shark: Check bin 0 for sched_switch event when plotting task graphs

Message ID 20190213161216.14438-4-ykaradzhov@vmware.com (mailing list archive)
State Accepted
Headers show
Series Various modifications toward KS 1.0 | expand

Commit Message

Yordan Karadzhov Feb. 13, 2019, 4:12 p.m. UTC
Handle the case when task is active in the Lower Overflow bin and the
sched_switch event that close the task graph happens to be in bin 0.

Fixes: ba206aaa45 ("kernel-shark-qt: Add C++ API for drawing of Graphs")
Signed-off-by: Yordan Karadzhov <ykaradzhov@vmware.com>
---
 kernel-shark/src/KsPlotTools.cpp | 28 +++++++++++++++++++---------
 1 file changed, 19 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/kernel-shark/src/KsPlotTools.cpp b/kernel-shark/src/KsPlotTools.cpp
index 816fa56..f97c6e4 100644
--- a/kernel-shark/src/KsPlotTools.cpp
+++ b/kernel-shark/src/KsPlotTools.cpp
@@ -1020,16 +1020,26 @@  void Graph::fillTaskGraph(int pid)
 		if (cpuFront >= 0) {
 			/*
 			 * The Lower Overflow Bin contains data from this Task.
-			 * Now look again in the Lower Overflow Bin and find
-			 * the Pid of the last active task on the same CPU.
+			 * Now look again in the Lower Overflow Bin and Bim 0
+			 * and find the Pid of the last active task on the same
+			 * CPU.
 			 */
-			int pidCpu = ksmodel_get_pid_back(_histoPtr,
-							  LOWER_OVERFLOW_BIN,
-							  cpuFront,
-							  false,
-							  _collectionPtr,
-							  nullptr);
-			if (pidCpu == pid) {
+			int pidCpu0, pidCpuLOB;
+
+			pidCpu0 = ksmodel_get_pid_back(_histoPtr,
+						       0,
+						       cpuFront,
+						       false,
+						       _collectionPtr,
+						       nullptr);
+
+			pidCpuLOB = ksmodel_get_pid_back(_histoPtr,
+							 LOWER_OVERFLOW_BIN,
+							 cpuFront,
+							 false,
+							 _collectionPtr,
+							 nullptr);
+			if (pidCpu0 < 0 && pidCpuLOB == pid) {
 				/*
 				 * The Task is the last one running on this
 				 * CPU. Set the Pid of the bin. In this case