* [GIT PULL] tracing/syscalls: Arch code shrinks, easier arch integration
@ 2009-09-19 5:39 Frederic Weisbecker
2009-09-19 5:39 ` [PATCH 1/2] tracing: Move syscalls metadata handling from arch to core Frederic Weisbecker
` (4 more replies)
0 siblings, 5 replies; 16+ messages in thread
From: Frederic Weisbecker @ 2009-09-19 5:39 UTC (permalink / raw)
To: Ingo Molnar
Cc: LKML, Frederic Weisbecker, Steven Rostedt, Li Zefan,
Masami Hiramatsu, Jason Baron, Lai Jiangshan, Heiko Carstens,
Martin Schwidefsky, Paul Mundt
Ingo,
This patchset moves most of the arch syscalls tracing code to core,
since most of it has become pretty generic since the latest changes.
Note: I haven't tested the s390 changes.
Please pull from the tracing/syscalls branch which can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing.git
tracing/syscalls
Thanks,
Frederic.
Frederic Weisbecker (2):
tracing: Move syscalls metadata handling from arch to core
tracing: Document HAVE_FTRACE_SYSCALLS needs
Documentation/trace/ftrace-design.txt | 11 ++++-
arch/s390/kernel/ftrace.c | 67 +--------------------------
arch/x86/kernel/ftrace.c | 76 +------------------------------
include/trace/syscall.h | 2 +-
kernel/trace/trace_syscalls.c | 80 +++++++++++++++++++++++++++++++++
5 files changed, 95 insertions(+), 141 deletions(-)
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 1/2] tracing: Move syscalls metadata handling from arch to core
2009-09-19 5:39 [GIT PULL] tracing/syscalls: Arch code shrinks, easier arch integration Frederic Weisbecker
@ 2009-09-19 5:39 ` Frederic Weisbecker
2009-09-19 7:16 ` Ingo Molnar
2009-09-19 7:48 ` Heiko Carstens
2009-09-19 5:39 ` [PATCH 2/2] tracing: Document HAVE_FTRACE_SYSCALLS needs Frederic Weisbecker
` (3 subsequent siblings)
4 siblings, 2 replies; 16+ messages in thread
From: Frederic Weisbecker @ 2009-09-19 5:39 UTC (permalink / raw)
To: Ingo Molnar
Cc: LKML, Frederic Weisbecker, Ingo Molnar, Steven Rostedt, Li Zefan,
Masami Hiramatsu, Jason Baron, Lai Jiangshan, Heiko Carstens,
Martin Schwidefsky, Paul Mundt
Most of the syscalls metadata processing is done from arch.
But these operations are mostly generic accross archs. Especially now
that we have a common variable name that expresses the number of
syscalls supported by an arch: NR_syscalls, the only remaining bits
that need to reside in arch is the syscall nr to addr translation.
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Masami Hiramatsu <mhiramat@redhat.com>
Cc: Jason Baron <jbaron@redhat.com>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Paul Mundt <lethal@linux-sh.org>
---
arch/s390/kernel/ftrace.c | 67 +---------------------------------
arch/x86/kernel/ftrace.c | 76 +-------------------------------------
include/trace/syscall.h | 2 +-
kernel/trace/trace_syscalls.c | 80 +++++++++++++++++++++++++++++++++++++++++
4 files changed, 85 insertions(+), 140 deletions(-)
diff --git a/arch/s390/kernel/ftrace.c b/arch/s390/kernel/ftrace.c
index 57bdcb1..7c5752c 100644
--- a/arch/s390/kernel/ftrace.c
+++ b/arch/s390/kernel/ftrace.c
@@ -206,73 +206,10 @@ out:
#ifdef CONFIG_FTRACE_SYSCALLS
-extern unsigned long __start_syscalls_metadata[];
-extern unsigned long __stop_syscalls_metadata[];
extern unsigned int sys_call_table[];
-static struct syscall_metadata **syscalls_metadata;
-
-struct syscall_metadata *syscall_nr_to_meta(int nr)
-{
- if (!syscalls_metadata || nr >= NR_syscalls || nr < 0)
- return NULL;
-
- return syscalls_metadata[nr];
-}
-
-int syscall_name_to_nr(char *name)
-{
- int i;
-
- if (!syscalls_metadata)
- return -1;
- for (i = 0; i < NR_syscalls; i++)
- if (syscalls_metadata[i])
- if (!strcmp(syscalls_metadata[i]->name, name))
- return i;
- return -1;
-}
-
-void set_syscall_enter_id(int num, int id)
-{
- syscalls_metadata[num]->enter_id = id;
-}
-
-void set_syscall_exit_id(int num, int id)
+unsigned long __init arch_syscall_addr(int nr)
{
- syscalls_metadata[num]->exit_id = id;
-}
-
-static struct syscall_metadata *find_syscall_meta(unsigned long syscall)
-{
- struct syscall_metadata *start;
- struct syscall_metadata *stop;
- char str[KSYM_SYMBOL_LEN];
-
- start = (struct syscall_metadata *)__start_syscalls_metadata;
- stop = (struct syscall_metadata *)__stop_syscalls_metadata;
- kallsyms_lookup(syscall, NULL, NULL, NULL, str);
-
- for ( ; start < stop; start++) {
- if (start->name && !strcmp(start->name + 3, str + 3))
- return start;
- }
- return NULL;
-}
-
-static int __init arch_init_ftrace_syscalls(void)
-{
- struct syscall_metadata *meta;
- int i;
- syscalls_metadata = kzalloc(sizeof(*syscalls_metadata) * NR_syscalls,
- GFP_KERNEL);
- if (!syscalls_metadata)
- return -ENOMEM;
- for (i = 0; i < NR_syscalls; i++) {
- meta = find_syscall_meta((unsigned long)sys_call_table[i]);
- syscalls_metadata[i] = meta;
- }
- return 0;
+ return (unsigned long)sys_call_table[nr];
}
-arch_initcall(arch_init_ftrace_syscalls);
#endif
diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
index 9dbb527..4adb867 100644
--- a/arch/x86/kernel/ftrace.c
+++ b/arch/x86/kernel/ftrace.c
@@ -468,82 +468,10 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr,
#ifdef CONFIG_FTRACE_SYSCALLS
-extern unsigned long __start_syscalls_metadata[];
-extern unsigned long __stop_syscalls_metadata[];
extern unsigned long *sys_call_table;
-static struct syscall_metadata **syscalls_metadata;
-
-static struct syscall_metadata *find_syscall_meta(unsigned long *syscall)
-{
- struct syscall_metadata *start;
- struct syscall_metadata *stop;
- char str[KSYM_SYMBOL_LEN];
-
-
- start = (struct syscall_metadata *)__start_syscalls_metadata;
- stop = (struct syscall_metadata *)__stop_syscalls_metadata;
- kallsyms_lookup((unsigned long) syscall, NULL, NULL, NULL, str);
-
- for ( ; start < stop; start++) {
- if (start->name && !strcmp(start->name, str))
- return start;
- }
- return NULL;
-}
-
-struct syscall_metadata *syscall_nr_to_meta(int nr)
-{
- if (!syscalls_metadata || nr >= NR_syscalls || nr < 0)
- return NULL;
-
- return syscalls_metadata[nr];
-}
-
-int syscall_name_to_nr(char *name)
-{
- int i;
-
- if (!syscalls_metadata)
- return -1;
-
- for (i = 0; i < NR_syscalls; i++) {
- if (syscalls_metadata[i]) {
- if (!strcmp(syscalls_metadata[i]->name, name))
- return i;
- }
- }
- return -1;
-}
-
-void set_syscall_enter_id(int num, int id)
-{
- syscalls_metadata[num]->enter_id = id;
-}
-
-void set_syscall_exit_id(int num, int id)
+unsigned long __init arch_syscall_addr(int nr)
{
- syscalls_metadata[num]->exit_id = id;
-}
-
-static int __init arch_init_ftrace_syscalls(void)
-{
- int i;
- struct syscall_metadata *meta;
- unsigned long **psys_syscall_table = &sys_call_table;
-
- syscalls_metadata = kzalloc(sizeof(*syscalls_metadata) *
- NR_syscalls, GFP_KERNEL);
- if (!syscalls_metadata) {
- WARN_ON(1);
- return -ENOMEM;
- }
-
- for (i = 0; i < NR_syscalls; i++) {
- meta = find_syscall_meta(psys_syscall_table[i]);
- syscalls_metadata[i] = meta;
- }
- return 0;
+ return (unsigned long)(&sys_call_table)[nr];
}
-arch_initcall(arch_init_ftrace_syscalls);
#endif
diff --git a/include/trace/syscall.h b/include/trace/syscall.h
index 5dc283b..e972f0a 100644
--- a/include/trace/syscall.h
+++ b/include/trace/syscall.h
@@ -33,7 +33,7 @@ struct syscall_metadata {
};
#ifdef CONFIG_FTRACE_SYSCALLS
-extern struct syscall_metadata *syscall_nr_to_meta(int nr);
+extern unsigned long arch_syscall_addr(int nr);
extern int syscall_name_to_nr(char *name);
void set_syscall_enter_id(int num, int id);
void set_syscall_exit_id(int num, int id);
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index 8712ce3..e281fd7 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -14,6 +14,63 @@ static int sys_refcount_exit;
static DECLARE_BITMAP(enabled_enter_syscalls, NR_syscalls);
static DECLARE_BITMAP(enabled_exit_syscalls, NR_syscalls);
+extern unsigned long __start_syscalls_metadata[];
+extern unsigned long __stop_syscalls_metadata[];
+
+static struct syscall_metadata **syscalls_metadata;
+
+static struct syscall_metadata *find_syscall_meta(unsigned long syscall)
+{
+ struct syscall_metadata *start;
+ struct syscall_metadata *stop;
+ char str[KSYM_SYMBOL_LEN];
+
+
+ start = (struct syscall_metadata *)__start_syscalls_metadata;
+ stop = (struct syscall_metadata *)__stop_syscalls_metadata;
+ kallsyms_lookup(syscall, NULL, NULL, NULL, str);
+
+ for ( ; start < stop; start++) {
+ if (start->name && !strcmp(start->name, str))
+ return start;
+ }
+ return NULL;
+}
+
+static struct syscall_metadata *syscall_nr_to_meta(int nr)
+{
+ if (!syscalls_metadata || nr >= NR_syscalls || nr < 0)
+ return NULL;
+
+ return syscalls_metadata[nr];
+}
+
+int syscall_name_to_nr(char *name)
+{
+ int i;
+
+ if (!syscalls_metadata)
+ return -1;
+
+ for (i = 0; i < NR_syscalls; i++) {
+ if (syscalls_metadata[i]) {
+ if (!strcmp(syscalls_metadata[i]->name, name))
+ return i;
+ }
+ }
+ return -1;
+}
+
+void set_syscall_enter_id(int num, int id)
+{
+ syscalls_metadata[num]->enter_id = id;
+}
+
+void set_syscall_exit_id(int num, int id)
+{
+ syscalls_metadata[num]->exit_id = id;
+}
+
enum print_line_t
print_syscall_enter(struct trace_iterator *iter, int flags)
{
@@ -375,6 +432,29 @@ struct trace_event event_syscall_exit = {
.trace = print_syscall_exit,
};
+int __init init_ftrace_syscalls(void)
+{
+ struct syscall_metadata *meta;
+ unsigned long addr;
+ int i;
+
+ syscalls_metadata = kzalloc(sizeof(*syscalls_metadata) *
+ NR_syscalls, GFP_KERNEL);
+ if (!syscalls_metadata) {
+ WARN_ON(1);
+ return -ENOMEM;
+ }
+
+ for (i = 0; i < NR_syscalls; i++) {
+ addr = arch_syscall_addr(i);
+ meta = find_syscall_meta(addr);
+ syscalls_metadata[i] = meta;
+ }
+
+ return 0;
+}
+core_initcall(init_ftrace_syscalls);
+
#ifdef CONFIG_EVENT_PROFILE
static DECLARE_BITMAP(enabled_prof_enter_syscalls, NR_syscalls);
--
1.6.2.3
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 2/2] tracing: Document HAVE_FTRACE_SYSCALLS needs
2009-09-19 5:39 [GIT PULL] tracing/syscalls: Arch code shrinks, easier arch integration Frederic Weisbecker
2009-09-19 5:39 ` [PATCH 1/2] tracing: Move syscalls metadata handling from arch to core Frederic Weisbecker
@ 2009-09-19 5:39 ` Frederic Weisbecker
2009-09-19 7:17 ` Ingo Molnar
2009-09-19 9:08 ` [GIT PULL v2] tracing/syscalls: Arch code shrinks, easier arch integration Frederic Weisbecker
` (2 subsequent siblings)
4 siblings, 1 reply; 16+ messages in thread
From: Frederic Weisbecker @ 2009-09-19 5:39 UTC (permalink / raw)
To: Ingo Molnar
Cc: LKML, Frederic Weisbecker, Ingo Molnar, Steven Rostedt, Li Zefan,
Masami Hiramatsu, Jason Baron, Lai Jiangshan, Heiko Carstens,
Martin Schwidefsky, Paul Mundt
Document the arch needed requirements to get the support for syscalls
tracing.
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Masami Hiramatsu <mhiramat@redhat.com>
Cc: Jason Baron <jbaron@redhat.com>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Paul Mundt <lethal@linux-sh.org>
---
Documentation/trace/ftrace-design.txt | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/Documentation/trace/ftrace-design.txt b/Documentation/trace/ftrace-design.txt
index 7003e10..04ab61c 100644
--- a/Documentation/trace/ftrace-design.txt
+++ b/Documentation/trace/ftrace-design.txt
@@ -216,7 +216,16 @@ If you can't trace NMI functions, then skip this option.
HAVE_FTRACE_SYSCALLS
---------------------
-<details to be filled>
+You need very few things to get the syscalls tracing in an arch.
+
+- Have a NR_syscalls variable in <asm/unistd.h> that provides the number
+ of syscalls supported by the arch.
+- Implement arch_syscall_addr() that resolves a syscall address from a
+ syscall number.
+- Support the TIF_SYSCALL_TRACEPOINT thread flags
+- Put the trace_sys_enter() and trace_sys_exit() tracepoints calls from ptrace
+ in the ptrace syscalls tracing path.
+- Tag this arch as HAVE_FTRACE_SYSCALLS.
HAVE_FTRACE_MCOUNT_RECORD
--
1.6.2.3
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH 1/2] tracing: Move syscalls metadata handling from arch to core
2009-09-19 5:39 ` [PATCH 1/2] tracing: Move syscalls metadata handling from arch to core Frederic Weisbecker
@ 2009-09-19 7:16 ` Ingo Molnar
2009-09-19 7:48 ` Heiko Carstens
1 sibling, 0 replies; 16+ messages in thread
From: Ingo Molnar @ 2009-09-19 7:16 UTC (permalink / raw)
To: Frederic Weisbecker, Martin Schwidefsky, Heiko Carstens
Cc: LKML, Steven Rostedt, Li Zefan, Masami Hiramatsu, Jason Baron,
Lai Jiangshan, Paul Mundt
* Frederic Weisbecker <fweisbec@gmail.com> wrote:
> Most of the syscalls metadata processing is done from arch. But these
> operations are mostly generic accross archs. Especially now that we
> have a common variable name that expresses the number of syscalls
> supported by an arch: NR_syscalls, the only remaining bits that need
> to reside in arch is the syscall nr to addr translation.
>
> Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
> Cc: Ingo Molnar <mingo@elte.hu>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: Li Zefan <lizf@cn.fujitsu.com>
> Cc: Masami Hiramatsu <mhiramat@redhat.com>
> Cc: Jason Baron <jbaron@redhat.com>
> Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
> Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
> Cc: Paul Mundt <lethal@linux-sh.org>
> ---
> arch/s390/kernel/ftrace.c | 67 +---------------------------------
> arch/x86/kernel/ftrace.c | 76 +-------------------------------------
> include/trace/syscall.h | 2 +-
> kernel/trace/trace_syscalls.c | 80 +++++++++++++++++++++++++++++++++++++++++
> 4 files changed, 85 insertions(+), 140 deletions(-)
Martin, Heiko, would this cleanup be fine with you?
Ingo
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 2/2] tracing: Document HAVE_FTRACE_SYSCALLS needs
2009-09-19 5:39 ` [PATCH 2/2] tracing: Document HAVE_FTRACE_SYSCALLS needs Frederic Weisbecker
@ 2009-09-19 7:17 ` Ingo Molnar
2009-09-19 7:22 ` Frederic Weisbecker
0 siblings, 1 reply; 16+ messages in thread
From: Ingo Molnar @ 2009-09-19 7:17 UTC (permalink / raw)
To: Frederic Weisbecker
Cc: LKML, Steven Rostedt, Li Zefan, Masami Hiramatsu, Jason Baron,
Lai Jiangshan, Heiko Carstens, Martin Schwidefsky, Paul Mundt
* Frederic Weisbecker <fweisbec@gmail.com> wrote:
> Document the arch needed requirements to get the support for syscalls
> tracing.
>
> Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
> Cc: Ingo Molnar <mingo@elte.hu>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: Li Zefan <lizf@cn.fujitsu.com>
> Cc: Masami Hiramatsu <mhiramat@redhat.com>
> Cc: Jason Baron <jbaron@redhat.com>
> Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
> Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
> Cc: Paul Mundt <lethal@linux-sh.org>
> ---
> Documentation/trace/ftrace-design.txt | 11 ++++++++++-
> 1 files changed, 10 insertions(+), 1 deletions(-)
>
> diff --git a/Documentation/trace/ftrace-design.txt b/Documentation/trace/ftrace-design.txt
> index 7003e10..04ab61c 100644
> --- a/Documentation/trace/ftrace-design.txt
> +++ b/Documentation/trace/ftrace-design.txt
> @@ -216,7 +216,16 @@ If you can't trace NMI functions, then skip this option.
> HAVE_FTRACE_SYSCALLS
> ---------------------
>
> -<details to be filled>
> +You need very few things to get the syscalls tracing in an arch.
> +
> +- Have a NR_syscalls variable in <asm/unistd.h> that provides the number
> + of syscalls supported by the arch.
> +- Implement arch_syscall_addr() that resolves a syscall address from a
> + syscall number.
> +- Support the TIF_SYSCALL_TRACEPOINT thread flags
> +- Put the trace_sys_enter() and trace_sys_exit() tracepoints calls from ptrace
> + in the ptrace syscalls tracing path.
> +- Tag this arch as HAVE_FTRACE_SYSCALLS.
HAVE_FTRACE_SYSCALLS is not actually used anywhere.
Ingo
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 2/2] tracing: Document HAVE_FTRACE_SYSCALLS needs
2009-09-19 7:17 ` Ingo Molnar
@ 2009-09-19 7:22 ` Frederic Weisbecker
2009-09-19 7:28 ` Ingo Molnar
0 siblings, 1 reply; 16+ messages in thread
From: Frederic Weisbecker @ 2009-09-19 7:22 UTC (permalink / raw)
To: Ingo Molnar
Cc: LKML, Steven Rostedt, Li Zefan, Masami Hiramatsu, Jason Baron,
Lai Jiangshan, Heiko Carstens, Martin Schwidefsky, Paul Mundt
On Sat, Sep 19, 2009 at 09:17:12AM +0200, Ingo Molnar wrote:
>
> * Frederic Weisbecker <fweisbec@gmail.com> wrote:
>
> > Document the arch needed requirements to get the support for syscalls
> > tracing.
> >
> > Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
> > Cc: Ingo Molnar <mingo@elte.hu>
> > Cc: Steven Rostedt <rostedt@goodmis.org>
> > Cc: Li Zefan <lizf@cn.fujitsu.com>
> > Cc: Masami Hiramatsu <mhiramat@redhat.com>
> > Cc: Jason Baron <jbaron@redhat.com>
> > Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
> > Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
> > Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
> > Cc: Paul Mundt <lethal@linux-sh.org>
> > ---
> > Documentation/trace/ftrace-design.txt | 11 ++++++++++-
> > 1 files changed, 10 insertions(+), 1 deletions(-)
> >
> > diff --git a/Documentation/trace/ftrace-design.txt b/Documentation/trace/ftrace-design.txt
> > index 7003e10..04ab61c 100644
> > --- a/Documentation/trace/ftrace-design.txt
> > +++ b/Documentation/trace/ftrace-design.txt
> > @@ -216,7 +216,16 @@ If you can't trace NMI functions, then skip this option.
> > HAVE_FTRACE_SYSCALLS
> > ---------------------
> >
> > -<details to be filled>
> > +You need very few things to get the syscalls tracing in an arch.
> > +
> > +- Have a NR_syscalls variable in <asm/unistd.h> that provides the number
> > + of syscalls supported by the arch.
> > +- Implement arch_syscall_addr() that resolves a syscall address from a
> > + syscall number.
> > +- Support the TIF_SYSCALL_TRACEPOINT thread flags
> > +- Put the trace_sys_enter() and trace_sys_exit() tracepoints calls from ptrace
> > + in the ptrace syscalls tracing path.
> > +- Tag this arch as HAVE_FTRACE_SYSCALLS.
>
> HAVE_FTRACE_SYSCALLS is not actually used anywhere.
>
> Ingo
Ah, that has been renamed HAVE_SYSCALL_TRACEPOINTS recently.
What do you prefer? A delta patch or a rebase?
Thanks.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 2/2] tracing: Document HAVE_FTRACE_SYSCALLS needs
2009-09-19 7:22 ` Frederic Weisbecker
@ 2009-09-19 7:28 ` Ingo Molnar
2009-09-19 7:29 ` Frederic Weisbecker
0 siblings, 1 reply; 16+ messages in thread
From: Ingo Molnar @ 2009-09-19 7:28 UTC (permalink / raw)
To: Frederic Weisbecker
Cc: LKML, Steven Rostedt, Li Zefan, Masami Hiramatsu, Jason Baron,
Lai Jiangshan, Heiko Carstens, Martin Schwidefsky, Paul Mundt
* Frederic Weisbecker <fweisbec@gmail.com> wrote:
> On Sat, Sep 19, 2009 at 09:17:12AM +0200, Ingo Molnar wrote:
> >
> > * Frederic Weisbecker <fweisbec@gmail.com> wrote:
> >
> > > Document the arch needed requirements to get the support for syscalls
> > > tracing.
> > >
> > > Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
> > > Cc: Ingo Molnar <mingo@elte.hu>
> > > Cc: Steven Rostedt <rostedt@goodmis.org>
> > > Cc: Li Zefan <lizf@cn.fujitsu.com>
> > > Cc: Masami Hiramatsu <mhiramat@redhat.com>
> > > Cc: Jason Baron <jbaron@redhat.com>
> > > Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
> > > Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
> > > Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
> > > Cc: Paul Mundt <lethal@linux-sh.org>
> > > ---
> > > Documentation/trace/ftrace-design.txt | 11 ++++++++++-
> > > 1 files changed, 10 insertions(+), 1 deletions(-)
> > >
> > > diff --git a/Documentation/trace/ftrace-design.txt b/Documentation/trace/ftrace-design.txt
> > > index 7003e10..04ab61c 100644
> > > --- a/Documentation/trace/ftrace-design.txt
> > > +++ b/Documentation/trace/ftrace-design.txt
> > > @@ -216,7 +216,16 @@ If you can't trace NMI functions, then skip this option.
> > > HAVE_FTRACE_SYSCALLS
> > > ---------------------
> > >
> > > -<details to be filled>
> > > +You need very few things to get the syscalls tracing in an arch.
> > > +
> > > +- Have a NR_syscalls variable in <asm/unistd.h> that provides the number
> > > + of syscalls supported by the arch.
> > > +- Implement arch_syscall_addr() that resolves a syscall address from a
> > > + syscall number.
> > > +- Support the TIF_SYSCALL_TRACEPOINT thread flags
> > > +- Put the trace_sys_enter() and trace_sys_exit() tracepoints calls from ptrace
> > > + in the ptrace syscalls tracing path.
> > > +- Tag this arch as HAVE_FTRACE_SYSCALLS.
> >
> > HAVE_FTRACE_SYSCALLS is not actually used anywhere.
> >
> > Ingo
>
> Ah, that has been renamed HAVE_SYSCALL_TRACEPOINTS recently. What do
> you prefer? A delta patch or a rebase?
We need the acks from Martin/Heiko so lets wait for that and do a new
tree then?
Ingo
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 2/2] tracing: Document HAVE_FTRACE_SYSCALLS needs
2009-09-19 7:28 ` Ingo Molnar
@ 2009-09-19 7:29 ` Frederic Weisbecker
0 siblings, 0 replies; 16+ messages in thread
From: Frederic Weisbecker @ 2009-09-19 7:29 UTC (permalink / raw)
To: Ingo Molnar
Cc: LKML, Steven Rostedt, Li Zefan, Masami Hiramatsu, Jason Baron,
Lai Jiangshan, Heiko Carstens, Martin Schwidefsky, Paul Mundt
On Sat, Sep 19, 2009 at 09:28:27AM +0200, Ingo Molnar wrote:
>
> * Frederic Weisbecker <fweisbec@gmail.com> wrote:
>
> > On Sat, Sep 19, 2009 at 09:17:12AM +0200, Ingo Molnar wrote:
> > >
> > > * Frederic Weisbecker <fweisbec@gmail.com> wrote:
> > >
> > > > Document the arch needed requirements to get the support for syscalls
> > > > tracing.
> > > >
> > > > Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
> > > > Cc: Ingo Molnar <mingo@elte.hu>
> > > > Cc: Steven Rostedt <rostedt@goodmis.org>
> > > > Cc: Li Zefan <lizf@cn.fujitsu.com>
> > > > Cc: Masami Hiramatsu <mhiramat@redhat.com>
> > > > Cc: Jason Baron <jbaron@redhat.com>
> > > > Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
> > > > Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
> > > > Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
> > > > Cc: Paul Mundt <lethal@linux-sh.org>
> > > > ---
> > > > Documentation/trace/ftrace-design.txt | 11 ++++++++++-
> > > > 1 files changed, 10 insertions(+), 1 deletions(-)
> > > >
> > > > diff --git a/Documentation/trace/ftrace-design.txt b/Documentation/trace/ftrace-design.txt
> > > > index 7003e10..04ab61c 100644
> > > > --- a/Documentation/trace/ftrace-design.txt
> > > > +++ b/Documentation/trace/ftrace-design.txt
> > > > @@ -216,7 +216,16 @@ If you can't trace NMI functions, then skip this option.
> > > > HAVE_FTRACE_SYSCALLS
> > > > ---------------------
> > > >
> > > > -<details to be filled>
> > > > +You need very few things to get the syscalls tracing in an arch.
> > > > +
> > > > +- Have a NR_syscalls variable in <asm/unistd.h> that provides the number
> > > > + of syscalls supported by the arch.
> > > > +- Implement arch_syscall_addr() that resolves a syscall address from a
> > > > + syscall number.
> > > > +- Support the TIF_SYSCALL_TRACEPOINT thread flags
> > > > +- Put the trace_sys_enter() and trace_sys_exit() tracepoints calls from ptrace
> > > > + in the ptrace syscalls tracing path.
> > > > +- Tag this arch as HAVE_FTRACE_SYSCALLS.
> > >
> > > HAVE_FTRACE_SYSCALLS is not actually used anywhere.
> > >
> > > Ingo
> >
> > Ah, that has been renamed HAVE_SYSCALL_TRACEPOINTS recently. What do
> > you prefer? A delta patch or a rebase?
>
> We need the acks from Martin/Heiko so lets wait for that and do a new
> tree then?
>
> Ingo
Ok.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 1/2] tracing: Move syscalls metadata handling from arch to core
2009-09-19 5:39 ` [PATCH 1/2] tracing: Move syscalls metadata handling from arch to core Frederic Weisbecker
2009-09-19 7:16 ` Ingo Molnar
@ 2009-09-19 7:48 ` Heiko Carstens
2009-09-19 8:12 ` Frederic Weisbecker
1 sibling, 1 reply; 16+ messages in thread
From: Heiko Carstens @ 2009-09-19 7:48 UTC (permalink / raw)
To: Frederic Weisbecker
Cc: Ingo Molnar, LKML, Steven Rostedt, Li Zefan, Masami Hiramatsu,
Jason Baron, Lai Jiangshan, Martin Schwidefsky, Paul Mundt
On Sat, Sep 19, 2009 at 07:39:16AM +0200, Frederic Weisbecker wrote:
> Most of the syscalls metadata processing is done from arch.
> But these operations are mostly generic accross archs. Especially now
> that we have a common variable name that expresses the number of
> syscalls supported by an arch: NR_syscalls, the only remaining bits
> that need to reside in arch is the syscall nr to addr translation.
That won't work in its current form, since there is a small difference
between x86 and s390:
> diff --git a/arch/s390/kernel/ftrace.c b/arch/s390/kernel/ftrace.c
> index 57bdcb1..7c5752c 100644
> --- a/arch/s390/kernel/ftrace.c
> +++ b/arch/s390/kernel/ftrace.c
> -static struct syscall_metadata *find_syscall_meta(unsigned long syscall)
> -{
> - struct syscall_metadata *start;
> - struct syscall_metadata *stop;
> - char str[KSYM_SYMBOL_LEN];
> -
> - start = (struct syscall_metadata *)__start_syscalls_metadata;
> - stop = (struct syscall_metadata *)__stop_syscalls_metadata;
> - kallsyms_lookup(syscall, NULL, NULL, NULL, str);
> -
> - for ( ; start < stop; start++) {
> - if (start->name && !strcmp(start->name + 3, str + 3))
^^^^^^^^^^^^^^^^^^^^^^^^
> diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
> index 9dbb527..4adb867 100644
> --- a/arch/x86/kernel/ftrace.c
> +++ b/arch/x86/kernel/ftrace.c
> -static struct syscall_metadata *find_syscall_meta(unsigned long *syscall)
> -{
> - struct syscall_metadata *start;
> - struct syscall_metadata *stop;
> - char str[KSYM_SYMBOL_LEN];
> -
> -
> - start = (struct syscall_metadata *)__start_syscalls_metadata;
> - stop = (struct syscall_metadata *)__stop_syscalls_metadata;
> - kallsyms_lookup((unsigned long) syscall, NULL, NULL, NULL, str);
> -
> - for ( ; start < stop; start++) {
> - if (start->name && !strcmp(start->name, str))
^^^^^^^^^^^^^^^^
> - return start;
> - }
> - return NULL;
The reason for the "+ 3 " is that architectures with syscall wrappers have
alias function names which also show up in kallsysms:
000000000001c788 t show_cpuinfo
000000000001c9e0 T SyS_s390_personality
000000000001c9e0 T sys_s390_personality
000000000001ca48 T SyS_s390_newuname
000000000001ca48 T sys_s390_newuname
000000000001cac8 T SyS_ipc
000000000001cac8 T sys_ipc
000000000001cd00 T SyS_s390_old_mmap
000000000001cd00 T sys_s390_old_mmap
000000000001ce68 T SyS_mmap2
000000000001ce68 T sys_mmap2
000000000001cfc4 t FixPerRegisters
So kallsyms_lookup(...) would currently always return a string that starts
with "SyS" instead of "sys". Since the metadata syscall names start with
"sys" there is no match.
If you could change the generic version so it also contains a "+ 3" it
should work for all architectures.
Might be worth a comment that I didn't add back then :)
Hmm... maybe it's even possible to throw out the "SyS" variants out of
the kallsyms table and only keep the alias names?
That would shrink the kernel image a bit.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 1/2] tracing: Move syscalls metadata handling from arch to core
2009-09-19 7:48 ` Heiko Carstens
@ 2009-09-19 8:12 ` Frederic Weisbecker
0 siblings, 0 replies; 16+ messages in thread
From: Frederic Weisbecker @ 2009-09-19 8:12 UTC (permalink / raw)
To: Heiko Carstens
Cc: Ingo Molnar, LKML, Steven Rostedt, Li Zefan, Masami Hiramatsu,
Jason Baron, Lai Jiangshan, Martin Schwidefsky, Paul Mundt
On Sat, Sep 19, 2009 at 09:48:16AM +0200, Heiko Carstens wrote:
> On Sat, Sep 19, 2009 at 07:39:16AM +0200, Frederic Weisbecker wrote:
> > Most of the syscalls metadata processing is done from arch.
> > But these operations are mostly generic accross archs. Especially now
> > that we have a common variable name that expresses the number of
> > syscalls supported by an arch: NR_syscalls, the only remaining bits
> > that need to reside in arch is the syscall nr to addr translation.
>
> That won't work in its current form, since there is a small difference
> between x86 and s390:
>
> > diff --git a/arch/s390/kernel/ftrace.c b/arch/s390/kernel/ftrace.c
> > index 57bdcb1..7c5752c 100644
> > --- a/arch/s390/kernel/ftrace.c
> > +++ b/arch/s390/kernel/ftrace.c
> > -static struct syscall_metadata *find_syscall_meta(unsigned long syscall)
> > -{
> > - struct syscall_metadata *start;
> > - struct syscall_metadata *stop;
> > - char str[KSYM_SYMBOL_LEN];
> > -
> > - start = (struct syscall_metadata *)__start_syscalls_metadata;
> > - stop = (struct syscall_metadata *)__stop_syscalls_metadata;
> > - kallsyms_lookup(syscall, NULL, NULL, NULL, str);
> > -
> > - for ( ; start < stop; start++) {
> > - if (start->name && !strcmp(start->name + 3, str + 3))
> ^^^^^^^^^^^^^^^^^^^^^^^^
Oh, I thought it was to zap the "sys" prefix comparison.
> > diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
> > index 9dbb527..4adb867 100644
> > --- a/arch/x86/kernel/ftrace.c
> > +++ b/arch/x86/kernel/ftrace.c
> > -static struct syscall_metadata *find_syscall_meta(unsigned long *syscall)
> > -{
> > - struct syscall_metadata *start;
> > - struct syscall_metadata *stop;
> > - char str[KSYM_SYMBOL_LEN];
> > -
> > -
> > - start = (struct syscall_metadata *)__start_syscalls_metadata;
> > - stop = (struct syscall_metadata *)__stop_syscalls_metadata;
> > - kallsyms_lookup((unsigned long) syscall, NULL, NULL, NULL, str);
> > -
> > - for ( ; start < stop; start++) {
> > - if (start->name && !strcmp(start->name, str))
> ^^^^^^^^^^^^^^^^
> > - return start;
> > - }
> > - return NULL;
>
> The reason for the "+ 3 " is that architectures with syscall wrappers have
> alias function names which also show up in kallsysms:
>
> 000000000001c788 t show_cpuinfo
> 000000000001c9e0 T SyS_s390_personality
> 000000000001c9e0 T sys_s390_personality
> 000000000001ca48 T SyS_s390_newuname
> 000000000001ca48 T sys_s390_newuname
> 000000000001cac8 T SyS_ipc
> 000000000001cac8 T sys_ipc
> 000000000001cd00 T SyS_s390_old_mmap
> 000000000001cd00 T sys_s390_old_mmap
> 000000000001ce68 T SyS_mmap2
> 000000000001ce68 T sys_mmap2
> 000000000001cfc4 t FixPerRegisters
>
> So kallsyms_lookup(...) would currently always return a string that starts
> with "SyS" instead of "sys". Since the metadata syscall names start with
> "sys" there is no match.
> If you could change the generic version so it also contains a "+ 3" it
> should work for all architectures.
> Might be worth a comment that I didn't add back then :)
Ah ok. So the fix is easy.
Thanks for the tip!
> Hmm... maybe it's even possible to throw out the "SyS" variants out of
> the kallsyms table and only keep the alias names?
> That would shrink the kernel image a bit.
Yeah, unless someone finds strong reasons to keep them.
Thanks!
^ permalink raw reply [flat|nested] 16+ messages in thread
* [GIT PULL v2] tracing/syscalls: Arch code shrinks, easier arch integration
2009-09-19 5:39 [GIT PULL] tracing/syscalls: Arch code shrinks, easier arch integration Frederic Weisbecker
2009-09-19 5:39 ` [PATCH 1/2] tracing: Move syscalls metadata handling from arch to core Frederic Weisbecker
2009-09-19 5:39 ` [PATCH 2/2] tracing: Document HAVE_FTRACE_SYSCALLS needs Frederic Weisbecker
@ 2009-09-19 9:08 ` Frederic Weisbecker
2009-10-13 22:25 ` Frederic Weisbecker
2009-09-19 9:08 ` [PATCH 1/2 v2] tracing: Move syscalls metadata handling from arch to core Frederic Weisbecker
2009-09-19 9:08 ` [PATCH 2/2 v2] tracing: Document HAVE_SYSCALL_TRACEPOINTS needs Frederic Weisbecker
4 siblings, 1 reply; 16+ messages in thread
From: Frederic Weisbecker @ 2009-09-19 9:08 UTC (permalink / raw)
To: Ingo Molnar
Cc: LKML, Frederic Weisbecker, Steven Rostedt, Li Zefan,
Masami Hiramatsu, Jason Baron, Lai Jiangshan, Heiko Carstens,
Martin Schwidefsky, Paul Mundt
Ingo, Heiko,
I've updated the patches following your reviews.
Please tell me if you see another troubles.
The new tree can be pulled from:
git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing.git
tracing/syscalls-v2
Thanks,
Frederic.
Frederic Weisbecker (2):
tracing: Move syscalls metadata handling from arch to core
tracing: Document HAVE_SYSCALL_TRACEPOINTS needs
Documentation/trace/ftrace-design.txt | 13 ++++-
arch/s390/kernel/ftrace.c | 67 +-------------------------
arch/x86/kernel/ftrace.c | 76 +----------------------------
include/trace/syscall.h | 2 +-
kernel/trace/trace_syscalls.c | 86 +++++++++++++++++++++++++++++++++
5 files changed, 102 insertions(+), 142 deletions(-)
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 1/2 v2] tracing: Move syscalls metadata handling from arch to core
2009-09-19 5:39 [GIT PULL] tracing/syscalls: Arch code shrinks, easier arch integration Frederic Weisbecker
` (2 preceding siblings ...)
2009-09-19 9:08 ` [GIT PULL v2] tracing/syscalls: Arch code shrinks, easier arch integration Frederic Weisbecker
@ 2009-09-19 9:08 ` Frederic Weisbecker
2009-09-19 9:08 ` [PATCH 2/2 v2] tracing: Document HAVE_SYSCALL_TRACEPOINTS needs Frederic Weisbecker
4 siblings, 0 replies; 16+ messages in thread
From: Frederic Weisbecker @ 2009-09-19 9:08 UTC (permalink / raw)
To: Ingo Molnar
Cc: LKML, Frederic Weisbecker, Ingo Molnar, Steven Rostedt, Li Zefan,
Masami Hiramatsu, Jason Baron, Lai Jiangshan, Heiko Carstens,
Martin Schwidefsky, Paul Mundt
Most of the syscalls metadata processing is done from arch.
But these operations are mostly generic accross archs. Especially now
that we have a common variable name that expresses the number of
syscalls supported by an arch: NR_syscalls, the only remaining bits
that need to reside in arch is the syscall nr to addr translation.
v2: Compare syscalls symbols only after the "sys" prefix so that we
avoid spurious mismatches with archs that have syscalls wrappers,
in which case syscalls symbols have "SyS" prefixed aliases.
(Reported by: Heiko Carstens)
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Masami Hiramatsu <mhiramat@redhat.com>
Cc: Jason Baron <jbaron@redhat.com>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Paul Mundt <lethal@linux-sh.org>
---
arch/s390/kernel/ftrace.c | 67 +-------------------------------
arch/x86/kernel/ftrace.c | 76 +-----------------------------------
include/trace/syscall.h | 2 +-
kernel/trace/trace_syscalls.c | 86 +++++++++++++++++++++++++++++++++++++++++
4 files changed, 91 insertions(+), 140 deletions(-)
diff --git a/arch/s390/kernel/ftrace.c b/arch/s390/kernel/ftrace.c
index 57bdcb1..7c5752c 100644
--- a/arch/s390/kernel/ftrace.c
+++ b/arch/s390/kernel/ftrace.c
@@ -206,73 +206,10 @@ out:
#ifdef CONFIG_FTRACE_SYSCALLS
-extern unsigned long __start_syscalls_metadata[];
-extern unsigned long __stop_syscalls_metadata[];
extern unsigned int sys_call_table[];
-static struct syscall_metadata **syscalls_metadata;
-
-struct syscall_metadata *syscall_nr_to_meta(int nr)
-{
- if (!syscalls_metadata || nr >= NR_syscalls || nr < 0)
- return NULL;
-
- return syscalls_metadata[nr];
-}
-
-int syscall_name_to_nr(char *name)
-{
- int i;
-
- if (!syscalls_metadata)
- return -1;
- for (i = 0; i < NR_syscalls; i++)
- if (syscalls_metadata[i])
- if (!strcmp(syscalls_metadata[i]->name, name))
- return i;
- return -1;
-}
-
-void set_syscall_enter_id(int num, int id)
-{
- syscalls_metadata[num]->enter_id = id;
-}
-
-void set_syscall_exit_id(int num, int id)
+unsigned long __init arch_syscall_addr(int nr)
{
- syscalls_metadata[num]->exit_id = id;
-}
-
-static struct syscall_metadata *find_syscall_meta(unsigned long syscall)
-{
- struct syscall_metadata *start;
- struct syscall_metadata *stop;
- char str[KSYM_SYMBOL_LEN];
-
- start = (struct syscall_metadata *)__start_syscalls_metadata;
- stop = (struct syscall_metadata *)__stop_syscalls_metadata;
- kallsyms_lookup(syscall, NULL, NULL, NULL, str);
-
- for ( ; start < stop; start++) {
- if (start->name && !strcmp(start->name + 3, str + 3))
- return start;
- }
- return NULL;
-}
-
-static int __init arch_init_ftrace_syscalls(void)
-{
- struct syscall_metadata *meta;
- int i;
- syscalls_metadata = kzalloc(sizeof(*syscalls_metadata) * NR_syscalls,
- GFP_KERNEL);
- if (!syscalls_metadata)
- return -ENOMEM;
- for (i = 0; i < NR_syscalls; i++) {
- meta = find_syscall_meta((unsigned long)sys_call_table[i]);
- syscalls_metadata[i] = meta;
- }
- return 0;
+ return (unsigned long)sys_call_table[nr];
}
-arch_initcall(arch_init_ftrace_syscalls);
#endif
diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
index 9dbb527..4adb867 100644
--- a/arch/x86/kernel/ftrace.c
+++ b/arch/x86/kernel/ftrace.c
@@ -468,82 +468,10 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr,
#ifdef CONFIG_FTRACE_SYSCALLS
-extern unsigned long __start_syscalls_metadata[];
-extern unsigned long __stop_syscalls_metadata[];
extern unsigned long *sys_call_table;
-static struct syscall_metadata **syscalls_metadata;
-
-static struct syscall_metadata *find_syscall_meta(unsigned long *syscall)
-{
- struct syscall_metadata *start;
- struct syscall_metadata *stop;
- char str[KSYM_SYMBOL_LEN];
-
-
- start = (struct syscall_metadata *)__start_syscalls_metadata;
- stop = (struct syscall_metadata *)__stop_syscalls_metadata;
- kallsyms_lookup((unsigned long) syscall, NULL, NULL, NULL, str);
-
- for ( ; start < stop; start++) {
- if (start->name && !strcmp(start->name, str))
- return start;
- }
- return NULL;
-}
-
-struct syscall_metadata *syscall_nr_to_meta(int nr)
-{
- if (!syscalls_metadata || nr >= NR_syscalls || nr < 0)
- return NULL;
-
- return syscalls_metadata[nr];
-}
-
-int syscall_name_to_nr(char *name)
-{
- int i;
-
- if (!syscalls_metadata)
- return -1;
-
- for (i = 0; i < NR_syscalls; i++) {
- if (syscalls_metadata[i]) {
- if (!strcmp(syscalls_metadata[i]->name, name))
- return i;
- }
- }
- return -1;
-}
-
-void set_syscall_enter_id(int num, int id)
-{
- syscalls_metadata[num]->enter_id = id;
-}
-
-void set_syscall_exit_id(int num, int id)
+unsigned long __init arch_syscall_addr(int nr)
{
- syscalls_metadata[num]->exit_id = id;
-}
-
-static int __init arch_init_ftrace_syscalls(void)
-{
- int i;
- struct syscall_metadata *meta;
- unsigned long **psys_syscall_table = &sys_call_table;
-
- syscalls_metadata = kzalloc(sizeof(*syscalls_metadata) *
- NR_syscalls, GFP_KERNEL);
- if (!syscalls_metadata) {
- WARN_ON(1);
- return -ENOMEM;
- }
-
- for (i = 0; i < NR_syscalls; i++) {
- meta = find_syscall_meta(psys_syscall_table[i]);
- syscalls_metadata[i] = meta;
- }
- return 0;
+ return (unsigned long)(&sys_call_table)[nr];
}
-arch_initcall(arch_init_ftrace_syscalls);
#endif
diff --git a/include/trace/syscall.h b/include/trace/syscall.h
index 5dc283b..e972f0a 100644
--- a/include/trace/syscall.h
+++ b/include/trace/syscall.h
@@ -33,7 +33,7 @@ struct syscall_metadata {
};
#ifdef CONFIG_FTRACE_SYSCALLS
-extern struct syscall_metadata *syscall_nr_to_meta(int nr);
+extern unsigned long arch_syscall_addr(int nr);
extern int syscall_name_to_nr(char *name);
void set_syscall_enter_id(int num, int id);
void set_syscall_exit_id(int num, int id);
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index 8712ce3..965ce55 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -14,6 +14,69 @@ static int sys_refcount_exit;
static DECLARE_BITMAP(enabled_enter_syscalls, NR_syscalls);
static DECLARE_BITMAP(enabled_exit_syscalls, NR_syscalls);
+extern unsigned long __start_syscalls_metadata[];
+extern unsigned long __stop_syscalls_metadata[];
+
+static struct syscall_metadata **syscalls_metadata;
+
+static struct syscall_metadata *find_syscall_meta(unsigned long syscall)
+{
+ struct syscall_metadata *start;
+ struct syscall_metadata *stop;
+ char str[KSYM_SYMBOL_LEN];
+
+
+ start = (struct syscall_metadata *)__start_syscalls_metadata;
+ stop = (struct syscall_metadata *)__stop_syscalls_metadata;
+ kallsyms_lookup(syscall, NULL, NULL, NULL, str);
+
+ for ( ; start < stop; start++) {
+ /*
+ * Only compare after the "sys" prefix. Archs that use
+ * syscall wrappers may have syscalls symbols aliases prefixed
+ * with "SyS" instead of "sys", leading to an unwanted
+ * mismatch.
+ */
+ if (start->name && !strcmp(start->name + 3, str + 3))
+ return start;
+ }
+ return NULL;
+}
+
+static struct syscall_metadata *syscall_nr_to_meta(int nr)
+{
+ if (!syscalls_metadata || nr >= NR_syscalls || nr < 0)
+ return NULL;
+
+ return syscalls_metadata[nr];
+}
+
+int syscall_name_to_nr(char *name)
+{
+ int i;
+
+ if (!syscalls_metadata)
+ return -1;
+
+ for (i = 0; i < NR_syscalls; i++) {
+ if (syscalls_metadata[i]) {
+ if (!strcmp(syscalls_metadata[i]->name, name))
+ return i;
+ }
+ }
+ return -1;
+}
+
+void set_syscall_enter_id(int num, int id)
+{
+ syscalls_metadata[num]->enter_id = id;
+}
+
+void set_syscall_exit_id(int num, int id)
+{
+ syscalls_metadata[num]->exit_id = id;
+}
+
enum print_line_t
print_syscall_enter(struct trace_iterator *iter, int flags)
{
@@ -375,6 +438,29 @@ struct trace_event event_syscall_exit = {
.trace = print_syscall_exit,
};
+int __init init_ftrace_syscalls(void)
+{
+ struct syscall_metadata *meta;
+ unsigned long addr;
+ int i;
+
+ syscalls_metadata = kzalloc(sizeof(*syscalls_metadata) *
+ NR_syscalls, GFP_KERNEL);
+ if (!syscalls_metadata) {
+ WARN_ON(1);
+ return -ENOMEM;
+ }
+
+ for (i = 0; i < NR_syscalls; i++) {
+ addr = arch_syscall_addr(i);
+ meta = find_syscall_meta(addr);
+ syscalls_metadata[i] = meta;
+ }
+
+ return 0;
+}
+core_initcall(init_ftrace_syscalls);
+
#ifdef CONFIG_EVENT_PROFILE
static DECLARE_BITMAP(enabled_prof_enter_syscalls, NR_syscalls);
--
1.6.2.3
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 2/2 v2] tracing: Document HAVE_SYSCALL_TRACEPOINTS needs
2009-09-19 5:39 [GIT PULL] tracing/syscalls: Arch code shrinks, easier arch integration Frederic Weisbecker
` (3 preceding siblings ...)
2009-09-19 9:08 ` [PATCH 1/2 v2] tracing: Move syscalls metadata handling from arch to core Frederic Weisbecker
@ 2009-09-19 9:08 ` Frederic Weisbecker
4 siblings, 0 replies; 16+ messages in thread
From: Frederic Weisbecker @ 2009-09-19 9:08 UTC (permalink / raw)
To: Ingo Molnar
Cc: LKML, Frederic Weisbecker, Ingo Molnar, Steven Rostedt, Li Zefan,
Masami Hiramatsu, Jason Baron, Lai Jiangshan, Heiko Carstens,
Martin Schwidefsky, Paul Mundt
Document the arch needed requirements to get the support for syscalls
tracing.
v2: HAVE_FTRACE_SYSCALLS have been changed to HAVE_SYSCALL_TRACEPOINTS
recently. Update this config name in the documentation then.
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Masami Hiramatsu <mhiramat@redhat.com>
Cc: Jason Baron <jbaron@redhat.com>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Paul Mundt <lethal@linux-sh.org>
---
Documentation/trace/ftrace-design.txt | 13 +++++++++++--
1 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/Documentation/trace/ftrace-design.txt b/Documentation/trace/ftrace-design.txt
index 7003e10..641a1ef 100644
--- a/Documentation/trace/ftrace-design.txt
+++ b/Documentation/trace/ftrace-design.txt
@@ -213,10 +213,19 @@ If you can't trace NMI functions, then skip this option.
<details to be filled>
-HAVE_FTRACE_SYSCALLS
+HAVE_SYSCALL_TRACEPOINTS
---------------------
-<details to be filled>
+You need very few things to get the syscalls tracing in an arch.
+
+- Have a NR_syscalls variable in <asm/unistd.h> that provides the number
+ of syscalls supported by the arch.
+- Implement arch_syscall_addr() that resolves a syscall address from a
+ syscall number.
+- Support the TIF_SYSCALL_TRACEPOINT thread flags
+- Put the trace_sys_enter() and trace_sys_exit() tracepoints calls from ptrace
+ in the ptrace syscalls tracing path.
+- Tag this arch as HAVE_SYSCALL_TRACEPOINTS.
HAVE_FTRACE_MCOUNT_RECORD
--
1.6.2.3
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [GIT PULL v2] tracing/syscalls: Arch code shrinks, easier arch integration
2009-09-19 9:08 ` [GIT PULL v2] tracing/syscalls: Arch code shrinks, easier arch integration Frederic Weisbecker
@ 2009-10-13 22:25 ` Frederic Weisbecker
2009-10-14 6:18 ` Ingo Molnar
0 siblings, 1 reply; 16+ messages in thread
From: Frederic Weisbecker @ 2009-10-13 22:25 UTC (permalink / raw)
To: Ingo Molnar
Cc: LKML, Steven Rostedt, Li Zefan, Masami Hiramatsu, Jason Baron,
Lai Jiangshan, Heiko Carstens, Martin Schwidefsky, Paul Mundt
On Sat, Sep 19, 2009 at 11:08:56AM +0200, Frederic Weisbecker wrote:
> Ingo, Heiko,
>
> I've updated the patches following your reviews.
> Please tell me if you see another troubles.
>
> The new tree can be pulled from:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing.git
> tracing/syscalls-v2
>
> Thanks,
> Frederic.
Ingo,
I wonder if you have forgotten this pull request, or if there is a
problem with it.
It's still cleanly mergeable into tip:/tracing/core.
Thanks.
> Frederic Weisbecker (2):
> tracing: Move syscalls metadata handling from arch to core
> tracing: Document HAVE_SYSCALL_TRACEPOINTS needs
>
> Documentation/trace/ftrace-design.txt | 13 ++++-
> arch/s390/kernel/ftrace.c | 67 +-------------------------
> arch/x86/kernel/ftrace.c | 76 +----------------------------
> include/trace/syscall.h | 2 +-
> kernel/trace/trace_syscalls.c | 86 +++++++++++++++++++++++++++++++++
> 5 files changed, 102 insertions(+), 142 deletions(-)
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [GIT PULL v2] tracing/syscalls: Arch code shrinks, easier arch integration
2009-10-13 22:25 ` Frederic Weisbecker
@ 2009-10-14 6:18 ` Ingo Molnar
2009-10-14 7:28 ` Heiko Carstens
0 siblings, 1 reply; 16+ messages in thread
From: Ingo Molnar @ 2009-10-14 6:18 UTC (permalink / raw)
To: Frederic Weisbecker
Cc: LKML, Steven Rostedt, Li Zefan, Masami Hiramatsu, Jason Baron,
Lai Jiangshan, Heiko Carstens, Martin Schwidefsky, Paul Mundt
* Frederic Weisbecker <fweisbec@gmail.com> wrote:
> On Sat, Sep 19, 2009 at 11:08:56AM +0200, Frederic Weisbecker wrote:
> > Ingo, Heiko,
> >
> > I've updated the patches following your reviews.
> > Please tell me if you see another troubles.
> >
> > The new tree can be pulled from:
> >
> > git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing.git
> > tracing/syscalls-v2
> >
> > Thanks,
> > Frederic.
>
>
> Ingo,
>
> I wonder if you have forgotten this pull request, or if there is a
> problem with it.
>
> It's still cleanly mergeable into tip:/tracing/core.
>
> Thanks.
>
>
>
>
> > Frederic Weisbecker (2):
> > tracing: Move syscalls metadata handling from arch to core
> > tracing: Document HAVE_SYSCALL_TRACEPOINTS needs
> >
> > Documentation/trace/ftrace-design.txt | 13 ++++-
> > arch/s390/kernel/ftrace.c | 67 +-------------------------
I skipped it because the s390 bit needs the ack of at least one of these
gents:
S390
M: Martin Schwidefsky <schwidefsky@de.ibm.com>
M: Heiko Carstens <heiko.carstens@de.ibm.com>
Thanks,
Ingo
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [GIT PULL v2] tracing/syscalls: Arch code shrinks, easier arch integration
2009-10-14 6:18 ` Ingo Molnar
@ 2009-10-14 7:28 ` Heiko Carstens
0 siblings, 0 replies; 16+ messages in thread
From: Heiko Carstens @ 2009-10-14 7:28 UTC (permalink / raw)
To: Ingo Molnar
Cc: Frederic Weisbecker, LKML, Steven Rostedt, Li Zefan,
Masami Hiramatsu, Jason Baron, Lai Jiangshan, Martin Schwidefsky,
Paul Mundt
On Wed, Oct 14, 2009 at 08:18:40AM +0200, Ingo Molnar wrote:
>
> * Frederic Weisbecker <fweisbec@gmail.com> wrote:
>
> > On Sat, Sep 19, 2009 at 11:08:56AM +0200, Frederic Weisbecker wrote:
> > > Ingo, Heiko,
> > >
> > > I've updated the patches following your reviews.
> > > Please tell me if you see another troubles.
> > >
> > > The new tree can be pulled from:
> > >
> > > git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing.git
> > > tracing/syscalls-v2
> > Ingo,
> >
> > I wonder if you have forgotten this pull request, or if there is a
> > problem with it.
> >
> > It's still cleanly mergeable into tip:/tracing/core.
> > > Frederic Weisbecker (2):
> > > tracing: Move syscalls metadata handling from arch to core
> > > tracing: Document HAVE_SYSCALL_TRACEPOINTS needs
> > >
> > > Documentation/trace/ftrace-design.txt | 13 ++++-
> > > arch/s390/kernel/ftrace.c | 67 +-------------------------
>
> I skipped it because the s390 bit needs the ack of at least one of these
> gents:
>
> S390
> M: Martin Schwidefsky <schwidefsky@de.ibm.com>
> M: Heiko Carstens <heiko.carstens@de.ibm.com>
Acked-by: Heiko Carstens <heiko.carstens@de.ibm.com>
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2009-10-14 7:29 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-19 5:39 [GIT PULL] tracing/syscalls: Arch code shrinks, easier arch integration Frederic Weisbecker
2009-09-19 5:39 ` [PATCH 1/2] tracing: Move syscalls metadata handling from arch to core Frederic Weisbecker
2009-09-19 7:16 ` Ingo Molnar
2009-09-19 7:48 ` Heiko Carstens
2009-09-19 8:12 ` Frederic Weisbecker
2009-09-19 5:39 ` [PATCH 2/2] tracing: Document HAVE_FTRACE_SYSCALLS needs Frederic Weisbecker
2009-09-19 7:17 ` Ingo Molnar
2009-09-19 7:22 ` Frederic Weisbecker
2009-09-19 7:28 ` Ingo Molnar
2009-09-19 7:29 ` Frederic Weisbecker
2009-09-19 9:08 ` [GIT PULL v2] tracing/syscalls: Arch code shrinks, easier arch integration Frederic Weisbecker
2009-10-13 22:25 ` Frederic Weisbecker
2009-10-14 6:18 ` Ingo Molnar
2009-10-14 7:28 ` Heiko Carstens
2009-09-19 9:08 ` [PATCH 1/2 v2] tracing: Move syscalls metadata handling from arch to core Frederic Weisbecker
2009-09-19 9:08 ` [PATCH 2/2 v2] tracing: Document HAVE_SYSCALL_TRACEPOINTS needs Frederic Weisbecker
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).