mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
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>
This commit is contained in:
parent
ea2e7ce5d0
commit
0515e5999a
5 changed files with 86 additions and 0 deletions
18
include/uapi/linux/bpf_perf_event.h
Normal file
18
include/uapi/linux/bpf_perf_event.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
/* Copyright (c) 2016 Facebook
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of version 2 of the GNU General Public
|
||||
* License as published by the Free Software Foundation.
|
||||
*/
|
||||
#ifndef _UAPI__LINUX_BPF_PERF_EVENT_H__
|
||||
#define _UAPI__LINUX_BPF_PERF_EVENT_H__
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <linux/ptrace.h>
|
||||
|
||||
struct bpf_perf_event_data {
|
||||
struct pt_regs regs;
|
||||
__u64 sample_period;
|
||||
};
|
||||
|
||||
#endif /* _UAPI__LINUX_BPF_PERF_EVENT_H__ */
|
Loading…
Add table
Add a link
Reference in a new issue