Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
130 commits
Select commit Hold shift + click to select a range
b96d171
KRN-1117: Add caller-owned stack trace fetch helper
May 26, 2026
0ffe344
KRN-1117: Add stackdepot files to MAINTAINERS
May 27, 2026
90214d6
KRN-1117: Clarify stack_depot_fetch_into contract
May 27, 2026
0becc55
KRN-1117: Stop page_owner reading stack entries directly
May 27, 2026
d328e21
KRN-1117: Store page_owner stack handles in stack list
May 27, 2026
3a5759e
KRN-1117: Hide page_owner stack count internals
May 28, 2026
42a90b1
KRN-1117: Keep stackdepot record layout private
May 28, 2026
75f1a4d
KRN-1117: Add stackdepot frame compression hooks
May 28, 2026
250c3b7
KRN-1117: Warn on stackdepot count underflow
May 28, 2026
03f8f0a
KRN-1117: Compress x86-64 stackdepot frames
May 28, 2026
8f7a08f
KRN-1117: Add stackdepot frame-run encoding helpers
May 29, 2026
fe07f92
KRN-1117: Tighten page_owner stack display accounting
May 29, 2026
dd85540
KRN-1117: Materialize stackdepot trie frame runs
May 29, 2026
83e1828
KRN-1117: Add stackdepot trie child arrays
May 29, 2026
78463e7
KRN-1117: Harden stackdepot trie helper contracts
May 29, 2026
60a1fa0
KRN-1117: Match stackdepot trie node prefixes
Jun 1, 2026
edfe0dd
KRN-1117: Build stackdepot trie append chains
Jun 1, 2026
2fe6b7a
KRN-1117: Publish stackdepot trie append chains
Jun 1, 2026
25ce568
KRN-1117: Order stackdepot trie append publication
Jun 1, 2026
3bc1633
KRN-1117: Classify stackdepot trie lookup steps
Jun 1, 2026
2663c87
KRN-1117: Harden stackdepot trie lookup prep
Jun 1, 2026
2d85c61
KRN-1117: Add stackdepot trie append insertion
Jun 2, 2026
cd0e400
KRN-1117: Add stackdepot trie descend insertion
Jun 2, 2026
a245616
KRN-1117: Add stackdepot maintainer routing
Jun 2, 2026
0040433
KRN-1117: Clarify stackdepot prep invariants
Jun 2, 2026
0569363
KRN-1117: Harden stackdepot prep helper contracts
Jun 2, 2026
2e18d10
KRN-1117: Add stackdepot trie promotion
Jun 3, 2026
5bf3754
KRN-1117: Preserve children during trie promotion
Jun 3, 2026
2f1fe8c
KRN-1117: Add stackdepot trie node slicing
Jun 3, 2026
c78948b
KRN-1117: Add stackdepot trie split child arrays
Jun 3, 2026
bf4d8ff
KRN-1117: Add stackdepot trie split tail planning
Jun 3, 2026
91c3fa7
KRN-1117: Add stackdepot trie split precheck
Jun 3, 2026
546033d
KRN-1117: Add stackdepot trie split subtree
Jun 3, 2026
677886e
KRN-1117: Harden stackdepot trie split precheck
Jun 3, 2026
b9469d6
KRN-1117: Add stackdepot trie split insertion
Jun 3, 2026
2658c72
KRN-1117: Add stackdepot trie leaf lookup
Jun 4, 2026
84fe194
KRN-1117: Add stackdepot trie pre-publish hook
Jun 4, 2026
feb01a3
KRN-1117: Add stackdepot trie insertion planning
Jun 4, 2026
8e6de92
KRN-1117: Add stackdepot trie handle namespace
Jun 4, 2026
b3e2e2a
KRN-1117: Fix stackdepot trie COW leaf lookup
Jun 4, 2026
b69ba25
KRN-1117: Clarify page_owner marker reporting
Jun 4, 2026
fa13111
KRN-1117: Add stackdepot trie side table
Jun 4, 2026
946ce65
KRN-1117: Harden stackdepot trie COW publication
Jun 5, 2026
e6f8b98
KRN-1117: Add stackdepot trie side-table prepare
Jun 5, 2026
a5d195c
KRN-1117: Add stackdepot trie pool sizing
Jun 5, 2026
403bd56
KRN-1117: Align stackdepot trie pool allocations
Jun 5, 2026
6f19677
KRN-1117: Add stackdepot trie pool carve helper
Jun 5, 2026
20027ae
KRN-1117: Add stackdepot trie pool batch carve
Jun 5, 2026
5628485
KRN-1117: Clarify page_owner count transition
Jun 5, 2026
3c2ee85
KRN-1117: Add stackdepot trie pool prealloc
Jun 8, 2026
8c8c0bc
KRN-1117: Add stackdepot trie pool rollover
Jun 8, 2026
72e99db
KRN-1117: Add stackdepot trie allocation rollback
Jun 8, 2026
258129d
KRN-1117: Add stackdepot trie transaction IDs
Jun 8, 2026
8c2112d
KRN-1117: Add stackdepot trie allocation reserve
Jun 8, 2026
e8820ad
KRN-1117: Add stackdepot trie allocation commit
Jun 8, 2026
8248768
KRN-1117: Add stackdepot trie allocation insert
Jun 8, 2026
4aeddae
KRN-1117: Serialize stackdepot trie allocation insert
Jun 8, 2026
0ee779c
KRN-1117: Add stackdepot trie feature flag
Jun 8, 2026
a405d3d
KRN-1117: Remove stackdepot trie feature flag
Jun 9, 2026
69b854a
KRN-1117: Add stackdepot trie allocation planning
Jun 9, 2026
3720e5f
KRN-1117: Add stackdepot trie allocation workspace
Jun 9, 2026
f93eb03
KRN-1117: Add stackdepot trie workspace insert
Jun 9, 2026
237bf20
KRN-1117: Add stackdepot trie allocation prealloc
Jun 9, 2026
9908ea6
KRN-1117: Add stackdepot trie save miss
Jun 9, 2026
f693df3
KRN-1117: Add stackdepot trie save helper
Jun 9, 2026
a1afe16
KRN-1117: Add stackdepot trie handle fetch helper
Jun 9, 2026
7e823e0
KRN-1117: Re-add stackdepot trie feature flag
Jun 9, 2026
76c26db
KRN-1117: Materialize stackdepot trie handles directly
Jun 9, 2026
c030eaf
KRN-1117: Route stackdepot fetch_into trie handles
Jun 10, 2026
7a8781f
KRN-1117: Add stackdepot trie materialization slots
Jun 10, 2026
2cd8dac
KRN-1117: Publish trie materialization slots locklessly
Jun 10, 2026
ed8ae1f
KRN-1117: Add stackdepot trie frame walker
Jun 10, 2026
8ee1a71
KRN-1117: Add stackdepot trie materialize helper
Jun 10, 2026
c76f251
KRN-1117: Size stackdepot trie materialization buffers
Jun 10, 2026
aff8685
KRN-1117: Add stackdepot trie materialized records
Jun 10, 2026
5d51a39
KRN-1117: Add stackdepot trie materialization cache
Jun 10, 2026
b94f73b
KRN-1117: Route stackdepot fetch to trie cache
Jun 10, 2026
0a86543
KRN-1117: Count stackdepot trie materialization bytes
Jun 11, 2026
dd3bf3e
KRN-1117: Add a locked stackdepot trie save helper
Jun 11, 2026
12d3d49
KRN-1117: Initialize stackdepot trie side table
Jun 11, 2026
a2ecf7b
KRN-1117: Initialize stackdepot trie workspace
Jun 11, 2026
b60ebcb
KRN-1117: Gate stackdepot trie allocation readiness
Jun 11, 2026
2a085a4
KRN-1117: Print stackdepot trie handles directly
Jun 11, 2026
ab20790
KRN-1117: Route stackdepot saves to trie storage
Jun 11, 2026
2c373ef
KRN-1117: Migrate persistent stackdepot fetches to copy-out
Jun 12, 2026
4007005
KRN-1117: Print stackdepot trie frames in stack order
Jun 12, 2026
50a0c84
KRN-1117: Stress stackdepot trie saves concurrently
Jun 15, 2026
72761b3
KRN-1117: Make stackdepot trie side table sparse
Jun 15, 2026
d8774f1
KRN-1117: Reuse retired stackdepot trie child arrays
Jun 15, 2026
222556b
KRN-1117: Assert x86 stackdepot frame prefix is nonzero
Jun 16, 2026
3358ba7
KRN-1117: Reuse retired stackdepot trie nodes
Jun 16, 2026
e356b33
KRN-1117: Harden arm64 stackdepot prefix scan
Jun 16, 2026
0df12cc
KRN-1117: Reduce stackdepot trie pool usage
Jun 16, 2026
961acf0
KRN-1117: Warn on direct fetch of trie stackdepot handles
Jun 17, 2026
3fddeba
KRN-1117: Clean up stackdepot save control flow
Jun 17, 2026
6f255eb
KRN-1117: Close stackdepot trie save-path gaps
Jun 17, 2026
428f519
KRN-1117: Preserve page owner handles without stack list nodes
Jun 17, 2026
88ac7ba
KRN-1117: Harden stackdepot trie teardown ordering
Jun 17, 2026
b8ee429
KRN-1117: Initialize stackdepot trie on runtime enable
Jun 18, 2026
8ca6e19
Merge greg/linux-6.18.y into KRN-1117 stackdepot port
Jun 18, 2026
4f5a99b
KRN-1117: Drop stackdepot MAINTAINERS entry
Jun 18, 2026
5bdac6c
KRN-1117: Reduce KMSAN stackdepot report stack usage
Jun 18, 2026
9fb876c
KRN-1117: Clarify stackdepot trie review details
Jun 18, 2026
842163f
KRN-1117: Read page owner threshold consistently
Jun 18, 2026
0f1de1c
KRN-1117: Clarify page owner count marker comment
Jun 18, 2026
6d9ee43
KRN-1117: Clarify stackdepot trie buffer contracts
Jun 18, 2026
c435880
KRN-1117: Drop test-only stackdepot pool carve helper
Jun 18, 2026
0c53020
KRN-1117: Simplify stackdepot trie internals
Jun 19, 2026
8ab08c2
KRN-1117: Clarify stackdepot caller assumptions
Jun 19, 2026
09a15a5
KRN-1117: Remove test-driven stackdepot trie indirection
Jun 19, 2026
bbf31e7
KRN-1117: Clarify stackdepot caller invariants
Jun 19, 2026
8f6d52c
KRN-1117: Fold stackdepot trie internals into implementation
Jun 22, 2026
3218ba2
KRN-1117: Document stackdepot trie design invariants
Jun 22, 2026
0542d6b
KRN-1117: Clarify stackdepot trie namespace checks
Jun 22, 2026
c1a9c70
KRN-1117: Avoid signed overflow in arm64 stackdepot compression
Jun 22, 2026
272a555
KRN-1117: Simplify stackdepot trie publication
Jun 22, 2026
d98d67e
KRN-1117: Reserve stackdepot trie IDs before pool storage
Jun 22, 2026
722792d
KRN-1117: Clear unused stackdepot trie child slots
Jun 23, 2026
3b2ea44
KRN-1117: Simplify stackdepot trie helpers
Jun 23, 2026
61a7987
KRN-1117: Simplify stackdepot trie state
Jun 23, 2026
891506d
KRN-1117: Test stackdepot overlong stack truncation
Jun 23, 2026
2858c84
KRN-1117: Tighten stackdepot trie save semantics
Jun 24, 2026
a4af172
KRN-1117: Tighten stackdepot trie reservation state
Jun 24, 2026
98b5919
KRN-1117: Simplify stackdepot trie and count handling
Jun 25, 2026
7029a52
KRN-1117: Clarify stackdepot trie failure semantics
Jun 25, 2026
6bbefcb
KRN-1117: Clarify stackdepot fetch handle constraints
Jun 25, 2026
20bb972
KRN-1117: Clarify stackdepot hash-only diagnostics
Jun 25, 2026
202dfc9
KRN-1117: Simplify stackdepot trie init paths
Jun 25, 2026
8cb7e4d
KRN-1117: Tighten stackdepot trie invariants
Jun 26, 2026
09c919f
KRN-1117: Remove unrelated page_owner changes
Jun 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions arch/arm64/include/asm/stackdepot.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __ASM_STACKDEPOT_H
#define __ASM_STACKDEPOT_H

#include <linux/types.h>
#include <linux/limits.h>
#include <asm/sections.h>

/*
* Modules are allocated inside a 2 GB relocation window containing the
* kernel image. Store a signed 32-bit offset from _text so compression is
* independent of 4 GB high-bit boundaries crossed by that window.
*/
static inline unsigned long arch_stack_depot_frame_from_low(u32 low)
{
long offset;

offset = (s32)low;
if (offset < 0)
return (unsigned long)_text - (unsigned long)(-offset);
return (unsigned long)_text + (unsigned long)offset;
}

static inline bool
arch_stack_depot_frame_try_compress(unsigned long frame, u32 *low)
{
u32 candidate;

candidate = (u32)(frame - (unsigned long)_text);
if (arch_stack_depot_frame_from_low(candidate) != frame)
return false;

*low = candidate;
return true;
}
Comment thread
caleb-kan marked this conversation as resolved.

static inline void
arch_stack_depot_frame_decompress(u32 low, unsigned long *frame)
{
*frame = arch_stack_depot_frame_from_low(low);
}

#endif /* __ASM_STACKDEPOT_H */
1 change: 1 addition & 0 deletions arch/um/include/asm/Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ generic-y += preempt.h
generic-y += ring_buffer.h
generic-y += runtime-const.h
generic-y += softirq_stack.h
generic-y += stackdepot.h
generic-y += switch_to.h
generic-y += topology.h
generic-y += trace_clock.h
Expand Down
40 changes: 40 additions & 0 deletions arch/x86/include/asm/stackdepot.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _ASM_X86_STACKDEPOT_H
#define _ASM_X86_STACKDEPOT_H

