cregit-Linux how code gets into the kernel

Release 4.7 kernel/trace/trace_syscalls.c

Directory: kernel/trace
#include <trace/syscall.h>
#include <trace/events/syscalls.h>
#include <linux/syscalls.h>
#include <linux/slab.h>
#include <linux/kernel.h>
#include <linux/module.h>	/* for MODULE_NAME_LEN via KSYM_SYMBOL_LEN */
#include <linux/ftrace.h>
#include <linux/perf_event.h>
#include <asm/syscall.h>

#include "trace_output.h"
#include "trace.h"

static DEFINE_MUTEX(syscall_trace_lock);

static int syscall_enter_register(struct trace_event_call *event,
				 enum trace_reg type, void *data);
static int syscall_exit_register(struct trace_event_call *event,
				 enum trace_reg type, void *data);


static struct list_head * syscall_get_enter_fields(struct trace_event_call *call) { struct syscall_metadata *entry = call->data; return &entry->enter_fields; }

Contributors

PersonTokensPropCommitsCommitProp
steven rostedtsteven rostedt28100.00%2100.00%
Total28100.00%2100.00%

extern struct syscall_metadata *__start_syscalls_metadata[]; extern struct syscall_metadata *__stop_syscalls_metadata[]; static struct syscall_metadata **syscalls_metadata; #ifndef ARCH_HAS_SYSCALL_MATCH_SYM_NAME
static inline bool arch_syscall_match_sym_name(const char *sym, const char *name) { /* * Only compare after the "sys" prefix. Archs that use * syscall wrappers may have syscalls symbols aliases prefixed * with ".SyS" or ".sys" instead of "sys", leading to an unwanted * mismatch. */ return !strcmp(sym + 3, name + 3); }

Contributors

PersonTokensPropCommitsCommitProp
ian munsieian munsie3096.77%150.00%
jovi zhangweijovi zhangwei13.23%150.00%
Total31100.00%2100.00%

#endif #ifdef ARCH_TRACE_IGNORE_COMPAT_SYSCALLS /* * Some architectures that allow for 32bit applications * to run on a 64bit kernel, do not map the syscalls for * the 32bit tasks the same as they do for 64bit tasks. * * *cough*x86*cough* * * In such a case, instead of reporting the wrong syscalls, * simply ignore them. * * For an arch to ignore the compat syscalls it needs to * define ARCH_TRACE_IGNORE_COMPAT_SYSCALLS as well as * define the function arch_trace_is_compat_syscall() to let * the tracing system know that it should ignore it. */
static int trace_get_syscall_nr(struct task_struct *task, struct pt_regs *regs) { if (unlikely(arch_trace_is_compat_syscall(regs))) return -1; return syscall_get_nr(task, regs); }

Contributors

PersonTokensPropCommitsCommitProp
steven rostedtsteven rostedt38100.00%1100.00%
Total38100.00%1100.00%

#else
static inline int trace_get_syscall_nr(struct task_struct *task, struct pt_regs *regs) { return syscall_get_nr(task, regs); }

Contributors

PersonTokensPropCommitsCommitProp
steven rostedtsteven rostedt25100.00%1100.00%
Total25100.00%1100.00%

#endif /* ARCH_TRACE_IGNORE_COMPAT_SYSCALLS */ static __init struct syscall_metadata * find_syscall_meta(unsigned long syscall) { struct syscall_metadata **start; struct syscall_metadata **stop; char str[KSYM_SYMBOL_LEN]; start = __start_syscalls_metadata; stop = __stop_syscalls_metadata; kallsyms_lookup(syscall, NULL, NULL, NULL, str); if (arch_syscall_match_sym_name(str, "sys_ni_syscall")) return NULL; for ( ; start < stop; start++) { if ((*start)->name && arch_syscall_match_sym_name(str, (*start)->name)) 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]; }

Contributors

PersonTokensPropCommitsCommitProp
frederic weisbeckerfrederic weisbecker3296.97%150.00%
steven rostedtsteven rostedt13.03%150.00%
Total33100.00%2100.00%


const char *get_syscall_name(int syscall) { struct syscall_metadata *entry; entry = syscall_nr_to_meta(syscall); if (!entry) return NULL; return entry->name; }

Contributors

PersonTokensPropCommitsCommitProp
tom zanussitom zanussi35100.00%1100.00%
Total35100.00%1100.00%


