From: Li Zefan <lizf@cn.fujitsu.com>
To: Jason Baron <jbaron@redhat.com>
Cc: linux-kernel@vger.kernel.org, fweisbec@gmail.com, mingo@elte.hu,
laijs@cn.fujitsu.com, rostedt@goodmis.org, peterz@infradead.org,
mathieu.desnoyers@polymtl.ca, jiayingz@google.com,
mbligh@google.com, roland@redhat.com, fche@redhat.com
Subject: Re: [PATCH 7/7] V2 add syscall tracepoints
Date: Thu, 25 Jun 2009 10:38:08 +0800 [thread overview]
Message-ID: <4A42E310.3010400@cn.fujitsu.com> (raw)
In-Reply-To: <92f34bb50412cc43e04a484b48cb3452aabce775.1245770664.git.jbaron@redhat.com>
> #endif /* _TRACE_SYSCALL_H */
> diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
> index 08aed43..cc283d6 100644
> --- a/kernel/trace/trace_syscalls.c
> +++ b/kernel/trace/trace_syscalls.c
> @@ -1,15 +1,16 @@
> #include <trace/syscall.h>
> #include <linux/kernel.h>
> +#include <linux/ftrace.h>
> #include <asm/syscall.h>
>
> #include "trace_output.h"
> #include "trace.h"
>
> -/* Keep a counter of the syscall tracing users */
> -static int refcount;
> -
> -/* Prevent from races on thread flags toggling */
> static DEFINE_MUTEX(syscall_trace_lock);
> +static int sys_refcount_enter;
> +static int sys_refcount_exit;
> +static DECLARE_BITMAP(enabled_enter_syscalls, FTRACE_SYSCALL_MAX + 1);
> +static DECLARE_BITMAP(enabled_exit_syscalls, FTRACE_SYSCALL_MAX + 1);
Why "+ 1" ?
> -static int init_syscall_tracer(struct trace_array *tr)
> +int reg_event_syscall_enter(char *name)
> {
> - start_ftrace_syscalls();
> + int ret = 0;
> + int num;
>
> - return 0;
> + num = syscall_name_to_nr(name);
> + if (num < 0 || num > FTRACE_SYSCALL_MAX)
> + return -ENOSYS;
syscall_name_to_nr() returns [0, FTRACE_SYSCALL_MAX) or -1,
so you don't need to check num > MAX, instead it should be
WAR_ON(num >= MAX).
> + mutex_lock(&syscall_trace_lock);
> + if (!sys_refcount_enter)
> + ret = register_trace_syscall_enter(ftrace_syscall_enter);
> + if (ret) {
> + pr_info("event trace: Could not activate"
> + "syscall entry trace point");
Should be:
+ pr_info("event trace: Could not activate "
+ "syscall entry trace point");
> + } else {
> + set_bit(num, enabled_enter_syscalls);
> + sys_refcount_enter++;
> + }
> + mutex_unlock(&syscall_trace_lock);
> + return ret;
> }
> +int reg_event_syscall_exit(char *name)
> {
> - int ret;
> + int ret = 0;
> + int num;
>
> - ret = register_ftrace_event(&syscall_enter_event);
> - if (!ret) {
> - printk(KERN_WARNING "event %d failed to register\n",
> - syscall_enter_event.type);
> - WARN_ON_ONCE(1);
> + num = syscall_name_to_nr(name);
> + if (num < 0 || num > FTRACE_SYSCALL_MAX)
> + return -ENOSYS;
ditto
> + mutex_lock(&syscall_trace_lock);
> + if (!sys_refcount_exit)
> + ret = register_trace_syscall_exit(ftrace_syscall_exit);
> + if (ret) {
> + pr_info("event trace: Could not activate"
> + "syscall exit trace point");
ditto
> + } else {
> + set_bit(num, enabled_exit_syscalls);
> + sys_refcount_exit++;
> }
> + mutex_unlock(&syscall_trace_lock);
> + return ret;
> +}
>
> - ret = register_ftrace_event(&syscall_exit_event);
> - if (!ret) {
> - printk(KERN_WARNING "event %d failed to register\n",
> - syscall_exit_event.type);
> - WARN_ON_ONCE(1);
> - }
> +void unreg_event_syscall_exit(char *name)
> +{
> + int num;
>
> - return register_tracer(&syscall_tracer);
> + num = syscall_name_to_nr(name);
> + if (num < 0 || num > FTRACE_SYSCALL_MAX)
> + return;
ditto
> + mutex_lock(&syscall_trace_lock);
> + sys_refcount_exit--;
> + clear_bit(num, enabled_exit_syscalls);
> + if (!sys_refcount_exit)
> + unregister_trace_syscall_exit(ftrace_syscall_exit);
> + mutex_unlock(&syscall_trace_lock);
> }
next prev parent reply other threads:[~2009-06-25 2:37 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-23 18:28 [PATCH 0/7] V2 add syscall tracepoints Jason Baron
2009-06-23 18:28 ` [PATCH 1/7] " Jason Baron
2009-06-23 18:29 ` [PATCH 2/7] " Jason Baron
2009-06-23 18:29 ` [PATCH 3/7] " Jason Baron
2009-06-25 2:20 ` Li Zefan
2009-06-25 4:47 ` Frederic Weisbecker
2009-06-23 18:29 ` [PATCH 4/7] " Jason Baron
2009-06-25 2:21 ` Li Zefan
2009-06-23 18:29 ` [PATCH 5/7] " Jason Baron
2009-06-23 18:29 ` [PATCH 6/7] " Jason Baron
2009-06-25 2:31 ` Li Zefan
2009-06-23 18:29 ` [PATCH 7/7] " Jason Baron
2009-06-25 2:38 ` Li Zefan [this message]
2009-06-25 1:27 ` [PATCH 0/7] " Li Zefan
2009-06-25 2:20 ` Li Zefan
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=4A42E310.3010400@cn.fujitsu.com \
--to=lizf@cn.fujitsu.com \
--cc=fche@redhat.com \
--cc=fweisbec@gmail.com \
--cc=jbaron@redhat.com \
--cc=jiayingz@google.com \
--cc=laijs@cn.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@polymtl.ca \
--cc=mbligh@google.com \
--cc=mingo@elte.hu \
--cc=peterz@infradead.org \
--cc=roland@redhat.com \
--cc=rostedt@goodmis.org \
/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