Commit b232b999 authored by Andrey Konovalov's avatar Andrey Konovalov Committed by Andrew Morton

lib/stackdepot: various comments clean-ups

Clean up comments in include/linux/stackdepot.h and lib/stackdepot.c:

1. Rework the initialization comment in stackdepot.h.
2. Rework the header comment in stackdepot.c.
3. Various clean-ups for other comments.

Also adjust whitespaces for find_stack and depot_alloc_stack call sites.

No functional changes.

Link: https://lkml.kernel.org/r/5836231b7954355e2311fc9b5870f697ea8e1f7d.1676063693.git.andreyknvl@google.comSigned-off-by: default avatarAndrey Konovalov <andreyknvl@google.com>
Reviewed-by: default avatarAlexander Potapenko <glider@google.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent beb3c23c
/* SPDX-License-Identifier: GPL-2.0-or-later */ /* SPDX-License-Identifier: GPL-2.0-or-later */
/* /*
* A generic stack depot implementation * Stack depot - a stack trace storage that avoids duplication.
* *
* Author: Alexander Potapenko <glider@google.com> * Author: Alexander Potapenko <glider@google.com>
* Copyright (C) 2016 Google, Inc. * Copyright (C) 2016 Google, Inc.
* *
* Based on code by Dmitry Chernenkov. * Based on the code by Dmitry Chernenkov.
*/ */
#ifndef _LINUX_STACKDEPOT_H #ifndef _LINUX_STACKDEPOT_H
...@@ -17,35 +17,37 @@ typedef u32 depot_stack_handle_t; ...@@ -17,35 +17,37 @@ typedef u32 depot_stack_handle_t;
/* /*
* Number of bits in the handle that stack depot doesn't use. Users may store * Number of bits in the handle that stack depot doesn't use. Users may store
* information in them. * information in them via stack_depot_set/get_extra_bits.
*/ */
#define STACK_DEPOT_EXTRA_BITS 5 #define STACK_DEPOT_EXTRA_BITS 5
/* /*
* Every user of stack depot has to call stack_depot_init() during its own init * Using stack depot requires its initialization, which can be done in 3 ways:
* when it's decided that it will be calling stack_depot_save() later. This is
* recommended for e.g. modules initialized later in the boot process, when
* slab_is_available() is true.
* *
* The alternative is to select STACKDEPOT_ALWAYS_INIT to have stack depot * 1. Selecting CONFIG_STACKDEPOT_ALWAYS_INIT. This option is suitable in
* enabled as part of mm_init(), for subsystems where it's known at compile time * scenarios where it's known at compile time that stack depot will be used.
* that stack depot will be used. * Enabling this config makes the kernel initialize stack depot in mm_init().
* *
* Another alternative is to call stack_depot_request_early_init(), when the * 2. Calling stack_depot_request_early_init() during early boot, before
* decision to use stack depot is taken e.g. when evaluating kernel boot * stack_depot_early_init() in mm_init() completes. For example, this can
* parameters, which precedes the enablement point in mm_init(). * be done when evaluating kernel boot parameters.
*
* 3. Calling stack_depot_init(). Possible after boot is complete. This option
* is recommended for modules initialized later in the boot process, after
* mm_init() completes.
* *
* stack_depot_init() and stack_depot_request_early_init() can be called * stack_depot_init() and stack_depot_request_early_init() can be called
* regardless of CONFIG_STACKDEPOT and are no-op when disabled. The actual * regardless of whether CONFIG_STACKDEPOT is enabled and are no-op when this
* save/fetch/print functions should only be called from code that makes sure * config is disabled. The save/fetch/print stack depot functions can only be
* CONFIG_STACKDEPOT is enabled. * called from the code that makes sure CONFIG_STACKDEPOT is enabled _and_
* initializes stack depot via one of the ways listed above.
*/ */
#ifdef CONFIG_STACKDEPOT #ifdef CONFIG_STACKDEPOT
int stack_depot_init(void); int stack_depot_init(void);
void __init stack_depot_request_early_init(void); void __init stack_depot_request_early_init(void);
/* This is supposed to be called only from mm_init() */ /* Must be only called from mm_init(). */
int __init stack_depot_early_init(void); int __init stack_depot_early_init(void);
#else #else
static inline int stack_depot_init(void) { return 0; } static inline int stack_depot_init(void) { return 0; }
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment