Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1305818rwr; Wed, 3 May 2023 13:09:47 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4PkpffqaYcWIkAbIO4bRxQIpy2v8oF0t0TLrBAp7AaYXNZtUJgXbHM5kdN+VpjV5Z6FtSb X-Received: by 2002:a17:90a:5785:b0:24e:edd:4d66 with SMTP id g5-20020a17090a578500b0024e0edd4d66mr3729618pji.19.1683144587454; Wed, 03 May 2023 13:09:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683144587; cv=none; d=google.com; s=arc-20160816; b=QiddZ9yncoPKa6q18MpBBaqCN4UqFz2/YmVXOQkV0JpVfCHyiF5yPTVVA6QM0Nf4ah F7/D5UUzea9Q5MLkHHip1kglOkPpymaxFpU3NkXmtjZzKBwiIopSMk8BL/JeR2NOFFXk lP7WpLkUwio6Lk2D0y5PI/BqhkVCm3Jy4KRXFgFWF2akqEJEByHB74kTCnvJ5gJd800b rk3zcXpDXyNZpbyQ0XJTHz4rCC9dzn9qUBXI/WZbZlCXlbab97jve+XUqO8Z+NCcb/NK saMn9UYnoKkXgz6DEgvYgA1qj8vx656jaHRJHBKpB7OAj1DAj4fQ6YA4reGDPSl7NROT qxtQ== 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=uaEl0+ttAfDVYkQkgOF9inVIlQxPo4MAHa3r5TcHPqs=; b=cmTeZWDqf3owJov8M6t8pprezGdYlcJxNcUWvBjO4mtJJ5xcT8uDLLJ1QsBhuC8VKM IZby4p0YoSK0dzcM2f9Q/pjVIkmLCzKMNHmt/DgYzlHpajuJTzlXdktopNw7/6vw2NhK fI3TJYBnG41Lso9kxJYFjq96fdz/JTsLcIm/VeEx/WO1TmuKnelxczdYWHC3IkAVODqN JsjsvNy4jGIB/UgLr+5Wc28/43xv42AZU/UM4WVi9fQSxCq+fcjz7/NVklW6av9ASlpn P/1hDxA+pJ2mAbr3HCC/aE4aq0jzu3r5KXIJubqgq/cMGVTmmjVyRevWAulcTYQ37Bi6 Q4zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=ZBFmhNUt; 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 a36-20020a631a24000000b0051b856ffbc1si33297743pga.659.2023.05.03.13.09.23; Wed, 03 May 2023 13:09:47 -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=ZBFmhNUt; 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 S229878AbjECUI4 (ORCPT + 99 others); Wed, 3 May 2023 16:08:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229631AbjECUIz (ORCPT ); Wed, 3 May 2023 16:08:55 -0400 Received: from mail-yb1-xb35.google.com (mail-yb1-xb35.google.com [IPv6:2607:f8b0:4864:20::b35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C5DD420B for ; Wed, 3 May 2023 13:08:53 -0700 (PDT) Received: by mail-yb1-xb35.google.com with SMTP id 3f1490d57ef6-b9a6eec8611so5484790276.0 for ; Wed, 03 May 2023 13:08:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683144532; x=1685736532; 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=uaEl0+ttAfDVYkQkgOF9inVIlQxPo4MAHa3r5TcHPqs=; b=ZBFmhNUtx4spDPZ2Tc+ao7Umap1oUxGgS6L35zoiaIlLMa3sbvfe1yyzPgLcae3Fty gA+quo34T7AKstKRwlQ7/Ft2WrnkU+rEhs/+hqpbEUBx2dmlPORy4QLjme1jFVo6xrFm 5ILD7V5NtcxuXC6YpDb35KI9Z72miAAGUfujh1KI5hzn6IQVZLP/6kKOSaDUuTufQ8Ku q+1OYE8Cg6APTP1NiSWm7QBLpXw9UsuF2OAhdSzB2PChvOsgj7ZoUWNOcF4i8/Nlqo2k 4O1C3AV8COhnBUUJ7YqqIWrgXPcexM0yzg0bdV03LGdXCG1g+DB8aKT153Xkp0dZ7AtK Zo3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683144532; x=1685736532; 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=uaEl0+ttAfDVYkQkgOF9inVIlQxPo4MAHa3r5TcHPqs=; b=SNfWi7xyaDOidAGBuemo4AcO8qz0NP35Fi/f35i1y0NvJJIH6SdWMpOkhZgJBXFiYM bV4bPafSGCdIl5iM1DqnETQT9TWdVhq7XFTNggCFENkcweYxWAwJqVOZbMdt8kZpY9Ab lNTjAM/EcdPijkUTG0rziRnaNB+X71zCmMzE65vdQtrpepbyL8PyGEAc4ctEL+hPiFiQ ZzZRcR08IF/xCG4acCoYwqnn1azsi63mJ8y47Gau6aTB8tkUacEv97H2vHC5N43rqIA0 OAsZNtbGi62cCs9/ud89fMpaO4bIjakmTxeqkMcKB34z8DIJCv1TmQF2OrnhQUU//vyX Jpeg== X-Gm-Message-State: AC+VfDyIstp62zWiCiTSImGJznobCf8bE5C5WMP2/XuED83dZ2ja4PP3 SWsYsRVxvW/TvL/G11mT7JyfrCCcRR2/+0qA8Ie0Tg== X-Received: by 2002:a25:3450:0:b0:b9d:9f6e:f1d5 with SMTP id b77-20020a253450000000b00b9d9f6ef1d5mr3049024yba.16.1683144532379; Wed, 03 May 2023 13:08:52 -0700 (PDT) MIME-Version: 1.0 References: <20230503180726.GA196054@cmpxchg.org> In-Reply-To: From: Suren Baghdasaryan Date: Wed, 3 May 2023 13:08:40 -0700 Message-ID: Subject: Re: [PATCH 00/40] Memory allocation profiling To: Tejun Heo Cc: Kent Overstreet , Johannes Weiner , Michal Hocko , akpm@linux-foundation.org, vbabka@suse.cz, 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, 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, Alexei Starovoitov , Andrii Nakryiko 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 Wed, May 3, 2023 at 12:49=E2=80=AFPM Tejun Heo wrote: > > Hello, > > On Wed, May 03, 2023 at 12:41:08PM -0700, Suren Baghdasaryan wrote: > > On Wed, May 3, 2023 at 12:09=E2=80=AFPM Tejun Heo wrote= : > > > > > > On Wed, May 03, 2023 at 08:58:51AM -1000, Tejun Heo wrote: > > > > On Wed, May 03, 2023 at 02:56:44PM -0400, Kent Overstreet wrote: > > > > > On Wed, May 03, 2023 at 08:40:07AM -1000, Tejun Heo wrote: > > > > > > > Yeah, easy / default visibility argument does make sense to m= e. > > > > > > > > > > > > So, a bit of addition here. If this is the thrust, the debugfs = part seems > > > > > > rather redundant, right? That's trivially obtainable with traci= ng / bpf and > > > > > > in a more flexible and performant manner. Also, are we happy wi= th recording > > > > > > just single depth for persistent tracking? > > > > IIUC, by single depth you mean no call stack capturing? > > Yes. > > > If so, that's the idea behind the context capture feature so that we > > can enable it on specific allocations only after we determine there is > > something interesting there. So, with low-cost persistent tracking we > > can determine the suspects and then pay some more to investigate those > > suspects in more detail. > > Yeah, I was wondering whether it'd be useful to have that configurable so > that it'd be possible for a user to say "I'm okay with the cost, please > track more context per allocation". I assume by "more context per allocation" you mean for a specific allocation, not for all allocations. So, in a sense you are asking if the context capture feature can be dropped from this series and implemented using some other means. Is that right? > Given that tracking the immediate caller > is already a huge improvement and narrowing it down from there using > existing tools shouldn't be that difficult, I don't think this is a block= er > in any way. It just bothers me a bit that the code is structured so that > source line is the main abstraction. > > > > > > Not sure what you're envisioning? > > > > > > > > > > I'd consider the debugfs interface pretty integral; it's much mor= e > > > > > discoverable for users, and it's hardly any code out of the whole > > > > > patchset. > > > > > > > > You can do the same thing with a bpftrace one liner tho. That's rat= her > > > > difficult to beat. > > > > debugfs seemed like a natural choice for such information. If another > > interface is more appropriate I'm happy to explore that. > > > > > > > > Ah, shit, I'm an idiot. Sorry. I thought allocations was under /proc = and > > > allocations.ctx under debugfs. I meant allocations.ctx is redundant. > > > > Do you mean that we could display allocation context in > > debugfs/allocations file (for the allocations which we explicitly > > enabled context capturing)? > > Sorry about the fumbled communication. Here's what I mean: > > * Improving memory allocation visibility makes sense to me. To me, a more > natural place for that feels like /proc/allocations next to other memor= y > info files rather than under debugfs. TBH I would love that if this approach is acceptable. > > * The default visibility provided by "allocations" provides something whi= ch > is more difficult or at least cumbersome to obtain using existing traci= ng > tools. However, what's provided by "allocations.ctx" can be trivially > obtained using kprobe and BPF and seems redundant. Hmm. That might be a good way forward. Since context capture has already high performance overhead, maybe choosing not the most performant but more generic solution is the right answer here. I'll need to think about it some more but thanks for the idea! > > Thanks. > > -- > tejun