aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/stacktrace.h
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2019-04-25 05:45:21 -0400
committerThomas Gleixner <tglx@linutronix.de>2019-04-29 06:37:57 -0400
commit214d8ca6ee854f696f75e75511fe66b409e656db (patch)
tree349ba0f7bacf52e843eaea99582edead15d5dae7 /include/linux/stacktrace.h
parent56d8f079c51afc8b564b9fb0252d48e7b437c1e5 (diff)
stacktrace: Provide common infrastructure
All architectures which support stacktrace carry duplicated code and do the stack storage and filtering at the architecture side. Provide a consolidated interface with a callback function for consuming the stack entries provided by the architecture specific stack walker. This removes lots of duplicated code and allows to implement better filtering than 'skip number of entries' in the future without touching any architecture specific code. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Andy Lutomirski <luto@kernel.org> Cc: linux-arch@vger.kernel.org Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Alexander Potapenko <glider@google.com> Cc: Alexey Dobriyan <adobriyan@gmail.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Christoph Lameter <cl@linux.com> Cc: Pekka Enberg <penberg@kernel.org> Cc: linux-mm@kvack.org Cc: David Rientjes <rientjes@google.com> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Dmitry Vyukov <dvyukov@google.com> Cc: Andrey Ryabinin <aryabinin@virtuozzo.com> Cc: kasan-dev@googlegroups.com Cc: Mike Rapoport <rppt@linux.vnet.ibm.com> Cc: Akinobu Mita <akinobu.mita@gmail.com> Cc: Christoph Hellwig <hch@lst.de> Cc: iommu@lists.linux-foundation.org Cc: Robin Murphy <robin.murphy@arm.com> Cc: Marek Szyprowski <m.szyprowski@samsung.com> Cc: Johannes Thumshirn <jthumshirn@suse.de> Cc: David Sterba <dsterba@suse.com> Cc: Chris Mason <clm@fb.com> Cc: Josef Bacik <josef@toxicpanda.com> Cc: linux-btrfs@vger.kernel.org Cc: dm-devel@redhat.com Cc: Mike Snitzer <snitzer@redhat.com> Cc: Alasdair Kergon <agk@redhat.com> Cc: Daniel Vetter <daniel@ffwll.ch> Cc: intel-gfx@lists.freedesktop.org Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Cc: dri-devel@lists.freedesktop.org Cc: David Airlie <airlied@linux.ie> Cc: Jani Nikula <jani.nikula@linux.intel.com> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com> Cc: Tom Zanussi <tom.zanussi@linux.intel.com> Cc: Miroslav Benes <mbenes@suse.cz> Link: https://lkml.kernel.org/r/20190425094803.713568606@linutronix.de
Diffstat (limited to 'include/linux/stacktrace.h')
-rw-r--r--include/linux/stacktrace.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/include/linux/stacktrace.h b/include/linux/stacktrace.h
index 40decfbb9a24..f0cfd12cb45e 100644
--- a/include/linux/stacktrace.h
+++ b/include/linux/stacktrace.h
@@ -23,6 +23,44 @@ unsigned int stack_trace_save_regs(struct pt_regs *regs, unsigned long *store,
23unsigned int stack_trace_save_user(unsigned long *store, unsigned int size); 23unsigned int stack_trace_save_user(unsigned long *store, unsigned int size);
24 24
25/* Internal interfaces. Do not use in generic code */ 25/* Internal interfaces. Do not use in generic code */
26#ifdef CONFIG_ARCH_STACKWALK
27
28/**
29 * stack_trace_consume_fn - Callback for arch_stack_walk()
30 * @cookie: Caller supplied pointer handed back by arch_stack_walk()
31 * @addr: The stack entry address to consume
32 * @reliable: True when the stack entry is reliable. Required by
33 * some printk based consumers.
34 *
35 * Return: True, if the entry was consumed or skipped
36 * False, if there is no space left to store
37 */
38typedef bool (*stack_trace_consume_fn)(void *cookie, unsigned long addr,
39 bool reliable);
40/**
41 * arch_stack_walk - Architecture specific function to walk the stack
42 * @consume_entry: Callback which is invoked by the architecture code for
43 * each entry.
44 * @cookie: Caller supplied pointer which is handed back to
45 * @consume_entry
46 * @task: Pointer to a task struct, can be NULL
47 * @regs: Pointer to registers, can be NULL
48 *
49 * ============ ======= ============================================
50 * task regs
51 * ============ ======= ============================================
52 * task NULL Stack trace from task (can be current)
53 * current regs Stack trace starting on regs->stackpointer
54 * ============ ======= ============================================
55 */
56void arch_stack_walk(stack_trace_consume_fn consume_entry, void *cookie,
57 struct task_struct *task, struct pt_regs *regs);
58int arch_stack_walk_reliable(stack_trace_consume_fn consume_entry, void *cookie,
59 struct task_struct *task);
60void arch_stack_walk_user(stack_trace_consume_fn consume_entry, void *cookie,
61 const struct pt_regs *regs);
62
63#else /* CONFIG_ARCH_STACKWALK */
26struct stack_trace { 64struct stack_trace {
27 unsigned int nr_entries, max_entries; 65 unsigned int nr_entries, max_entries;
28 unsigned long *entries; 66 unsigned long *entries;
@@ -37,6 +75,7 @@ extern void save_stack_trace_tsk(struct task_struct *tsk,
37extern int save_stack_trace_tsk_reliable(struct task_struct *tsk, 75extern int save_stack_trace_tsk_reliable(struct task_struct *tsk,
38 struct stack_trace *trace); 76 struct stack_trace *trace);
39extern void save_stack_trace_user(struct stack_trace *trace); 77extern void save_stack_trace_user(struct stack_trace *trace);
78#endif /* !CONFIG_ARCH_STACKWALK */
40#endif /* CONFIG_STACKTRACE */ 79#endif /* CONFIG_STACKTRACE */
41 80
42#if defined(CONFIG_STACKTRACE) && defined(CONFIG_HAVE_RELIABLE_STACKTRACE) 81#if defined(CONFIG_STACKTRACE) && defined(CONFIG_HAVE_RELIABLE_STACKTRACE)