Received: by 10.223.164.202 with SMTP id h10csp173183wrb; Fri, 10 Nov 2017 04:33:10 -0800 (PST) X-Google-Smtp-Source: AGs4zMZa3/A0eeU7WKZKludR8N6ZoIxQuvBEmevVoRH0cUQbhRgpm902SWMs5/AMTF9vuuHwCe0d X-Received: by 10.159.253.147 with SMTP id q19mr240189pls.54.1510317190751; Fri, 10 Nov 2017 04:33:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510317190; cv=none; d=google.com; s=arc-20160816; b=bMrrEeZZoNJPM2+10elaKvW9yTXKhTsv2/x8+15n3yoxBbxJTDtCKvW1Z+5yXbL5EQ duvBFrhUXpwYykqQ/CBjhK31ZxvSuDd7ZwM/naAKLVFi45D2X453tzJKCN5VMKOxAX7F Q96dI60JNKYknINEe/EMZt20zZyt6aAxSYf2SZh9uLfZOSvu0TUqLJtJTJysUGp/pkf4 P3qGICfPDIwHLIQHvz5b3e3a8Np798Kas8zkriPpr14LWiVkoG9C0mPe8UOe4YijQaIB 8YN5WHIUDE/kBhIBJvUnTypaELN+JSToLf4hJ2UtIrPeu4KYOr97fdN9RPMcmXnRgi7d 10lA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=uLi+YgoNjH/qqOsZ8ybkwAoMIJN7UNj8pSAXtj2muw4=; b=AVje12GnaWjkpxvlEjLL9lTRYyZAARiPSW9F0eedoS67Dkf+bmfUCgHvgIdqpWctTf U7tJW3bi5oy3zUQUNwDmqhx75chWKAxfA9vGplgHAfFDRP8ahgf90340YbqSbrOH8ep2 AUcQYkhlJPTMDzQAiAJ1FTgdfB80uBjI1WyLQ50FLsAECihlmK8rUggA6agkSmQtqu+S SBIb7vCtAcVK/qfNCIq+/xsgCqWNM5aZZAEAZAkxS7HZk/Vv9S/oQmZyw4kT2CpPU1eS 1lQzgfrO5TmejIC5nGW5GlF0Ue0tKfJgV+tfkZ0YOfdIt2Ub99tIgbQULEMARSiUshqw eWUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=XSqU/u3p; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n27si560758pgf.117.2017.11.10.04.32.59; Fri, 10 Nov 2017 04:33:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=XSqU/u3p; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753107AbdKJMbF (ORCPT + 82 others); Fri, 10 Nov 2017 07:31:05 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:34052 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753057AbdKJMbC (ORCPT ); Fri, 10 Nov 2017 07:31:02 -0500 Received: by mail-wm0-f68.google.com with SMTP id n74so5681667wmi.1 for ; Fri, 10 Nov 2017 04:31:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=uLi+YgoNjH/qqOsZ8ybkwAoMIJN7UNj8pSAXtj2muw4=; b=XSqU/u3p+SW12V23g6jgSef6oR/p7sl3DvWVx5VWUM9QCnrPYwyVOBbYWJFo3JGk7f tF8eBvB9aqgAidBruxlv84jWHPGHpBsWzlZzDZhuQ7wqA7vcEHUkf+n8SDilUxElQWYd yKYxbCEFqVxYdI0qMuGx3sIegTWMLYitUlk1CMRiWMGdrI9MeAtioP3QpX2s0qd2mmfs KbR73uNrESIhrZgUMO6gtihuyg/O+1pQZdyQRgxUQKupKOXgru1RqOJFOUUBgVa8jpog Rzq+SbTWxcC74mll9qvJ9ynHzTwV7AZpVSTvXoprweJ9J1Hnkc5wGYvf+Dp7bWeJIsBS ustg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=uLi+YgoNjH/qqOsZ8ybkwAoMIJN7UNj8pSAXtj2muw4=; b=b1E3iAZr/YnYalc4WE9R37eNTj2RasvaSIIbju9cAOncE+GBb1f0uijT73KcXlWs1X fAEcBoBN5TD1x0+vmmrUlQanYscy5DOVAFVFuc9rc7FJbqarMR1xdNnrfC4OS6DiRAPg 9IMZKpnXxF1ni2/rVXPAgxz4ZO+vM5Zx3xxt/qJiwSDqYFNjxonsA3vFTEVn/8u4osx2 kqwCM0Lj5BpbwcgmvsRx3l2pAU9UfjjFU5/1TbmgTcGAyCbqfcZMXhKrUVanl8iXvo0W GBLrWual9gz1kevcKQmbNv1u8hpjyU6j5IXLGFM9ktWB41m+eQfpvXAlZxepKuKQtXCO 19uA== X-Gm-Message-State: AJaThX5zvguP5h88WGmrXcGQJX7dwrpOgred9+31Q7LJ9MdDGSN8Opy2 upXEtj61G+1ojOPeOO+4BKY= X-Received: by 10.28.19.73 with SMTP id 70mr91604wmt.87.1510317060826; Fri, 10 Nov 2017 04:31:00 -0800 (PST) Received: from sc9-mailhost2.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id p4sm6196517wrf.36.2017.11.10.04.31.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 04:31:00 -0800 (PST) From: "Yordan Karadzhov (VMware)" To: rostedt@goodmis.org Cc: jan.kiszka@siemens.com, linux-kernel@vger.kernel.org, "Yordan Karadzhov (VMware)" Subject: [PATCH v2 3/4] kernelshark: Adding gui_event_handlers for View and Graph Date: Fri, 10 Nov 2017 14:29:14 +0200 Message-Id: <20171110122915.24929-3-y.karadz@gmail.com> X-Mailer: git-send-email 2.15.0.rc0 In-Reply-To: <20171110122915.24929-1-y.karadz@gmail.com> References: <20171110122915.24929-1-y.karadz@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org gui_event_handlers are added to trace_view_store and graph_info. The handlers are used to execute plugin-specific actions during the processing of the trace data. Signed-off-by: Yordan Karadzhov (VMware) --- kshark-plugin.h | 3 +++ trace-graph.c | 41 +++++++++++++++++++++++++++++++++++++++++ trace-graph.h | 7 +++++++ trace-plot-task.c | 17 +++++++++++++---- trace-view-store.c | 16 ++++++++++++++++ trace-view-store.h | 5 +++++ 6 files changed, 85 insertions(+), 4 deletions(-) diff --git a/kshark-plugin.h b/kshark-plugin.h index d65ee02..42fb40c 100644 --- a/kshark-plugin.h +++ b/kshark-plugin.h @@ -48,6 +48,9 @@ enum gui_plugin_actions { KSHARK_PLUGIN_LOAD, KSHARK_PLUGIN_RELOAD, KSHARK_PLUGIN_UNLOAD, + KSHARK_PLUGIN_GET_PID, + KSHARK_PLUGIN_GET_PREV_STATE, + KSHARK_PLUGIN_GET_COMMAND, }; enum gui_event_types { diff --git a/trace-graph.c b/trace-graph.c index 1db342f..a79aacf 100644 --- a/trace-graph.c +++ b/trace-graph.c @@ -129,6 +129,12 @@ static void free_task_hash(struct graph_info *ginfo) } } +void trace_graph_register_gui_handler(struct graph_info *info, + struct gui_event_handler *handler) { + handler->next = info->event_handlers; + info->event_handlers = handler; +} + /** * trace_graph_task_list - return an allocated list of all found tasks * @ginfo: The graph info structure @@ -1021,6 +1027,7 @@ int trace_graph_check_sched_wakeup(struct graph_info *ginfo, gint *pid) { struct event_format *event; + struct gui_event_handler *handler; unsigned long long val; gboolean found; gint id; @@ -1079,6 +1086,20 @@ int trace_graph_check_sched_wakeup(struct graph_info *ginfo, return 1; } + handler = find_gui_event_handler(ginfo->event_handlers, id); + + if (handler) { + if (handler->type == KSHARK_PLUGIN_WAKEUP_EVENT) { + if (!handler->event_func(record, KSHARK_PLUGIN_GET_PID, &val)) + return 0; + + if (pid) + *pid = val; + + return 1; + } + } + return 0; } @@ -1088,6 +1109,7 @@ int trace_graph_check_sched_switch(struct graph_info *ginfo, { unsigned long long val; struct event_format *event; + struct gui_event_handler *handler; gint this_pid; gint id; int ret = 1; @@ -1118,7 +1140,9 @@ int trace_graph_check_sched_switch(struct graph_info *ginfo, } } + id = pevent_data_type(ginfo->pevent, record); + if (id == ginfo->event_sched_switch_id) { pevent_read_number_field(ginfo->event_pid_field, record->data, &val); if (comm) @@ -1139,6 +1163,20 @@ int trace_graph_check_sched_switch(struct graph_info *ginfo, goto out; } + handler = find_gui_event_handler(ginfo->event_handlers, id); + + if (handler) { + if (handler->type == KSHARK_PLUGIN_SWITCH_EVENT) { + if (handler->event_func(record, KSHARK_PLUGIN_GET_PID, &val)) { + if (pid) + *pid = val; + if(comm) + handler->event_func(record, KSHARK_PLUGIN_GET_COMMAND, &comm); + goto out; + } + } + } + ret = 0; out: if (ret && comm && ginfo->read_comms) { @@ -1285,6 +1323,7 @@ static void draw_info_box(struct graph_info *ginfo, const gchar *buffer, view_start = gtk_adjustment_get_value(ginfo->hadj); view_width = gtk_adjustment_get_page_size(ginfo->hadj); + if (x > view_start + width) x -= width; @@ -2781,6 +2820,8 @@ trace_graph_create_with_callbacks(struct tracecmd_input *handle, ginfo->callbacks = cbs; + ginfo->event_handlers = NULL; + ginfo->task_filter = filter_task_hash_alloc(); ginfo->hide_tasks = filter_task_hash_alloc(); diff --git a/trace-graph.h b/trace-graph.h index 7e66838..21e8feb 100644 --- a/trace-graph.h +++ b/trace-graph.h @@ -24,6 +24,7 @@ #include "trace-cmd.h" #include "trace-filter-hash.h" #include "trace-xml.h" +#include "kshark-plugin.h" struct graph_info; @@ -258,6 +259,8 @@ struct graph_info { gint plot_data_y; gint plot_data_w; gint plot_data_h; + + struct gui_event_handler *event_handlers; }; @@ -266,6 +269,10 @@ trace_graph_create(struct tracecmd_input *handle); struct graph_info * trace_graph_create_with_callbacks(struct tracecmd_input *handle, struct graph_callbacks *cbs); + +void trace_graph_register_gui_handler(struct graph_info *info, + struct gui_event_handler *handler); + void trace_graph_select_by_time(struct graph_info *ginfo, guint64 time); void trace_graph_event_filter_callback(gboolean accept, diff --git a/trace-plot-task.c b/trace-plot-task.c index 3b7e81f..56c3e96 100644 --- a/trace-plot-task.c +++ b/trace-plot-task.c @@ -68,11 +68,20 @@ static gboolean is_running(struct graph_info *ginfo, struct pevent_record *recor int id; id = pevent_data_type(ginfo->pevent, record); - if (id != ginfo->event_sched_switch_id) - return FALSE; - pevent_read_number_field(ginfo->event_prev_state, record->data, &val); - return val & ((1 << 11) - 1)? FALSE : TRUE; + if (id == ginfo->event_sched_switch_id) { + pevent_read_number_field(ginfo->event_prev_state, record->data, &val); + return val & ((1 << 11) - 1)? FALSE : TRUE; + } + + struct gui_event_handler *handler = + find_gui_event_handler(ginfo->event_handlers, id); + if (handler) { + if (handler->type == KSHARK_PLUGIN_SWITCH_EVENT) + return handler->event_func(record, KSHARK_PLUGIN_GET_PREV_STATE, NULL); + } + + return FALSE; } static gboolean record_matches_pid(struct graph_info *ginfo, diff --git a/trace-view-store.c b/trace-view-store.c index f5d0a04..39d0c74 100644 --- a/trace-view-store.c +++ b/trace-view-store.c @@ -70,6 +70,12 @@ static gboolean trace_view_store_iter_parent (GtkTreeModel *tree_model, static GObjectClass *parent_class = NULL; /* GObject stuff - nothing to worry about */ +void trace_view_store_register_gui_handler(TraceViewStore *store, struct gui_event_handler *handler) +{ + handler->next = store->event_handlers; + store->event_handlers = handler; +} + /***************************************************************************** * * trace_view_store_get_type: here we register our new type and its interfaces @@ -866,6 +872,7 @@ trace_view_store_new (struct tracecmd_input *handle) g_assert( newstore != NULL ); + newstore->event_handlers = NULL; newstore->handle = handle; newstore->cpus = tracecmd_cpus(handle); tracecmd_ref(handle); @@ -1194,6 +1201,7 @@ static gboolean show_task(TraceViewStore *store, struct pevent *pevent, struct pevent_record *record, gint pid) { gint event_id; + struct gui_event_handler *ge_handler; if (view_task(store, pid)) return TRUE; @@ -1224,6 +1232,14 @@ static gboolean show_task(TraceViewStore *store, struct pevent *pevent, return TRUE; } + ge_handler = find_gui_event_handler(store->event_handlers, event_id); + + if (ge_handler) { + if (ge_handler->event_func(record, KSHARK_PLUGIN_GET_PID, &pid)) + if (view_task(store, pid)) + return TRUE; + } + return FALSE; } diff --git a/trace-view-store.h b/trace-view-store.h index 03141b1..333116c 100644 --- a/trace-view-store.h +++ b/trace-view-store.h @@ -23,6 +23,7 @@ #include #include "trace-cmd.h" #include "trace-filter-hash.h" +#include "kshark-plugin.h" /* Some boilerplate GObject defines. 'klass' is used * instead of 'class', because 'class' is a C++ keyword */ @@ -125,8 +126,12 @@ struct trace_view_store guint64 *cpu_mask; /* cpus that are enabled */ gint stamp; /* Random integer to check whether an iter belongs to our model */ + + struct gui_event_handler *event_handlers; }; +void trace_view_store_register_gui_handler(TraceViewStore *store, struct gui_event_handler *handler); + gboolean trace_view_store_cpu_isset(TraceViewStore *store, gint cpu); void trace_view_store_set_all_cpus(TraceViewStore *store); -- 2.15.0.rc0 From 1583698896472549549@xxx Fri Nov 10 16:56:02 +0000 2017 X-GM-THRID: 1582233922270524938 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread