From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752918AbdKJO1e (ORCPT ); Fri, 10 Nov 2017 09:27:34 -0500 Received: from mail.kernel.org ([198.145.29.99]:34534 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751022AbdKJO1d (ORCPT ); Fri, 10 Nov 2017 09:27:33 -0500 DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3E51B218C5 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=goodmis.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=rostedt@goodmis.org Date: Fri, 10 Nov 2017 09:27:30 -0500 From: Steven Rostedt To: "Yordan Karadzhov (VMware)" Cc: jan.kiszka@siemens.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 2/4] kernelshark: Adding a GUI event handler Message-ID: <20171110092730.41526356@gandalf.local.home> In-Reply-To: <20171110122915.24929-2-y.karadz@gmail.com> References: <20171110122915.24929-1-y.karadz@gmail.com> <20171110122915.24929-2-y.karadz@gmail.com> X-Mailer: Claws Mail 3.14.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 10 Nov 2017 14:29:13 +0200 "Yordan Karadzhov (VMware)" wrote: > gui_event_handler is defined. Instruments for dealing > with this handler are added. Please add why this patch is needed in the change log. > > Signed-off-by: Yordan Karadzhov (VMware) > --- > Makefile | 6 ++--- > kshark-plugin.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > kshark-plugin.h | 22 ++++++++++++++++++ > 3 files changed, 94 insertions(+), 3 deletions(-) > create mode 100644 kshark-plugin.c > > diff --git a/Makefile b/Makefile > index 8d0f16f..992e6b0 100644 > --- a/Makefile > +++ b/Makefile > @@ -348,17 +348,17 @@ $(obj)/%.o: $(src)/%.c > $(Q)$(call check_gui) > > TRACE_GUI_OBJS = trace-filter.o trace-compat.o trace-filter-hash.o trace-dialog.o \ > - trace-xml.o > + trace-xml.o kshark-plugin.o > TRACE_CMD_OBJS = trace-cmd.o trace-record.o trace-read.o trace-split.o trace-listen.o \ > trace-stack.o trace-hist.o trace-mem.o trace-snapshot.o trace-stat.o \ > trace-hash.o trace-profile.o trace-stream.o trace-record.o trace-restore.o \ > trace-check-events.o trace-show.o trace-list.o > -TRACE_VIEW_OBJS = trace-view.o trace-view-store.o > +TRACE_VIEW_OBJS = trace-view.o trace-view-store.o kshark-plugin.o > TRACE_GRAPH_OBJS = trace-graph.o trace-plot.o trace-plot-cpu.o trace-plot-task.o > TRACE_VIEW_MAIN_OBJS = trace-view-main.o $(TRACE_VIEW_OBJS) $(TRACE_GUI_OBJS) > TRACE_GRAPH_MAIN_OBJS = trace-graph-main.o $(TRACE_GRAPH_OBJS) $(TRACE_GUI_OBJS) > KERNEL_SHARK_OBJS = $(TRACE_VIEW_OBJS) $(TRACE_GRAPH_OBJS) $(TRACE_GUI_OBJS) \ > - trace-capture.o kernel-shark.o > + trace-capture.o kernel-shark.o kshark-plugin.o > > PEVENT_LIB_OBJS = event-parse.o trace-seq.o parse-filter.o parse-utils.o str_error_r.o > TCMD_LIB_OBJS = $(PEVENT_LIB_OBJS) trace-util.o trace-input.o trace-ftrace.o \ > diff --git a/kshark-plugin.c b/kshark-plugin.c > new file mode 100644 > index 0000000..6532512 > --- /dev/null > +++ b/kshark-plugin.c > @@ -0,0 +1,69 @@ > +/* > + * Copyright (C) 2017 VMware Inc, Yordan Karadzhov > + * > + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License as published by > + * the Free Software Foundation; version 2 of the License (not later!) > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + * > + * You should have received a copy of the GNU General Public License > + * along with this program; if not, see > + * > + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > + */ > + > +#include > + > +#include "kshark-plugin.h" > + > +struct gui_event_handler *make_gui_event_handler(int event_id, int type, > + kshark_plugin_event_handler_func evt_func, > + kshark_plugin_context_update_func ctx_func) > +{ > + struct gui_event_handler *handler = malloc(sizeof(struct gui_event_handler)); > + > + if (!handler) > + return NULL; > + > + handler->next = NULL; > + handler->id = event_id; > + handler->type = type; > + handler->event_func = evt_func; > + handler->context_func = ctx_func; > + > + return handler; > +} > + > +struct gui_event_handler *find_gui_event_handler(struct gui_event_handler *handlers, > + int event_id) > +{ > + while (handlers) { > + if (handlers->id == event_id) > + return handlers; > + > + handlers = handlers->next; > + } > + > + return NULL; > +} > + > +void unregister_gui_event_handler(struct gui_event_handler **handlers, int event_id) > +{ > + struct gui_event_handler **last = handlers; > + struct gui_event_handler *list; > + > + for (list = *handlers; list; list = list->next) { > + if (list->id == event_id) { > + *last = list->next; > + return; > + } > + > + last = &list->next; > + } Is something suppose to free the gui_event_handler? Should there be a matching register_gui_event_handler()? -- Steve > +} > diff --git a/kshark-plugin.h b/kshark-plugin.h > index 81c09b5..d65ee02 100644 > --- a/kshark-plugin.h > +++ b/kshark-plugin.h > @@ -50,4 +50,26 @@ enum gui_plugin_actions { > KSHARK_PLUGIN_UNLOAD, > }; > > +enum gui_event_types { > + KSHARK_PLUGIN_SWITCH_EVENT, > + KSHARK_PLUGIN_WAKEUP_EVENT, > +}; > + > +struct gui_event_handler { > + struct gui_event_handler *next; > + int id; > + int type; > + kshark_plugin_event_handler_func event_func; > + kshark_plugin_context_update_func context_func; > +}; > + > +struct gui_event_handler *make_gui_event_handler(int event_id, int type, > + kshark_plugin_event_handler_func evt_func, > + kshark_plugin_context_update_func ctx_func); > + > +struct gui_event_handler *find_gui_event_handler(struct gui_event_handler *handlers, > + int event_id); > + > +void unregister_gui_event_handler(struct gui_event_handler **handlers, int event_id); > + > #endif