linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: "zhangwei(Jovi)" <jovi.zhangwei@huawei.com>
Cc: Steven Rostedt <rostedt@goodmis.org>,
	Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Ingo Molnar <mingo@redhat.com>,
	Srikar Dronamraju <srikar@linux.vnet.ibm.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] tracing/uprobes: Support ftrace_event_file base multibuffer
Date: Mon, 24 Jun 2013 20:05:47 +0200	[thread overview]
Message-ID: <20130624180547.GA2794@redhat.com> (raw)
In-Reply-To: <51C7ED2B.4040701@huawei.com>

Hi Jovi,

I'll try to read this patch carefully tomorrow.

Looks fine at first glance, but some nits below.

On 06/24, zhangwei(Jovi) wrote:
>
>  static int uprobe_trace_func(struct trace_uprobe *tu, struct pt_regs *regs)
>  {
> -	if (!is_ret_probe(tu))
> -		uprobe_trace_print(tu, 0, regs);
> +	struct event_file_link *link;
> +
> +	if (is_ret_probe(tu))
> +		return 0;
> +
> +	rcu_read_lock();
> +
> +	list_for_each_entry(link, &tu->files, list)
> +		uprobe_trace_print(tu, 0, regs, link->file);
> +
> +	rcu_read_unlock();

Purely cosmetic and I won't argue, but why the empty lines around
list_for_each_entry() ?

>  static int
> -probe_event_enable(struct trace_uprobe *tu, int flag, filter_func_t filter)
> +probe_event_enable(struct trace_uprobe *tu, struct ftrace_event_file *file,
> +		   filter_func_t filter)
>  {
> +	int enabled = 0;
>  	int ret = 0;
> 
> -	if (is_trace_uprobe_enabled(tu))
> +	/*
> +	 * Currently TP_FLAG_TRACE/TP_FLAG_PROFILE are mutually exclusive
> +	 * for uprobe(filter argument issue), this need to fix in future.
> +	 */
> +	if ((file && (tu->flags & TP_FLAG_PROFILE)) ||
> +	    (!file && (tu->flags & TP_FLAG_TRACE)))
>  		return -EINTR;

Well, this looks confusing and overcomplicated, see below.

> +	/* Currently we cannot call uprobe_register twice for same tu */
> +	if (is_trace_uprobe_enabled(tu))
> +		enabled = 1;

The comment is wrong. It is not that we can't do this "Currently".

We must not do uprobe_register(..., consumer) twice, consumer/uprobe
are linked together.

> +	if (file) {
> +		struct event_file_link *link;
> +

Just add
		if (TP_FLAG_PROFILE)
			return -EINTR;

here and kill the complicated check below. Same for the "else" branch.

> +static void
> +probe_event_disable(struct trace_uprobe *tu, struct ftrace_event_file *file)
> +{
> +	if (file) {
> +		struct event_file_link *link;
> +
> +		link = find_event_file_link(tu, file);
> +		if (!link)
> +			return;
> +
> +		list_del_rcu(&link->list);
> +		/* synchronize with uprobe_trace_func/uretprobe_trace_func */
> +		synchronize_sched();
> +		kfree(link);
> +
> +		if (!list_empty(&tu->files))
> +			return;
> +
> +		tu->flags &= ~TP_FLAG_TRACE;
> +	} else
> +		tu->flags &= ~TP_FLAG_PROFILE;
> +
> 
>  	WARN_ON(!uprobe_filter_is_empty(&tu->filter));
> 
> -	uprobe_unregister(tu->inode, tu->offset, &tu->consumer);
> -	tu->flags &= ~flag;
> +	if (!is_trace_uprobe_enabled(tu))
> +		uprobe_unregister(tu->inode, tu->offset, &tu->consumer);

Well, this is not exactly right... Currently this is fine, but still.

It would be better to clear TP_FLAG_TRACE/TP_FLAG_PROFILE after
uprobe_unregister(), when we can't race with the running handler
which can check ->flags.

And I'd suggest you to send the soft-enable/disable change in a
separate (and trivial) patch.

Oleg.


  parent reply	other threads:[~2013-06-24 18:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-24  6:54 [PATCH v2] tracing/uprobes: Support ftrace_event_file base multibuffer zhangwei(Jovi)
2013-06-24 11:49 ` Masami Hiramatsu
2013-06-24 18:05 ` Oleg Nesterov [this message]
2013-06-24 18:53   ` Oleg Nesterov
2013-06-25  3:24   ` zhangwei(Jovi)

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=20130624180547.GA2794@redhat.com \
    --to=oleg@redhat.com \
    --cc=fweisbec@gmail.com \
    --cc=jovi.zhangwei@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masami.hiramatsu.pt@hitachi.com \
    --cc=mingo@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=srikar@linux.vnet.ibm.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;
as well as URLs for NNTP newsgroup(s).