On Mon, Feb 28, 2022 at 11:50:49AM +0100, Marco Elver wrote: > On Mon, 28 Feb 2022 at 11:05, Hyeonggon Yoo <42.hyeyoo@xxxxxxxxx> wrote: > [...] > > > This is odd - who is calling stack_depot_init() while neither slab nor > > > memblock are available? > > > > It's not merged yet - but Oliver's patch (2/5) in his series [1] does: > > If user is debugging cache, it calls stack_depot_init() when creating > > cache. > > > > > @@ -4221,6 +4220,9 @@ static int kmem_cache_open(struct kmem_cache *s, slab_flags_t flags) > > > s->remote_node_defrag_ratio = 1000; > > > #endif > > > > > > + if (s->flags & SLAB_STORE_USER && IS_ENABLED(CONFIG_STACKDEPOT)) > > > + stack_depot_init(); > > > + > > > > Oliver's patch series enables stack depot when arch supports stacktrace, > > to store slab objects' stack traces. (as slub debugging feature.) > > > > Because slub debugging is turned on by default, the commit 2dba5eb1c73b > > ("lib/stackdepot: allow optional init and stack_table allocation by > > kvmalloc()") made stack_depot_init() can be called later. > > > > With Oliver's patch applied, stack_depot_init() can be called in > > contexts below: > > > > 1) only memblock available (for kasan) > > 2) only buddy available, vmalloc/memblock unavailable (for boot caches) > > 3) buddy/slab available, vmalloc/memblock unavailable (vmap_area cache) > > 4) buddy/slab/vmalloc available, memblock unavailable (other caches) > > > > SLUB supports enabling debugging for specific cache by passing > > slub_debug boot parameter. As slab caches can be created in > > various context, stack_depot_init() should consider all contexts above. > > > > Writing this, I realized my patch does not handle case 3).. I'll send v3. > > > > [1] https://lore.kernel.org/linux-mm/YhoakP7Kih%2FYUgiN@xxxxxxxxxxxxxxxxxxx-northeast-1.compute.internal/T/#t > > [2] https://git.kernel.org/pub/scm/linux/kernel/git/vbabka/linux.git/log/?h=slub-stackdepot-v1 > > > > > Do you have a stacktrace? > > > > Yeah, here: > > > > You can reproduce this on vbabka's slab-stackdepot-v1 branch [2] with > > slub_debug=U, and CONFIG_STACKDEPOT_ALWAYS_INIT=n > > > [...] > > [ 0.000000] Call trace: > > [ 0.000000] __memset+0x16c/0x188 > > [ 0.000000] stack_depot_init+0xc8/0x100 > > [ 0.000000] __kmem_cache_create+0x454/0x570 > > [ 0.000000] create_boot_cache+0xa0/0xe0 > > I think even before this point you have all the information required > to determine if stackdepot will be required. It's available after > setup_slub_debug(). > > So why can't you just call stack_depot_init() somewhere else and avoid > all this complexity? > You are right. That is much simpler and sound good as SLUB does not support enabling SLAB_STORE_USER flag when system is up. I'll try this approach. Thank you! > > [ 0.000000] kmem_cache_init+0xf8/0x204 > > [ 0.000000] start_kernel+0x3ec/0x668 > > [ 0.000000] __primary_switched+0xc0/0xc8 > > [ 0.000000] Code: 91010108 54ffff4a 8b040108 cb050042 (d50b7428) > > [ 0.000000] ---[ end trace 0000000000000000 ]--- > > [ 0.000000] Kernel panic - not syncing: Attempted to kill the idle task! > > [ 0.000000] ---[ end Kernel panic - not syncing: Attempted to kill the idle task! ]--- -- Thank you, You are awesome! Hyeonggon :-)