All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: "Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
Cc: linux-trace-devel@vger.kernel.org
Subject: Re: [PATCH 2/7] kernel-shark-qt: Add Plugin event handlers to session.
Date: Wed, 29 Aug 2018 22:08:08 -0400	[thread overview]
Message-ID: <20180829220808.5dc8057a@vmware.local.home> (raw)
In-Reply-To: <20180829164224.20677-3-y.karadz@gmail.com>

On Wed, 29 Aug 2018 19:42:19 +0300
"Yordan Karadzhov (VMware)" <y.karadz@gmail.com> wrote:

> Plugin event handlers are added to the Session context descriptor.
> The handlers are used to execute plugin-specific actions (callback
> function) during the processing of the trace data.
> 
> Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
> ---
>  kernel-shark-qt/src/libkshark.c | 24 ++++++++++++++++++++++++
>  kernel-shark-qt/src/libkshark.h | 12 ++++++++++++
>  2 files changed, 36 insertions(+)
> 
> diff --git a/kernel-shark-qt/src/libkshark.c b/kernel-shark-qt/src/libkshark.c
> index b4a76ae..3d9f0d5 100644
> --- a/kernel-shark-qt/src/libkshark.c
> +++ b/kernel-shark-qt/src/libkshark.c
> @@ -33,6 +33,9 @@ static bool kshark_default_context(struct kshark_context **context)
>  	if (!kshark_ctx)
>  		return false;
>  
> +	kshark_ctx->event_handlers = NULL;
> +	kshark_ctx->plugins = NULL;
> +
>  	kshark_ctx->show_task_filter = tracecmd_filter_id_hash_alloc();
>  	kshark_ctx->hide_task_filter = tracecmd_filter_id_hash_alloc();
>  
> @@ -217,6 +220,12 @@ void kshark_free(struct kshark_context *kshark_ctx)
>  	tracecmd_filter_id_hash_free(kshark_ctx->show_event_filter);
>  	tracecmd_filter_id_hash_free(kshark_ctx->hide_event_filter);
>  
> +	if(kshark_ctx->plugins) {
> +		kshark_handle_plugins(kshark_ctx, KSHARK_PLUGIN_UNLOAD);
> +		kshark_free_plugin_list(kshark_ctx->plugins);
> +		kshark_free_event_handler_list(kshark_ctx->event_handlers);
> +	}
> +
>  	kshark_free_task_list(kshark_ctx);
>  
>  	if (seq.buffer)
> @@ -564,6 +573,7 @@ static void free_rec_list(struct rec_list **rec_list, int n_cpus,
>  static size_t get_records(struct kshark_context *kshark_ctx,
>  			  struct rec_list ***rec_list, enum rec_type type)
>  {
> +	struct kshark_event_handler *evt_handler;
>  	struct event_filter *adv_filter;
>  	struct kshark_task_list *task;
>  	struct tep_record *rec;
> @@ -608,6 +618,20 @@ static size_t get_records(struct kshark_context *kshark_ctx,
>  
>  				entry = &temp_rec->entry;
>  				kshark_set_entry_values(kshark_ctx, rec, entry);
> +
> +				/* Execute all plugin-provided actions (if any). */
> +				evt_handler = kshark_ctx->event_handlers;
> +				while ((evt_handler =
> +						find_event_handler(evt_handler,
> +								   entry->event_id))) {

Note, the 80 character line limit is a guideline and not a rule. Part
of that guideline states "If breaking up the line makes the code less
readable, then it should not be broken up". The above makes the code
less readable ;-)

				while ((evt_handler = find_event_handler(evt_handler, entry->event_id))) {

Is fine. Or if you do want to break it, it can be broken as:

				while ((evt_handler = find_event_handler(evt_handler,
									 entry->event_id))) {



> +					evt_handler->event_func(kshark_ctx,
> +								rec, entry);
> +
> +					if ((evt_handler = evt_handler->next))
> +						entry->visible &=
> +							~KS_PLUGIN_UNTOUCHED_MASK;

Same here. Don't be too strict with the 80 char limit.

-- Steve

> +				}
> +
>  				pid = entry->pid;
>  				/* Apply event filtering. */
>  				ret = FILTER_MATCH;
> diff --git a/kernel-shark-qt/src/libkshark.h b/kernel-shark-qt/src/libkshark.h
> index fda133c..203c812 100644
> --- a/kernel-shark-qt/src/libkshark.h
> +++ b/kernel-shark-qt/src/libkshark.h
> @@ -29,6 +29,9 @@ extern "C" {
>  #include "event-parse.h"
>  #include "trace-filter-hash.h"
>  
> +// KernelShark
> +#include "libkshark-plugin.h"
> +
>  /**
>   * Kernel Shark entry contains all information from one trace record needed
>   * in order to  visualize the time-series of trace records. The part of the
> @@ -124,6 +127,9 @@ struct kshark_context {
>  
>  	/** List of Plugins. */
>  	struct kshark_plugin_list	*plugins;
> +
> +	/** List of Plugin Event handlers. */
> +	struct kshark_event_handler	*event_handlers;
>  };
>  
>  bool kshark_instance(struct kshark_context **kshark_ctx);
> @@ -160,6 +166,12 @@ enum kshark_filter_masks {
>  
>  	/** Special mask used whene filtering events. */
>  	KS_EVENT_VIEW_FILTER_MASK	= 1 << 2,
> +
> +	/**
> +	 * Use this mask to check if the content of the entry has been accessed
> +	 * by a plugin-defined function.
> +	 */
> +	KS_PLUGIN_UNTOUCHED_MASK	= 1 << 7
>  };
>  
>  /** Filter type identifier. */

  reply	other threads:[~2018-08-30  6:07 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-29 16:42 [PATCH 0/7] The infrastructure for plugins used by the Qt-based Yordan Karadzhov (VMware)
2018-08-29 16:42 ` [PATCH 1/7] kernel-shark-qt: Add plugin infrastructure to be used by the Qt-baset KS Yordan Karadzhov (VMware)
2018-08-29 20:12   ` Steven Rostedt
2018-08-29 20:17   ` Steven Rostedt
2018-08-29 20:32   ` Steven Rostedt
2018-08-30 11:45     ` Yordan Karadzhov (VMware)
2018-08-30 16:17       ` Steven Rostedt
2018-08-29 16:42 ` [PATCH 2/7] kernel-shark-qt: Add Plugin event handlers to session Yordan Karadzhov (VMware)
2018-08-30  2:08   ` Steven Rostedt [this message]
2018-08-29 16:42 ` [PATCH 3/7] kernel-shark-qt: Add C++/C conversion for args of a plugin draw function Yordan Karadzhov (VMware)
2018-08-29 16:42 ` [PATCH 4/7] kernel-shark-qt: Make kshark_read_at() non-static Yordan Karadzhov (VMware)
2018-08-29 16:42 ` [PATCH 5/7] kernel-shark-qt: Add src/plugins dir. to hold the source code of the plugins Yordan Karadzhov (VMware)
2018-08-29 16:42 ` [PATCH 6/7] kernel-shark-qt: Tell Doxygen to enter ../src/plugins/ Yordan Karadzhov (VMware)
2018-08-29 16:42 ` [PATCH 7/7] kernel-shark-qt: Add a plugin for sched events Yordan Karadzhov (VMware)
2018-08-30  2:43   ` Steven Rostedt
2018-08-30 11:48     ` Yordan Karadzhov (VMware)
2018-08-30 11:49       ` Yordan Karadzhov (VMware)
2018-08-30 14:12       ` Steven Rostedt
2018-08-30 11:51     ` Yordan Karadzhov (VMware)
2018-08-30 14:13       ` Steven Rostedt
2018-08-30 14:50     ` Steven Rostedt
2018-08-30 17:38   ` Steven Rostedt
2018-08-29 16:49 ` [PATCH 0/7] Add infrastructure for plugins Yordan Karadzhov (VMware)
  -- strict thread matches above, loose matches on Subject: below --
2018-09-04 15:52 Yordan Karadzhov (VMware)
2018-09-04 15:52 ` [PATCH 2/7] kernel-shark-qt: Add Plugin event handlers to session Yordan Karadzhov (VMware)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180829220808.5dc8057a@vmware.local.home \
    --to=rostedt@goodmis.org \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=y.karadz@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.