History

perf, bpf: Introduce PERF_RECORD_BPF_EVENT

For better performance analysis of BPF programs, this patch introduces PERF_RECORD_BPF_EVENT, a new perf_event_type that exposes BPF program load/unload information to user space. Each BPF program may contain up to BPF_MAX_SUBPROGS (256) sub programs. The following example shows kernel symbols for a BPF program with 7 sub programs: ffffffffa0257cf9 t bpf_prog_b07ccb89267cf242_F ffffffffa02592e1 t bpf_prog_2dcecc18072623fc_F ffffffffa025b0e9 t bpf_prog_bb7a405ebaec5d5c_F ffffffffa025dd2c t bpf_prog_a7540d4a39ec1fc7_F ffffffffa025fcca t bpf_prog_05762d4ade0e3737_F ffffffffa026108f t bpf_prog_db4bd11e35df90d4_F ffffffffa0263f00 t bpf_prog_89d64e4abf0f0126_F ffffffffa0257cf9 t bpf_prog_ae31629322c4b018__dummy_tracepoi When a bpf program is loaded, PERF_RECORD_KSYMBOL is generated for each of these sub programs. Therefore, PERF_RECORD_BPF_EVENT is not needed for simple profiling. For annotation, user space need to listen to PERF_RECORD_BPF_EVENT and gather more information about these (sub) programs via sys_bpf.

Song Liu committed 7 years ago

Commit 6ee52e21 parent d764ac66 files · +159 −2Browse files

Showing the changes to include/linux (2 of 6 files). Show all

Unified · Split

2 files
  1. include/linux/filter.h +7 −0
  2. include/linux/perf_event.h +6 −0
include/linux/filter.h+7−0
@@ -951,6 +951,7 @@ bpf_address_lookup(unsigned long addr, unsigned long *size, · 950 unmodified lines
951951
952952 void bpf_prog_kallsyms_add(struct bpf_prog *fp);
953953 void bpf_prog_kallsyms_del(struct bpf_prog *fp);
954+void bpf_get_prog_name(const struct bpf_prog *prog, char *sym);
954955
955956 #else /* CONFIG_BPF_JIT */
956957
@@ -1006,6 +1007,12 @@ static inline void bpf_prog_kallsyms_add(struct bpf_prog *fp) · 49 unmodified lines
10061007 static inline void bpf_prog_kallsyms_del(struct bpf_prog *fp)
10071008 {
10081009 }
1010+
1011+static inline void bpf_get_prog_name(const struct bpf_prog *prog, char *sym)
1012+{
1013+ sym[0] = '\0';
1014+}
1015+
10091016 #endif /* CONFIG_BPF_JIT */
10101017
10111018 void bpf_prog_kallsyms_del_subprogs(struct bpf_prog *fp);
include/linux/perf_event.h+6−0
@@ -1125,6 +1125,9 @@ extern void perf_event_mmap(struct vm_area_struct *vma); · 1124 unmodified lines
11251125
11261126 extern void perf_event_ksymbol(u16 ksym_type, u64 addr, u32 len,
11271127 bool unregister, const char *sym);
1128+extern void perf_event_bpf_event(struct bpf_prog *prog,
1129+ enum perf_bpf_event_type type,
1130+ u16 flags);
11281131
11291132 extern struct perf_guest_info_callbacks *perf_guest_cbs;
11301133 extern int perf_register_guest_info_callbacks(struct perf_guest_info_callbacks *callbacks);
@@ -1350,6 +1353,9 @@ static inline void perf_event_mmap(struct vm_area_struct *vma) { } · 219 unmodified lines
13501353 typedef int (perf_ksymbol_get_name_f)(char *name, int name_len, void *data);
13511354 static inline void perf_event_ksymbol(u16 ksym_type, u64 addr, u32 len,
13521355 bool unregister, const char *sym) { }
1356+static inline void perf_event_bpf_event(struct bpf_prog *prog,
1357+ enum perf_bpf_event_type type,
1358+ u16 flags) { }
13531359 static inline void perf_event_exec(void) { }
13541360 static inline void perf_event_comm(struct task_struct *tsk, bool exec) { }
13551361 static inline void perf_event_namespaces(struct task_struct *tsk) { }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t