static enum print_line_t print_syscall_enter(struct trace_iterator *iter, int flags, struct trace_event *event) { struct trace_array *tr = iter->tr; struct trace_seq *s = &iter->seq; struct trace_entry *ent = iter->ent; struct syscall_trace_enter *trace; struct syscall_metadata *entry; int i, syscall; trace = (typeof(trace))ent; syscall = trace->nr; entry = syscall_nr_to_meta(syscall); if (!entry) goto end; if (entry->enter_event->event.type != ent->type) { WARN_ON_ONCE(1); goto end; } trace_seq_printf(s, "%s(", entry->name); for (i = 0; i < entry->nb_args; i++) { if (trace_seq_has_overflowed(s)) goto end; /* parameter types */ if (tr->trace_flags & TRACE_ITER_VERBOSE) trace_seq_printf(s, "%s ", entry->types[i]); /* parameter values */ trace_seq_printf(s, "%s: %lx%s", entry->args[i], trace->args[i], i == entry->nb_args - 1 ? "" : ", "); } trace_seq_putc(s, ')'); end: trace_seq_putc(s, '\n'); return trace_handle_return(s); }

Contributors

PersonTokensPropCommitsCommitProp
frederic weisbeckerfrederic weisbecker15967.66%110.00%
steven rostedtsteven rostedt3314.04%440.00%
jason baronjason baron2510.64%110.00%
li zefanli zefan156.38%220.00%
lai jiangshanlai jiangshan20.85%110.00%
fengguang wufengguang wu10.43%110.00%
Total235100.00%10100.00%


static enum print_line_t print_syscall_exit(struct trace_iterator *iter, int flags, struct trace_event *event) { struct trace_seq *s = &iter->seq; struct trace_entry *ent = iter->ent; struct syscall_trace_exit *trace; int syscall; struct syscall_metadata *entry; trace = (typeof(trace))ent; syscall = trace->nr; entry = syscall_nr_to_meta(syscall); if (!entry) { trace_seq_putc(s, '\n'); goto out; } if (entry->exit_event->event.type != ent->type) { WARN_ON_ONCE(1); return TRACE_TYPE_UNHANDLED; } trace_seq_printf(s, "%s -> 0x%lx\n", entry->name, trace->ret); out: return trace_handle_return(s); }

Contributors

PersonTokensPropCommitsCommitProp
frederic weisbeckerfrederic weisbecker9266.19%112.50%
jason baronjason baron2517.99%112.50%
steven rostedtsteven rostedt1712.23%337.50%
jovi zhangweijovi zhangwei21.44%112.50%
lai jiangshanlai jiangshan21.44%112.50%
fengguang wufengguang wu10.72%112.50%
Total139100.00%8100.00%