#include <linux/build_bug.h>
#include <linux/types.h>

#ifdef CONFIG_X86_64
/*
* Compress canonical kernel text/module addresses whose upper 32 bits are all
* ones. Other kernel virtual addresses stay raw, so decompression reconstructs
* the original frame by restoring this prefix.
*/
#define STACK_DEPOT_X86_64_FRAME_PREFIX 0xffffffff00000000UL
#define STACK_DEPOT_X86_64_FRAME_LOW_MASK 0x00000000ffffffffUL

static_assert(STACK_DEPOT_X86_64_FRAME_PREFIX != 0);

static inline bool
arch_stack_depot_frame_try_compress(unsigned long frame, u32 *low)
{
if ((frame & ~STACK_DEPOT_X86_64_FRAME_LOW_MASK) !=
STACK_DEPOT_X86_64_FRAME_PREFIX)
return false;

*low = (u32)frame;
return true;
}

static inline void
arch_stack_depot_frame_decompress(u32 low, unsigned long *frame)
{
*frame = STACK_DEPOT_X86_64_FRAME_PREFIX | low;
}

#else
#include <asm-generic/stackdepot.h>
#endif /* CONFIG_X86_64 */

#endif /* _ASM_X86_STACKDEPOT_H */
9 changes: 6 additions & 3 deletions drivers/gpu/drm/drm_modeset_lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,12 @@
static DEFINE_WW_CLASS(crtc_ww_class);

