* [merged mm-stable] lib-stackdepot-lower-the-indentation-in-stack_depot_init.patch removed from -mm tree
@ 2023-02-17 4:44 Andrew Morton
0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2023-02-17 4:44 UTC (permalink / raw)
To: mm-commits, glider, andreyknvl, akpm
The quilt patch titled
Subject: lib/stackdepot: lower the indentation in stack_depot_init
has been removed from the -mm tree. Its filename was
lib-stackdepot-lower-the-indentation-in-stack_depot_init.patch
This patch was dropped because it was merged into the mm-stable branch
of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: Andrey Konovalov <andreyknvl@google.com>
Subject: lib/stackdepot: lower the indentation in stack_depot_init
Date: Fri, 10 Feb 2023 22:15:54 +0100
stack_depot_init does most things inside an if check. Move them out and
use a goto statement instead.
No functional changes.
Link: https://lkml.kernel.org/r/8e382f1f0c352e4b2ad47326fec7782af961fe8e.1676063693.git.andreyknvl@google.com
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
Reviewed-by: Alexander Potapenko <glider@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
--- a/lib/stackdepot.c~lib-stackdepot-lower-the-indentation-in-stack_depot_init
+++ a/lib/stackdepot.c
@@ -165,46 +165,50 @@ int __init stack_depot_early_init(void)
int stack_depot_init(void)
{
static DEFINE_MUTEX(stack_depot_init_mutex);
+ unsigned long entries;
int ret = 0;
mutex_lock(&stack_depot_init_mutex);
- if (!stack_depot_disabled && !stack_table) {
- unsigned long entries;
- /*
- * Similarly to stack_depot_early_init, use stack_hash_order
- * if assigned, and rely on automatic scaling otherwise.
- */
- if (stack_hash_order) {
- entries = 1UL << stack_hash_order;
- } else {
- int scale = STACK_HASH_SCALE;
-
- entries = nr_free_buffer_pages();
- entries = roundup_pow_of_two(entries);
-
- if (scale > PAGE_SHIFT)
- entries >>= (scale - PAGE_SHIFT);
- else
- entries <<= (PAGE_SHIFT - scale);
- }
-
- if (entries < 1UL << STACK_HASH_ORDER_MIN)
- entries = 1UL << STACK_HASH_ORDER_MIN;
- if (entries > 1UL << STACK_HASH_ORDER_MAX)
- entries = 1UL << STACK_HASH_ORDER_MAX;
-
- pr_info("allocating hash table of %lu entries via kvcalloc\n",
- entries);
- stack_table = kvcalloc(entries, sizeof(struct stack_record *), GFP_KERNEL);
- if (!stack_table) {
- pr_err("hash table allocation failed, disabling\n");
- stack_depot_disabled = true;
- ret = -ENOMEM;
- }
- stack_hash_mask = entries - 1;
+ if (stack_depot_disabled || stack_table)
+ goto out_unlock;
+
+ /*
+ * Similarly to stack_depot_early_init, use stack_hash_order
+ * if assigned, and rely on automatic scaling otherwise.
+ */
+ if (stack_hash_order) {
+ entries = 1UL << stack_hash_order;
+ } else {
+ int scale = STACK_HASH_SCALE;
+
+ entries = nr_free_buffer_pages();
+ entries = roundup_pow_of_two(entries);
+
+ if (scale > PAGE_SHIFT)
+ entries >>= (scale - PAGE_SHIFT);
+ else
+ entries <<= (PAGE_SHIFT - scale);
+ }
+
+ if (entries < 1UL << STACK_HASH_ORDER_MIN)
+ entries = 1UL << STACK_HASH_ORDER_MIN;
+ if (entries > 1UL << STACK_HASH_ORDER_MAX)
+ entries = 1UL << STACK_HASH_ORDER_MAX;
+
+ pr_info("allocating hash table of %lu entries via kvcalloc\n", entries);
+ stack_table = kvcalloc(entries, sizeof(struct stack_record *), GFP_KERNEL);
+ if (!stack_table) {
+ pr_err("hash table allocation failed, disabling\n");
+ stack_depot_disabled = true;
+ ret = -ENOMEM;
+ goto out_unlock;
}
+ stack_hash_mask = entries - 1;
+
+out_unlock:
mutex_unlock(&stack_depot_init_mutex);
+
return ret;
}
EXPORT_SYMBOL_GPL(stack_depot_init);
_
Patches currently in -mm which might be from andreyknvl@google.com are
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-02-17 4:44 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-17 4:44 [merged mm-stable] lib-stackdepot-lower-the-indentation-in-stack_depot_init.patch removed from -mm tree Andrew Morton
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.