From patchwork Fri Nov 9 19:50:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 10759737 Return-Path: Received: from mail-cys01nam02on0082.outbound.protection.outlook.com ([104.47.37.82]:58643 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725752AbeKJFdL (ORCPT ); Sat, 10 Nov 2018 00:33:11 -0500 From: Yordan Karadzhov To: "rostedt@goodmis.org" CC: "linux-trace-devel@vger.kernel.org" Subject: [PATCH v2 1/8] kernel-shark-qt: Reset the second pass hash when reloading Sched plugin Date: Fri, 9 Nov 2018 19:50:24 +0000 Message-ID: <20181109195004.25455-2-ykaradzhov@vmware.com> References: <20181109195004.25455-1-ykaradzhov@vmware.com> In-Reply-To: <20181109195004.25455-1-ykaradzhov@vmware.com> Content-Language: en-US MIME-Version: 1.0 Sender: linux-trace-devel-owner@vger.kernel.org List-ID: Content-Length: 3139 When the plugin is reloaded, the trace data gets reloaded as well. Hence the second pass over the data has to be repeated. Signed-off-by: Yordan Karadzhov --- kernel-shark-qt/src/plugins/SchedEvents.cpp | 15 ++++++--------- kernel-shark-qt/src/plugins/sched_events.c | 4 ++++ kernel-shark-qt/src/plugins/sched_events.h | 3 +++ 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/kernel-shark-qt/src/plugins/SchedEvents.cpp b/kernel-shark-qt/src/plugins/SchedEvents.cpp index 7f75baa..5f833df 100644 --- a/kernel-shark-qt/src/plugins/SchedEvents.cpp +++ b/kernel-shark-qt/src/plugins/SchedEvents.cpp @@ -193,8 +193,6 @@ static void pluginDraw(plugin_sched_context *plugin_ctx, return; } -static std::unordered_set secondPassDone; - /* * Ideally, the sched_switch has to be the last trace event recorded before the * task is preempted. Because of this, when the data is loaded (the first pass), @@ -250,8 +248,6 @@ static void secondPass(kshark_entry **data, } } } - - secondPassDone.insert(pid); } /** @@ -298,12 +294,13 @@ void plugin_draw(kshark_cpp_argv *argv_c, int pid, int draw_action) KS_TASK_COLLECTION_MARGIN); } - try { - if (secondPassDone.find(pid) == secondPassDone.end()) { - /* The second pass for this task is not done yet. */ - secondPass(argvCpp->_histo->data, col, pid); - } + if (!tracecmd_filter_id_find(plugin_ctx->second_pass_hash, pid)) { + /* The second pass for this task is not done yet. */ + secondPass(argvCpp->_histo->data, col, pid); + tracecmd_filter_id_add(plugin_ctx->second_pass_hash, pid); + } + try { pluginDraw(plugin_ctx, kshark_ctx, argvCpp->_histo, col, SchedEvent::Switch, pid, diff --git a/kernel-shark-qt/src/plugins/sched_events.c b/kernel-shark-qt/src/plugins/sched_events.c index 80ac214..f23c916 100644 --- a/kernel-shark-qt/src/plugins/sched_events.c +++ b/kernel-shark-qt/src/plugins/sched_events.c @@ -79,6 +79,8 @@ static bool plugin_sched_init_context(struct kshark_context *kshark_ctx) plugin_ctx->sched_wakeup_new_success_field = tep_find_field(event, "success"); + plugin_ctx->second_pass_hash = tracecmd_filter_id_hash_alloc(); + return true; } @@ -279,6 +281,8 @@ static int plugin_sched_close(struct kshark_context *kshark_ctx) plugin_sched_action, plugin_draw); + tracecmd_filter_id_hash_free(plugin_ctx->second_pass_hash); + free(plugin_ctx); plugin_sched_context_handler = NULL; diff --git a/kernel-shark-qt/src/plugins/sched_events.h b/kernel-shark-qt/src/plugins/sched_events.h index 5a9406b..481413f 100644 --- a/kernel-shark-qt/src/plugins/sched_events.h +++ b/kernel-shark-qt/src/plugins/sched_events.h @@ -55,6 +55,9 @@ struct plugin_sched_context { * Pointer to the sched_wakeup_new_success_field format descriptor. */ struct tep_format_field *sched_wakeup_new_success_field; + + /** Hash of the tasks for which the second pass is already done. */ + struct tracecmd_filter_id *second_pass_hash; }; int plugin_get_next_pid(struct tep_record *record);