lib-stackdepot-replace-config_stack_hash_order-with-automatic-sizing.patch removed from -mm tree
The quilt patch titled
Subject: lib/stackdepot: replace CONFIG_STACK_HASH_ORDER with automatic sizing
has been removed from the -mm tree. Its filename was
lib-stackdepot-replace-config_stack_hash_order-with-automatic-sizing.patch
This patch was dropped because it was merged into the mm-nonmm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: Vlastimil Babka <[email protected]>
Subject: lib/stackdepot: replace CONFIG_STACK_HASH_ORDER with automatic sizing
Date: Mon, 20 Jun 2022 17:02:49 +0200
As Linus explained [1], setting the stackdepot hash table size as a config option is suboptimal, especially as stackdepot becomes a dependency of less "expert" subsystems than initially (e.g. DRM, networking, SLUB_DEBUG):
: (a) it introduces a new compile-time question that isn't sane to ask : a regular user, but is now exposed to regular users.
: (b) this by default uses 1MB of memory for a feature that didn't in : the past, so now if you have small machines you need to make sure you : make a special kernel config for them.
Ideally we would employ rhashtable for fully automatic resizing, which should be feasible for many of the new users, but problematic for the original users with restricted context that call __stack_depot_save() with can_alloc == false, i.e. KASAN.
However we can easily remove the config option and scale the hash table automatically with system memory. The STACK_HASH_MASK constant becomes stack_hash_mask variable and is used only in one mask operation, so the overhead should be negligible to none. For early allocation we can employ the existing alloc_large_system_hash() function and perform similar scaling for the late allocation.
The existing limits of the config option (between 4k and 1M buckets) are preserved, and scaling factor is set to one bucket per 16kB memory so on 64bit the max 1M buckets (8MB memory) is achieved with 16GB system, while a 1GB system will use 512kB.
Because KASAN is reported to need the maximum number of buckets even with smaller amounts of memory [2], set it as such when kasan_enabled().
If needed, the automatic scaling could be complemented with a boot-time kernel parameter, but it feels pointless to add it without a specific use case.
[1] https://lore.kernel.org/all/CAHk-=wjC5nS+fnf6EzRD9yQRJApAhxx7gRB87ZV+pAWo9oVrTg@mail.gmail.com/
[2] https://lore.kernel.org/all/CACT4Y+Y4GZfXOru2z5tFPzFdaSUd+GFc6KVL=bsa0+1m197cQQ@mail.gmail.com/
---
lib/Kconfig | 9 ------ lib/stackdepot.c | 59 +++++++++++++++++++++++++++++++++++++-------- 2 files changed, 49 insertions(+), 19 deletions(-)
lib/Kconfig renamed from lib/Kconfig~lib-stackdepot-replace-config_stack_hash_order-with-automatic-sizing +0 -9
@@ -685,15 +685,6 @@ config STACKDEPOT_ALWAYS_INIT bool select STACKDEPOT -config STACK_HASH_ORDER - int "stack depot hash size (12 => 4KB, 20 => 1024KB)" - range 12 20 - default 20 - depends on STACKDEPOT - help - Select the hash size as a power of 2 for the stackdepot hash table. - Choose a lower value to reduce the memory impact. - config REF_TRACKER bool depends on STACKTRACE_SUPPORT
lib/stackdepot.c renamed from lib/stackdepot.c~lib-stackdepot-replace-config_stack_hash_order-with-automatic-sizing +49 -10
105 lines not on this page · raw message
_
Patches currently in -mm which might be from [email protected] are