]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: introduce BPF_PROG_TYPE_PERF_EVENT program type
authorAlexei Starovoitov <ast@fb.com>
Fri, 2 Sep 2016 01:37:22 +0000 (18:37 -0700)
committerDavid S. Miller <davem@davemloft.net>
Fri, 2 Sep 2016 17:46:44 +0000 (10:46 -0700)
commit87ce88016a266e83d8861da01f77fefe6da89df3
treee4ba954bea80d223248c57885019b7620375164a
parentee626bee51e62408c1ca0eaa09267d241de7ac88
bpf: introduce BPF_PROG_TYPE_PERF_EVENT program type

Introduce BPF_PROG_TYPE_PERF_EVENT programs that can be attached to
HW and SW perf events (PERF_TYPE_HARDWARE and PERF_TYPE_SOFTWARE
correspondingly in uapi/linux/perf_event.h)

The program visible context meta structure is
struct bpf_perf_event_data {
    struct pt_regs regs;
     __u64 sample_period;
};
which is accessible directly from the program:
int bpf_prog(struct bpf_perf_event_data *ctx)
{
  ... ctx->sample_period ...
  ... ctx->regs.ip ...
}

The bpf verifier rewrites the accesses into kernel internal
struct bpf_perf_event_data_kern which allows changing
struct perf_sample_data without affecting bpf programs.
New fields can be added to the end of struct bpf_perf_event_data
in the future.

Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/perf_event.h
include/uapi/linux/Kbuild
include/uapi/linux/bpf.h
include/uapi/linux/bpf_perf_event.h [new file with mode: 0644]
kernel/trace/bpf_trace.c