2023-01-30 20:56:23

by andrey.konovalov

[permalink] [raw]
Subject: [PATCH 00/18] lib/stackdepot: fixes and clean-ups

From: Andrey Konovalov <[email protected]>

A set of fixes, comments, and clean-ups I came up with while reading
the stack depot code.

The only fix that might be worth backporting to stable kernels is
in the first patch.

Andrey Konovalov (18):
lib/stackdepot: fix setting next_slab_inited in init_stack_slab
lib/stackdepot: put functions in logical order
lib/stackdepot: use pr_fmt to define message format
lib/stackdepot, mm: rename stack_depot_want_early_init
lib/stackdepot: rename stack_depot_disable
lib/stackdepot: annotate init and early init functions
lib/stackdepot: lower the indentation in stack_depot_init
lib/stackdepot: reorder and annotate global variables
lib/stackdepot: rename hash table constants and variables
lib/stackdepot: rename init_stack_slab
lib/stackdepot: rename slab variables
lib/stackdepot: rename handle and slab constants
lib/stacktrace: drop impossible WARN_ON for depot_init_slab
lib/stackdepot: annotate depot_init_slab and depot_alloc_stack
lib/stacktrace, kasan, kmsan: rework extra_bits interface
lib/stackdepot: annotate racy slab_index accesses
lib/stackdepot: various comments clean-ups
lib/stackdepot: move documentation comments to stackdepot.h

include/linux/stackdepot.h | 152 +++++++--
lib/stackdepot.c | 628 ++++++++++++++++++-------------------
mm/kasan/common.c | 2 +-
mm/kmsan/core.c | 10 +-
mm/page_owner.c | 2 +-
mm/slub.c | 4 +-
6 files changed, 435 insertions(+), 363 deletions(-)

--
2.25.1



2023-01-30 20:56:25

by andrey.konovalov

[permalink] [raw]
Subject: [PATCH 03/18] lib/stackdepot: use pr_fmt to define message format

From: Andrey Konovalov <[email protected]>

Use pr_fmt to define the format for printing stack depot messages instead
of duplicating the "Stack Depot" prefix in each message.

Signed-off-by: Andrey Konovalov <[email protected]>
---
lib/stackdepot.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/lib/stackdepot.c b/lib/stackdepot.c
index 23d2a68a587b..90c4dd48d75e 100644
--- a/lib/stackdepot.c
+++ b/lib/stackdepot.c
@@ -19,6 +19,8 @@
* Based on code by Dmitry Chernenkov.
*/

+#define pr_fmt(fmt) "stackdepot: " fmt
+
#include <linux/gfp.h>
#include <linux/jhash.h>
#include <linux/kernel.h>
@@ -98,7 +100,7 @@ static int __init is_stack_depot_disabled(char *str)

ret = kstrtobool(str, &stack_depot_disable);
if (!ret && stack_depot_disable) {
- pr_info("Stack Depot is disabled\n");
+ pr_info("disabled\n");
stack_table = NULL;
}
return 0;
@@ -142,7 +144,7 @@ int __init stack_depot_early_init(void)
1UL << STACK_HASH_ORDER_MAX);

if (!stack_table) {
- pr_err("Stack Depot hash table allocation failed, disabling\n");
+ pr_err("hash table allocation failed, disabling\n");
stack_depot_disable = true;
return -ENOMEM;
}
@@ -177,11 +179,11 @@ int stack_depot_init(void)
if (entries > 1UL << STACK_HASH_ORDER_MAX)
entries = 1UL << STACK_HASH_ORDER_MAX;

- pr_info("Stack Depot allocating hash table of %lu entries with kvcalloc\n",
+ pr_info("allocating hash table of %lu entries with kvcalloc\n",
entries);
stack_table = kvcalloc(entries, sizeof(struct stack_record *), GFP_KERNEL);
if (!stack_table) {
- pr_err("Stack Depot hash table allocation failed, disabling\n");
+ pr_err("hash table allocation failed, disabling\n");
stack_depot_disable = true;
ret = -ENOMEM;
}
--
2.25.1


2023-01-31 10:24:57

by Alexander Potapenko

[permalink] [raw]
Subject: Re: [PATCH 03/18] lib/stackdepot: use pr_fmt to define message format

On Mon, Jan 30, 2023 at 9:49 PM <[email protected]> wrote:
>
> From: Andrey Konovalov <[email protected]>
>
> Use pr_fmt to define the format for printing stack depot messages instead
> of duplicating the "Stack Depot" prefix in each message.
>
> Signed-off-by: Andrey Konovalov <[email protected]>
Reviewed-by: Alexander Potapenko <[email protected]>