]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
stackdepot: rename pool_index to pool_index_plus_1
authorPeter Collingbourne <pcc@google.com>
Tue, 2 Apr 2024 00:14:58 +0000 (17:14 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 10 Apr 2024 14:38:14 +0000 (16:38 +0200)
[ Upstream commit a6c1d9cb9a68bfa4512248419c4f4d880d19fe90 ]

Commit 3ee34eabac2a ("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: 3ee34eabac2a ("lib/stackdepot: fix first entry having a 0-handle")
Link: https://lkml.kernel.org/r/20240402001500.53533-1-pcc@google.com
Link: https://linux-review.googlesource.com/id/Ib3e70c36c1d230dd0a118dc22649b33e768b9f88
Signed-off-by: Peter Collingbourne <pcc@google.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Reviewed-by: Alexander Potapenko <glider@google.com>
Acked-by: Marco Elver <elver@google.com>
Acked-by: Oscar Salvador <osalvador@suse.de>
Cc: Andrey Konovalov <andreyknvl@gmail.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Omar Sandoval <osandov@fb.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
include/linux/stackdepot.h
lib/stackdepot.c

index c4b5ad57c0660cb0b52ed6179ebb9f229c31937a..bf0136891a0f25e7684ce0fe9d9e3e0283e6032d 100644 (file)
@@ -44,10 +44,9 @@ typedef u32 depot_stack_handle_t;
 union handle_parts {
        depot_stack_handle_t handle;
        struct {
-               /* pool_index is offset by 1 */
-               u32 pool_index  : DEPOT_POOL_INDEX_BITS;
-               u32 offset      : DEPOT_OFFSET_BITS;
-               u32 extra       : STACK_DEPOT_EXTRA_BITS;
+               u32 pool_index_plus_1   : DEPOT_POOL_INDEX_BITS;
+               u32 offset              : DEPOT_OFFSET_BITS;
+               u32 extra               : STACK_DEPOT_EXTRA_BITS;
        };
 };
 
index ee4bbe6513aa4aa056dc1750001a57bce3ec98f3..ee830f14afb78ad2f31ae26bf0006aabafe17f83 100644 (file)
@@ -330,7 +330,7 @@ static struct stack_record *depot_pop_free_pool(void **prealloc, size_t size)
        stack = current_pool + pool_offset;
 
        /* Pre-initialize handle once. */
-       stack->handle.pool_index = pool_index + 1;
+       stack->handle.pool_index_plus_1 = pool_index + 1;
        stack->handle.offset = pool_offset >> DEPOT_STACK_ALIGN;
        stack->handle.extra = 0;
        INIT_LIST_HEAD(&stack->hash_list);
@@ -441,7 +441,7 @@ static struct stack_record *depot_fetch_stack(depot_stack_handle_t handle)
        const int pools_num_cached = READ_ONCE(pools_num);
        union handle_parts parts = { .handle = handle };
        void *pool;
-       u32 pool_index = parts.pool_index - 1;
+       u32 pool_index = parts.pool_index_plus_1 - 1;
        size_t offset = parts.offset << DEPOT_STACK_ALIGN;
        struct stack_record *stack;