Skip to contentSkip to conversation

tracing/syscalls: Arch code shrinks, easier arch integration

GIT PULL Superseded Frederic Weisbecker 3 participants 16 messages Sep 19, 2009 – Oct 14, 2009

Subsystems (5)
Documentation x86 Tracing s390 +1 more subsystems
lore
Share & tools
lore
#0 lore raw

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(-)
#1 lore raw

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.

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]>
---
 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
index 57bdcb1..7c5752c 100644
@@ -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
index 5dc283b..e972f0a 100644
@@ -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
#2 lore raw

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.

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

#3 lore raw

Re: [PATCH 1/2] tracing: Move syscalls metadata handling from arch to core

In reply to Frederic Weisbecker
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 6 lines
arch/s390/kernel/ftrace.c +0 -2
index 57bdcb1..7c5752c 100644
-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
index 9dbb527..4adb867 100644
-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_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.

#4 lore raw

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
index 57bdcb1..7c5752c 100644
-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
index 9dbb527..4adb867 100644
-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_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

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!

#5 lore raw

PATCH 2/2 tracing: Document HAVE_FTRACE_SYSCALLS needs

In reply to Frederic Weisbecker

Document the arch needed requirements to get the support for syscalls tracing.

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 +10 -1
index 7003e10..04ab61c 100644
@@ -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
#6 lore raw

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.

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
index 7003e10..04ab61c 100644
@@ -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

#7 lore raw

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.

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
index 7003e10..04ab61c 100644
@@ -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.

Quoted 1 line

Ingo

Ah, that has been renamed HAVE_SYSCALL_TRACEPOINTS recently. What do you prefer? A delta patch or a rebase?

Thanks.

#8 lore raw

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.

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
index 7003e10..04ab61c 100644
@@ -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.

Quoted 4 lines
Quoted 1 line

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

#9 lore raw

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.

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
index 7003e10..04ab61c 100644
@@ -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

Quoted 7 lines
Quoted 2 lines

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.

#10 lore raw
In reply to 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:

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(-)
#11 lore raw
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-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.

Quoted 10 lines

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(-)
#12 lore raw
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-v2

Thanks,
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: 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 <[email protected]>
M: Heiko Carstens <[email protected]>

Thanks,

Ingo

#13 lore raw
Quoted 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-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.

Quoted 6 lines

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 +-------------------------
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]>

#14 lore raw

PATCH v2 1/2 tracing: Move syscalls metadata handling from arch to core

In reply to 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.

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)

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]>
---
 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
index 57bdcb1..7c5752c 100644
@@ -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
index 5dc283b..e972f0a 100644
@@ -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
#15 lore raw

PATCH v2 2/2 tracing: Document HAVE_SYSCALL_TRACEPOINTS needs

In reply to Frederic Weisbecker

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.

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 |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)
Documentation/trace/ftrace-design.txt +11 -2
index 7003e10..641a1ef 100644
@@ -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