@@ -32,6 +32,17 @@ typedef u32 depot_stack_handle_t;
3232 */
3333#define STACK_DEPOT_EXTRA_BITS 5
3434
35+ typedef u32 depot_flags_t ;
36+
37+ /*
38+ * Flags that can be passed to stack_depot_save_flags(); see the comment next
39+ * to its declaration for more details.
40+ */
41+ #define STACK_DEPOT_FLAG_CAN_ALLOC ((depot_flags_t)0x0001)
42+
43+ #define STACK_DEPOT_FLAGS_NUM 1
44+ #define STACK_DEPOT_FLAGS_MASK ((depot_flags_t)((1 << STACK_DEPOT_FLAGS_NUM) - 1))
45+
3546/*
3647 * Using stack depot requires its initialization, which can be done in 3 ways:
3748 *
@@ -69,31 +80,34 @@ static inline int stack_depot_early_init(void) { return 0; }
6980#endif
7081
7182/**
72- * __stack_depot_save - Save a stack trace to stack depot
83+ * stack_depot_save_flags - Save a stack trace to stack depot
7384 *
7485 * @entries: Pointer to the stack trace
7586 * @nr_entries: Number of frames in the stack
7687 * @alloc_flags: Allocation GFP flags
77- * @can_alloc: Allocate stack pools (increased chance of failure if false)
88+ * @depot_flags: Stack depot flags
89+ *
90+ * Saves a stack trace from @entries array of size @nr_entries.
7891 *
79- * Saves a stack trace from @entries array of size @nr_entries. If @can_alloc is
80- * %true, stack depot can replenish the stack pools in case no space is left
81- * (allocates using GFP flags of @alloc_flags). If @can_alloc is %false, avoids
82- * any allocations and fails if no space is left to store the stack trace.
92+ * If STACK_DEPOT_FLAG_CAN_ALLOC is set in @depot_flags, stack depot can
93+ * replenish the stack pools in case no space is left (allocates using GFP
94+ * flags of @alloc_flags). Otherwise, stack depot avoids any allocations and
95+ * fails if no space is left to store the stack trace.
8396 *
8497 * If the provided stack trace comes from the interrupt context, only the part
8598 * up to the interrupt entry is saved.
8699 *
87- * Context: Any context, but setting @can_alloc to %false is required if
100+ * Context: Any context, but setting STACK_DEPOT_FLAG_CAN_ALLOC is required if
88101 * alloc_pages() cannot be used from the current context. Currently
89102 * this is the case for contexts where neither %GFP_ATOMIC nor
90103 * %GFP_NOWAIT can be used (NMI, raw_spin_lock).
91104 *
92105 * Return: Handle of the stack struct stored in depot, 0 on failure
93106 */
94- depot_stack_handle_t __stack_depot_save (unsigned long * entries ,
95- unsigned int nr_entries ,
96- gfp_t gfp_flags , bool can_alloc );
107+ depot_stack_handle_t stack_depot_save_flags (unsigned long * entries ,
108+ unsigned int nr_entries ,
109+ gfp_t gfp_flags ,
110+ depot_flags_t depot_flags );
97111
98112/**
99113 * stack_depot_save - Save a stack trace to stack depot
@@ -103,7 +117,7 @@ depot_stack_handle_t __stack_depot_save(unsigned long *entries,
103117 * @alloc_flags: Allocation GFP flags
104118 *
105119 * Context: Contexts where allocations via alloc_pages() are allowed.
106- * See __stack_depot_save () for more details.
120+ * See stack_depot_save_flags () for more details.
107121 *
108122 * Return: Handle of the stack trace stored in depot, 0 on failure
109123 */
0 commit comments