All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Wagner <wagi@monom.org>
To: Tom Zanussi <tom.zanussi@linux.intel.com>
Cc: rostedt@goodmis.org, masami.hiramatsu.pt@hitachi.com,
	namhyung@kernel.org, andi@firstfloor.org,
	alexei.starovoitov@gmail.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 0/7] tracing: 'hist' triggers
Date: Tue, 21 Apr 2015 12:36:57 +0200	[thread overview]
Message-ID: <55362849.7020000@monom.org> (raw)
In-Reply-To: <1429567429.2757.7.camel@picadillo>

Hi Tom,

On 04/21/2015 12:03 AM, Tom Zanussi wrote:
> On Mon, 2015-04-20 at 14:52 +0200, Daniel Wagner wrote:
>> On 04/10/2015 06:05 PM, Tom Zanussi wrote:
>> So I am wondering if the path from ftrace_trigger_soft_disabled()
>> to event_triggers_call() is supposed never to happen? The comment
>> on ftrace_trigger_soft_disabled() indicate this might happen on
>> normal operation:
>>
> 
> So I looked at this on the plane and you're right, this is a path that
> should never be taken in this case, since the hist trigger does set the
> post_trigger flag and should therefore TRIGGER_COND would be true and
> that block should never be entered.
> 
> However, the code that registers the trigger first enables the event,
> then sets the cond flag, which would allow this to happen - a trigger
> expecting data would be passed a NULL rec.
> 
> Can you try the patch below and see if it fixes the problem? (untested
> and I haven't even had a chance to compile-test it..)

Thanks for the explanation. With that and your patch I could get
it working. There are a couple of calling places missing in your
patch. With them it works nicely. Maybe moving update_cond_flag()
inside trace_event_trigger_enable_disable() would be an option?

cheers,
daniel


diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
index 4d8f5df..221ab1f 100644
--- a/kernel/trace/trace_events_hist.c
+++ b/kernel/trace/trace_events_hist.c
@@ -1471,11 +1471,12 @@ static int hist_register_trigger(char *glob, struct event_trigger_ops *ops,
 	list_add_rcu(&data->list, &file->triggers);
 	ret++;
 
+	update_cond_flag(file);
 	if (trace_event_trigger_enable_disable(file, 1) < 0) {
 		list_del_rcu(&data->list);
+		update_cond_flag(file);
 		ret--;
 	}
-	update_cond_flag(file);
  out:
 	return ret;
 }
diff --git a/kernel/trace/trace_events_trigger.c b/kernel/trace/trace_events_trigger.c
index 8c8f2ee..e47a229 100644
--- a/kernel/trace/trace_events_trigger.c
+++ b/kernel/trace/trace_events_trigger.c
@@ -1264,6 +1264,7 @@ int event_enable_trigger_func(struct event_command *cmd_ops,
 		goto out_free;
 	}
 
+	update_cond_flag(file);
 	ret = trace_event_enable_disable(event_enable_file, 1, 1);
 	if (ret < 0)
 		goto out_put;
@@ -1286,6 +1287,7 @@ int event_enable_trigger_func(struct event_command *cmd_ops,
  out_disable:
 	trace_event_enable_disable(event_enable_file, 0, 1);
  out_put:
+	update_cond_flag(file);
 	module_put(event_enable_file->event_call->mod);
  out_free:
 	if (cmd_ops->set_filter)



 
> Tom
> 
> [PATCH] tracing: Update cond flag before enabling or disabling a trigger
> 
> Before a trigger is enabled, the cond flag should be set beforehand,
> otherwise an trigger that's expecting to process a trace record
> (e.g. one with post_trigger set) could be invoked without one.
> 
> Likewise a trigger's cond flag should be reset after it's disabled,
> not before.
> 
> Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>
> ---
>  kernel/trace/trace_events_trigger.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/kernel/trace/trace_events_trigger.c b/kernel/trace/trace_events_trigger.c
> index 7105f15..108e46c 100644
> --- a/kernel/trace/trace_events_trigger.c
> +++ b/kernel/trace/trace_events_trigger.c
> @@ -546,11 +546,12 @@ static int register_trigger(char *glob, struct event_trigger_ops *ops,
>  	list_add_rcu(&data->list, &file->triggers);
>  	ret++;
>  
> +	update_cond_flag(file);
>  	if (trace_event_trigger_enable_disable(file, 1) < 0) {
>  		list_del_rcu(&data->list);
> +		update_cond_flag(file);
>  		ret--;
>  	}
> -	update_cond_flag(file);
>  out:
>  	return ret;
>  }
> @@ -578,8 +579,8 @@ void unregister_trigger(char *glob, struct event_trigger_ops *ops,
>  		if (data->cmd_ops->trigger_type == test->cmd_ops->trigger_type) {
>  			unregistered = true;
>  			list_del_rcu(&data->list);
> -			update_cond_flag(file);
>  			trace_event_trigger_enable_disable(file, 0);
> +			update_cond_flag(file);
>  			break;
>  		}
>  	}
> @@ -1324,11 +1325,12 @@ int event_enable_register_trigger(char *glob,
>  	list_add_rcu(&data->list, &file->triggers);
>  	ret++;
>  
> +	update_cond_flag(file);
>  	if (trace_event_trigger_enable_disable(file, 1) < 0) {
>  		list_del_rcu(&data->list);
> +		update_cond_flag(file);
>  		ret--;
>  	}
> -	update_cond_flag(file);
>  out:
>  	return ret;
>  }
> @@ -1351,8 +1353,8 @@ void event_enable_unregister_trigger(char *glob,
>  		    (enable_data->file == test_enable_data->file)) {
>  			unregistered = true;
>  			list_del_rcu(&data->list);
> -			update_cond_flag(file);
>  			trace_event_trigger_enable_disable(file, 0);
> +			update_cond_flag(file);
>  			break;
>  		}
>  	}
> 

  reply	other threads:[~2015-04-21 10:37 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-10 16:05 [PATCH v4 0/7] tracing: 'hist' triggers Tom Zanussi
2015-04-10 16:05 ` [PATCH v4 1/7] tracing: Make ftrace_event_field checking functions available Tom Zanussi
2015-04-10 16:05 ` [PATCH v4 2/7] tracing: Add event record param to trigger_ops.func() Tom Zanussi
2015-04-10 16:05 ` [PATCH v4 3/7] tracing: Add get_syscall_name() Tom Zanussi
2015-04-10 16:05 ` [PATCH v4 4/7] tracing: Add a per-event-trigger 'paused' field Tom Zanussi
2015-04-10 16:05 ` [PATCH v4 5/7] tracing: Add 'hist' event trigger command Tom Zanussi
2015-04-10 16:05 ` [PATCH v4 6/7] tracing: Add enable_hist/disable_hist triggers Tom Zanussi
2015-04-10 16:05 ` [PATCH v4 7/7] tracing: Add 'hist' trigger Documentation Tom Zanussi
2015-04-20 12:52 ` [PATCH v4 0/7] tracing: 'hist' triggers Daniel Wagner
2015-04-20 14:15   ` Tom Zanussi
2015-04-20 22:03   ` Tom Zanussi
2015-04-21 10:36     ` Daniel Wagner [this message]
2015-04-21 19:03       ` Tom Zanussi

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=55362849.7020000@monom.org \
    --to=wagi@monom.org \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andi@firstfloor.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masami.hiramatsu.pt@hitachi.com \
    --cc=namhyung@kernel.org \
    --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 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.