Skip to content

Commit

Permalink
lib/stackdepot: store next pool pointer in new_pool
Browse files Browse the repository at this point in the history
Instead of using the last pointer in stack_pools for storing the pointer
to a new pool (which does not yet store any stack records), use a new
new_pool variable.

This a purely code readability change: it seems more logical to store the
pointer to a pool with a special meaning in a dedicated variable.

Link: https://lkml.kernel.org/r/448bc18296c16bef95cb3167697be6583dcc8ce3.1700502145.git.andreyknvl@google.com
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
Reviewed-by: Alexander Potapenko <glider@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Evgenii Stepanov <eugenis@google.com>
Cc: Marco Elver <elver@google.com>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
  • Loading branch information
Andrey Konovalov authored and Andrew Morton committed Dec 11, 2023
1 parent b6a353d commit a5d21f7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/stackdepot.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ static unsigned int stack_hash_mask;

/* Array of memory regions that store stack traces. */
static void *stack_pools[DEPOT_MAX_POOLS];
/* Newly allocated pool that is not yet added to stack_pools. */
static void *new_pool;
/* Currently used pool in stack_pools. */
static int pool_index;
/* Offset to the unused space in the currently used pool. */
Expand Down Expand Up @@ -241,7 +243,7 @@ static void depot_keep_new_pool(void **prealloc)
* as long as we do not exceed the maximum number of pools.
*/
if (pool_index + 1 < DEPOT_MAX_POOLS) {
stack_pools[pool_index + 1] = *prealloc;
new_pool = *prealloc;
*prealloc = NULL;
}

Expand Down Expand Up @@ -272,6 +274,8 @@ static bool depot_update_pools(size_t required_size, void **prealloc)
* stack_depot_fetch().
*/
WRITE_ONCE(pool_index, pool_index + 1);
stack_pools[pool_index] = new_pool;
new_pool = NULL;
pool_offset = 0;

/*
Expand Down

0 comments on commit a5d21f7

Please sign in to comment.