extern char *__bad_type_size(void); #define SYSCALL_FIELD(type, field, name) \ sizeof(type) != sizeof(trace.field) ? \ __bad_type_size() : \ #type, #name, offsetof(typeof(trace), field), \ sizeof(trace.field), is_signed_type(type)
static int __init __set_enter_print_fmt(struct syscall_metadata *entry, char *buf, int len) { int i; int pos = 0; /* When len=0, we just calculate the needed length */ #define LEN_OR_ZERO (len ? len - pos : 0) pos += snprintf(buf + pos, LEN_OR_ZERO, "\""); for (i = 0; i < entry->nb_args; i++) { pos += snprintf(buf + pos, LEN_OR_ZERO, "%s: 0x%%0%zulx%s", entry->args[i], sizeof(unsigned long), i == entry->nb_args - 1 ? "" : ", "); } pos += snprintf(buf + pos, LEN_OR_ZERO, "\""); for (i = 0; i < entry->nb_args; i++) { pos += snprintf(buf + pos, LEN_OR_ZERO, ", ((unsigned long)(REC->%s))", entry->args[i]); } #undef LEN_OR_ZERO /* return the length of print_fmt */ return pos; }

Contributors

PersonTokensPropCommitsCommitProp
lai jiangshanlai jiangshan15699.36%150.00%
li zefanli zefan10.64%150.00%
Total157100.00%2100.00%


static int __init set_syscall_print_fmt(struct trace_event_call *call) { char *print_fmt; int len; struct syscall_metadata *entry = call->data; if (entry->enter_event != call) { call->print_fmt = "\"0x%lx\", REC->ret"; return 0; } /* First: called with 0 length to calculate the needed length */ len = __set_enter_print_fmt(entry, NULL, 0); print_fmt = kmalloc(len + 1, GFP_KERNEL); if (!print_fmt) return -ENOMEM; /* Second: actually write the @print_fmt */ __set_enter_print_fmt(entry, print_fmt, len + 1); call->print_fmt = print_fmt; return 0; }

Contributors

PersonTokensPropCommitsCommitProp
lai jiangshanlai jiangshan9898.00%133.33%
steven rostedtsteven rostedt11.00%133.33%
li zefanli zefan11.00%133.33%
Total100100.00%3100.00%


static void __init free_syscall_print_fmt(struct trace_event_call *call) { struct syscall_metadata *entry = call->data; if (entry->enter_event == call) kfree(call->print_fmt); }

Contributors

PersonTokensPropCommitsCommitProp
lai jiangshanlai jiangshan3494.44%133.33%
steven rostedtsteven rostedt12.78%133.33%
li zefanli zefan12.78%133.33%
Total36100.00%3100.00%


static int __init syscall_enter_define_fields(struct trace_event_call *call) { struct syscall_trace_enter trace; struct syscall_metadata *meta = call->data; int ret; int i; int offset = offsetof(typeof(trace), args); ret = trace_define_field(call, SYSCALL_FIELD(int, nr, __syscall_nr), FILTER_OTHER); if (ret) return ret; for (i = 0; i < meta->nb_args; i++) { ret = trace_define_field(call, meta->types[i], meta->args[i], offset, sizeof(unsigned long), 0, FILTER_OTHER); offset += sizeof(unsigned long); } return ret; }

Contributors

PersonTokensPropCommitsCommitProp
li zefanli zefan10177.69%337.50%
lai jiangshanlai jiangshan2519.23%225.00%
taeung songtaeung song21.54%112.50%
steven rostedtsteven rostedt21.54%225.00%
Total130100.00%8100.00%


static int __init syscall_exit_define_fields(struct trace_event_call *call) { struct syscall_trace_exit trace; int ret; ret = trace_define_field(call, SYSCALL_FIELD(int, nr, __syscall_nr), FILTER_OTHER); if (ret) return ret; ret = trace_define_field(call, SYSCALL_FIELD(long, ret, ret), FILTER_OTHER); return ret; }

Contributors

PersonTokensPropCommitsCommitProp
li zefanli zefan3452.31%337.50%
lai jiangshanlai jiangshan2335.38%112.50%
taeung songtaeung song46.15%112.50%
steven rostedtsteven rostedt23.08%225.00%
tom zanussitom zanussi23.08%112.50%
Total65100.00%8100.00%


static void ftrace_syscall_enter(void *data, struct pt_regs *regs, long id) { struct trace_array *tr = data; struct trace_event_file *trace_file; struct syscall_trace_enter *entry; struct syscall_metadata *sys_data; struct ring_buffer_event *event; struct ring_buffer *buffer; unsigned long irq_flags; int pc; int syscall_nr; int size; syscall_nr = trace_get_syscall_nr(current, regs); if (syscall_nr < 0 || syscall_nr >= NR_syscalls) return; /* Here we're inside tp handler's rcu_read_lock_sched (__DO_TRACE) */ trace_file = rcu_dereference_sched(tr->enter_syscall_files[syscall_nr]); if (!trace_file) return; if (trace_trigger_soft_disabled(trace_file)) return; sys_data = syscall_nr_to_meta(syscall_nr); if (!sys_data) return; size = sizeof(*entry) + sizeof(unsigned long) * sys_data->nb_args; local_save_flags(irq_flags); pc = preempt_count(); buffer = tr->trace_buffer.buffer; event = trace_buffer_lock_reserve(buffer, sys_data->enter_event->event.type, size, irq_flags, pc); if (!event) return; entry = ring_buffer_event_data(event); entry->nr = syscall_nr; syscall_get_arguments(current, regs, 0, sys_data->nb_args, entry->args); event_trigger_unlock_commit(trace_file, buffer, event, entry, irq_flags, pc); }

Contributors

PersonTokensPropCommitsCommitProp
frederic weisbeckerfrederic weisbecker11650.22%29.09%
steven rostedtsteven rostedt4117.75%940.91%
tom zanussitom zanussi2611.26%313.64%
jovi zhangweijovi zhangwei219.09%14.55%
jason baronjason baron104.33%29.09%
hendrik bruecknerhendrik brueckner73.03%14.55%
rabin vincentrabin vincent41.73%14.55%
li zefanli zefan31.30%14.55%
lai jiangshanlai jiangshan20.87%14.55%
fengguang wufengguang wu10.43%14.55%
Total231100.00%22100.00%


static void ftrace_syscall_exit(void *data, struct pt_regs *regs, long ret) { struct trace_array *tr = data; struct trace_event_file *trace_file; struct syscall_trace_exit *entry; struct syscall_metadata *sys_data; struct ring_buffer_event *event; struct ring_buffer *buffer; unsigned long irq_flags; int pc; int syscall_nr; syscall_nr = trace_get_syscall_nr(current, regs); if (syscall_nr < 0 || syscall_nr >= NR_syscalls) return; /* Here we're inside tp handler's rcu_read_lock_sched (__DO_TRACE()) */ trace_file = rcu_dereference_sched(tr->exit_syscall_files[syscall_nr]); if (!trace_file) return; if (trace_trigger_soft_disabled(trace_file)) return; sys_data = syscall_nr_to_meta(syscall_nr); if (!sys_data) return; local_save_flags(irq_flags); pc = preempt_count(); buffer = tr->trace_buffer.buffer; event = trace_buffer_lock_reserve(buffer, sys_data->exit_event->event.type, sizeof(*entry), irq_flags, pc); if (!event) return; entry = ring_buffer_event_data(event); entry->nr = syscall_nr; entry->ret = syscall_get_return_value(current, regs); event_trigger_unlock_commit(trace_file, buffer, event, entry, irq_flags, pc); }

Contributors

PersonTokensPropCommitsCommitProp
frederic weisbeckerfrederic weisbecker9545.67%29.09%
steven rostedtsteven rostedt3918.75%940.91%
tom zanussitom zanussi2612.50%313.64%
jovi zhangweijovi zhangwei2110.10%14.55%
jason baronjason baron104.81%29.09%
hendrik bruecknerhendrik brueckner73.37%14.55%
rabin vincentrabin vincent41.92%14.55%
li zefanli zefan31.44%14.55%
lai jiangshanlai jiangshan20.96%14.55%
fengguang wufengguang wu10.48%14.55%
Total208100.00%22100.00%


static int reg_event_syscall_enter(struct trace_event_file *file, struct trace_event_call *call) { struct trace_array *tr = file->tr; int ret = 0; int num; num = ((struct syscall_metadata *)call->data)->syscall_nr; if (WARN_ON_ONCE(num < 0 || num >= NR_syscalls)) return -ENOSYS; mutex_lock(&syscall_trace_lock); if (!tr->sys_refcount_enter) ret = register_trace_sys_enter(ftrace_syscall_enter, tr); if (!ret) { rcu_assign_pointer(tr->enter_syscall_files[num], file); tr->sys_refcount_enter++; } mutex_unlock(&syscall_trace_lock); return ret; }

Contributors

PersonTokensPropCommitsCommitProp
jason baronjason baron6050.00%212.50%
steven rostedtsteven rostedt2319.17%425.00%
frederic weisbeckerfrederic weisbecker1210.00%212.50%
tom zanussitom zanussi75.83%16.25%
lai jiangshanlai jiangshan75.83%212.50%
masami hiramatsumasami hiramatsu54.17%16.25%
ian munsieian munsie32.50%16.25%
fengguang wufengguang wu10.83%16.25%
josh stonejosh stone10.83%16.25%
li zefanli zefan10.83%16.25%
Total120100.00%16100.00%


static void unreg_event_syscall_enter(struct trace_event_file *file, struct trace_event_call *call) { struct trace_array *tr = file->tr; int num; num = ((struct syscall_metadata *)call->data)->syscall_nr; if (WARN_ON_ONCE(num < 0 || num >= NR_syscalls)) return; mutex_lock(&syscall_trace_lock); tr->sys_refcount_enter--; RCU_INIT_POINTER(tr->enter_syscall_files[num], NULL); if (!tr->sys_refcount_enter) unregister_trace_sys_enter(ftrace_syscall_enter, tr); mutex_unlock(&syscall_trace_lock); }

Contributors

PersonTokensPropCommitsCommitProp
jason baronjason baron4949.00%212.50%
steven rostedtsteven rostedt2323.00%425.00%
lai jiangshanlai jiangshan77.00%212.50%
tom zanussitom zanussi66.00%16.25%
masami hiramatsumasami hiramatsu55.00%16.25%
frederic weisbeckerfrederic weisbecker44.00%212.50%
ian munsieian munsie33.00%16.25%
fengguang wufengguang wu11.00%16.25%
josh stonejosh stone11.00%16.25%
andreea-cristina bernatandreea-cristina bernat11.00%16.25%
Total100100.00%16100.00%


static int reg_event_syscall_exit(struct trace_event_file *file, struct trace_event_call *call) { struct trace_array *tr = file->tr; int ret = 0; int num; num = ((struct syscall_metadata *)call->data)->syscall_nr; if (WARN_ON_ONCE(num < 0 || num >= NR_syscalls)) return -ENOSYS; mutex_lock(&syscall_trace_lock); if (!tr->sys_refcount_exit) ret = register_trace_sys_exit(ftrace_syscall_exit, tr); if (!ret) { rcu_assign_pointer(tr->exit_syscall_files[num], file); tr->sys_refcount_exit++; } mutex_unlock(&syscall_trace_lock); return ret; }

Contributors

PersonTokensPropCommitsCommitProp
jason baronjason baron4638.33%213.33%
frederic weisbeckerfrederic weisbecker2319.17%16.67%
steven rostedtsteven rostedt2319.17%426.67%
lai jiangshanlai jiangshan108.33%213.33%
tom zanussitom zanussi75.83%16.67%
masami hiramatsumasami hiramatsu54.17%16.67%
ian munsieian munsie32.50%16.67%
li zefanli zefan10.83%16.67%
josh stonejosh stone10.83%16.67%
fengguang wufengguang wu10.83%16.67%
Total120100.00%15100.00%


static void unreg_event_syscall_exit(struct trace_event_file *file, struct trace_event_call *call) { struct trace_array *tr = file->tr; int num; num = ((struct syscall_metadata *)call->data)->syscall_nr; if (WARN_ON_ONCE(num < 0 || num >= NR_syscalls)) return; mutex_lock(&syscall_trace_lock); tr->sys_refcount_exit--; RCU_INIT_POINTER(tr->exit_syscall_files[num], NULL); if (!tr->sys_refcount_exit) unregister_trace_sys_exit(ftrace_syscall_exit, tr); mutex_unlock(&syscall_trace_lock); }

Contributors

PersonTokensPropCommitsCommitProp
jason baronjason baron3636.00%213.33%
steven rostedtsteven rostedt2323.00%426.67%
frederic weisbeckerfrederic weisbecker1414.00%16.67%
lai jiangshanlai jiangshan1010.00%213.33%
tom zanussitom zanussi66.00%16.67%
masami hiramatsumasami hiramatsu55.00%16.67%
ian munsieian munsie33.00%16.67%
josh stonejosh stone11.00%16.67%
andreea-cristina bernatandreea-cristina bernat11.00%16.67%
fengguang wufengguang wu11.00%16.67%
Total100100.00%15100.00%


static int __init init_syscall_trace(struct trace_event_call *call) { int id; int num; num = ((struct syscall_metadata *)call->data)->syscall_nr; if (num < 0 || num >= NR_syscalls) { pr_debug("syscall %s metadata not mapped, disabling ftrace event\n", ((struct syscall_metadata *)call->data)->name); return -ENOSYS; } if (set_syscall_print_fmt(call) < 0) return -ENOMEM; id = trace_event_raw_init(call); if (id < 0) { free_syscall_print_fmt(call); return id; } return id; }

Contributors

PersonTokensPropCommitsCommitProp
ian munsieian munsie5249.06%114.29%
lai jiangshanlai jiangshan4643.40%228.57%
steven rostedtsteven rostedt65.66%228.57%
vaibhav nagarnaikvaibhav nagarnaik10.94%114.29%
li zefanli zefan10.94%114.29%
Total106100.00%7100.00%

struct trace_event_functions enter_syscall_print_funcs = { .trace = print_syscall_enter, }; struct trace_event_functions exit_syscall_print_funcs = { .trace = print_syscall_exit, }; struct trace_event_class __refdata event_class_syscall_enter = { .system = "syscalls", .reg = syscall_enter_register, .define_fields = syscall_enter_define_fields, .get_fields = syscall_get_enter_fields, .raw_init = init_syscall_trace, }; struct trace_event_class __refdata event_class_syscall_exit = { .system = "syscalls", .reg = syscall_exit_register, .define_fields = syscall_exit_define_fields, .fields = LIST_HEAD_INIT(event_class_syscall_exit.fields), .raw_init = init_syscall_trace, };
unsigned long __init __weak arch_syscall_addr(int nr) { return (unsigned long)sys_call_table[nr]; }

Contributors

PersonTokensPropCommitsCommitProp
mike frysingermike frysinger2095.24%150.00%
ian munsieian munsie14.76%150.00%
Total21100.00%2100.00%


void __init init_ftrace_syscalls(void) { struct syscall_metadata *meta; unsigned long addr; int i; syscalls_metadata = kcalloc(NR_syscalls, sizeof(*syscalls_metadata), GFP_KERNEL); if (!syscalls_metadata) { WARN_ON(1); return; } for (i = 0; i < NR_syscalls; i++) { addr = arch_syscall_addr(i); meta = find_syscall_meta(addr); if (!meta) continue; meta->syscall_nr = i; syscalls_metadata[i] = meta; } }

Contributors

PersonTokensPropCommitsCommitProp
frederic weisbeckerfrederic weisbecker7982.29%125.00%
lai jiangshanlai jiangshan1212.50%125.00%
thomas meyerthomas meyer33.12%125.00%
steven rostedtsteven rostedt22.08%125.00%
Total96100.00%4100.00%

#ifdef CONFIG_PERF_EVENTS static DECLARE_BITMAP(enabled_perf_enter_syscalls, NR_syscalls); static DECLARE_BITMAP(enabled_perf_exit_syscalls, NR_syscalls); static int sys_perf_refcount_enter; static int sys_perf_refcount_exit;
static void perf_syscall_enter(void *ignore, struct pt_regs *regs, long id) { struct syscall_metadata *sys_data; struct syscall_trace_enter *rec; struct hlist_head *head; int syscall_nr; int rctx; int size; syscall_nr = trace_get_syscall_nr(current, regs); if (syscall_nr < 0 || syscall_nr >= NR_syscalls) return; if (!test_bit(syscall_nr, enabled_perf_enter_syscalls)) return; sys_data = syscall_nr_to_meta(syscall_nr); if (!sys_data) return; head = this_cpu_ptr(sys_data->enter_event->perf_events); if (hlist_empty(head)) return; /* get the size after alignment with the u32 buffer size field */ size = sizeof(unsigned long) * sys_data->nb_args + sizeof(*rec); size = ALIGN(size + sizeof(u32), sizeof(u64)); size -= sizeof(u32); rec = perf_trace_buf_alloc(size, NULL, &rctx); if (!rec) return; rec->nr = syscall_nr; syscall_get_arguments(current, regs, 0, sys_data->nb_args, (unsigned long *)&rec->args); perf_trace_buf_submit(rec, size, rctx, sys_data->enter_event->event.type, 1, regs, head, NULL); }

Contributors

PersonTokensPropCommitsCommitProp
frederic weisbeckerfrederic weisbecker9241.82%525.00%
jason baronjason baron5123.18%15.00%
oleg nesterovoleg nesterov198.64%15.00%
xiao guangrongxiao guangrong156.82%15.00%
peter zijlstrapeter zijlstra104.55%525.00%
alexei starovoitovalexei starovoitov83.64%15.00%
li zefanli zefan73.18%15.00%
will deaconwill deacon73.18%15.00%
steven rostedtsteven rostedt52.27%210.00%
rabin vincentrabin vincent41.82%15.00%
andrey vaginandrey vagin20.91%15.00%
Total220100.00%20100.00%


static int perf_sysenter_enable(struct trace_event_call *call) { int ret = 0; int num; num = ((struct syscall_metadata *)call->data)->syscall_nr; mutex_lock(&syscall_trace_lock); if (!sys_perf_refcount_enter) ret = register_trace_sys_enter(perf_syscall_enter, NULL); if (ret) { pr_info("event trace: Could not activate" "syscall entry trace point"); } else { set_bit(num, enabled_perf_enter_syscalls); sys_perf_refcount_enter++; } mutex_unlock(&syscall_trace_lock); return ret; }

Contributors

PersonTokensPropCommitsCommitProp
jason baronjason baron6472.73%114.29%
lai jiangshanlai jiangshan1415.91%114.29%
frederic weisbeckerfrederic weisbecker55.68%114.29%
steven rostedtsteven rostedt33.41%228.57%
josh stonejosh stone11.14%114.29%
vaibhav nagarnaikvaibhav nagarnaik11.14%114.29%
Total88100.00%7100.00%


static void perf_sysenter_disable(struct trace_event_call *call) { int num; num = ((struct syscall_metadata *)call->data)->syscall_nr; mutex_lock(&syscall_trace_lock); sys_perf_refcount_enter--; clear_bit(num, enabled_perf_enter_syscalls); if (!sys_perf_refcount_enter) unregister_trace_sys_enter(perf_syscall_enter, NULL); mutex_unlock(&syscall_trace_lock); }

Contributors

PersonTokensPropCommitsCommitProp
jason baronjason baron3961.90%114.29%
lai jiangshanlai jiangshan1422.22%114.29%
frederic weisbeckerfrederic weisbecker57.94%114.29%
steven rostedtsteven rostedt34.76%228.57%
vaibhav nagarnaikvaibhav nagarnaik11.59%114.29%
josh stonejosh stone11.59%114.29%
Total63100.00%7100.00%


static void perf_syscall_exit(void *ignore, struct pt_regs *regs, long ret) { struct syscall_metadata *sys_data; struct syscall_trace_exit *rec; struct hlist_head *head; int syscall_nr; int rctx; int size; syscall_nr = trace_get_syscall_nr(current, regs); if (syscall_nr < 0 || syscall_nr >= NR_syscalls) return; if (!test_bit(syscall_nr, enabled_perf_exit_syscalls)) return; sys_data = syscall_nr_to_meta(syscall_nr); if (!sys_data) return; head = this_cpu_ptr(sys_data->exit_event->perf_events); if (hlist_empty(head)) return; /* We can probably do that at build time */ size = ALIGN(sizeof(*rec) + sizeof(u32), sizeof(u64)); size -= sizeof(u32); rec = perf_trace_buf_alloc(size, NULL, &rctx); if (!rec) return; rec->nr = syscall_nr; rec->ret = syscall_get_return_value(current, regs); perf_trace_buf_submit(rec, size, rctx, sys_data->exit_event->event.type, 1, regs, head, NULL); }

Contributors

PersonTokensPropCommitsCommitProp
frederic weisbeckerfrederic weisbecker6030.93%525.00%
jason baronjason baron5930.41%15.00%
oleg nesterovoleg nesterov199.79%15.00%
xiao guangrongxiao guangrong157.73%15.00%
peter zijlstrapeter zijlstra94.64%525.00%
alexei starovoitovalexei starovoitov84.12%15.00%
will deaconwill deacon73.61%15.00%
li zefanli zefan63.09%15.00%
steven rostedtsteven rostedt52.58%210.00%
rabin vincentrabin vincent42.06%15.00%
andrey vaginandrey vagin21.03%15.00%
Total194100.00%20100.00%


static int perf_sysexit_enable(struct trace_event_call *call) { int ret = 0; int num; num = ((struct syscall_metadata *)call->data)->syscall_nr; mutex_lock(&syscall_trace_lock); if (!sys_perf_refcount_exit) ret = register_trace_sys_exit(perf_syscall_exit, NULL); if (ret) { pr_info("event trace: Could not activate" "syscall exit trace point"); } else { set_bit(num, enabled_perf_exit_syscalls); sys_perf_refcount_exit++; } mutex_unlock(&syscall_trace_lock); return ret; }

Contributors

PersonTokensPropCommitsCommitProp
jason baronjason baron6371.59%112.50%
lai jiangshanlai jiangshan1415.91%112.50%
frederic weisbeckerfrederic weisbecker55.68%112.50%
steven rostedtsteven rostedt33.41%225.00%
josh stonejosh stone11.14%112.50%
wenji huangwenji huang11.14%112.50%
vaibhav nagarnaikvaibhav nagarnaik11.14%112.50%
Total88100.00%8100.00%


static void perf_sysexit_disable(struct trace_event_call *call) { int num; num = ((struct syscall_metadata *)call->data)->syscall_nr; mutex_lock(&syscall_trace_lock); sys_perf_refcount_exit--; clear_bit(num, enabled_perf_exit_syscalls); if (!sys_perf_refcount_exit) unregister_trace_sys_exit(perf_syscall_exit, NULL); mutex_unlock(&syscall_trace_lock); }

Contributors

PersonTokensPropCommitsCommitProp
jason baronjason baron3961.90%114.29%
lai jiangshanlai jiangshan1422.22%114.29%
frederic weisbeckerfrederic weisbecker57.94%114.29%
steven rostedtsteven rostedt34.76%228.57%
vaibhav nagarnaikvaibhav nagarnaik11.59%114.29%
josh stonejosh stone11.59%114.29%
Total63100.00%7100.00%

#endif /* CONFIG_PERF_EVENTS */
static int syscall_enter_register(struct trace_event_call *event, enum trace_reg type, void *data) { struct trace_event_file *file = data; switch (type) { case TRACE_REG_REGISTER: return reg_event_syscall_enter(file, event); case TRACE_REG_UNREGISTER: unreg_event_syscall_enter(file, event); return 0; #ifdef CONFIG_PERF_EVENTS case TRACE_REG_PERF_REGISTER: return perf_sysenter_enable(event); case TRACE_REG_PERF_UNREGISTER: perf_sysenter_disable(event); return 0; case TRACE_REG_PERF_OPEN: case TRACE_REG_PERF_CLOSE: case TRACE_REG_PERF_ADD: case TRACE_REG_PERF_DEL: return 0; #endif } return 0; }

Contributors

PersonTokensPropCommitsCommitProp
steven rostedtsteven rostedt8080.81%466.67%
jiri olsajiri olsa1919.19%233.33%
Total99100.00%6100.00%


static int syscall_exit_register(struct trace_event_call *event, enum trace_reg type, void *data) { struct trace_event_file *file = data; switch (type) { case TRACE_REG_REGISTER: return reg_event_syscall_exit(file, event); case TRACE_REG_UNREGISTER: unreg_event_syscall_exit(file, event); return 0; #ifdef CONFIG_PERF_EVENTS case TRACE_REG_PERF_REGISTER: return perf_sysexit_enable(event); case TRACE_REG_PERF_UNREGISTER: perf_sysexit_disable(event); return 0; case TRACE_REG_PERF_OPEN: case TRACE_REG_PERF_CLOSE: case TRACE_REG_PERF_ADD: case TRACE_REG_PERF_DEL: return 0; #endif } return 0; }

Contributors

PersonTokensPropCommitsCommitProp
steven rostedtsteven rostedt8080.81%466.67%
jiri olsajiri olsa1919.19%233.33%
Total99100.00%6100.00%


Overall Contributors

PersonTokensPropCommitsCommitProp
frederic weisbeckerfrederic weisbecker89226.09%1011.36%
jason baronjason baron61117.87%44.55%
steven rostedtsteven rostedt58217.02%1820.45%
lai jiangshanlai jiangshan49214.39%77.95%
li zefanli zefan1965.73%1011.36%
tom zanussitom zanussi1153.36%55.68%
ian munsieian munsie1153.36%55.68%
vaibhav nagarnaikvaibhav nagarnaik922.69%11.14%
jiri olsajiri olsa461.35%22.27%
jovi zhangweijovi zhangwei451.32%33.41%
oleg nesterovoleg nesterov381.11%11.14%
xiao guangrongxiao guangrong300.88%11.14%
masami hiramatsumasami hiramatsu200.58%11.14%
mike frysingermike frysinger200.58%11.14%
peter zijlstrapeter zijlstra190.56%55.68%
rabin vincentrabin vincent160.47%11.14%
alexei starovoitovalexei starovoitov160.47%11.14%
will deaconwill deacon140.41%11.14%
hendrik bruecknerhendrik brueckner140.41%11.14%
josh stonejosh stone110.32%11.14%
taeung songtaeung song90.26%11.14%
fengguang wufengguang wu80.23%11.14%
andrey vaginandrey vagin40.12%11.14%
paul gortmakerpaul gortmaker40.12%11.14%
thomas meyerthomas meyer30.09%11.14%
tejun heotejun heo30.09%11.14%
andreea-cristina bernatandreea-cristina bernat20.06%11.14%
ingo molnaringo molnar10.03%11.14%
wenji huangwenji huang10.03%11.14%
Total3419100.00%88100.00%
Directory: kernel/trace
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
{% endraw %}