mirror of
https://github.com/torvalds/linux.git
synced 2024-11-10 22:21:40 +00:00
2541517c32
BPF programs, attached to kprobes, provide a safe way to execute user-defined BPF byte-code programs without being able to crash or hang the kernel in any way. The BPF engine makes sure that such programs have a finite execution time and that they cannot break out of their sandbox. The user interface is to attach to a kprobe via the perf syscall: struct perf_event_attr attr = { .type = PERF_TYPE_TRACEPOINT, .config = event_id, ... }; event_fd = perf_event_open(&attr,...); ioctl(event_fd, PERF_EVENT_IOC_SET_BPF, prog_fd); 'prog_fd' is a file descriptor associated with BPF program previously loaded. 'event_id' is an ID of the kprobe created. Closing 'event_fd': close(event_fd); ... automatically detaches BPF program from it. BPF programs can call in-kernel helper functions to: - lookup/update/delete elements in maps - probe_read - wraper of probe_kernel_read() used to access any kernel data structures BPF programs receive 'struct pt_regs *' as an input ('struct pt_regs' is architecture dependent) and return 0 to ignore the event and 1 to store kprobe event into the ring buffer. Note, kprobes are a fundamentally _not_ a stable kernel ABI, so BPF programs attached to kprobes must be recompiled for every kernel version and user must supply correct LINUX_VERSION_CODE in attr.kern_version during bpf_prog_load() call. Signed-off-by: Alexei Starovoitov <ast@plumgrid.com> Reviewed-by: Steven Rostedt <rostedt@goodmis.org> Reviewed-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Arnaldo Carvalho de Melo <acme@infradead.org> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Daniel Borkmann <daniel@iogearbox.net> Cc: David S. Miller <davem@davemloft.net> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/1427312966-8434-4-git-send-email-ast@plumgrid.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
71 lines
2.3 KiB
Makefile
71 lines
2.3 KiB
Makefile
|
|
# Do not instrument the tracer itself:
|
|
|
|
ifdef CONFIG_FUNCTION_TRACER
|
|
ORIG_CFLAGS := $(KBUILD_CFLAGS)
|
|
KBUILD_CFLAGS = $(subst $(CC_FLAGS_FTRACE),,$(ORIG_CFLAGS))
|
|
|
|
ifdef CONFIG_FTRACE_SELFTEST
|
|
# selftest needs instrumentation
|
|
CFLAGS_trace_selftest_dynamic.o = $(CC_FLAGS_FTRACE)
|
|
obj-y += trace_selftest_dynamic.o
|
|
endif
|
|
endif
|
|
|
|
# If unlikely tracing is enabled, do not trace these files
|
|
ifdef CONFIG_TRACING_BRANCHES
|
|
KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
|
|
endif
|
|
|
|
CFLAGS_trace_benchmark.o := -I$(src)
|
|
CFLAGS_trace_events_filter.o := -I$(src)
|
|
|
|
obj-$(CONFIG_TRACE_CLOCK) += trace_clock.o
|
|
|
|
obj-$(CONFIG_FUNCTION_TRACER) += libftrace.o
|
|
obj-$(CONFIG_RING_BUFFER) += ring_buffer.o
|
|
obj-$(CONFIG_RING_BUFFER_BENCHMARK) += ring_buffer_benchmark.o
|
|
|
|
obj-$(CONFIG_TRACING) += trace.o
|
|
obj-$(CONFIG_TRACING) += trace_output.o
|
|
obj-$(CONFIG_TRACING) += trace_seq.o
|
|
obj-$(CONFIG_TRACING) += trace_stat.o
|
|
obj-$(CONFIG_TRACING) += trace_printk.o
|
|
obj-$(CONFIG_CONTEXT_SWITCH_TRACER) += trace_sched_switch.o
|
|
obj-$(CONFIG_FUNCTION_TRACER) += trace_functions.o
|
|
obj-$(CONFIG_IRQSOFF_TRACER) += trace_irqsoff.o
|
|
obj-$(CONFIG_PREEMPT_TRACER) += trace_irqsoff.o
|
|
obj-$(CONFIG_SCHED_TRACER) += trace_sched_wakeup.o
|
|
obj-$(CONFIG_NOP_TRACER) += trace_nop.o
|
|
obj-$(CONFIG_STACK_TRACER) += trace_stack.o
|
|
obj-$(CONFIG_MMIOTRACE) += trace_mmiotrace.o
|
|
obj-$(CONFIG_FUNCTION_GRAPH_TRACER) += trace_functions_graph.o
|
|
obj-$(CONFIG_TRACE_BRANCH_PROFILING) += trace_branch.o
|
|
obj-$(CONFIG_BLK_DEV_IO_TRACE) += blktrace.o
|
|
ifeq ($(CONFIG_BLOCK),y)
|
|
obj-$(CONFIG_EVENT_TRACING) += blktrace.o
|
|
endif
|
|
obj-$(CONFIG_EVENT_TRACING) += trace_events.o
|
|
obj-$(CONFIG_EVENT_TRACING) += trace_export.o
|
|
obj-$(CONFIG_FTRACE_SYSCALLS) += trace_syscalls.o
|
|
ifeq ($(CONFIG_PERF_EVENTS),y)
|
|
obj-$(CONFIG_EVENT_TRACING) += trace_event_perf.o
|
|
endif
|
|
obj-$(CONFIG_EVENT_TRACING) += trace_events_filter.o
|
|
obj-$(CONFIG_EVENT_TRACING) += trace_events_trigger.o
|
|
obj-$(CONFIG_BPF_SYSCALL) += bpf_trace.o
|
|
obj-$(CONFIG_KPROBE_EVENT) += trace_kprobe.o
|
|
obj-$(CONFIG_TRACEPOINTS) += power-traces.o
|
|
ifeq ($(CONFIG_PM),y)
|
|
obj-$(CONFIG_TRACEPOINTS) += rpm-traces.o
|
|
endif
|
|
ifeq ($(CONFIG_TRACING),y)
|
|
obj-$(CONFIG_KGDB_KDB) += trace_kdb.o
|
|
endif
|
|
obj-$(CONFIG_PROBE_EVENTS) += trace_probe.o
|
|
obj-$(CONFIG_UPROBE_EVENT) += trace_uprobe.o
|
|
|
|
obj-$(CONFIG_TRACEPOINT_BENCHMARK) += trace_benchmark.o
|
|
|
|
libftrace-y := ftrace.o
|