Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1258992rwr; Fri, 5 May 2023 11:17:16 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5WaodBKV8UoEkJIGEJ3DzQ5ZD70gftmDg8HO2ScBBuddGUXu5kX6SlZb2K7pWSENAHXYy7 X-Received: by 2002:a17:902:a402:b0:1a1:9020:f9c7 with SMTP id p2-20020a170902a40200b001a19020f9c7mr2250087plq.44.1683310636531; Fri, 05 May 2023 11:17:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683310636; cv=none; d=google.com; s=arc-20160816; b=iaVIX/vWh246gmvoa/5/22Gf8Qi1LDmSGSxKSj/7vXZnd7Q9RC4otBoWOSkDZYFQDP ZeLOdrZnr7/unz7caZQ5tU0igpJQOYebIw3UI+izVVJNy4ondb0MCddJkMfHEiIGjElh TgETYJ6X/NJPhPqh+4Haa2hCKVDBY6NGGYBw71tDhQF3IkzJ531mWPFPg20UFWUgDNBK yXj30+MsaF6l5gwJKq7EvZVhwO/b2a08WNCEVZybRcBsQ7G9yDm2PGdbkaz3xTkE2hXu AYE6sy5TnPywYEFjT1obuvnorlBPnb63W3hzXBMcHZpvGfb8lQsW8nEOWsMIcHLYSpvT E0ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=QVZYG1JecNO86jzNV6C/AMNw6VQt+fJvqwCxq5mp/Nc=; b=fvY4Dw3jSw96rOzr6UAnzd+TVqVhJY6rMtRt/XcMijCbXyFJVHD1/mgWcyH7hJXkbA YILabqJTS+Bj2U7+RXC/MVALC7AD7rVElyhTKdSokW6+cgDpJtbe3UCisp/ascni8mPq yu0IEB6ZIyWpKcPcJz56JvcuarsoaXt8O9U78wzfBEg8Mp3uRG0OeR2QvwrsGc1Mc8wX PH7bFIcHz76Pjuqbj6mGhL2yhOl8NEaxrdFKKKOTqt8JV1INIMnPU3bnm32neTwnZoxb vvi2z/I9Nw9NaCMm8fmkDONlTtC3m0AtxR2PoItU+n96JXBuV9rd84d1Yew/VAlpvWDt FUIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b="JuehaV/R"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d6-20020a170902cec600b001ab10e58308si2379413plg.400.2023.05.05.11.17.01; Fri, 05 May 2023 11:17:16 -0700 (PDT) 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=@google.com header.s=20221208 header.b="JuehaV/R"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233264AbjEESKk (ORCPT + 99 others); Fri, 5 May 2023 14:10:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233147AbjEESKh (ORCPT ); Fri, 5 May 2023 14:10:37 -0400 Received: from mail-yb1-xb30.google.com (mail-yb1-xb30.google.com [IPv6:2607:f8b0:4864:20::b30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1614160B1 for ; Fri, 5 May 2023 11:10:32 -0700 (PDT) Received: by mail-yb1-xb30.google.com with SMTP id 3f1490d57ef6-b9d8b458e10so2742226276.1 for ; Fri, 05 May 2023 11:10:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683310232; x=1685902232; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=QVZYG1JecNO86jzNV6C/AMNw6VQt+fJvqwCxq5mp/Nc=; b=JuehaV/RJK9Y4fUOdxkcZEuqDGAuEF/acJdDqJ45XbKARUoqq4czDg4ZH8mqWvQs0W C3cMUZ3VtCr6q/eI+6qJp58nulUMjZvQdZpvpUFXRdmOfRfhasZuNayk1xVHyGVy9Mwz ItoP45q/KUOjBJ5HUc+Vlm240zAnqes7cusDh4wsBFNSxkmDsbQVgr1QY7ENaCb2Pf+o stmyjKNibly7r3/lcAzIGX4ZSS4stgbgtYjMfq5c0cI/ZADNQtKt98fqV/f8MiQv11Tt rfeoXeDHmM1lnkcbyLTsW9UrOEazY/VwbfsLiL1Vyfp7oqXyyedjHeSP3hv1vKGbwqQn 8juQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683310232; x=1685902232; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QVZYG1JecNO86jzNV6C/AMNw6VQt+fJvqwCxq5mp/Nc=; b=ak9nomQreHO9E5et1t92sOxoXrJnXCfH5Z0WzPuEaBfi06cO0atPBHnGI0wIrTNgSn cjeV/7Zfxx9a84xDI+Bxf0n0HAEjjrUonpCODapzn6mZnpQdNLdS4pTIASyKRfYg93m2 oICOdz7OVPR1aAk8lmJQCPPdaQP3mpLcy/Pt+EiqdLRYFlbEpchWnfe5EP1Q76Da6LLk 0OR4jW8pDlnPEZupf5BT3BUbrYvWjCItU+DFWYOpi72Kt2WubuYERlUnaJjdyy5CtZmf cgVMGMrPukVuc3xJbK7NUrebK3W28jHKA7E/KtFkPUTecZcP5Ub8bmNgkYhoP6M8L8El vroQ== X-Gm-Message-State: AC+VfDzKhX8sHnbSYGymQAVx18fLH2W/9ktu4vyuNDhhHPCFF7QPx1TS 8kAWNzz8OYU6WxE7dreDAtFvTr/OJdSWiAtxqeEkdQ== X-Received: by 2002:a25:19d7:0:b0:b97:1e2e:a4e5 with SMTP id 206-20020a2519d7000000b00b971e2ea4e5mr2351347ybz.40.1683310231779; Fri, 05 May 2023 11:10:31 -0700 (PDT) MIME-Version: 1.0 References: <20230501165450.15352-1-surenb@google.com> <20230501165450.15352-36-surenb@google.com> In-Reply-To: From: Suren Baghdasaryan Date: Fri, 5 May 2023 11:10:20 -0700 Message-ID: Subject: Re: [PATCH 35/40] lib: implement context capture support for tagged allocations To: Michal Hocko Cc: akpm@linux-foundation.org, kent.overstreet@linux.dev, vbabka@suse.cz, hannes@cmpxchg.org, roman.gushchin@linux.dev, mgorman@suse.de, dave@stgolabs.net, willy@infradead.org, liam.howlett@oracle.com, corbet@lwn.net, void@manifault.com, peterz@infradead.org, juri.lelli@redhat.com, ldufour@linux.ibm.com, catalin.marinas@arm.com, will@kernel.org, arnd@arndb.de, tglx@linutronix.de, mingo@redhat.com, dave.hansen@linux.intel.com, x86@kernel.org, peterx@redhat.com, david@redhat.com, axboe@kernel.dk, mcgrof@kernel.org, masahiroy@kernel.org, nathan@kernel.org, dennis@kernel.org, tj@kernel.org, muchun.song@linux.dev, rppt@kernel.org, paulmck@kernel.org, pasha.tatashin@soleen.com, yosryahmed@google.com, yuzhao@google.com, dhowells@redhat.com, hughd@google.com, andreyknvl@gmail.com, keescook@chromium.org, ndesaulniers@google.com, gregkh@linuxfoundation.org, ebiggers@google.com, ytcoode@gmail.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, bristot@redhat.com, vschneid@redhat.com, cl@linux.com, penberg@kernel.org, iamjoonsoo.kim@lge.com, 42.hyeyoo@gmail.com, glider@google.com, elver@google.com, dvyukov@google.com, shakeelb@google.com, songmuchun@bytedance.com, jbaron@akamai.com, rientjes@google.com, minchan@google.com, kaleshsingh@google.com, kernel-team@android.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, iommu@lists.linux.dev, linux-arch@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-modules@vger.kernel.org, kasan-dev@googlegroups.com, cgroups@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable 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 Fri, May 5, 2023 at 1:40=E2=80=AFAM Michal Hocko wrote= : > > On Thu 04-05-23 09:22:07, Suren Baghdasaryan wrote: > [...] > > > But even then I really detest an additional allocation from this cont= ext > > > for every single allocation request. There GFP_NOWAIT allocation for > > > steckdepot but that is at least cached and generally not allocating. > > > This will allocate for every single allocation. > > > > A small correction here. alloc_tag_create_ctx() is used only for > > allocations which we requested to capture the context. So, this last > > sentence is true for allocations we specifically marked to capture the > > context, not in general. > > Ohh, right. I have misunderstood that part. Slightly better, still > potentially a scalability issue because hard to debug memory leaks > usually use a generic caches (for kmalloc). So this might be still a lot > of objects to track. Yes, generally speaking, if a single code location is allocating very frequently then enabling context capture for it will generate many callstack buffers. Your note about use of generic caches makes me think we still have a small misunderstanding. We tag at the allocation call site, not based on which cache is used. Two kmalloc calls from different code locations will have unique codetags for each, so enabling context capture for one would not result in context capturing for the other one. > > > > There must be a better way. > > > > Yeah, agree, it would be good to avoid allocations in this path. Any > > specific ideas on how to improve this? Pooling/caching perhaps? I > > think kmem_cache does some of that already but maybe something else? > > The best I can come up with is a preallocated hash table to store > references to stack depots with some additional data associated. The > memory overhead could be still quite big but the hash tables could be > resized lazily. Ok, that seems like the continuation of you suggestion in another thread to combine identical callstack traces. That's an excellent idea! I think it would not be hard to implement. Thanks! > -- > Michal Hocko > SUSE Labs