aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYordan Karadzhov (VMware) <y.karadz@gmail.com>2020-12-09 15:45:27 +0200
committerSteven Rostedt (VMware) <rostedt@goodmis.org>2020-12-22 10:53:25 -0500
commitf994d53c7cbfd26bfa7007dd426caf702ffff814 (patch)
tree2471b05d1fa8be87360854bb11194b423166113f
parent811823c3ae8b7d9425200e2d4e21e8aa063b9ac4 (diff)
downloadkernel-shark-f994d53c7cbfd26bfa7007dd426caf702ffff814.tar.gz
kernel-shark: Remove the hard-coded Idle PID
KernelShark plots differently all events coming from Idle tasks. This is done in order to provide more intuitive visualization of the Idleness of the system. So far the process Id of the Idle task was assumed to be Zero. However this is true only for Linux systems. In this patch we make the PID of the Idle task configurable. Link: https://lore.kernel.org/linux-trace-devel/20201209134530.428368-8-y.karadz@gmail.com Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
-rw-r--r--src/KsPlotTools.cpp48
-rw-r--r--src/KsPlotTools.hpp22
2 files changed, 44 insertions, 26 deletions
diff --git a/src/KsPlotTools.cpp b/src/KsPlotTools.cpp
index d952f5e0..529f737d 100644
--- a/src/KsPlotTools.cpp
+++ b/src/KsPlotTools.cpp
@@ -755,12 +755,13 @@ Graph::Graph()
: _histoPtr(nullptr),
_bins(nullptr),
_size(0),
- _hMargin(30),
_collectionPtr(nullptr),
_binColors(nullptr),
_ensembleColors(nullptr),
_label(),
- _zeroSuppress(false)
+ _idleSuppress(false),
+ _idlePid(0),
+ _drawBase(true)
{}
/**
@@ -774,12 +775,13 @@ Graph::Graph(kshark_trace_histo *histo, KsPlot::ColorTable *bct, KsPlot::ColorTa
: _histoPtr(histo),
_bins(new(std::nothrow) Bin[histo->n_bins]),
_size(histo->n_bins),
- _hMargin(30),
_collectionPtr(nullptr),
_binColors(bct),
_ensembleColors(ect),
_label(),
- _zeroSuppress(false)
+ _idleSuppress(false),
+ _idlePid(0),
+ _drawBase(true)
{
if (!_bins) {
_size = 0;
@@ -905,6 +907,20 @@ void Graph::setLabelAppearance(ksplot_font *f, Color col, int lSize, int hMargin
}
/**
+ * @brief Set Idle Suppression. If True, the bins containing Idle task records
+ * are not grouped together.
+ *
+ * @param is: If True, Idle is suppressed.
+ * @param ip: The process Id of the Idle task. If Idle is not suppressed, this
+ * value has no effect.
+ */
+void Graph::setIdleSuppressed(bool is, int ip)
+{
+ _idleSuppress = is;
+ _idlePid = ip;
+}
+
+/**
* @brief Set the value of a given bin.
*
* @param bin: Bin Id.
@@ -916,7 +932,7 @@ void Graph::setBinValue(int bin, int val)
}
/**
- * @brief Set the Process Id (Front and Back) a given bin.
+ * @brief Set the Process Id (Front and Back) of a given bin.
*
* @param bin: Bin Id.
* @param pidF: The Process Id detected at the from (first in time) edge of
@@ -1328,22 +1344,28 @@ void Graph::draw(float size)
_label.draw();
- /*
- * Start by drawing a line between the base points of the first and
- * the last bin.
- */
- drawLine(_bins[0]._base, _bins[_size - 1]._base, {}, size);
+ if (_drawBase) {
+ /*
+ * Start by drawing a line between the base points of the first and
+ * the last bin.
+ */
+ drawLine(_bins[0]._base, _bins[_size - 1]._base, {}, size);
+ }
/* Draw as vartical lines all bins containing data. */
for (int i = 0; i < _size; ++i)
- if (_bins[i]._idFront >= 0 || _bins[i]._idBack >= 0)
+ if (_bins[i]._idFront >= 0 || _bins[i]._idBack >= 0 ||
+ _bins[i]._idFront == _idlePid || _bins[i]._idBack ==_idlePid)
if (_bins[i]._visMask & KS_EVENT_VIEW_FILTER_MASK) {
_bins[i]._size = size;
_bins[i].draw();
}
auto lamCheckEnsblVal = [this] (int v) {
- return v > 0 || (v == 0 && !this->_zeroSuppress);
+ if (_idleSuppress && v == _idlePid)
+ return false;
+
+ return v >= 0;
};
/*
@@ -1424,4 +1446,4 @@ void Graph::draw(float size)
}
}
-}; // KsPlot
+} // KsPlot
diff --git a/src/KsPlotTools.hpp b/src/KsPlotTools.hpp
index 8f530b0e..5ce8f6fc 100644
--- a/src/KsPlotTools.hpp
+++ b/src/KsPlotTools.hpp
@@ -449,7 +449,7 @@ public:
*/
Graph(const Graph &) = delete;
- /* Disable moving. Same as copying.*/
+ /* Disable moving. Same as copying. */
Graph(Graph &&) = delete;
Graph(kshark_trace_histo *histo, KsPlot::ColorTable *bct,
@@ -512,18 +512,10 @@ public:
void setLabelAppearance(ksplot_font *f, Color col,
int lSize, int hMargin);
- /**
- * Check if this graph is Zero Suppressed. Zero Suppressed means that
- * bins having Id value = 0 (Idle task records) are not grouped
- * together.
- */
- bool zeroSuppressed(bool zs) {return _zeroSuppress;}
+ void setIdleSuppressed(bool is, int ip = 0);
- /**
- * Set Zero Suppression. If True, the bins having Id value = 0 (Idle
- * task records) are not grouped together.
- */
- void setZeroSuppressed(bool zs) {_zeroSuppress = zs;}
+ /** Draw the base line of the graph or not. */
+ void setDrawBase(bool b) {_drawBase = b;}
protected:
/** Pointer to the model descriptor object. */
@@ -559,7 +551,11 @@ protected:
private:
TextBox _label;
- bool _zeroSuppress;
+ bool _idleSuppress;
+
+ int _idlePid;
+
+ bool _drawBase;
void _initBins();