Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp494419pxm; Wed, 2 Mar 2022 02:47:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJxMkIz6F6ig3jATmlE410NF12Wd6MlUj4DqWCtPdGUGfIdy9facc81xDC0/XGRKfp42AKX7 X-Received: by 2002:a17:90b:3503:b0:1bc:5d68:e7a2 with SMTP id ls3-20020a17090b350300b001bc5d68e7a2mr26562410pjb.29.1646218029602; Wed, 02 Mar 2022 02:47:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646218029; cv=none; d=google.com; s=arc-20160816; b=TEwwu92N1gCx7BXVnBxNZ+oHXhC6Ka+zGTSqJ3thV145RLPILdv1Tr4ET8dVSAyDTu c2JkMM1Q1KauPTVHNC/I1hh7lyA2A8XmQNJ0lL6cUBZdBlqYHp+znSs3Nvq7XsBLMgRo s0ZKDnk7v0VgLz1dgRKk0Yo9MdjZrRcZNUL4G20G8UNn3p9ZTcNVi6+C5+riHvM9WUkF J2Ireu0xvE7sKWyOdo88H/snA6GTLjSF4hZNta/XAUx3+rbX6g6UcyF1hvQtt890ifYy iGBLbhlcj3+9AuClJOZ1XsI7y43AQzxXs0m/Ve2diRHTmJzyQJovZ9isx2OASAiSlfEV MEbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature:dkim-signature; bh=v+CJOTOD4n7/OSSm073QF8ULoWYfiH4GzE5utXJnhxA=; b=RryabS51vpBZKe/XVZA64t/WKlBMjpRY/ce+9lLbVdx5geD0wgzKXmYHD6gKaqCa7n 9yeXCng4BPFNAIQbXPA/TV9rjvh9TbQOb98kmqsljLOKUQTfrqKTAF/k7Qn1IHKhS35F civslRcAvWyLnSW6cgExH0iTsGvzuZRYNbCOQWvWjjtbDReWbANVR8X89xg5xs2S+p1N 2O1QdqN5LHSw2P4F0MgacvEzHUwxY1qmpvHKLhDRgVt75n6RR+O9DEoSa5jJGsnCioAk 8iy9/TcKqK6QOR4BzbgerRKuhIXiwWeHSyTTk9hWm9GgyM8dqCGX9H0IIJWauBZ0Lr6u T6Tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=oD83E4vs; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j13-20020a170903028d00b0014f8a32b7e8si15053002plr.555.2022.03.02.02.46.53; Wed, 02 Mar 2022 02:47:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=oD83E4vs; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240364AbiCBJK3 (ORCPT + 99 others); Wed, 2 Mar 2022 04:10:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240358AbiCBJKW (ORCPT ); Wed, 2 Mar 2022 04:10:22 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0E49B82F8 for ; Wed, 2 Mar 2022 01:09:39 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 1ED8E21991; Wed, 2 Mar 2022 09:09:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1646212178; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=v+CJOTOD4n7/OSSm073QF8ULoWYfiH4GzE5utXJnhxA=; b=oD83E4vsqXcSYoJNs6mRPFvLd5ik2FsCH6wAEbZDKRYSB3S8Tg0EsvFkVSwbfvOb+It4sn KxdAN2XxMcBG5bDaLQJ2+jbBh6r4/VamLm5/F6taZn2sGdiCI6rJaCkuvlk6Rn1s1xrqPJ 71ksSdOrEk2GotWCREp7ZdZqpPEigWU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1646212178; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=v+CJOTOD4n7/OSSm073QF8ULoWYfiH4GzE5utXJnhxA=; b=tbETP8MJoXoBANx3DZ02m94JinwzFvQyiFW421CBLBOFkk9Clo4I7VJubxuwEMyZGfTimy HNCUOupVS4B8EfDw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id CE49813345; Wed, 2 Mar 2022 09:09:37 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id u5OBMVE0H2LhVgAAMHmgww (envelope-from ); Wed, 02 Mar 2022 09:09:37 +0000 Message-ID: <024aacf5-ac49-7d04-7293-1e1451ff9029@suse.cz> Date: Wed, 2 Mar 2022 10:09:37 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [PATCH 0/5] SLUB debugfs improvements based on stackdepot Content-Language: en-US To: Mike Rapoport , Hyeonggon Yoo <42.hyeyoo@gmail.com> Cc: David Rientjes , Christoph Lameter , Joonsoo Kim , Pekka Enberg , Roman Gushchin , Andrew Morton , linux-mm@kvack.org, patches@lists.linux.dev, linux-kernel@vger.kernel.org, Oliver Glitta , Faiyaz Mohammed , Jonathan Corbet , Randy Dunlap , Marco Elver , Karolina Drobnik References: <20220225180318.20594-1-vbabka@suse.cz> From: Vlastimil Babka In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/2/22 09:37, Mike Rapoport wrote: > On Mon, Feb 28, 2022 at 09:27:02PM +0000, Hyeonggon Yoo wrote: >> On Mon, Feb 28, 2022 at 08:10:18PM +0100, Vlastimil Babka wrote: >> > On 2/26/22 08:19, Hyeonggon Yoo wrote: >> > > On Fri, Feb 25, 2022 at 07:03:13PM +0100, Vlastimil Babka wrote: >> > >> Hi, >> > >> >> > >> this series combines and revives patches from Oliver's last year >> > >> bachelor thesis (where I was the advisor) that make SLUB's debugfs >> > >> files alloc_traces and free_traces more useful. >> > >> The resubmission was blocked on stackdepot changes that are now merged, >> > >> as explained in patch 2. >> > >> >> > > >> > > Hello. I just started review/testing this series. >> > > >> > > it crashed on my system (arm64) >> > >> > Hmm, interesting. On x86_64 this works for me and stackdepot is allocated >> > from memblock. arm64 must have memblock freeing happen earlier or something. >> > (CCing memblock experts) >> > >> > > I ran with boot parameter slub_debug=U, and without KASAN. >> > > So CONFIG_STACKDEPOT_ALWAYS_INIT=n. >> > > >> > > void * __init memblock_alloc_try_nid( >> > > phys_addr_t size, phys_addr_t align, >> > > phys_addr_t min_addr, phys_addr_t max_addr, >> > > int nid) >> > > { >> > > void *ptr; >> > > >> > > memblock_dbg("%s: %llu bytes align=0x%llx nid=%d from=%pa max_addr=%pa %pS\n", >> > > __func__, (u64)size, (u64)align, nid, &min_addr, >> > > &max_addr, (void *)_RET_IP_); >> > > ptr = memblock_alloc_internal(size, align, >> > > min_addr, max_addr, nid, false); >> > > if (ptr) >> > > memset(ptr, 0, size); <--- Crash Here >> > > >> > > return ptr; >> > > } >> > > >> > > It crashed during create_boot_cache() -> stack_depot_init() -> >> > > memblock_alloc(). >> > > >> > > I think That's because, in kmem_cache_init(), both slab and memblock is not >> > > available. (AFAIU memblock is not available after mem_init() because of >> > > memblock_free_all(), right?) >> > >> > Hm yes I see, even in x86_64 version mem_init() calls memblock_free_all(). >> > But then, I would expect stack_depot_init() to detect that memblock_alloc() >> > returns NULL, we print ""Stack Depot hash table allocation failed, >> > disabling" and disable it. Instead it seems memblock_alloc() returns >> > something that's already potentially used by somebody else? Sounds like a bug? >> >> >> By the way, I fixed this by allowing stack_depot_init() to be called in >> kmem_cache_init() too [1] and Marco suggested that calling >> stack_depot_init() depending on slub_debug parameter for simplicity. [2] >> >> I would prefer [2], Would you take a look? >> >> [1] https://lkml.org/lkml/2022/2/27/31 >> >> [2] https://lkml.org/lkml/2022/2/28/717 > > I have the third version :) While simple, it changes the timing of stack_depot_early_init() that was supposed to be at a single callsite - now it's less predictable and depends on e.g. kernel parameter ordering. Some arch/config combo could break, dunno. Setting a variable that stack_depot_early_init() checks should be more robust. > > diff --git a/mm/slub.c b/mm/slub.c > index a74afe59a403..0c3ab2335b46 100644 > --- a/mm/slub.c > +++ b/mm/slub.c > @@ -1548,6 +1548,10 @@ static int __init setup_slub_debug(char *str) > } > out: > slub_debug = global_flags; > + > + if (slub_flags & SLAB_STORE_USER && IS_ENABLED(CONFIG_STACKDEPOT)) > + stack_depot_early_init(); > + > if (slub_debug != 0 || slub_debug_string) > static_branch_enable(&slub_debug_enabled); > else > @@ -4221,9 +4225,6 @@ 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(); > - > /* Initialize the pre-computed randomized freelist if slab is up */ > if (slab_state >= UP) { > if (init_cache_random_seq(s)) > >> -- >> Thank you, You are awesome! >> Hyeonggon :-) >