From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7B23C48BC3 for ; Wed, 14 Feb 2024 19:24:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 397866B00A0; Wed, 14 Feb 2024 14:24:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 348816B00A1; Wed, 14 Feb 2024 14:24:38 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1C2276B00A2; Wed, 14 Feb 2024 14:24:38 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 0859E6B00A0 for ; Wed, 14 Feb 2024 14:24:38 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id D3E7D120DE4 for ; Wed, 14 Feb 2024 19:24:37 +0000 (UTC) X-FDA: 81791386194.05.5ECF7B1 Received: from mail-yb1-f170.google.com (mail-yb1-f170.google.com [209.85.219.170]) by imf18.hostedemail.com (Postfix) with ESMTP id 42DBB1C0008 for ; Wed, 14 Feb 2024 19:24:35 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="AJfoVT/w"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf18.hostedemail.com: domain of surenb@google.com designates 209.85.219.170 as permitted sender) smtp.mailfrom=surenb@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707938676; h=from:from:sender:reply-to:subject:subject: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:dkim-signature; bh=QCBYE/AD/BvL6op5scnwP5wjSjqsrmapht1Ra223I1c=; b=3COHQcf5sHIeTqJGcGzB2rgEIOK+fuhUFDgnAFYT52zNvfhgEf73YMKs5l00VVkBF6bvll DQJCixABimG/Wepsqyod1MTRt9HRLYeD69Rgn/3Xo4tzEiNEFp6660cqzOAY+7D2HENPPG 3Q2m9BTZE3EHLrONlH6bpMwTM6yxBqw= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="AJfoVT/w"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf18.hostedemail.com: domain of surenb@google.com designates 209.85.219.170 as permitted sender) smtp.mailfrom=surenb@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707938676; a=rsa-sha256; cv=none; b=uud52mqKgcKlUHL5X9lu64wmuhexLUleWvvjomW/RKC3Ltn/LWFDi4/aaNeqyw7DyJpaae O99375qwux9sQ0sQFWqk9p/crLWobnucl0xn9vdBdpWXVcc13VdxOgoyseVuBTyzfGS3y0 /XunRWPIjSYajdvQuzRxlneONQs2758= Received: by mail-yb1-f170.google.com with SMTP id 3f1490d57ef6-dcc86086c9fso6271276.3 for ; Wed, 14 Feb 2024 11:24:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707938675; x=1708543475; darn=kvack.org; 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=QCBYE/AD/BvL6op5scnwP5wjSjqsrmapht1Ra223I1c=; b=AJfoVT/wzkaigbhVsI7C1eg0LRJBhIWhZVmsQtgtqxMsCrGbB6x9di57vSp2rApi3z NU0tNtavx37ugemcX0cpE5fnCHDckccxO1w7ehdm9gPFnDbe+kv07dnwD4G6LJCfshb/ baMDeoBnlePdX3nwnEQu3kw79lJiog4dtl5FlrgTt0/NLL1nF0yHOCIyxdLPj5kbyg7q c6k5U8FsHdJOR6N5I9xBdbGme3mhWj1jAf1Zr4wDZ15GWMrRk1TJ/DAfhaCICdVIeOhZ NQs5asfg+2+tuaSZaEYKAbWqM3pwAy0WQW8mtS02ApFSOyp98UeJGIQgc9mZ88sQ5SAV 8Gdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707938675; x=1708543475; 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=QCBYE/AD/BvL6op5scnwP5wjSjqsrmapht1Ra223I1c=; b=GfQEdrjfhEeQ1E5dM08CS/PkHRV+NK/nuqv9p4xuA2TFr4gs4B4nHUrQhtsd3K7Bez bKGQSKecUFrUOnEhzsq4b/1XW52FeYVurrFkAxNyyWnJ8q/rO9/QnFP7h+GnMw4TCDHS Sz+O9Id4HieHgyHVYKZ8VKbF5jLEhtu9Ja26AkLQH9os3ngKvWSkkksi+l1GTIJOiHqz +O6g6UIwqYWyNLWto8HhsMwZY4Fj5VZmi6JfVT4W07nbnQjDcB7T5dYL8Dgv7B6pku+i dixa6YLkPpRxaSGhmdGQH7GYBGfpC/vJZobL3KQuFnzph3UM0Srwe/k8aaOjYYrXejhn YrKg== X-Forwarded-Encrypted: i=1; AJvYcCVdwpItM5FyFZdsZvwfwca1R0TAy6RT1vAZOQ+ftVNmHR6F6UR6HjJ+RBtoWIdrGWRBZUDdRoJZKJ5h8KI9KSgTuHU= X-Gm-Message-State: AOJu0YxjGAVSCGZm4DgMzXy4BwXgLSzFVN9uYDOfRgqj+zPuteNTXwDP aoUJ0smCvf9/iAXlrz1MNWUwT6RbxC8Gn1n1mzC02C689ZCl66/LE+6eKl12ZVFn5nIuMqMzdBV ++UlSpMqU6Z3aGFLTj2//ZHysNFDl8kXzi2qV X-Google-Smtp-Source: AGHT+IEHeftxzGg3B5Z0Zkp/sdZtFFtkyDYYBmhmOt9OEJce/O9D422LSeKSHbRCNIcYUksKiHgnsjkqT91cBPG3844= X-Received: by 2002:a05:6902:143:b0:dcb:cdce:3902 with SMTP id p3-20020a056902014300b00dcbcdce3902mr3406955ybh.55.1707938674882; Wed, 14 Feb 2024 11:24:34 -0800 (PST) MIME-Version: 1.0 References: <9e14adec-2842-458d-8a58-af6a2d18d823@redhat.com> <2hphuyx2dnqsj3hnzyifp5yqn2hpgfjuhfu635dzgofr5mst27@4a5dixtcuxyi> <6a0f5d8b-9c67-43f6-b25e-2240171265be@redhat.com> <20240214085548.d3608627739269459480d86e@linux-foundation.org> <7c3walgmzmcygchqaylcz2un5dandlnzdqcohyooryurx6utxr@66adcw7f26c3> In-Reply-To: <7c3walgmzmcygchqaylcz2un5dandlnzdqcohyooryurx6utxr@66adcw7f26c3> From: Suren Baghdasaryan Date: Wed, 14 Feb 2024 11:24:23 -0800 Message-ID: Subject: Re: [PATCH v3 00/35] Memory allocation profiling To: Kent Overstreet Cc: Andrew Morton , David Hildenbrand , Michal Hocko , 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, 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, 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, vvvvvv@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-Rspam-User: X-Stat-Signature: 9kxouyz49t4c5s5tmqzuikb4k3qr7mt5 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 42DBB1C0008 X-HE-Tag: 1707938675-217201 X-HE-Meta: U2FsdGVkX18rMin/pSgClVHCZq3xKZH+0pEhS72sW4D7p/RWhk1RGUJ7UgiHWBidDVsrpUprrzOQIqgdeI1wtYe6QrlI4R6CM21jhMkZhRng8cn5VqwcJZ4F2di4jwPmAAS4yWeG+Z5+siTHlzvVOxUyvrv/j9qWQajyrls0dXFGk6j27j/FUQEZ8lSja8wT5zVjmOlj77qnHfPD+Euva7VL61hdtlLxxWgCeTAJ7W1KoSSSVRuks12sLnVnJ7z9nQmVEjHXS07v3B6xR3xZnEPq1Ck/TmakGVbW4WaaeeAaXa5oNkrv4iSf020kn2oDimRVKaEZh8MFGI90Apd1VZDh8c46bVOZi+YgJvGbIQv2VqECNyuYdS4ZapAYn4Kiszc9kJD5MJLI4wNtc2mdR6G9SC1ZddSJa3tUXNUTkZJLcEJAJV/7RiF50s4Rhbjf8e2pxdjOMyuvYKKrQ3oShENYEu03Oi3OajGZcnRfuG64GmkHoq9gWfJh9g6WWwAoBplj4DT6KV2TXARXgogzhHTTOk0LD8eu49/Mr7KE321ZVpG46wDEkRqmUeanmBpMnJVUjM7zkDANZgVOqO3ftoJx+l0xaXrDrxxPP+MEcIry7rdJczvKoo+WDzr34ClQ116w19vmBOaVULIEKeAhWDYtbIziIOvabDZwc6I3WMDT/B+yj2jL4xjGkdHlIetmzVR399ANN6HT3XRePFXEKRYDfo8WU96D5AuHTSRevOkzFfx5650mXiPml7REdD+7+3KVrY/2bYb7GOzOn0Rw8JvV5vRFIh8JkaxF/vj45sCE2GHr/qNkU+GsWa31/hDyAV3UNpjRxYG6Z3CBu6SsNnBtTrB+ZgnbFyrvdMDokvAH4S5aAyCQ/MpyMjYz7yvWhgR18XRgN6GsuAsCx4YmSe5+6BVDVG1kMiIkvxMJJF06t8Z1JoSxRlylMSrCEoSdQg04mK72OppBZLmdXQP RuJvKS8t zD7sPDIYoxyED3ZUGrlPXKqLZ6PVVopA77TXVp25QYguKHq/g8vVBABykDmUh8GHhMKix X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Wed, Feb 14, 2024 at 9:52=E2=80=AFAM Kent Overstreet wrote: > > On Wed, Feb 14, 2024 at 08:55:48AM -0800, Andrew Morton wrote: > > On Tue, 13 Feb 2024 14:59:11 -0800 Suren Baghdasaryan wrote: > > > > > > > If you think you can easily achieve what Michal requested without= all that, > > > > > good. > > > > > > > > He requested something? > > > > > > Yes, a cleaner instrumentation. Unfortunately the cleanest one is not > > > possible until the compiler feature is developed and deployed. And it > > > still would require changes to the headers, so don't think it's worth > > > delaying the feature for years. > > > > Can we please be told much more about this compiler feature? > > Description of what it is, what it does, how it will affect this kernel > > feature, etc. > > > > Who is developing it and when can we expect it to become available? > > > > Will we be able to migrate to it without back-compatibility concerns? > > (I think "you need quite recent gcc for memory profiling" is > > reasonable). > > > > > > > > Because: if the maintainability issues which Michel describes will be > > significantly addressed with the gcc support then we're kinda reviewing > > the wrong patchset. Yes, it may be a maintenance burden initially, but > > at some (yet to be revealed) time in the future, this will be addressed > > with the gcc support? > > Even if we had compiler magic, after considering it more I don't think > the patchset would be improved by it - I would still prefer to stick > with the macro approach. > > There's also a lot of unresolved questions about whether the compiler > approach would even end being what we need; we need macro expansion to > happen in the caller of the allocation function For the record, that's what this attribute will be doing. So it should cover our usecase. > , and that's another > level of hooking that I don't think the compiler people are even > considering yet, since cpp runs before the main part of the compiler; if > C macros worked and were implemented more like Rust macros I'm sure it > could be done - in fact, I think this could all be done in Rust > _without_ any new compiler support - but in C, this is a lot to ask. > > Let's look at the instrumentation again. There's two steps: > > - Renaming the original function to _noprof > - Adding a hooked version of the original function. > > We need to do the renaming regardless of what approach we take in order > to correctly handle allocations that happen inside the context of an > existing alloc tag hook but should not be accounted to the outer > context; we do that by selecting the alloc_foo() or alloc_foo_noprof() > version as appropriate. > > It's important to get this right; consider slab object extension > vectors or the slab allocator allocating pages from the page allocator. > > Second step, adding a hooked version of the original function. We do > that with > > #define alloc_foo(...) alloc_hooks(alloc_foo_noprof(__VA_ARGS__)) > > That's pretty clean, if you ask me. The only way to make it more succint > be if it were possible for a C macro to define a new macro, then it > could be just > > alloc_fn(alloc_foo); > > But honestly, the former is probably preferable anyways from a ctags/csco= pe POV.