@@ -193,8 +193,6 @@ static void pluginDraw(plugin_sched_context *plugin_ctx,
return;
}
-static std::unordered_set<int> 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,
@@ -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;
@@ -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);
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 <ykaradzhov@vmware.com> --- 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(-)