Commit 66c6e29f authored by Ingo Molnar's avatar Ingo Molnar

Merge branch 'tracing/core' of...

Merge branch 'tracing/core' of git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing into tracing/core
parents 6c347d43 117226d1
...@@ -220,6 +220,29 @@ struct syscall_metadata *syscall_nr_to_meta(int nr) ...@@ -220,6 +220,29 @@ struct syscall_metadata *syscall_nr_to_meta(int nr)
return syscalls_metadata[nr]; 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;
}
static struct syscall_metadata *find_syscall_meta(unsigned long syscall) static struct syscall_metadata *find_syscall_meta(unsigned long syscall)
{ {
struct syscall_metadata *start; struct syscall_metadata *start;
...@@ -237,24 +260,19 @@ static struct syscall_metadata *find_syscall_meta(unsigned long syscall) ...@@ -237,24 +260,19 @@ static struct syscall_metadata *find_syscall_meta(unsigned long syscall)
return NULL; return NULL;
} }
void arch_init_ftrace_syscalls(void) static int __init arch_init_ftrace_syscalls(void)
{ {
struct syscall_metadata *meta; struct syscall_metadata *meta;
int i; int i;
static atomic_t refs;
if (atomic_inc_return(&refs) != 1)
goto out;
syscalls_metadata = kzalloc(sizeof(*syscalls_metadata) * NR_syscalls, syscalls_metadata = kzalloc(sizeof(*syscalls_metadata) * NR_syscalls,
GFP_KERNEL); GFP_KERNEL);
if (!syscalls_metadata) if (!syscalls_metadata)
goto out; return -ENOMEM;
for (i = 0; i < NR_syscalls; i++) { for (i = 0; i < NR_syscalls; i++) {
meta = find_syscall_meta((unsigned long)sys_call_table[i]); meta = find_syscall_meta((unsigned long)sys_call_table[i]);
syscalls_metadata[i] = meta; syscalls_metadata[i] = meta;
} }
return; return 0;
out:
atomic_dec(&refs);
} }
arch_initcall(arch_init_ftrace_syscalls);
#endif #endif
...@@ -28,13 +28,6 @@ ...@@ -28,13 +28,6 @@
#endif #endif
/* FIXME: I don't want to stay hardcoded */
#ifdef CONFIG_X86_64
# define FTRACE_SYSCALL_MAX 299
#else
# define FTRACE_SYSCALL_MAX 337
#endif
#ifdef CONFIG_FUNCTION_TRACER #ifdef CONFIG_FUNCTION_TRACER
#define MCOUNT_ADDR ((long)(mcount)) #define MCOUNT_ADDR ((long)(mcount))
#define MCOUNT_INSN_SIZE 5 /* sizeof mcount call */ #define MCOUNT_INSN_SIZE 5 /* sizeof mcount call */
......
...@@ -345,6 +345,8 @@ ...@@ -345,6 +345,8 @@
#ifdef __KERNEL__ #ifdef __KERNEL__
#define NR_syscalls 337
#define __ARCH_WANT_IPC_PARSE_VERSION #define __ARCH_WANT_IPC_PARSE_VERSION
#define __ARCH_WANT_OLD_READDIR #define __ARCH_WANT_OLD_READDIR
#define __ARCH_WANT_OLD_STAT #define __ARCH_WANT_OLD_STAT
......
...@@ -688,6 +688,12 @@ __SYSCALL(__NR_perf_counter_open, sys_perf_counter_open) ...@@ -688,6 +688,12 @@ __SYSCALL(__NR_perf_counter_open, sys_perf_counter_open)
#endif /* __NO_STUBS */ #endif /* __NO_STUBS */
#ifdef __KERNEL__ #ifdef __KERNEL__
#ifndef COMPILE_OFFSETS
#include <asm/asm-offsets.h>
#define NR_syscalls (__NR_syscall_max + 1)
#endif
/* /*
* "Conditional" syscalls * "Conditional" syscalls
* *
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
* This code generates raw asm output which is post-processed to extract * This code generates raw asm output which is post-processed to extract
* and format the required data. * and format the required data.
*/ */
#define COMPILE_OFFSETS
#include <linux/crypto.h> #include <linux/crypto.h>
#include <linux/sched.h> #include <linux/sched.h>
......
...@@ -494,7 +494,7 @@ static struct syscall_metadata *find_syscall_meta(unsigned long *syscall) ...@@ -494,7 +494,7 @@ static struct syscall_metadata *find_syscall_meta(unsigned long *syscall)
struct syscall_metadata *syscall_nr_to_meta(int nr) struct syscall_metadata *syscall_nr_to_meta(int nr)
{ {
if (!syscalls_metadata || nr >= FTRACE_SYSCALL_MAX || nr < 0) if (!syscalls_metadata || nr >= NR_syscalls || nr < 0)
return NULL; return NULL;
return syscalls_metadata[nr]; return syscalls_metadata[nr];
...@@ -507,7 +507,7 @@ int syscall_name_to_nr(char *name) ...@@ -507,7 +507,7 @@ int syscall_name_to_nr(char *name)
if (!syscalls_metadata) if (!syscalls_metadata)
return -1; return -1;
for (i = 0; i < FTRACE_SYSCALL_MAX; i++) { for (i = 0; i < NR_syscalls; i++) {
if (syscalls_metadata[i]) { if (syscalls_metadata[i]) {
if (!strcmp(syscalls_metadata[i]->name, name)) if (!strcmp(syscalls_metadata[i]->name, name))
return i; return i;
...@@ -533,13 +533,13 @@ static int __init arch_init_ftrace_syscalls(void) ...@@ -533,13 +533,13 @@ static int __init arch_init_ftrace_syscalls(void)
unsigned long **psys_syscall_table = &sys_call_table; unsigned long **psys_syscall_table = &sys_call_table;
syscalls_metadata = kzalloc(sizeof(*syscalls_metadata) * syscalls_metadata = kzalloc(sizeof(*syscalls_metadata) *
FTRACE_SYSCALL_MAX, GFP_KERNEL); NR_syscalls, GFP_KERNEL);
if (!syscalls_metadata) { if (!syscalls_metadata) {
WARN_ON(1); WARN_ON(1);
return -ENOMEM; return -ENOMEM;
} }
for (i = 0; i < FTRACE_SYSCALL_MAX; i++) { for (i = 0; i < NR_syscalls; i++) {
meta = find_syscall_meta(psys_syscall_table[i]); meta = find_syscall_meta(psys_syscall_table[i]);
syscalls_metadata[i] = meta; syscalls_metadata[i] = meta;
} }
......
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
static DEFINE_MUTEX(syscall_trace_lock); static DEFINE_MUTEX(syscall_trace_lock);
static int sys_refcount_enter; static int sys_refcount_enter;
static int sys_refcount_exit; static int sys_refcount_exit;
static DECLARE_BITMAP(enabled_enter_syscalls, FTRACE_SYSCALL_MAX); static DECLARE_BITMAP(enabled_enter_syscalls, NR_syscalls);
static DECLARE_BITMAP(enabled_exit_syscalls, FTRACE_SYSCALL_MAX); static DECLARE_BITMAP(enabled_exit_syscalls, NR_syscalls);
enum print_line_t enum print_line_t
print_syscall_enter(struct trace_iterator *iter, int flags) print_syscall_enter(struct trace_iterator *iter, int flags)
...@@ -227,6 +227,8 @@ void ftrace_syscall_enter(struct pt_regs *regs, long id) ...@@ -227,6 +227,8 @@ void ftrace_syscall_enter(struct pt_regs *regs, long id)
int syscall_nr; int syscall_nr;
syscall_nr = syscall_get_nr(current, regs); syscall_nr = syscall_get_nr(current, regs);
if (syscall_nr < 0)
return;
if (!test_bit(syscall_nr, enabled_enter_syscalls)) if (!test_bit(syscall_nr, enabled_enter_syscalls))
return; return;
...@@ -257,6 +259,8 @@ void ftrace_syscall_exit(struct pt_regs *regs, long ret) ...@@ -257,6 +259,8 @@ void ftrace_syscall_exit(struct pt_regs *regs, long ret)
int syscall_nr; int syscall_nr;
syscall_nr = syscall_get_nr(current, regs); syscall_nr = syscall_get_nr(current, regs);
if (syscall_nr < 0)
return;
if (!test_bit(syscall_nr, enabled_exit_syscalls)) if (!test_bit(syscall_nr, enabled_exit_syscalls))
return; return;
...@@ -285,7 +289,7 @@ int reg_event_syscall_enter(void *ptr) ...@@ -285,7 +289,7 @@ int reg_event_syscall_enter(void *ptr)
name = (char *)ptr; name = (char *)ptr;
num = syscall_name_to_nr(name); num = syscall_name_to_nr(name);
if (num < 0 || num >= FTRACE_SYSCALL_MAX) if (num < 0 || num >= NR_syscalls)
return -ENOSYS; return -ENOSYS;
mutex_lock(&syscall_trace_lock); mutex_lock(&syscall_trace_lock);
if (!sys_refcount_enter) if (!sys_refcount_enter)
...@@ -308,7 +312,7 @@ void unreg_event_syscall_enter(void *ptr) ...@@ -308,7 +312,7 @@ void unreg_event_syscall_enter(void *ptr)
name = (char *)ptr; name = (char *)ptr;
num = syscall_name_to_nr(name); num = syscall_name_to_nr(name);
if (num < 0 || num >= FTRACE_SYSCALL_MAX) if (num < 0 || num >= NR_syscalls)
return; return;
mutex_lock(&syscall_trace_lock); mutex_lock(&syscall_trace_lock);
sys_refcount_enter--; sys_refcount_enter--;
...@@ -326,7 +330,7 @@ int reg_event_syscall_exit(void *ptr) ...@@ -326,7 +330,7 @@ int reg_event_syscall_exit(void *ptr)
name = (char *)ptr; name = (char *)ptr;
num = syscall_name_to_nr(name); num = syscall_name_to_nr(name);
if (num < 0 || num >= FTRACE_SYSCALL_MAX) if (num < 0 || num >= NR_syscalls)
return -ENOSYS; return -ENOSYS;
mutex_lock(&syscall_trace_lock); mutex_lock(&syscall_trace_lock);
if (!sys_refcount_exit) if (!sys_refcount_exit)
...@@ -349,7 +353,7 @@ void unreg_event_syscall_exit(void *ptr) ...@@ -349,7 +353,7 @@ void unreg_event_syscall_exit(void *ptr)
name = (char *)ptr; name = (char *)ptr;
num = syscall_name_to_nr(name); num = syscall_name_to_nr(name);
if (num < 0 || num >= FTRACE_SYSCALL_MAX) if (num < 0 || num >= NR_syscalls)
return; return;
mutex_lock(&syscall_trace_lock); mutex_lock(&syscall_trace_lock);
sys_refcount_exit--; sys_refcount_exit--;
...@@ -369,8 +373,8 @@ struct trace_event event_syscall_exit = { ...@@ -369,8 +373,8 @@ struct trace_event event_syscall_exit = {
#ifdef CONFIG_EVENT_PROFILE #ifdef CONFIG_EVENT_PROFILE
static DECLARE_BITMAP(enabled_prof_enter_syscalls, FTRACE_SYSCALL_MAX); static DECLARE_BITMAP(enabled_prof_enter_syscalls, NR_syscalls);
static DECLARE_BITMAP(enabled_prof_exit_syscalls, FTRACE_SYSCALL_MAX); static DECLARE_BITMAP(enabled_prof_exit_syscalls, NR_syscalls);
static int sys_prof_refcount_enter; static int sys_prof_refcount_enter;
static int sys_prof_refcount_exit; static int sys_prof_refcount_exit;
...@@ -416,7 +420,7 @@ int reg_prof_syscall_enter(char *name) ...@@ -416,7 +420,7 @@ int reg_prof_syscall_enter(char *name)
int num; int num;
num = syscall_name_to_nr(name); num = syscall_name_to_nr(name);
if (num < 0 || num >= FTRACE_SYSCALL_MAX) if (num < 0 || num >= NR_syscalls)
return -ENOSYS; return -ENOSYS;
mutex_lock(&syscall_trace_lock); mutex_lock(&syscall_trace_lock);
...@@ -438,7 +442,7 @@ void unreg_prof_syscall_enter(char *name) ...@@ -438,7 +442,7 @@ void unreg_prof_syscall_enter(char *name)
int num; int num;
num = syscall_name_to_nr(name); num = syscall_name_to_nr(name);
if (num < 0 || num >= FTRACE_SYSCALL_MAX) if (num < 0 || num >= NR_syscalls)
return; return;
mutex_lock(&syscall_trace_lock); mutex_lock(&syscall_trace_lock);
...@@ -477,7 +481,7 @@ int reg_prof_syscall_exit(char *name) ...@@ -477,7 +481,7 @@ int reg_prof_syscall_exit(char *name)
int num; int num;
num = syscall_name_to_nr(name); num = syscall_name_to_nr(name);
if (num < 0 || num >= FTRACE_SYSCALL_MAX) if (num < 0 || num >= NR_syscalls)
return -ENOSYS; return -ENOSYS;
mutex_lock(&syscall_trace_lock); mutex_lock(&syscall_trace_lock);
...@@ -499,7 +503,7 @@ void unreg_prof_syscall_exit(char *name) ...@@ -499,7 +503,7 @@ void unreg_prof_syscall_exit(char *name)
int num; int num;
num = syscall_name_to_nr(name); num = syscall_name_to_nr(name);
if (num < 0 || num >= FTRACE_SYSCALL_MAX) if (num < 0 || num >= NR_syscalls)
return; return;
mutex_lock(&syscall_trace_lock); mutex_lock(&syscall_trace_lock);
......
...@@ -597,7 +597,9 @@ void syscall_regfunc(void) ...@@ -597,7 +597,9 @@ void syscall_regfunc(void)
if (!sys_tracepoint_refcount) { if (!sys_tracepoint_refcount) {
read_lock_irqsave(&tasklist_lock, flags); read_lock_irqsave(&tasklist_lock, flags);
do_each_thread(g, t) { do_each_thread(g, t) {
set_tsk_thread_flag(t, TIF_SYSCALL_TRACEPOINT); /* Skip kernel threads. */
if (t->mm)
set_tsk_thread_flag(t, TIF_SYSCALL_TRACEPOINT);
} while_each_thread(g, t); } while_each_thread(g, t);
read_unlock_irqrestore(&tasklist_lock, flags); read_unlock_irqrestore(&tasklist_lock, flags);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment