[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <7e7434a0d4e8a71138aec2c8a3c69a4eebf49935.1675111415.git.andreyknvl@google.com>
Date: Mon, 30 Jan 2023 21:49:37 +0100
From: andrey.konovalov@...ux.dev
To: Marco Elver <elver@...gle.com>,
Alexander Potapenko <glider@...gle.com>
Cc: Andrey Konovalov <andreyknvl@...il.com>,
Vlastimil Babka <vbabka@...e.cz>, kasan-dev@...glegroups.com,
Evgenii Stepanov <eugenis@...gle.com>,
Andrew Morton <akpm@...ux-foundation.org>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org,
Andrey Konovalov <andreyknvl@...gle.com>
Subject: [PATCH 13/18] lib/stacktrace: drop impossible WARN_ON for depot_init_slab
From: Andrey Konovalov <andreyknvl@...gle.com>
depot_init_slab has two call sites:
1. In depot_alloc_stack with a potentially NULL prealloc.
2. In __stack_depot_save with a non-NULL prealloc.
At the same time depot_init_slab can only return false when prealloc is
NULL.
As the second call site makes sure that prealloc is not NULL, the WARN_ON
there can never trigger. Thus, drop the WARN_ON and also move the prealloc
check from depot_init_slab to its first call site.
Also change the return type of depot_init_slab to void as it now always
returns true.
Signed-off-by: Andrey Konovalov <andreyknvl@...gle.com>
---
lib/stackdepot.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/lib/stackdepot.c b/lib/stackdepot.c
index b946ba74fea0..d6be82a5c223 100644
--- a/lib/stackdepot.c
+++ b/lib/stackdepot.c
@@ -218,16 +218,14 @@ int stack_depot_init(void)
}
EXPORT_SYMBOL_GPL(stack_depot_init);
-static bool depot_init_slab(void **prealloc)
+static void depot_init_slab(void **prealloc)
{
- if (!*prealloc)
- return false;
/*
* This smp_load_acquire() pairs with smp_store_release() to
* |next_slab_inited| below and in depot_alloc_stack().
*/
if (smp_load_acquire(&next_slab_inited))
- return true;
+ return;
if (stack_slabs[slab_index] == NULL) {
stack_slabs[slab_index] = *prealloc;
*prealloc = NULL;
@@ -244,7 +242,6 @@ static bool depot_init_slab(void **prealloc)
smp_store_release(&next_slab_inited, 1);
}
}
- return true;
}
/* Allocation of a new stack in raw storage */
@@ -271,7 +268,8 @@ depot_alloc_stack(unsigned long *entries, int size, u32 hash, void **prealloc)
if (slab_index + 1 < DEPOT_MAX_SLABS)
smp_store_release(&next_slab_inited, 0);
}
- depot_init_slab(prealloc);
+ if (*prealloc)
+ depot_init_slab(prealloc);
if (stack_slabs[slab_index] == NULL)
return NULL;
@@ -436,7 +434,7 @@ depot_stack_handle_t __stack_depot_save(unsigned long *entries,
* We didn't need to store this stack trace, but let's keep
* the preallocated memory for the future.
*/
- WARN_ON(!depot_init_slab(&prealloc));
+ depot_init_slab(&prealloc);
}
raw_spin_unlock_irqrestore(&slab_lock, flags);
--
2.25.1
Powered by blists - more mailing lists