tracing/syscalls: Arch code shrinks, easier arch integration
Subsystems (5)
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(-)
PATCH 1/2 tracing: Move syscalls metadata handling from arch to core
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.
--- 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(-)
arch/s390/kernel/ftrace.c +2 -65
@@ -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
arch/x86/kernel/ftrace.c +2 -74
84 lines not on this page · raw message
include/trace/syscall.h +1 -1
@@ -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);
kernel/trace/trace_syscalls.c +80 -0
92 lines not on this page · raw message
Signature · 1 line
1.6.2.3
Re: [PATCH 1/2] tracing: Move syscalls metadata handling from arch to core
Quoted 16 lines · Frederic Weisbecker
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 <[email protected]>Cc Ingo Molnar <[email protected]>Cc Steven Rostedt <[email protected]>Cc Li Zefan <[email protected]>Cc Masami Hiramatsu <[email protected]>Cc Jason Baron <[email protected]>Cc Lai Jiangshan <[email protected]>Cc Heiko Carstens <[email protected]>Cc Martin Schwidefsky <[email protected]>Cc Paul Mundt <[email protected]>
Quoted 6 lines
--- 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
Re: [PATCH 1/2] tracing: Move syscalls metadata handling from arch to core
In reply to Frederic WeisbeckerQuoted 5 lines · Frederic Weisbecker
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:
Quoted 6 lines
arch/s390/kernel/ftrace.c +0
-2-static struct syscall_metadata *find_syscall_meta (unsigned long syscall) -{
arch/s390/kernel/ftrace.c out: · line 257
Quoted 10 lines
arch/s390/kernel/ftrace.c +0
-10-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 ))
^^^^^^^^^^^^^^^^^^^^^^^^
Quoted 7 lines
arch/x86/kernel/ftrace.c +0
-3-static struct syscall_metadata *find_syscall_meta (unsigned long *syscall) -{ -struct syscall_metadata *start;
arch/x86/kernel/ftrace.c void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr, · line 489
Quoted 10 lines
arch/x86/kernel/ftrace.c +0
-10-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))
^^^^^^^^^^^^^^^^
arch/x86/kernel/ftrace.c
Quoted 3 lines
arch/x86/kernel/ftrace.c +0
-3-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_cpuinfo000000000001c9e0 T SyS_s390_personality000000000001c9e0 T sys_s390_personality000000000001ca48 T SyS_s390_newuname000000000001ca48 T sys_s390_newuname000000000001cac8 T SyS_ipc000000000001cac8 T sys_ipc000000000001cd00 T SyS_s390_old_mmap000000000001cd00 T sys_s390_old_mmap000000000001ce68 T SyS_mmap2000000000001ce68 T sys_mmap2000000000001cfc4 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.
Re: [PATCH 1/2] tracing: Move syscalls metadata handling from arch to core
Quoted 19 lines · Heiko Carstens
Quoted 5 lines · Frederic Weisbecker
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:
Quoted 9 lines
arch/s390/kernel/ftrace.c +0
-5-static struct syscall_metadata *find_syscall_meta (unsigned long syscall) -{ -struct syscall_metadata *start; -struct syscall_metadata *stop; -char str[KSYM_SYMBOL_LEN ];
Quoted 8 lines
arch/s390/kernel/ftrace.c out: · line 257
Quoted 7 lines
arch/s390/kernel/ftrace.c +0
-7- - 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.
Quoted 38 lines
Quoted 7 lines
arch/x86/kernel/ftrace.c +0
-3-static struct syscall_metadata *find_syscall_meta (unsigned long *syscall) -{ -struct syscall_metadata *start;arch/x86/kernel/ftrace.c void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr, · line 489
Quoted 10 lines
arch/x86/kernel/ftrace.c +0
-10-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))^^^^^^^^^^^^^^^^arch/x86/kernel/ftrace.c
Quoted 3 lines
arch/x86/kernel/ftrace.c +0
-3-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:
000000000001c788tshow_cpuinfo000000000001c9e0TSyS_s390_personality000000000001c9e0Tsys_s390_personality000000000001ca48TSyS_s390_newuname000000000001ca48Tsys_s390_newuname000000000001cac8TSyS_ipc000000000001cac8Tsys_ipc000000000001cd00TSyS_s390_old_mmap000000000001cd00Tsys_s390_old_mmap000000000001ce68TSyS_mmap2000000000001ce68Tsys_mmap2000000000001cfc4t FixPerRegisters
Quoted 6 lines
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!
Quoted 3 lines
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!
PATCH 2/2 tracing: Document HAVE_FTRACE_SYSCALLS needs
In reply to Frederic WeisbeckerDocument the arch needed requirements to get the support for syscalls tracing.
--- Documentation/trace/ftrace-design.txt | 11 ++++++++++- 1 files changed, 10 insertions(+), 1 deletions(-)
Documentation/trace/ftrace-design.txt +10 -1
@@ -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
Signature · 1 line
1.6.2.3
Re: [PATCH 2/2] tracing: Document HAVE_FTRACE_SYSCALLS needs
Quoted 26 lines · Frederic Weisbecker
Document the arch needed requirements to get the support for syscalls tracing.
Signed-off-by Frederic Weisbecker <[email protected]>Cc Ingo Molnar <[email protected]>Cc Steven Rostedt <[email protected]>Cc Li Zefan <[email protected]>Cc Masami Hiramatsu <[email protected]>Cc Jason Baron <[email protected]>Cc Lai Jiangshan <[email protected]>Cc Heiko Carstens <[email protected]>Cc Martin Schwidefsky <[email protected]>Cc Paul Mundt <[email protected]>--- Documentation/trace/ftrace-design.txt | 11 ++++++++++- 1 files changed, 10 insertions(+), 1 deletions(-)Documentation/trace/ftrace-design.txt +0
-1@@ -216,7 +216,16 @@ If you can't trace NMI functions, then skip this option. HAVE_FTRACE_SYSCALLS --------------------- -<details to be filled>
Documentation/trace/ftrace-design.txt If you can't trace NMI functions, then skip this option. · line 228
Quoted 10 lines
Documentation/trace/ftrace-design.txt +10
-0+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
Re: [PATCH 2/2] tracing: Document HAVE_FTRACE_SYSCALLS needs
Quoted 42 lines · Ingo Molnar
Quoted 26 lines · Frederic Weisbecker
Document the arch needed requirements to get the support for syscalls tracing.
Signed-off-by Frederic Weisbecker <[email protected]>Cc Ingo Molnar <[email protected]>Cc Steven Rostedt <[email protected]>Cc Li Zefan <[email protected]>Cc Masami Hiramatsu <[email protected]>Cc Jason Baron <[email protected]>Cc Lai Jiangshan <[email protected]>Cc Heiko Carstens <[email protected]>Cc Martin Schwidefsky <[email protected]>Cc Paul Mundt <[email protected]>--- Documentation/trace/ftrace-design.txt | 11 ++++++++++- 1 files changed, 10 insertions(+), 1 deletions(-)Documentation/trace/ftrace-design.txt +0
-1@@ -216,7 +216,16 @@ If you can't trace NMI functions, then skip this option. HAVE_FTRACE_SYSCALLS --------------------- -<details to be filled>Documentation/trace/ftrace-design.txt If you can't trace NMI functions, then skip this option. · line 228
Quoted 10 lines
Documentation/trace/ftrace-design.txt +10
-0+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_SYSCALLSis not actually used anywhere.
Quoted 1 line
Ingo
Ah, that has been renamed HAVE_SYSCALL_TRACEPOINTS recently. What do you prefer? A delta patch or a rebase?
Thanks.
Re: [PATCH 2/2] tracing: Document HAVE_FTRACE_SYSCALLS needs
Quoted 43 lines · Frederic Weisbecker
Quoted 42 lines · Ingo Molnar
Quoted 26 lines · Frederic Weisbecker
Document the arch needed requirements to get the support for syscalls tracing.
Signed-off-by Frederic Weisbecker <[email protected]>Cc Ingo Molnar <[email protected]>Cc Steven Rostedt <[email protected]>Cc Li Zefan <[email protected]>Cc Masami Hiramatsu <[email protected]>Cc Jason Baron <[email protected]>Cc Lai Jiangshan <[email protected]>Cc Heiko Carstens <[email protected]>Cc Martin Schwidefsky <[email protected]>Cc Paul Mundt <[email protected]>--- Documentation/trace/ftrace-design.txt | 11 ++++++++++- 1 files changed, 10 insertions(+), 1 deletions(-)Documentation/trace/ftrace-design.txt +0
-1@@ -216,7 +216,16 @@ If you can't trace NMI functions, then skip this option. HAVE_FTRACE_SYSCALLS --------------------- -<details to be filled>Documentation/trace/ftrace-design.txt If you can't trace NMI functions, then skip this option. · line 228
Quoted 10 lines
Documentation/trace/ftrace-design.txt +10
-0+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_SYSCALLSis not actually used anywhere.
Quoted 4 lines
Quoted 1 line
Ingo
Ah, that has been renamed
HAVE_SYSCALL_TRACEPOINTSrecently. 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
Re: [PATCH 2/2] tracing: Document HAVE_FTRACE_SYSCALLS needs
Quoted 48 lines · Ingo Molnar
Quoted 45 lines · Frederic Weisbecker
Quoted 43 lines · Ingo Molnar
Quoted 26 lines · Frederic Weisbecker
Document the arch needed requirements to get the support for syscalls tracing.
Signed-off-by Frederic Weisbecker <[email protected]>Cc Ingo Molnar <[email protected]>Cc Steven Rostedt <[email protected]>Cc Li Zefan <[email protected]>Cc Masami Hiramatsu <[email protected]>Cc Jason Baron <[email protected]>Cc Lai Jiangshan <[email protected]>Cc Heiko Carstens <[email protected]>Cc Martin Schwidefsky <[email protected]>Cc Paul Mundt <[email protected]>--- Documentation/trace/ftrace-design.txt | 11 ++++++++++- 1 files changed, 10 insertions(+), 1 deletions(-)Documentation/trace/ftrace-design.txt +0
-1@@ -216,7 +216,16 @@ If you can't trace NMI functions, then skip this option. HAVE_FTRACE_SYSCALLS --------------------- -<details to be filled>Documentation/trace/ftrace-design.txt If you can't trace NMI functions, then skip this option. · line 228
Quoted 10 lines
Documentation/trace/ftrace-design.txt +10
-0+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_SYSCALLSis not actually used anywhere.Ingo
Quoted 7 lines
Quoted 2 lines
Ah, that has been renamed
HAVE_SYSCALL_TRACEPOINTSrecently. 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.
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(-)
Quoted 5 lines · Frederic Weisbecker
Ingo, Heiko,
I've updated the patches following your reviews.
Please tell me if you see another troubles.
Quoted 7 lines
The new tree can be pulled from:
git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing.git
tracing/syscalls-v2Thanks,
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.
Quoted 10 lines
Frederic Weisbecker (2):
tracing: Move syscalls metadata handling from arch to core
tracing: DocumentHAVE_SYSCALL_TRACEPOINTSneedsDocumentation/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(-)
Quoted 15 lines · Frederic Weisbecker
Quoted 5 lines · Frederic Weisbecker
Ingo, Heiko,
I've updated the patches following your reviews.
Please tell me if you see another troubles.Quoted 7 lines
The new tree can be pulled from:
git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing.git
tracing/syscalls-v2Thanks,
Frederic.
Quoted 18 lines
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.
Quoted 6 lines
Frederic Weisbecker (2):
tracing: Move syscalls metadata handling from arch to core
tracing: DocumentHAVE_SYSCALL_TRACEPOINTSneedsDocumentation/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 <[email protected]>
M: Heiko Carstens <[email protected]>
Thanks,
Ingo
Heiko Carstens
Acked-byQuoted 26 lines · Ingo Molnar
Quoted 8 lines · Frederic Weisbecker
Quoted 7 lines · Frederic Weisbecker
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:
Quoted 14 lines
Quoted 2 lines
git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing.git
tracing/syscalls-v2Ingo,
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.
Quoted 6 lines
Frederic Weisbecker (2):
tracing: Move syscalls metadata handling from arch to core
tracing: DocumentHAVE_SYSCALL_TRACEPOINTSneedsDocumentation/trace/ftrace-design.txt | 13 ++++- arch/s390/kernel/ftrace.c | 67 +-------------------------
Quoted 6 lines
I skipped it because the s390 bit needs the ack of at least one of these gents:
S390
M: Martin Schwidefsky <[email protected]>
M: Heiko Carstens <[email protected]>
PATCH v2 1/2 tracing: Move syscalls metadata handling from arch to core
In reply to Frederic WeisbeckerMost 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)
--- 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(-)
arch/s390/kernel/ftrace.c +2 -65
@@ -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
arch/x86/kernel/ftrace.c +2 -74
84 lines not on this page · raw message
include/trace/syscall.h +1 -1
@@ -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);
kernel/trace/trace_syscalls.c +86 -0
98 lines not on this page · raw message
Signature · 1 line
1.6.2.3
PATCH v2 2/2 tracing: Document HAVE_SYSCALL_TRACEPOINTS needs
In reply to Frederic WeisbeckerDocument 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.
--- Documentation/trace/ftrace-design.txt | 13 +++++++++++-- 1 files changed, 11 insertions(+), 2 deletions(-)
Documentation/trace/ftrace-design.txt +11 -2
@@ -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
Signature · 1 line
1.6.2.3