2019-05-27 08:55:06 +02:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
2016-03-25 14:22:08 -07:00
|
|
|
/*
|
|
|
|
|
* A generic stack depot implementation
|
|
|
|
|
*
|
|
|
|
|
* Author: Alexander Potapenko <glider@google.com>
|
|
|
|
|
* Copyright (C) 2016 Google, Inc.
|
|
|
|
|
*
|
|
|
|
|
* Based on code by Dmitry Chernenkov.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef _LINUX_STACKDEPOT_H
|
|
|
|
|
#define _LINUX_STACKDEPOT_H
|
|
|
|
|
|
2021-11-05 13:35:33 -07:00
|
|
|
#include <linux/gfp.h>
|
|
|
|
|
|
2016-03-25 14:22:08 -07:00
|
|
|
typedef u32 depot_stack_handle_t;
|
|
|
|
|
|
2021-11-05 13:35:39 -07:00
|
|
|
depot_stack_handle_t __stack_depot_save(unsigned long *entries,
|
|
|
|
|
unsigned int nr_entries,
|
|
|
|
|
gfp_t gfp_flags, bool can_alloc);
|
|
|
|
|
|
2022-01-21 22:14:27 -08:00
|
|
|
/*
|
|
|
|
|
* Every user of stack depot has to call this during its own init when it's
|
|
|
|
|
* decided that it will be calling stack_depot_save() later.
|
|
|
|
|
*
|
|
|
|
|
* The alternative is to select STACKDEPOT_ALWAYS_INIT to have stack depot
|
|
|
|
|
* enabled as part of mm_init(), for subsystems where it's known at compile time
|
|
|
|
|
* that stack depot will be used.
|
|
|
|
|
*/
|
|
|
|
|
int stack_depot_init(void);
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_STACKDEPOT_ALWAYS_INIT
|
|
|
|
|
static inline int stack_depot_early_init(void) { return stack_depot_init(); }
|
|
|
|
|
#else
|
|
|
|
|
static inline int stack_depot_early_init(void) { return 0; }
|
|
|
|
|
#endif
|
|
|
|
|
|
2019-04-25 11:44:56 +02:00
|
|
|
depot_stack_handle_t stack_depot_save(unsigned long *entries,
|
|
|
|
|
unsigned int nr_entries, gfp_t gfp_flags);
|
2016-03-25 14:22:08 -07:00
|
|
|
|
2019-04-25 11:44:56 +02:00
|
|
|
unsigned int stack_depot_fetch(depot_stack_handle_t handle,
|
|
|
|
|
unsigned long **entries);
|
2016-03-25 14:22:08 -07:00
|
|
|
|
2021-11-08 18:33:16 -08:00
|
|
|
int stack_depot_snprint(depot_stack_handle_t handle, char *buf, size_t size,
|
|
|
|
|
int spaces);
|
|
|
|
|
|
2021-11-08 18:33:12 -08:00
|
|
|
void stack_depot_print(depot_stack_handle_t stack);
|
|
|
|
|
|
2016-03-25 14:22:08 -07:00
|
|
|
#endif
|