All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marco Elver <elver@google.com>
To: Caleb Kan <calebkan1106@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	kasan-dev@googlegroups.com, Vlastimil Babka <vbabka@kernel.org>,
	Alexander Potapenko <glider@google.com>,
	Dmitry Vyukov <dvyukov@google.com>,
	Andrey Konovalov <andreyknvl@gmail.com>,
	Oscar Salvador <osalvador@suse.de>,
	Caleb Kan <ckan@cloudflare.com>,
	kernel-team@cloudflare.com
Subject: Re: [PATCH RFC v2 09/11] stackdepot: add architecture hooks for compact frame storage
Date: Tue, 20 Oct 2026 14:56:10 +0000	[thread overview]
Message-ID: <ateBClusB8nSEnAr@elver.google.com> (raw)
In-Reply-To: <20260908-stackdepot-trie-v2-9-1996d5cef732@cloudflare.com>

On Tue, Sep 08, 2026 at 02:13PM +0100, Caleb Kan wrote:
> From: Caleb Kan <ckan@cloudflare.com>
> 
> Path-compressed trie nodes can reduce their frame storage further when an
> architecture can represent kernel text and module addresses in 32 bits.
> Add architecture hooks that compress a frame only when decompression
> reproduces the original address exactly.
> 
> Store arm64 frames as signed 32-bit offsets from _text. This covers the
> 2 GB module relocation window without depending on a 4 GB high-bit
> boundary. On x86-64, store the low 32 bits when the upper 32 bits are all
> set. Keep other frames full-width, and provide a generic implementation
> that always rejects compression.
> 
> Make the generic header available to architectures without a specialized
> implementation and wire it explicitly for UML. Add KUnit coverage for raw
> fallback, arm64 boundary round trips, and native x86-64 prefix compression.
> 
> These hooks do not change stack depot behavior until a later patch adds
> trie storage.
> 
> Signed-off-by: Caleb Kan <ckan@cloudflare.com>
> ---
>  arch/arm64/include/asm/stackdepot.h | 42 ++++++++++++++++++
>  arch/um/include/asm/Kbuild          |  1 +
>  arch/x86/include/asm/stackdepot.h   | 37 ++++++++++++++++
>  include/asm-generic/Kbuild          |  1 +
>  include/asm-generic/stackdepot.h    | 19 ++++++++
>  lib/tests/stackdepot_kunit.c        | 86 +++++++++++++++++++++++++++++++++++++
>  6 files changed, 186 insertions(+)
> 
> diff --git a/arch/arm64/include/asm/stackdepot.h b/arch/arm64/include/asm/stackdepot.h
> new file mode 100644
> index 000000000000..df8959d59336
> --- /dev/null
> +++ b/arch/arm64/include/asm/stackdepot.h
> @@ -0,0 +1,42 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#ifndef __ASM_STACKDEPOT_H
> +#define __ASM_STACKDEPOT_H
> +
> +#include <linux/types.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_payload(u32 payload)
> +{
> +	long offset;
> +
> +	offset = (s32)payload;
> +	if (offset < 0)
> +		return (unsigned long)_text - (unsigned long)(-offset);
> +	return (unsigned long)_text + (unsigned long)offset;
> +}

'(unsigned long)_text + (s64)(s32)payload' avoids the branch and the
potential UB if 'offset == S32_MIN' on a 32-bit 'long' (though arm64 is
LP64, sign-extending directly is simpler).

More importantly: why not use these 32-bit frame compression hooks
directly in the existing hash-backed 'struct stack_record'? That gives
most of the memory savings across *all* stackdepot users with almost no
added code.


  reply	other threads:[~2026-10-20 14:56 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-08 13:13 [PATCH RFC v2 00/11] stackdepot: reduce memory use for persistent stack records with a trie Caleb Kan
2026-09-08 13:13 ` [PATCH RFC v2 01/11] stackdepot: stop preallocating after the final pool Caleb Kan
2026-10-16 16:53   ` Marco Elver
2026-09-08 13:13 ` [PATCH RFC v2 02/11] stackdepot: add caller-owned stack trace fetching Caleb Kan
2026-10-20 11:00   ` Marco Elver
2026-09-08 13:13 ` [PATCH RFC v2 03/11] mm/page_owner: preserve accounting with countable stack depot records Caleb Kan
2026-10-20 11:11   ` Marco Elver
2026-09-08 13:13 ` [PATCH RFC v2 04/11] mm/kmemleak: print trie-backed stack depot traces Caleb Kan
2026-09-08 13:13 ` [PATCH RFC v2 05/11] kmsan: report " Caleb Kan
2026-10-20 14:53   ` Marco Elver
2026-09-08 13:13 ` [PATCH RFC v2 06/11] mm/slub: materialize " Caleb Kan
2026-09-08 13:13 ` [PATCH RFC v2 07/11] drm/locking: preserve deadlock diagnostics for trie-backed stacks Caleb Kan
2026-09-08 13:13 ` [PATCH RFC v2 08/11] scripts/gdb: reject trie-backed stack depot handles Caleb Kan
2026-09-08 13:13 ` [PATCH RFC v2 09/11] stackdepot: add architecture hooks for compact frame storage Caleb Kan
2026-10-20 14:56   ` Marco Elver [this message]
2026-09-08 13:13 ` [PATCH RFC v2 10/11] stackdepot: share persistent stack prefixes with trie storage Caleb Kan
2026-10-20 15:04   ` Marco Elver
2026-09-08 13:13 ` [PATCH RFC v2 11/11] stackdepot: add KUnit tests for " Caleb Kan
2026-10-07 10:34 ` [PATCH RFC v2 00/11] stackdepot: reduce memory use for persistent stack records with a trie Matt Fleming
2026-10-20 15:07 ` Marco Elver

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ateBClusB8nSEnAr@elver.google.com \
    --to=elver@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=andreyknvl@gmail.com \
    --cc=calebkan1106@gmail.com \
    --cc=ckan@cloudflare.com \
    --cc=dvyukov@google.com \
    --cc=glider@google.com \
    --cc=kasan-dev@googlegroups.com \
    --cc=kernel-team@cloudflare.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=osalvador@suse.de \
    --cc=vbabka@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.