1 /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 /* 3 * A generic stack depot implementation 4 * 5 * Author: Alexander Potapenko <[email protected]> 6 * Copyright (C) 2016 Google, Inc. 7 * 8 * Based on code by Dmitry Chernenkov. 9 */ 10 11 #ifndef _LINUX_STACKDEPOT_H 12 #define _LINUX_STACKDEPOT_H 13 14 #include <linux/gfp.h> 15 16 typedef u32 depot_stack_handle_t; 17 18 depot_stack_handle_t __stack_depot_save(unsigned long *entries, 19 unsigned int nr_entries, 20 gfp_t gfp_flags, bool can_alloc); 21 22 /* 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. 25 * 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. 29 */ 30 int stack_depot_init(void); 31 32 #ifdef CONFIG_STACKDEPOT_ALWAYS_INIT 33 static inline int stack_depot_early_init(void) { return stack_depot_init(); } 34 #else 35 static inline int stack_depot_early_init(void) { return 0; } 36 #endif 37 38 depot_stack_handle_t stack_depot_save(unsigned long *entries, 39 unsigned int nr_entries, gfp_t gfp_flags); 40 41 unsigned int stack_depot_fetch(depot_stack_handle_t handle, 42 unsigned long **entries); 43 44 int stack_depot_snprint(depot_stack_handle_t handle, char *buf, size_t size, 45 int spaces); 46 47 void stack_depot_print(depot_stack_handle_t stack); 48 49 #endif 50