|
36 | 36 | #include <linux/memblock.h>
|
37 | 37 | #include <linux/kasan-enabled.h>
|
38 | 38 |
|
39 |
| -#define DEPOT_HANDLE_BITS (sizeof(depot_stack_handle_t) * 8) |
40 |
| - |
41 |
| -#define DEPOT_POOL_ORDER 2 /* Pool size order, 4 pages */ |
42 |
| -#define DEPOT_POOL_SIZE (1LL << (PAGE_SHIFT + DEPOT_POOL_ORDER)) |
43 |
| -#define DEPOT_STACK_ALIGN 4 |
44 |
| -#define DEPOT_OFFSET_BITS (DEPOT_POOL_ORDER + PAGE_SHIFT - DEPOT_STACK_ALIGN) |
45 |
| -#define DEPOT_POOL_INDEX_BITS (DEPOT_HANDLE_BITS - DEPOT_OFFSET_BITS - \ |
46 |
| - STACK_DEPOT_EXTRA_BITS) |
47 | 39 | #define DEPOT_POOLS_CAP 8192
|
48 | 40 | /* The pool_index is offset by 1 so the first record does not have a 0 handle. */
|
49 | 41 | #define DEPOT_MAX_POOLS \
|
50 | 42 | (((1LL << (DEPOT_POOL_INDEX_BITS)) - 1 < DEPOT_POOLS_CAP) ? \
|
51 | 43 | (1LL << (DEPOT_POOL_INDEX_BITS)) - 1 : DEPOT_POOLS_CAP)
|
52 | 44 |
|
53 |
| -/* Compact structure that stores a reference to a stack. */ |
54 |
| -union handle_parts { |
55 |
| - depot_stack_handle_t handle; |
56 |
| - struct { |
57 |
| - u32 pool_index : DEPOT_POOL_INDEX_BITS; /* pool_index is offset by 1 */ |
58 |
| - u32 offset : DEPOT_OFFSET_BITS; |
59 |
| - u32 extra : STACK_DEPOT_EXTRA_BITS; |
60 |
| - }; |
61 |
| -}; |
62 |
| - |
63 |
| -struct stack_record { |
64 |
| - struct list_head hash_list; /* Links in the hash table */ |
65 |
| - u32 hash; /* Hash in hash table */ |
66 |
| - u32 size; /* Number of stored frames */ |
67 |
| - union handle_parts handle; /* Constant after initialization */ |
68 |
| - refcount_t count; |
69 |
| - union { |
70 |
| - unsigned long entries[CONFIG_STACKDEPOT_MAX_FRAMES]; /* Frames */ |
71 |
| - struct { |
72 |
| - /* |
73 |
| - * An important invariant of the implementation is to |
74 |
| - * only place a stack record onto the freelist iff its |
75 |
| - * refcount is zero. Because stack records with a zero |
76 |
| - * refcount are never considered as valid, it is safe to |
77 |
| - * union @entries and freelist management state below. |
78 |
| - * Conversely, as soon as an entry is off the freelist |
79 |
| - * and its refcount becomes non-zero, the below must not |
80 |
| - * be accessed until being placed back on the freelist. |
81 |
| - */ |
82 |
| - struct list_head free_list; /* Links in the freelist */ |
83 |
| - unsigned long rcu_state; /* RCU cookie */ |
84 |
| - }; |
85 |
| - }; |
86 |
| -}; |
87 |
| - |
88 | 45 | static bool stack_depot_disabled;
|
89 | 46 | static bool __stack_depot_early_init_requested __initdata = IS_ENABLED(CONFIG_STACKDEPOT_ALWAYS_INIT);
|
90 | 47 | static bool __stack_depot_early_init_passed __initdata;
|
|
0 commit comments