Skip to content

Commit

Permalink
Add new bpf_perf_{event|prog}_read_value helpers implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
palmtenor committed Dec 15, 2017
1 parent 99978d2 commit 4186f5e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/kernel-versions.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,5 @@ Helper | Kernel version | Commit
`BPF_FUNC_tail_call()` | 4.2 | [04fd61ab36ec](https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=04fd61ab36ec065e194ab5e74ae34a5240d992bb)
`BPF_FUNC_trace_printk()` | 4.1 | [9c959c863f82](https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=9c959c863f8217a2ff3d7c296e8223654d240569)
`BPF_FUNC_xdp_adjust_head()` | 4.10 | [17bedab27231](https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=17bedab2723145d17b14084430743549e6943d03)
`BPF_FUNC_perf_event_read_value()` | 4.15 | [908432ca84fc](https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=908432ca84fc229e906ba164219e9ad0fe56f755)
`BPF_FUNC_perf_prog_read_value()` | 4.15 | [4bebdc7a85aa](https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=4bebdc7a85aa400c0222b5329861e4ad9252f1e5)
5 changes: 5 additions & 0 deletions src/cc/export/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ struct _name##_table_t { \
u32 leaf; \
/* counter = map.perf_read(index) */ \
u64 (*perf_read) (int); \
int (*perf_counter_value) (int, void *, u32); \
u32 max_entries; \
}; \
__attribute__((section("maps/perf_array"))) \
Expand Down Expand Up @@ -245,6 +246,10 @@ static int (*bpf_perf_event_output)(void *ctx, void *map, u64 index, void *data,
(void *) BPF_FUNC_perf_event_output;
static int (*bpf_skb_load_bytes)(void *ctx, int offset, void *to, u32 len) =
(void *) BPF_FUNC_skb_load_bytes;
static int (*bpf_perf_event_read_value)(void *map, u64 flags, void *buf, u32 buf_size) =
(void *) BPF_FUNC_perf_event_read_value;
static int (*bpf_perf_prog_read_value)(void *ctx, void *buf, u32 buf_size) =
(void *) BPF_FUNC_perf_prog_read_value;

/* bcc_get_stackid will return a negative value in the case of an error
*
Expand Down
3 changes: 3 additions & 0 deletions src/cc/frontends/clang/b_frontend_action.cc
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,9 @@ bool BTypeVisitor::VisitCallExpr(CallExpr *Call) {
} else if (memb_name == "perf_read") {
prefix = "bpf_perf_event_read";
suffix = ")";
} else if (memb_name == "perf_counter_value") {
prefix = "bpf_perf_event_read_value";
suffix = ")";
} else {
error(Call->getLocStart(), "invalid bpf_table operation %0") << memb_name;
return false;
Expand Down

0 comments on commit 4186f5e

Please sign in to comment.