From patchwork Fri Nov 30 15:42:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 10760089 Return-Path: Received: from mail-eopbgr740058.outbound.protection.outlook.com ([40.107.74.58]:6592 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726645AbeLACwa (ORCPT ); Fri, 30 Nov 2018 21:52:30 -0500 From: Yordan Karadzhov To: "rostedt@goodmis.org" CC: "linux-trace-devel@vger.kernel.org" Subject: [PATCH 2/2] kernel-shark-qt: Make Sched event plugin use its own data collections Date: Fri, 30 Nov 2018 15:42:38 +0000 Message-ID: <20181130154211.4575-3-ykaradzhov@vmware.com> References: <20181130154211.4575-1-ykaradzhov@vmware.com> In-Reply-To: <20181130154211.4575-1-ykaradzhov@vmware.com> Content-Language: en-US MIME-Version: 1.0 Sender: linux-trace-devel-owner@vger.kernel.org List-ID: Content-Length: 6211 The Sched events plugin now mentains its own list of per-task data collections of Sched events. Since this restors the log(n) complexity of the latency plotting, we no longer need the cut which disables plotting if the number of entries shown by the graph is bigger than PLUGIN_MAX_ENTRIES. Signed-off-by: Yordan Karadzhov --- kernel-shark-qt/src/plugins/SchedEvents.cpp | 33 ++++++++------------- kernel-shark-qt/src/plugins/sched_events.c | 21 +++++++++++++ kernel-shark-qt/src/plugins/sched_events.h | 6 ++++ 3 files changed, 40 insertions(+), 20 deletions(-) diff --git a/kernel-shark-qt/src/plugins/SchedEvents.cpp b/kernel-shark-qt/src/plugins/SchedEvents.cpp index c8dc3bf..8408657 100644 --- a/kernel-shark-qt/src/plugins/SchedEvents.cpp +++ b/kernel-shark-qt/src/plugins/SchedEvents.cpp @@ -28,8 +28,6 @@ #define PLUGIN_MIN_BOX_SIZE 4 -#define PLUGIN_MAX_ENTRIES 10000 - #define KS_TASK_COLLECTION_MARGIN 25 //! @endcond @@ -133,15 +131,13 @@ static void pluginDraw(plugin_sched_context *plugin_ctx, /* * Starting from the last element in this bin, go backward * in time until you find a trace entry that satisfies the - * condition defined by plugin_wakeup_match_rec_pid. Note - * that the wakeup event does not belong to this task, - * hence we cannot use the task's collection. + * condition defined by plugin_wakeup_match_rec_pid. */ entryOpen = ksmodel_get_entry_back(histo, bin, false, plugin_wakeup_match_rec_pid, pid, - nullptr, // No collection. + col, &indexOpen); if (entryOpen) { @@ -207,6 +203,9 @@ static void secondPass(kshark_entry **data, kshark_entry_collection *col, int pid) { + if (!col) + return; + const kshark_entry *e; kshark_entry *last; int first, n; @@ -275,8 +274,8 @@ void plugin_draw(kshark_cpp_argv *argv_c, int pid, int draw_action) * Try to find a collections for this task. It is OK if * coll = NULL. */ - col = kshark_find_data_collection(kshark_ctx->collections, - kshark_match_pid, pid); + col = kshark_find_data_collection(plugin_ctx->collections, + plugin_match_pid, pid); if (!col) { /* * If a data collection for this task does not exist, @@ -284,10 +283,12 @@ void plugin_draw(kshark_cpp_argv *argv_c, int pid, int draw_action) */ kshark_entry **data = argvCpp->_histo->data; int size = argvCpp->_histo->data_size; - col = kshark_register_data_collection(kshark_ctx, - data, size, - kshark_match_pid, pid, - KS_TASK_COLLECTION_MARGIN); + + col = kshark_add_collection_to_list(kshark_ctx, + &plugin_ctx->collections, + data, size, + plugin_match_pid, pid, + KS_TASK_COLLECTION_MARGIN); } if (!tracecmd_filter_id_find(plugin_ctx->second_pass_hash, pid)) { @@ -296,14 +297,6 @@ void plugin_draw(kshark_cpp_argv *argv_c, int pid, int draw_action) tracecmd_filter_id_add(plugin_ctx->second_pass_hash, pid); } - /* - * Plotting the latencies makes sense only in the case of a deep zoom. - * Here we set a threshold based on the total number of entries being - * visualized by the model. - * Don't be afraid to play with different values for this threshold. - */ - if (argvCpp->_histo->tot_count > PLUGIN_MAX_ENTRIES) - return; try { pluginDraw(plugin_ctx, kshark_ctx, argvCpp->_histo, col, diff --git a/kernel-shark-qt/src/plugins/sched_events.c b/kernel-shark-qt/src/plugins/sched_events.c index 59ffcfe..1500110 100644 --- a/kernel-shark-qt/src/plugins/sched_events.c +++ b/kernel-shark-qt/src/plugins/sched_events.c @@ -42,6 +42,7 @@ static bool plugin_sched_init_context(struct kshark_context *kshark_ctx) plugin_ctx = plugin_sched_context_handler; plugin_ctx->handle = kshark_ctx->handle; plugin_ctx->pevent = kshark_ctx->pevent; + plugin_ctx->collections = NULL; event = tep_find_event_by_name(plugin_ctx->pevent, "sched", "sched_switch"); @@ -279,6 +280,25 @@ bool plugin_switch_match_entry_pid(struct kshark_context *kshark_ctx, return false; } +/** + * @brief A match function to be used to process a data collections for + * the Sched events plugin. + * + * @param kshark_ctx: Input location for the session context pointer. + * @param e: kshark_entry to be checked. + * @param pid: Matching condition value. + * + * @returns True if the entry is relevant for the Sched events plugin. + * Otherwise false. + */ +bool plugin_match_pid(struct kshark_context *kshark_ctx, + struct kshark_entry *e, int pid) +{ + return plugin_switch_match_entry_pid(kshark_ctx, e, pid) || + plugin_switch_match_rec_pid(kshark_ctx, e, pid) || + plugin_wakeup_match_rec_pid(kshark_ctx, e, pid); +} + static void plugin_sched_action(struct kshark_context *kshark_ctx, struct tep_record *rec, struct kshark_entry *entry) @@ -326,6 +346,7 @@ static int plugin_sched_close(struct kshark_context *kshark_ctx) tracecmd_filter_id_hash_free(plugin_ctx->second_pass_hash); + kshark_free_collection_list(plugin_ctx->collections); 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 28625e3..5318ef3 100644 --- a/kernel-shark-qt/src/plugins/sched_events.h +++ b/kernel-shark-qt/src/plugins/sched_events.h @@ -59,6 +59,9 @@ struct plugin_sched_context { */ struct tep_format_field *sched_wakeup_new_success_field; + /** List of Data collections used by this plugin. */ + struct kshark_entry_collection *collections; + /** Hash of the tasks for which the second pass is already done. */ struct tracecmd_filter_id *second_pass_hash; }; @@ -75,6 +78,9 @@ bool plugin_switch_match_entry_pid(struct kshark_context *kshark_ctx, struct kshark_entry *e, int pid); +bool plugin_match_pid(struct kshark_context *kshark_ctx, + struct kshark_entry *e, int pid); + void plugin_draw(struct kshark_cpp_argv *argv, int pid, int draw_action); #ifdef __cplusplus