From patchwork Wed Nov 28 15:16:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 10760059 Return-Path: Received: from mail-eopbgr710043.outbound.protection.outlook.com ([40.107.71.43]:7840 "EHLO NAM05-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728732AbeK2CSs (ORCPT ); Wed, 28 Nov 2018 21:18:48 -0500 From: Yordan Karadzhov To: "rostedt@goodmis.org" CC: "linux-trace-devel@vger.kernel.org" Subject: [PATCH 14/17] kernel-shark-qt: Add Hide CPU action to the Quick Context Menu Date: Wed, 28 Nov 2018 15:16:25 +0000 Message-ID: <20181128151530.21965-15-ykaradzhov@vmware.com> References: <20181128151530.21965-1-ykaradzhov@vmware.com> In-Reply-To: <20181128151530.21965-1-ykaradzhov@vmware.com> Content-Language: en-US MIME-Version: 1.0 Sender: linux-trace-devel-owner@vger.kernel.org List-ID: Content-Length: 2729 Now the Quick Context Menu can be used to hide all data from a CPU core. The CPU Id value is added to the list of CPUs to be filtered-out. Signed-off-by: Yordan Karadzhov --- kernel-shark-qt/src/KsQuickContextMenu.cpp | 26 ++++++++++++++++++++++ kernel-shark-qt/src/KsQuickContextMenu.hpp | 6 +++++ 2 files changed, 32 insertions(+) diff --git a/kernel-shark-qt/src/KsQuickContextMenu.cpp b/kernel-shark-qt/src/KsQuickContextMenu.cpp index 16b8d19..95ffc4f 100644 --- a/kernel-shark-qt/src/KsQuickContextMenu.cpp +++ b/kernel-shark-qt/src/KsQuickContextMenu.cpp @@ -54,6 +54,7 @@ KsQuickContextMenu::KsQuickContextMenu(KsDataStore *data, size_t row, _showTaskAction(this), _hideEventAction(this), _showEventAction(this), + _hideCPUAction(this), _addCPUPlotAction(this), _addTaskPlotAction(this), _removeCPUPlotAction(this), @@ -108,6 +109,9 @@ KsQuickContextMenu::KsQuickContextMenu(KsDataStore *data, size_t row, descr += "] only"; lamAddAction(&_showEventAction, &KsQuickContextMenu::_showEvent); + descr = QString("Hide CPU [%1]").arg(_data->rows()[_row]->cpu); + lamAddAction(&_hideCPUAction, &KsQuickContextMenu::_hideCPU); + if (parentName == "KsTraceViewer") { descr = "Add ["; descr += taskName; @@ -194,6 +198,28 @@ void KsQuickContextMenu::_showEvent() _data->applyPosEventFilter(QVector(1, eventId)); } +void KsQuickContextMenu::_hideCPU() +{ + kshark_context *kshark_ctx(nullptr); + QVector vec; + + if (!kshark_instance(&kshark_ctx)) + return; + + vec =_getFilterVector(kshark_ctx->hide_cpu_filter, + _data->rows()[_row]->cpu); + _data->applyNegCPUFilter(vec); +} + +QVector KsQuickContextMenu::_getFilterVector(tracecmd_filter_id *filter, int newId) +{ + QVector vec = KsUtils::getFilterIds(filter); + if (!vec.contains(newId)) + vec.append(newId); + + return vec; +} + void KsQuickContextMenu::_addTaskPlot() { int pid = kshark_get_pid_easy(_data->rows()[_row]); diff --git a/kernel-shark-qt/src/KsQuickContextMenu.hpp b/kernel-shark-qt/src/KsQuickContextMenu.hpp index 040942f..6ca1b08 100644 --- a/kernel-shark-qt/src/KsQuickContextMenu.hpp +++ b/kernel-shark-qt/src/KsQuickContextMenu.hpp @@ -71,6 +71,8 @@ private: void _showEvent(); + void _hideCPU(); + void _addCPUPlot(); void _addTaskPlot(); @@ -79,6 +81,8 @@ private: void _removeTaskPlot(); + QVector _getFilterVector(tracecmd_filter_id *filter, int newId); + KsDataStore *_data; size_t _row; @@ -87,6 +91,8 @@ private: QAction _hideEventAction, _showEventAction; + QAction _hideCPUAction; + QAction _addCPUPlotAction; QAction _addTaskPlotAction;