Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp2956834pxm; Mon, 28 Feb 2022 09:12:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJwT1mcfoRQyvAzthcPoVdRS8s2zyZ0/mDAEJM2InQNCt+pfpUBjR7hg4XlaEGqNReJWosNu X-Received: by 2002:aca:5b43:0:b0:2d3:fa59:9125 with SMTP id p64-20020aca5b43000000b002d3fa599125mr11590897oib.47.1646068350278; Mon, 28 Feb 2022 09:12:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646068350; cv=none; d=google.com; s=arc-20160816; b=0nNcnj2acohK/jyECdho3Imhuu1pFy4lQn7RuLvwHR8AgTn24GSLWx1V/uFaTRXu23 8bAl8PFMhQ4ibAa3FsM5LvSkUxL5KTC4yt6yfufAHUQ19wfaTKMT76H5NcM+rSFJeDs4 RojeXr5r7tqbFv07kZzknjv3x6OkavOcOoTcmXuf1m9W5KOoKHoF3VqnkpQn8k8XDKiG AsQZMPD+mA6Q1DFivGrHE+rpdtj6BpRGFRN7WAMYsVvL1eGt7/lkKrRJ2uWx3y8pad8z Uu6ZnZOO7Wchhds8SHGM1X4p98qiqSlcMC2z9Af5SHyjVpJapYij1HRgb7t+FJXXqIqa WB9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=am2anFkVsG7Bze9aa1vWnJKsuTrnWK6q1iSh7BZsgF8=; b=z8QHZ8ARy9wwGT5gp2Vku3j4Nu6ZcTjP1ov2D6A/26C28SlifWaG/0oMPrfoT82BYf Z/4mySSdXHOnbM4DOdp0Jxc1k8nTGRSILksY/AK+TAwdvZjXAuLLrrxoVPZj4yljKAjR k+UKss2o9m9lR9PCPJ/oF6U6R2ZdYq8ZNnkoURRpT+pNHEJz8MsL1yrKaOWbKvwIYkRK UEu5peeHC85Pdnjzlh01/fFOmZrwUeIfawMpFVLODgPKmv5hbDwoBuE0vvLCpoNgRtDe AgNg5p4YEYKvr1iLxJCuQSvKkqD7WrqOZ5MCxrZ3sq4x7wTmCCBrIABodLHd6ioakC4D uevQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Jip0IPk5; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h16-20020a9d5550000000b005af44c9f118si5696856oti.105.2022.02.28.09.12.15; Mon, 28 Feb 2022 09:12:30 -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=@gmail.com header.s=20210112 header.b=Jip0IPk5; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235534AbiB1Ltd (ORCPT + 99 others); Mon, 28 Feb 2022 06:49:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233996AbiB1Ltb (ORCPT ); Mon, 28 Feb 2022 06:49:31 -0500 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6822593BD for ; Mon, 28 Feb 2022 03:48:52 -0800 (PST) Received: by mail-pg1-x52e.google.com with SMTP id bc27so2263672pgb.4 for ; Mon, 28 Feb 2022 03:48:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=am2anFkVsG7Bze9aa1vWnJKsuTrnWK6q1iSh7BZsgF8=; b=Jip0IPk53So+30XIUMs2CfvnweRALN+JwVNG1WrTMGEowE5C/a8zXwDHJhPj04WrLI cQAPc1b0V8sDEQx0OJj9/iSyLDJk+DyMyH3eTfUCMxOtKxpp/nLRJHV2khpgW0mWBjAL zTA31kiFhYQkwKdLgEiLa465Zn+dVcSODGz/KKKsI6wxa6Aold4doNku6mJkrXzgn1/s nl72LHYsR09xeM8kERKdiBj/T0gMyXncypLlsx5Us2B+QqTJ2aM4b038hNGkl31hm5+v +97KqUXNsgLKHy+x/FBL0HI8uSfcjUGtTvlNC0PrC/eE/VqvzSJc4MAMnVdm5xkiXNIH +wPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=am2anFkVsG7Bze9aa1vWnJKsuTrnWK6q1iSh7BZsgF8=; b=kadbrIGyn9aSN8Zg39VdHqHigVQGeLlPqXP6Apmk2d63DsY6enjQCUh7TlE2bbV6cL ZPJqtf90qhhfq3mSGqyTfipI8Zxowj/ITncINRw3tUfmp3UniWZPVmUw1Rx1bZdJJMFa GrVCOo2zoylYqXeNfrLXFN9osyKf/PU93fNkJayyHwOu65GY2Vb0ER+41oyxkcDhjjUB aohNl+BRHDPHs7v0rjzx/1iKmCSGM0iNyzWUqqWrPIfbnU+yxC0UDQnW5DKokPDIvJye yRqOGppviRE4ln7nRvnixSYY2QevNTBgWnT0U2Z5+BUA/HU2oyAmJJdytJV/gDK4TYYs ibbg== X-Gm-Message-State: AOAM530I4qMjSM9jonYgVvy47dLBb4L5slTJXv3TxP5EpouSr854DWGH /gkhppBD69+fGz72fwfa9wc= X-Received: by 2002:a63:584d:0:b0:370:14d9:8238 with SMTP id i13-20020a63584d000000b0037014d98238mr16675435pgm.166.1646048931891; Mon, 28 Feb 2022 03:48:51 -0800 (PST) Received: from ip-172-31-19-208.ap-northeast-1.compute.internal (ec2-18-181-137-102.ap-northeast-1.compute.amazonaws.com. [18.181.137.102]) by smtp.gmail.com with ESMTPSA id v22-20020a17090ad59600b001b7deb42251sm16690979pju.15.2022.02.28.03.48.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 03:48:51 -0800 (PST) Date: Mon, 28 Feb 2022 11:48:45 +0000 From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Marco Elver Cc: Vlastimil Babka , 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 , Dmitry Vyukov , Eric Dumazet , Jarkko Sakkinen , Johannes Berg , Yury Norov , Arnd Bergmann , James Bottomley , Matteo Croce , Andrey Konovalov , Imran Khan , Zqiang Subject: Re: [PATCH] lib/stackdepot: Use page allocator if both slab and memblock is unavailable Message-ID: References: <20220225180318.20594-3-vbabka@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HK_RANDOM_ENVFROM, HK_RANDOM_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no 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 Mon, Feb 28, 2022 at 11:50:49AM +0100, Marco Elver wrote: > On Mon, 28 Feb 2022 at 11:05, Hyeonggon Yoo <42.hyeyoo@gmail.com> 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@ip-172-31-19-208.ap-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 :-)