diff options
author | Alexei Starovoitov <ast@fb.com> | 2016-02-17 19:58:57 -0800 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-02-20 00:21:44 -0500 |
commit | 568b329a02f75ed3aaae5eb2cca384cb9e09cb29 (patch) | |
tree | ae50fa4f98c1c7ad07ad834677be3304a282499e /arch/x86/kernel/stacktrace.c | |
parent | 6b83d28a55a891a9d70fc61ccb1c138e47dcbe74 (diff) | |
download | talos-obmc-linux-568b329a02f75ed3aaae5eb2cca384cb9e09cb29.tar.gz talos-obmc-linux-568b329a02f75ed3aaae5eb2cca384cb9e09cb29.zip |
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>
Diffstat (limited to 'arch/x86/kernel/stacktrace.c')
-rw-r--r-- | arch/x86/kernel/stacktrace.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/arch/x86/kernel/stacktrace.c b/arch/x86/kernel/stacktrace.c index fdd0c6430e5a..9ee98eefc44d 100644 --- a/arch/x86/kernel/stacktrace.c +++ b/arch/x86/kernel/stacktrace.c @@ -14,30 +14,34 @@ static int save_stack_stack(void *data, char *name) return 0; } -static void +static int __save_stack_address(void *data, unsigned long addr, bool reliable, bool nosched) { struct stack_trace *trace = data; #ifdef CONFIG_FRAME_POINTER if (!reliable) - return; + return 0; #endif if (nosched && in_sched_functions(addr)) - return; + return 0; if (trace->skip > 0) { trace->skip--; - return; + return 0; } - if (trace->nr_entries < trace->max_entries) + if (trace->nr_entries < trace->max_entries) { trace->entries[trace->nr_entries++] = addr; + return 0; + } else { + return -1; /* no more room, stop walking the stack */ + } } -static void save_stack_address(void *data, unsigned long addr, int reliable) +static int save_stack_address(void *data, unsigned long addr, int reliable) { return __save_stack_address(data, addr, reliable, false); } -static void +static int save_stack_address_nosched(void *data, unsigned long addr, int reliable) { return __save_stack_address(data, addr, reliable, true); |