mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
To: Tom Zanussi <tom.zanussi@linux.intel.com>
Cc: rostedt@goodmis.org, jovi.zhangwei@huawei.com,
	linux-kernel@vger.kernel.org, Oleg Nesterov <oleg@redhat.com>
Subject: Re: [PATCH v3 2/9] tracing: add basic event trigger framework
Date: Mon, 22 Jul 2013 20:19:04 +0900	[thread overview]
Message-ID: <51ED1528.8070807@hitachi.com> (raw)
In-Reply-To: <8392a194f5994bc59b387bcde5cab5588e341fff.1374245042.git.tom.zanussi@linux.intel.com>

(2013/07/20 0:09), Tom Zanussi wrote:
> diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
> index af6eb2c..d3e8626 100644
> --- a/kernel/trace/trace.h
> +++ b/kernel/trace/trace.h
> @@ -1021,6 +1021,43 @@ extern int event_trace_del_tracer(struct trace_array *tr);
>  extern struct mutex event_mutex;
>  extern struct list_head ftrace_events;
>  
> +extern const struct file_operations event_trigger_fops;
> +
> +extern int register_trigger_cmds(void);
> +
> +struct event_trigger_ops {
> +	void			(*func)(void **data);
> +	int			(*init)(struct event_trigger_ops *ops,
> +					void **data);
> +	void			(*free)(struct event_trigger_ops *ops,
> +					void **data);
> +	int			(*print)(struct seq_file *m,
> +					 struct event_trigger_ops *ops,
> +					 void *data);
> +};

Please add comments what each ops does. :)

> +
> +struct event_command {
> +	struct list_head	list;
> +	char			*name;
> +	enum trigger_mode	trigger_mode;
> +	int			(*func)(struct event_command *cmd_ops,
> +					void *cmd_data,	char *glob, char *cmd,
> +					char *params, int enable);
> +	int			(*reg)(char *glob,
> +				       struct event_trigger_ops *trigger_ops,
> +				       void *trigger_data, void *cmd_data);
> +	void			(*unreg)(char *glob,
> +					 struct event_trigger_ops *trigger_ops,
> +					 void *trigger_data, void *cmd_data);
> +	int			(*set_filter)(char *filter_str,
> +					      void *trigger_data,
> +					      void *cmd_data);
> +	struct event_trigger_ops *(*get_trigger_ops)(char *cmd, char *param);
> +};

Ditto.

[...]
> +static int event_trigger_regex_open(struct inode *inode, struct file *file)
> +{
> +	struct trigger_iterator *iter;
> +	int ret = 0;
> +
> +	iter = kzalloc(sizeof(*iter), GFP_KERNEL);
> +	if (!iter)
> +		return -ENOMEM;
> +
> +	iter->file = inode->i_private;
> +
> +	mutex_lock(&event_mutex);
> +
> +	if (file->f_mode & FMODE_READ) {
> +		ret = seq_open(file, &event_triggers_seq_ops);
> +		if (!ret) {
> +			struct seq_file *m = file->private_data;
> +			m->private = iter;
> +		} else {
> +			/* Failed */
> +			kfree(iter);
> +		}
> +	} else
> +		file->private_data = iter;
> +

Perhaps, unfortunately, this will not work correctly if currently
discussing bugfix approach is applied.

Oleg, would you help us what this should be?

> +	mutex_unlock(&event_mutex);
> +
> +	return ret;
> +}

[...]

> +static int unregister_event_command(struct event_command *cmd,
> +				    struct list_head *cmd_list,
> +				    struct mutex *cmd_list_mutex)
> +{
> +	struct event_command *p, *n;
> +	int ret = -ENODEV;
> +
> +	mutex_lock(cmd_list_mutex);
> +	list_for_each_entry_safe(p, n, cmd_list, list) {
> +		if (strcmp(cmd->name, p->name) == 0) {
> +			ret = 0;
> +			list_del_init(&p->list);
> +			goto out_unlock;
> +		}
> +	}
> + out_unlock:
> +	mutex_unlock(cmd_list_mutex);
> +
> +	return ret;
> +}

OK, it seems that this is used only for rollback process in __init
functions. If so, it should have __init (and a comment),
or we need a refcount to check no one uses the command anymore.

Thank you,

-- 
Masami HIRAMATSU
IT Management Research Dept. Linux Technology Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: masami.hiramatsu.pt@hitachi.com



  reply	other threads:[~2013-07-22 11:19 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-19 15:09 [PATCH v3 0/9] tracing: trace event triggers Tom Zanussi
2013-07-19 15:09 ` [PATCH v3 1/9] tracing: Add support for SOFT_DISABLE to syscall events Tom Zanussi
2013-07-22  7:53   ` Masami Hiramatsu
2013-07-19 15:09 ` [PATCH v3 2/9] tracing: add basic event trigger framework Tom Zanussi
2013-07-22 11:19   ` Masami Hiramatsu [this message]
2013-07-19 15:09 ` [PATCH v3 3/9] tracing: add 'traceon' and 'traceoff' event trigger commands Tom Zanussi
2013-07-22 11:09   ` Masami Hiramatsu
2013-07-19 15:09 ` [PATCH v3 4/9] tracing: add 'snapshot' event trigger command Tom Zanussi
2013-07-19 15:09 ` [PATCH v3 5/9] tracing: add 'stacktrace' " Tom Zanussi
2013-07-19 15:09 ` [PATCH v3 6/9] tracing: add 'enable_event' and 'disable_event' event trigger commands Tom Zanussi
2013-07-19 15:09 ` [PATCH v3 7/9] tracing: add and use generic set_trigger_filter() implementation Tom Zanussi
2013-07-19 15:09 ` [PATCH v3 8/9] tracing: update event filters for multibuffer Tom Zanussi
2013-07-19 15:09 ` [PATCH v3 9/9] tracing: add documentation for trace event triggers Tom Zanussi
2013-07-22  7:35 ` [PATCH v3 0/9] tracing: " Masami Hiramatsu

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=51ED1528.8070807@hitachi.com \
    --to=masami.hiramatsu.pt@hitachi.com \
    --cc=jovi.zhangwei@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleg@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=tom.zanussi@linux.intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome