Skip to content

Commit a6c1d9c

Browse files
pccakpm00
authored andcommitted
stackdepot: rename pool_index to pool_index_plus_1
Commit 3ee34ea ("lib/stackdepot: fix first entry having a 0-handle") changed the meaning of the pool_index field to mean "the pool index plus 1". This made the code accessing this field less self-documenting, as well as causing debuggers such as drgn to not be able to easily remain compatible with both old and new kernels, because they typically do that by testing for presence of the new field. Because stackdepot is a debugging tool, we should make sure that it is debugger friendly. Therefore, give the field a different name to improve readability as well as enabling debugger backwards compatibility. This is needed in 6.9, which would otherwise become an odd release with the new semantics and old name so debuggers wouldn't recognize the new semantics there. Fixes: 3ee34ea ("lib/stackdepot: fix first entry having a 0-handle") Link: https://lkml.kernel.org/r/[email protected] Link: https://linux-review.googlesource.com/id/Ib3e70c36c1d230dd0a118dc22649b33e768b9f88 Signed-off-by: Peter Collingbourne <[email protected]> Acked-by: Vlastimil Babka <[email protected]> Reviewed-by: Alexander Potapenko <[email protected]> Acked-by: Marco Elver <[email protected]> Acked-by: Oscar Salvador <[email protected]> Cc: Andrey Konovalov <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Omar Sandoval <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 04c35ab commit a6c1d9c

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

include/linux/stackdepot.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,9 @@ typedef u32 depot_stack_handle_t;
4444
union handle_parts {
4545
depot_stack_handle_t handle;
4646
struct {
47-
/* pool_index is offset by 1 */
48-
u32 pool_index : DEPOT_POOL_INDEX_BITS;
49-
u32 offset : DEPOT_OFFSET_BITS;
50-
u32 extra : STACK_DEPOT_EXTRA_BITS;
47+
u32 pool_index_plus_1 : DEPOT_POOL_INDEX_BITS;
48+
u32 offset : DEPOT_OFFSET_BITS;
49+
u32 extra : STACK_DEPOT_EXTRA_BITS;
5150
};
5251
};
5352

lib/stackdepot.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ static struct stack_record *depot_pop_free_pool(void **prealloc, size_t size)
330330
stack = current_pool + pool_offset;
331331

332332
/* Pre-initialize handle once. */
333-
stack->handle.pool_index = pool_index + 1;
333+
stack->handle.pool_index_plus_1 = pool_index + 1;
334334
stack->handle.offset = pool_offset >> DEPOT_STACK_ALIGN;
335335
stack->handle.extra = 0;
336336
INIT_LIST_HEAD(&stack->hash_list);
@@ -441,7 +441,7 @@ static struct stack_record *depot_fetch_stack(depot_stack_handle_t handle)
441441
const int pools_num_cached = READ_ONCE(pools_num);
442442
union handle_parts parts = { .handle = handle };
443443
void *pool;
444-
u32 pool_index = parts.pool_index - 1;
444+
u32 pool_index = parts.pool_index_plus_1 - 1;
445445
size_t offset = parts.offset << DEPOT_STACK_ALIGN;
446446
struct stack_record *stack;
447447

0 commit comments

Comments
 (0)