1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * A generic stack depot implementation
6 * Copyright (C) 2016 Google, Inc.
8 * Based on code by Dmitry Chernenkov.
11 #ifndef _LINUX_STACKDEPOT_H
12 #define _LINUX_STACKDEPOT_H
14 #include <linux/gfp.h>
16 typedef u32 depot_stack_handle_t;
18 depot_stack_handle_t __stack_depot_save(unsigned long *entries,
19 unsigned int nr_entries,
20 gfp_t gfp_flags, bool can_alloc);
23 * Every user of stack depot has to call this during its own init when it's
24 * decided that it will be calling stack_depot_save() later.
26 * The alternative is to select STACKDEPOT_ALWAYS_INIT to have stack depot
27 * enabled as part of mm_init(), for subsystems where it's known at compile time
28 * that stack depot will be used.
30 int stack_depot_init(void);
32 #ifdef CONFIG_STACKDEPOT_ALWAYS_INIT
33 static inline int stack_depot_early_init(void) { return stack_depot_init(); }
35 static inline int stack_depot_early_init(void) { return 0; }
38 depot_stack_handle_t stack_depot_save(unsigned long *entries,
39 unsigned int nr_entries, gfp_t gfp_flags);
41 unsigned int stack_depot_fetch(depot_stack_handle_t handle,
42 unsigned long **entries);
44 int stack_depot_snprint(depot_stack_handle_t handle, char *buf, size_t size,
47 void stack_depot_print(depot_stack_handle_t stack);