diff mbox series

[2/2] kernel-shark: CPU plots dialog ease spotting empty CPUs

Message ID 20220316143717.272899-2-y.karadz@gmail.com (mailing list archive)
State Accepted
Commit 027ccb9b4e2fd5fde2a41a4e5ff1931ddf0df9d5
Headers show
Series [1/2] kernel-shark: Hide CPUs with no data in them | expand

Commit Message

Yordan Karadzhov March 16, 2022, 2:37 p.m. UTC
The CPU plots dialog will show only the ones with content. A "hide empty"
checkbox is added, that by default is checked. If it is unchecked, then
all the CPUs would show up.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=215677
Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---
 src/KsWidgetsLib.cpp | 26 +++++++++++++++++++++++++-
 src/KsWidgetsLib.hpp |  7 +++++--
 2 files changed, 30 insertions(+), 3 deletions(-)

Comments

Steven Rostedt March 16, 2022, 3:03 p.m. UTC | #1
On Wed, 16 Mar 2022 16:37:17 +0200
"Yordan Karadzhov (VMware)" <y.karadz@gmail.com> wrote:

> The CPU plots dialog will show only the ones with content. A "hide empty"
> checkbox is added, that by default is checked. If it is unchecked, then
> all the CPUs would show up.
> 
> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=215677
> Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
> ---
>

This is awesome Yordan!

It's exactly what I was looking for.

Tested-by: Steven Rostedt (Google) <rostedt@goodmis.org>

Although, I found that if I select more that 16 CPU plots at a time it
hangs. I can add that to the BZ. (I noticed this before these patches).

-- Steve
Steven Rostedt March 16, 2022, 3:11 p.m. UTC | #2
On Wed, 16 Mar 2022 11:03:56 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:

> Although, I found that if I select more that 16 CPU plots at a time it
> hangs. I can add that to the BZ. (I noticed this before these patches).

Strange, it hung just before posting this, but trying it again, I can't
reproduce the lockup :-/

I'll play some more with it.

-- Steve
diff mbox series

Patch

diff --git a/src/KsWidgetsLib.cpp b/src/KsWidgetsLib.cpp
index e30bf27..7b3192d 100644
--- a/src/KsWidgetsLib.cpp
+++ b/src/KsWidgetsLib.cpp
@@ -906,12 +906,35 @@  void KsCheckBoxTreeWidget::_verify()
  * @param parent: The parent of this widget.
  */
 KsCPUCheckBoxWidget::KsCPUCheckBoxWidget(kshark_data_stream *stream, QWidget *parent)
-: KsCheckBoxTreeWidget(stream->stream_id, "CPUs", parent)
+: KsCheckBoxTreeWidget(stream->stream_id, "CPUs", parent),
+  _hideEmpty("hide empty")
 {
 	int height(FONT_HEIGHT * 1.5);
 	KsPlot::ColorTable colors;
 	QString style;
 
+	_hideEmpty.setCheckState(Qt::Checked);
+	_tb.addSeparator();
+	_tb.addWidget(&_hideEmpty);
+
+	auto lamHideEmpty = [this, stream] (bool hide) {
+		QTreeWidgetItem *item;
+		bool isIdle;
+
+		for(int cpu = 0; cpu < stream->n_cpus; ++cpu) {
+			item = _tree.topLevelItem(cpu);
+			if (hide) {
+				isIdle = kshark_hash_id_find(stream->idle_cpus, cpu);
+				item->setHidden(isIdle);
+			} else {
+				item->setHidden(false);
+			}
+		}
+	};
+
+	connect(&_hideEmpty,	&QCheckBox::clicked,
+				lamHideEmpty);
+
 	style = QString("QTreeView::item { height: %1 ;}").arg(height);
 	_tree.setStyleSheet(style);
 
@@ -934,6 +957,7 @@  KsCPUCheckBoxWidget::KsCPUCheckBoxWidget(kshark_data_stream *stream, QWidget *pa
 		_cb[i] = cpuItem;
 	}
 
+	lamHideEmpty(true);
 	_adjustSize();
 }
 
diff --git a/src/KsWidgetsLib.hpp b/src/KsWidgetsLib.hpp
index 6ec2bd1..2cc3535 100644
--- a/src/KsWidgetsLib.hpp
+++ b/src/KsWidgetsLib.hpp
@@ -275,10 +275,9 @@  public:
 	/** The user provided an input. The widget has been modified. */
 	bool _userInput;
 
-private:
+protected:
 	QToolBar _tb;
 
-protected:
 	/** Identifier of the Data stream for which the selection applies. */
 	int		_sd;
 
@@ -544,6 +543,10 @@  struct KsCPUCheckBoxWidget : public KsCheckBoxTreeWidget
 
 	KsCPUCheckBoxWidget(kshark_data_stream *stream,
 			    QWidget *parent = nullptr);
+
+private:
+	/** The "hide empty" checkbox. */
+	QCheckBox	_hideEmpty;
 };
 
 /**