linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "zhangwei(Jovi)" <jovi.zhangwei@huawei.com>
To: Tom Zanussi <tom.zanussi@linux.intel.com>
Cc: <rostedt@goodmis.org>, <masami.hiramatsu.pt@hitachi.com>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 03/11] tracing: add soft disable for syscall events
Date: Sat, 29 Jun 2013 14:26:40 +0800	[thread overview]
Message-ID: <51CE7E20.9030909@huawei.com> (raw)
In-Reply-To: <d7a32766817e9050997629b195676e357e410726.1372479499.git.tom.zanussi@linux.intel.com>

On 2013/6/29 13:08, Tom Zanussi wrote:
> Add support for SOFT_DISABLE to syscall events.
> 
> The original SOFT_DISABLE patches didn't add support for soft disable
> of syscall events; this adds it and paves the way for future patches
> allowing triggers to be added to syscall events, since triggers are
> built on top of SOFT_DISABLE.
> 
> The existing code grabs the trace_array from the ftrace_file passed to
> the event registration functions and passes that to the probe
> functions.  Passing the file instead allows the probe functions to
> access not only the trace_array attached to the file but the flags as
> well.
> 
> Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>
> ---
>  kernel/trace/trace_syscalls.c | 20 ++++++++++++++------
>  1 file changed, 14 insertions(+), 6 deletions(-)
> 
> diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
> index 8f2ac73..1765088 100644
> --- a/kernel/trace/trace_syscalls.c
> +++ b/kernel/trace/trace_syscalls.c
> @@ -301,7 +301,8 @@ static int __init syscall_exit_define_fields(struct ftrace_event_call *call)
>  
>  static void ftrace_syscall_enter(void *data, struct pt_regs *regs, long id)
>  {
> -	struct trace_array *tr = data;
> +	struct ftrace_event_file *ftrace_file = data;
> +	struct trace_array *tr = ftrace_file->tr;
>  	struct syscall_trace_enter *entry;
>  	struct syscall_metadata *sys_data;
>  	struct ring_buffer_event *event;
> @@ -319,6 +320,9 @@ static void ftrace_syscall_enter(void *data, struct pt_regs *regs, long id)
>  	if (!sys_data)
>  		return;
>  
> +	if (test_bit(FTRACE_EVENT_FL_SOFT_DISABLED_BIT, &ftrace_file->flags))
> +		return;
> +
>  	size = sizeof(*entry) + sizeof(unsigned long) * sys_data->nb_args;
>  
>  	buffer = tr->trace_buffer.buffer;
> @@ -338,7 +342,8 @@ static void ftrace_syscall_enter(void *data, struct pt_regs *regs, long id)
>  
>  static void ftrace_syscall_exit(void *data, struct pt_regs *regs, long ret)
>  {
> -	struct trace_array *tr = data;
> +	struct ftrace_event_file *ftrace_file = data;
> +	struct trace_array *tr = ftrace_file->tr;
>  	struct syscall_trace_exit *entry;
>  	struct syscall_metadata *sys_data;
>  	struct ring_buffer_event *event;
> @@ -355,6 +360,9 @@ static void ftrace_syscall_exit(void *data, struct pt_regs *regs, long ret)
>  	if (!sys_data)
>  		return;
>  
> +	if (test_bit(FTRACE_EVENT_FL_SOFT_DISABLED_BIT, &ftrace_file->flags))
> +		return;
> +
>  	buffer = tr->trace_buffer.buffer;
>  	event = trace_buffer_lock_reserve(buffer,
>  			sys_data->exit_event->event.type, sizeof(*entry), 0, 0);
> @@ -382,7 +390,7 @@ static int reg_event_syscall_enter(struct ftrace_event_file *file,
>  		return -ENOSYS;
>  	mutex_lock(&syscall_trace_lock);
>  	if (!tr->sys_refcount_enter)
> -		ret = register_trace_sys_enter(ftrace_syscall_enter, tr);
> +		ret = register_trace_sys_enter(ftrace_syscall_enter, file);
>  	if (!ret) {
>  		set_bit(num, tr->enabled_enter_syscalls);
>  		tr->sys_refcount_enter++;

Is this change can work correctly?

It seems that all syscalls in same tr will use same ftrace_event_file(first registered)
in ftrace_syscall_enter/ftrace_syscall_exit, obviously this is wrong.

Basically I think we still need pass tr into register_trace_sys_enter/exit, for
performance reason. If you use ftrace_event_file as argument, then when your are
using command 'perf stat -e syscalls:* -a sleep 10',
it will looping NR_SYSCALLS tracepoints for every syscall enter and exit,
that's unacceptable.

Thanks.

> @@ -404,7 +412,7 @@ static void unreg_event_syscall_enter(struct ftrace_event_file *file,
>  	tr->sys_refcount_enter--;
>  	clear_bit(num, tr->enabled_enter_syscalls);
>  	if (!tr->sys_refcount_enter)
> -		unregister_trace_sys_enter(ftrace_syscall_enter, tr);
> +		unregister_trace_sys_enter(ftrace_syscall_enter, file);
>  	mutex_unlock(&syscall_trace_lock);
>  }
>  
> @@ -420,7 +428,7 @@ static int reg_event_syscall_exit(struct ftrace_event_file *file,
>  		return -ENOSYS;
>  	mutex_lock(&syscall_trace_lock);
>  	if (!tr->sys_refcount_exit)
> -		ret = register_trace_sys_exit(ftrace_syscall_exit, tr);
> +		ret = register_trace_sys_exit(ftrace_syscall_exit, file);
>  	if (!ret) {
>  		set_bit(num, tr->enabled_exit_syscalls);
>  		tr->sys_refcount_exit++;
> @@ -442,7 +450,7 @@ static void unreg_event_syscall_exit(struct ftrace_event_file *file,
>  	tr->sys_refcount_exit--;
>  	clear_bit(num, tr->enabled_exit_syscalls);
>  	if (!tr->sys_refcount_exit)
> -		unregister_trace_sys_exit(ftrace_syscall_exit, tr);
> +		unregister_trace_sys_exit(ftrace_syscall_exit, file);
>  	mutex_unlock(&syscall_trace_lock);
>  }
>  
> 



  reply	other threads:[~2013-06-29  6:27 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-29  5:08 [PATCH v2 00/11] tracing: trace event triggers Tom Zanussi
2013-06-29  5:08 ` [PATCH v2 01/11] tracing: simplify event_enable_read() Tom Zanussi
2013-06-29  5:08 ` [PATCH v2 02/11] tracing: add missing syscall_metadata comment Tom Zanussi
2013-06-29  5:08 ` [PATCH v2 03/11] tracing: add soft disable for syscall events Tom Zanussi
2013-06-29  6:26   ` zhangwei(Jovi) [this message]
2013-07-01 11:26   ` Masami Hiramatsu
2013-06-29  5:08 ` [PATCH v2 04/11] tracing: fix disabling of soft disable Tom Zanussi
2013-06-29  5:08 ` [PATCH v2 05/11] tracing: add basic event trigger framework Tom Zanussi
2013-06-29  5:08 ` [PATCH v2 06/11] tracing: add 'traceon' and 'traceoff' event trigger commands Tom Zanussi
2013-06-29  5:08 ` [PATCH v2 07/11] tracing: add 'snapshot' event trigger command Tom Zanussi
2013-06-29  5:08 ` [PATCH v2 08/11] tracing: add 'stacktrace' " Tom Zanussi
2013-06-29  5:08 ` [PATCH v2 09/11] tracing: add 'enable_event' and 'disable_event' event trigger commands Tom Zanussi
2013-06-29  5:08 ` [PATCH v2 10/11] tracing: add and use generic set_trigger_filter() implementation Tom Zanussi
2013-06-29  5:08 ` [PATCH v2 11/11] tracing: add documentation for trace event triggers Tom Zanussi
2013-06-29  9:30 ` [PATCH v2 00/11] tracing: " zhangwei(Jovi)
2013-07-01 12:32   ` Masami Hiramatsu
2013-07-02  4:53     ` zhangwei(Jovi)
2013-07-01 15:49   ` Tom Zanussi
2013-07-02  3:54     ` zhangwei(Jovi)
2013-07-02 14:46       ` 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=51CE7E20.9030909@huawei.com \
    --to=jovi.zhangwei@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masami.hiramatsu.pt@hitachi.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;
as well as URLs for NNTP newsgroup(s).