diff options
author | Alexei Starovoitov <ast@fb.com> | 2016-02-17 19:58:57 -0800 |
---|---|---|
committer | Michael Bestas <mkbestas@lineageos.org> | 2022-04-19 00:50:12 +0300 |
commit | f7e38e862fb6a6175fd364933c12c409c50a7ce7 (patch) | |
tree | 9117dc5a9f9f380327cffd948c86680f0aa6e0d9 /include/linux/perf_event.h | |
parent | c16c3d51c5001b9baab6d5f1cc2acb6c8b83b034 (diff) |
perf: generalize perf_callchain
. avoid walking the stack when there is no room left in the buffer
. generalize get_perf_callchain() to be called from bpf helper
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Chatur27 <jasonbright2709@gmail.com>
Diffstat (limited to 'include/linux/perf_event.h')
-rw-r--r-- | include/linux/perf_event.h | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index 23afdb70b90f..c6feb45c1aa4 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h @@ -986,11 +986,20 @@ DECLARE_PER_CPU(struct perf_callchain_entry, perf_callchain_entry); extern void perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs); extern void perf_callchain_kernel(struct perf_callchain_entry *entry, struct pt_regs *regs); +extern struct perf_callchain_entry * +get_perf_callchain(struct pt_regs *regs, u32 init_nr, bool kernel, bool user, + bool crosstask, bool add_mark); +extern int get_callchain_buffers(void); +extern void put_callchain_buffers(void); -static inline void perf_callchain_store(struct perf_callchain_entry *entry, u64 ip) +static inline int perf_callchain_store(struct perf_callchain_entry *entry, u64 ip) { - if (entry->nr < PERF_MAX_STACK_DEPTH) + if (entry->nr < PERF_MAX_STACK_DEPTH) { entry->ip[entry->nr++] = ip; + return 0; + } else { + return -1; /* no more room, stop walking the stack */ + } } extern int sysctl_perf_event_paranoid; |