#if IS_ENABLED(CONFIG_DRM_DEBUG_MODESET_LOCK)
/* Existing debug output only records a short caller chain; keep save/fetch caps in sync. */
#define DRM_STACK_DEPOT_MAX_FRAMES 8

static noinline depot_stack_handle_t __drm_stack_depot_save(void)
{
unsigned long entries[8];
unsigned long entries[DRM_STACK_DEPOT_MAX_FRAMES];
unsigned int n;

n = stack_trace_save(entries, ARRAY_SIZE(entries), 1);
Expand All @@ -94,15 +97,15 @@ static noinline depot_stack_handle_t __drm_stack_depot_save(void)
static void __drm_stack_depot_print(depot_stack_handle_t stack_depot)
{
struct drm_printer p = drm_dbg_printer(NULL, DRM_UT_KMS, "drm_modeset_lock");
unsigned long *entries;
unsigned long entries[DRM_STACK_DEPOT_MAX_FRAMES];
unsigned int nr_entries;
Comment thread
caleb-kan marked this conversation as resolved.
char *buf;

buf = kmalloc(PAGE_SIZE, GFP_NOWAIT | __GFP_NOWARN);
if (!buf)
return;

nr_entries = stack_depot_fetch(stack_depot, &entries);
nr_entries = stack_depot_fetch_into(stack_depot, entries, ARRAY_SIZE(entries));
stack_trace_snprint(buf, PAGE_SIZE, entries, nr_entries, 2);

drm_printf(&p, "attempting to lock a contended lock without backoff:\n%s", buf);
Expand Down
1 change: 1 addition & 0 deletions include/asm-generic/Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ mandatory-y += serial.h
mandatory-y += shmparam.h
mandatory-y += simd.h
mandatory-y += softirq_stack.h
mandatory-y += stackdepot.h
mandatory-y += switch_to.h
mandatory-y += timex.h
mandatory-y += tlbflush.h
Expand Down
19 changes: 19 additions & 0 deletions include/asm-generic/stackdepot.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __ASM_GENERIC_STACKDEPOT_H
#define __ASM_GENERIC_STACKDEPOT_H

#include <linux/types.h>

static inline bool
arch_stack_depot_frame_try_compress(unsigned long frame, u32 *low)
{
return false;
}

static inline void
arch_stack_depot_frame_decompress(u32 low, unsigned long *frame)
{
/* Generic code never compresses frames, so this hook is unreachable. */
}

#endif /* __ASM_GENERIC_STACKDEPOT_H */
87 changes: 74 additions & 13 deletions include/linux/stackdepot.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#define _LINUX_STACKDEPOT_H

#include <linux/gfp.h>
#include <linux/list.h>
#include <linux/refcount.h>

typedef u32 depot_stack_handle_t;

Expand Down Expand Up @@ -53,7 +55,8 @@ union handle_parts {
struct stack_record {
struct list_head hash_list; /* Links in the hash table */
u32 hash; /* Hash in hash table */
u32 size; /* Number of stored frames */
u16 size; /* Number of stored frames */
u16 flags;
union handle_parts handle; /* Constant after initialization */
refcount_t count;
union {
Expand Down Expand Up @@ -84,8 +87,9 @@ typedef u32 depot_flags_t;
*/
#define STACK_DEPOT_FLAG_CAN_ALLOC ((depot_flags_t)0x0001)
#define STACK_DEPOT_FLAG_GET ((depot_flags_t)0x0002)
#define STACK_DEPOT_FLAG_COUNTABLE ((depot_flags_t)0x0004)

#define STACK_DEPOT_FLAGS_NUM 2
#define STACK_DEPOT_FLAGS_NUM 3
#define STACK_DEPOT_FLAGS_MASK ((depot_flags_t)((1 << STACK_DEPOT_FLAGS_NUM) - 1))

/*
Expand Down Expand Up @@ -144,6 +148,16 @@ static inline int stack_depot_early_init(void) { return 0; }
* Users of this flag must also call stack_depot_put() when keeping the stack
* trace is no longer required to avoid overflowing the refcount.
*
* If STACK_DEPOT_FLAG_COUNTABLE is set in @depot_flags, stack depot stores the
* stack in hash-backed storage for callers that need direct stack_record count
* access. This flag does not imply %STACK_DEPOT_FLAG_CAN_ALLOC and is mutually
* exclusive with %STACK_DEPOT_FLAG_GET.
*
* When trie storage is enabled, persistent non-refcounted saves use trie
* storage. Constrained contexts remain best effort and can return 0 if a
* required trylock or reserved resource is unavailable; trie failures do not
* fall back to hash storage.
*
* If the provided stack trace comes from the interrupt context, only the part
* up to the interrupt entry is saved.
*
Expand All @@ -169,6 +183,10 @@ depot_stack_handle_t stack_depot_save_flags(unsigned long *entries,
* Does not increment the refcount on the saved stack trace; see
* stack_depot_save_flags() for more details.
*
* When trie storage is enabled, this can return trie-backed handles. Use
* stack_depot_fetch_into(), stack_depot_print(), or stack_depot_snprint() for
* backend-independent access to the stack contents.
*
* Context: Contexts where allocations via alloc_pages() are allowed;
* see stack_depot_save_flags() for more details.
*
Expand All @@ -178,27 +196,66 @@ depot_stack_handle_t stack_depot_save(unsigned long *entries,
unsigned int nr_entries, gfp_t alloc_flags);

/**
* __stack_depot_get_stack_record - Get a pointer to a stack_record struct
* __stack_depot_get_stack_record - Get a hash-backed stack record
*
* @handle: Stack depot handle
*
* This function is only for internal purposes.
* This function is only for internal purposes. @handle must have been saved
* with %STACK_DEPOT_FLAG_COUNTABLE.
*
* Return: Returns a pointer to a stack_record struct
* Return: Returns a pointer to a stack_record struct.
*/
struct stack_record *__stack_depot_get_stack_record(depot_stack_handle_t handle);

/**
* stack_depot_fetch - Fetch a stack trace from stack depot
*
* @handle: Stack depot handle returned from stack_depot_save()
* @handle: Hash-backed stack depot handle
* @entries: Pointer to store the address of the stack trace
*
* This helper returns a pointer to stackdepot-owned contiguous storage for
* legacy hash-backed handles. Callers that need backend-independent access to
* stack contents should use stack_depot_fetch_into(), stack_depot_print(), or
* stack_depot_snprint().
*
* Return: Number of frames for the fetched stack
*/
unsigned int stack_depot_fetch(depot_stack_handle_t handle,
unsigned long **entries);

/**
* stack_depot_fetch_into - Fetch a stack trace into caller-owned storage
*
* @handle: Stack depot handle returned from stack_depot_save()
* @entries: Caller-owned buffer to copy the stack trace into
* @max_entries: Number of frames that fit in @entries
*
* Copies the stored frames into caller-owned @entries. If fewer frames are
* stored than @max_entries, only the stored frames are written and their count
* is returned. If more frames are stored than @max_entries, the copy is skipped
* entirely and 0 is returned.
*
* Callers should size @entries to match the save-side stack depth cap (for
* example, %CONFIG_STACKDEPOT_MAX_FRAMES or the local stack_trace_save() limit)
* when losing diagnostics on an undersized buffer would be surprising.
*
* A non-zero invalid or post-put @handle is treated like stack_depot_fetch(): it
* returns 0 and may WARN because such handles indicate a corrupt caller state.
*
* Callers must ensure @handle remains valid for the duration of this call.
* Persistent handles saved without %STACK_DEPOT_FLAG_GET require no extra
* reference; handles saved with %STACK_DEPOT_FLAG_GET require a held reference.
* Callers must not call stack_depot_put() on persistent handles.
* Racing this helper with stack_depot_put() on the same handle is invalid.
*
* Return: Number of frames copied, 0 if @entries is NULL, @max_entries is 0,
* @handle is 0 or invalid, stack depot is disabled, or @max_entries is less
Comment thread
caleb-kan marked this conversation as resolved.
* than the number of stored frames.
*/
unsigned int stack_depot_fetch_into(depot_stack_handle_t handle,
unsigned long *entries,
unsigned int max_entries);

/**
* stack_depot_print - Print a stack trace from stack depot
*
Expand All @@ -217,17 +274,21 @@ void stack_depot_print(depot_stack_handle_t stack);
* Return: Number of bytes printed
*/
int stack_depot_snprint(depot_stack_handle_t handle, char *buf, size_t size,
int spaces);
int spaces);

/**
* stack_depot_put - Drop a reference to a stack trace from stack depot
*
* @handle: Stack depot handle returned from stack_depot_save()
*
* The stack trace is evicted from stack depot once all references to it have
* been dropped (once the number of stack_depot_evict() calls matches the
* number of stack_depot_save_flags() calls with STACK_DEPOT_FLAG_GET set for
* this stack trace).
* Drop a reference acquired by stack_depot_save_flags() with
* %STACK_DEPOT_FLAG_GET. Calling this for a handle saved without
* %STACK_DEPOT_FLAG_GET is invalid; persistent handles, including trie-backed
* handles, are owned by stack depot for the lifetime of the system.
*
* The stack trace is evicted once the number of stack_depot_put() calls matches
* the number of successful stack_depot_save_flags() calls with
* %STACK_DEPOT_FLAG_GET for this stack trace.
*/
void stack_depot_put(depot_stack_handle_t handle);

Expand All @@ -242,8 +303,8 @@ void stack_depot_put(depot_stack_handle_t handle);
* Stack depot handles have a few unused bits, which can be used for storing
* user-specific information. These bits are transparent to the stack depot.
*/
depot_stack_handle_t __must_check stack_depot_set_extra_bits(
depot_stack_handle_t handle, unsigned int extra_bits);
depot_stack_handle_t __must_check stack_depot_set_extra_bits(depot_stack_handle_t handle,
unsigned int extra_bits);

/**
* stack_depot_get_extra_bits - Retrieve extra bits from a stack depot handle
Expand Down
16 changes: 16 additions & 0 deletions lib/Kconfig.debug
Original file line number Diff line number Diff line change
Expand Up @@ -2706,6 +2706,22 @@ config RESOURCE_KUNIT_TEST

If unsure, say N.

config STACKDEPOT_KUNIT_TEST
bool "KUnit test for stack depot" if !KUNIT_ALL_TESTS
depends on KUNIT=y && STACKDEPOT
default KUNIT_ALL_TESTS
help
Enable this option to test stack depot API behavior at boot.
This test is built in because it exercises internal, non-exported
stack depot helpers, so KUNIT must also be built in.

KUnit tests run during boot and output the results to the debug log
in TAP format (https://testanything.org/). Only useful for kernel
developers running the KUnit test harness, and not intended for
inclusion into a production build.

If unsure, say N.

config SYSCTL_KUNIT_TEST
tristate "KUnit test for sysctl" if !KUNIT_ALL_TESTS
depends on KUNIT
Expand Down
Loading