* [GIT PULL] tracing: Arch syscalls tracing shrinks and fixlets
@ 2009-10-14 19:13 Frederic Weisbecker
2009-10-14 19:13 ` [PATCH 1/4] tracing: Move syscalls metadata handling from arch to core Frederic Weisbecker
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Frederic Weisbecker @ 2009-10-14 19:13 UTC (permalink / raw)
To: Ingo Molnar; +Cc: LKML, Frederic Weisbecker, Steven Rostedt, Li Zefan
Ingo,
Please pull the tracing/core branch that can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing.git
tracing/core
Thanks,
Frederic.
---
Frederic Weisbecker (4):
tracing: Move syscalls metadata handling from arch to core
tracing: Document HAVE_SYSCALL_TRACEPOINTS needs
ftrace: Copy ftrace_graph_filter boot param using strlcpy
ftrace: Rename set_bootup_ftrace into set_cmdline_ftrace
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/ftrace.c | 2 +-
kernel/trace/trace.c | 4 +-
kernel/trace/trace_syscalls.c | 86 +++++++++++++++++++++++++++++++++
7 files changed, 105 insertions(+), 145 deletions(-)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/4] tracing: Move syscalls metadata handling from arch to core
2009-10-14 19:13 [GIT PULL] tracing: Arch syscalls tracing shrinks and fixlets Frederic Weisbecker
@ 2009-10-14 19:13 ` Frederic Weisbecker
2009-10-14 19:13 ` [PATCH 2/4] tracing: Document HAVE_SYSCALL_TRACEPOINTS needs Frederic Weisbecker
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Frederic Weisbecker @ 2009-10-14 19:13 UTC (permalink / raw)
To: Ingo Molnar
Cc: LKML, Frederic Weisbecker, Ingo Molnar, Steven Rostedt, Li Zefan,
Masami Hiramatsu, Jason Baron, Lai Jiangshan, 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>
Acked-by: Heiko Carstens <heiko.carstens@de.ibm.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: 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 25e6f5f..5a1b975 100644
--- a/arch/x86/kernel/ftrace.c
+++ b/arch/x86/kernel/ftrace.c
@@ -470,82 +470,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 9fbce6c..8bda4bf 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 [flat|nested] 6+ messages in thread
* [PATCH 2/4] tracing: Document HAVE_SYSCALL_TRACEPOINTS needs
2009-10-14 19:13 [GIT PULL] tracing: Arch syscalls tracing shrinks and fixlets Frederic Weisbecker
2009-10-14 19:13 ` [PATCH 1/4] tracing: Move syscalls metadata handling from arch to core Frederic Weisbecker
@ 2009-10-14 19:13 ` Frederic Weisbecker
2009-10-14 19:13 ` [PATCH 3/4] ftrace: Copy ftrace_graph_filter boot param using strlcpy Frederic Weisbecker
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Frederic Weisbecker @ 2009-10-14 19:13 UTC (permalink / raw)
To: Ingo Molnar
Cc: LKML, Frederic Weisbecker, Ingo Molnar, Steven Rostedt, Li Zefan,
Masami Hiramatsu, Jason Baron, Lai Jiangshan, 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>
Acked-by: Heiko Carstens <heiko.carstens@de.ibm.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: 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 [flat|nested] 6+ messages in thread
* [PATCH 3/4] ftrace: Copy ftrace_graph_filter boot param using strlcpy
2009-10-14 19:13 [GIT PULL] tracing: Arch syscalls tracing shrinks and fixlets Frederic Weisbecker
2009-10-14 19:13 ` [PATCH 1/4] tracing: Move syscalls metadata handling from arch to core Frederic Weisbecker
2009-10-14 19:13 ` [PATCH 2/4] tracing: Document HAVE_SYSCALL_TRACEPOINTS needs Frederic Weisbecker
@ 2009-10-14 19:13 ` Frederic Weisbecker
2009-10-14 19:13 ` [PATCH 4/4] ftrace: Rename set_bootup_ftrace into set_cmdline_ftrace Frederic Weisbecker
2009-10-15 6:40 ` [GIT PULL] tracing: Arch syscalls tracing shrinks and fixlets Ingo Molnar
4 siblings, 0 replies; 6+ messages in thread
From: Frederic Weisbecker @ 2009-10-14 19:13 UTC (permalink / raw)
To: Ingo Molnar; +Cc: LKML, Frederic Weisbecker, Steven Rostedt, Li Zefan
We are using strncpy in the wrong way to copy the ftrace_graph_filter
boot param because we pass the buffer size instead of the max string
size it can contain (buffer size - 1). The end result might not be
NULL terminated as we are abusing the max string size.
Lets use strlcpy() instead.
Reported-by: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
---
kernel/trace/ftrace.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index aaea9cd..b10c0d9 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -2293,7 +2293,7 @@ __setup("ftrace_filter=", set_ftrace_filter);
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
static int __init set_graph_function(char *str)
{
- strncpy(ftrace_graph_buf, str, FTRACE_FILTER_SIZE);
+ strlcpy(ftrace_graph_buf, str, FTRACE_FILTER_SIZE);
return 1;
}
__setup("ftrace_graph_filter=", set_graph_function);
--
1.6.2.3
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 4/4] ftrace: Rename set_bootup_ftrace into set_cmdline_ftrace
2009-10-14 19:13 [GIT PULL] tracing: Arch syscalls tracing shrinks and fixlets Frederic Weisbecker
` (2 preceding siblings ...)
2009-10-14 19:13 ` [PATCH 3/4] ftrace: Copy ftrace_graph_filter boot param using strlcpy Frederic Weisbecker
@ 2009-10-14 19:13 ` Frederic Weisbecker
2009-10-15 6:40 ` [GIT PULL] tracing: Arch syscalls tracing shrinks and fixlets Ingo Molnar
4 siblings, 0 replies; 6+ messages in thread
From: Frederic Weisbecker @ 2009-10-14 19:13 UTC (permalink / raw)
To: Ingo Molnar; +Cc: LKML, Frederic Weisbecker, Steven Rostedt, Li Zefan
set_cmdline_ftrace is a better match against what does this function:
apply a tracer name from the kernel command line.
Reported-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Li Zefan <lizf@cn.fujitsu.com>
---
kernel/trace/trace.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 4311ec3..026e715 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -129,7 +129,7 @@ static int tracing_set_tracer(const char *buf);
static char bootup_tracer_buf[MAX_TRACER_SIZE] __initdata;
static char *default_bootup_tracer;
-static int __init set_bootup_ftrace(char *str)
+static int __init set_cmdline_ftrace(char *str)
{
strncpy(bootup_tracer_buf, str, MAX_TRACER_SIZE);
default_bootup_tracer = bootup_tracer_buf;
@@ -137,7 +137,7 @@ static int __init set_bootup_ftrace(char *str)
ring_buffer_expanded = 1;
return 1;
}
-__setup("ftrace=", set_bootup_ftrace);
+__setup("ftrace=", set_cmdline_ftrace);
static int __init set_ftrace_dump_on_oops(char *str)
{
--
1.6.2.3
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [GIT PULL] tracing: Arch syscalls tracing shrinks and fixlets
2009-10-14 19:13 [GIT PULL] tracing: Arch syscalls tracing shrinks and fixlets Frederic Weisbecker
` (3 preceding siblings ...)
2009-10-14 19:13 ` [PATCH 4/4] ftrace: Rename set_bootup_ftrace into set_cmdline_ftrace Frederic Weisbecker
@ 2009-10-15 6:40 ` Ingo Molnar
4 siblings, 0 replies; 6+ messages in thread
From: Ingo Molnar @ 2009-10-15 6:40 UTC (permalink / raw)
To: Frederic Weisbecker; +Cc: LKML, Steven Rostedt, Li Zefan
* Frederic Weisbecker <fweisbec@gmail.com> wrote:
> Ingo,
>
> Please pull the tracing/core branch that can be found at:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing.git
> tracing/core
>
> Thanks,
> Frederic.
>
> ---
> Frederic Weisbecker (4):
> tracing: Move syscalls metadata handling from arch to core
> tracing: Document HAVE_SYSCALL_TRACEPOINTS needs
> ftrace: Copy ftrace_graph_filter boot param using strlcpy
> ftrace: Rename set_bootup_ftrace into set_cmdline_ftrace
>
> 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/ftrace.c | 2 +-
> kernel/trace/trace.c | 4 +-
> kernel/trace/trace_syscalls.c | 86 +++++++++++++++++++++++++++++++++
> 7 files changed, 105 insertions(+), 145 deletions(-)
Pulled, thanks a lot Frederic!
Ingo
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-10-15 6:41 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-14 19:13 [GIT PULL] tracing: Arch syscalls tracing shrinks and fixlets Frederic Weisbecker
2009-10-14 19:13 ` [PATCH 1/4] tracing: Move syscalls metadata handling from arch to core Frederic Weisbecker
2009-10-14 19:13 ` [PATCH 2/4] tracing: Document HAVE_SYSCALL_TRACEPOINTS needs Frederic Weisbecker
2009-10-14 19:13 ` [PATCH 3/4] ftrace: Copy ftrace_graph_filter boot param using strlcpy Frederic Weisbecker
2009-10-14 19:13 ` [PATCH 4/4] ftrace: Rename set_bootup_ftrace into set_cmdline_ftrace Frederic Weisbecker
2009-10-15 6:40 ` [GIT PULL] tracing: Arch syscalls tracing shrinks and fixlets Ingo Molnar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®