Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp24846rdb; Wed, 14 Feb 2024 11:27:07 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWv9kWL4L5+//WqqnNV9E8KS8wvRikKhNSybGYj9YBtzUJEGsA7NiqCoLeyDKOC6t33IWzAL0hPFI8q7a8ovlwLF0HIk6lvb4t4hbv3sQ== X-Google-Smtp-Source: AGHT+IH/B7pgExnPzEIJRMKuGLwNtMMDrXnJEtLl6C+pvWsJtTnZQQfrMxxIi7W8Uq1ny2mlAT9Z X-Received: by 2002:a17:902:7c90:b0:1d8:e4b8:95e5 with SMTP id y16-20020a1709027c9000b001d8e4b895e5mr3419750pll.32.1707938827544; Wed, 14 Feb 2024 11:27:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707938827; cv=pass; d=google.com; s=arc-20160816; b=yC+uitSxZZc1UsZ52LPeCYj7guhnbZEKFK70w5FZ28EsnrzQVogHuOs6qw0OVHTSro 4kfIexfSyK8w3dtU6oo4uzIX9cb2NejkICQCPLvJTuryb5z+YmA78jZ8NDmM8dyaVAqr vOFkKq1AlOQpeAPfeYRUpCXKAkIKIbqGl2NY9ahA+H9yJM6+ti5ZBJF2AEqYeP/l5/4E aUSx5FYqUfxRXmGDVsQrAmfiNwuM2fAJE8ZuUqnLIr8hN6GmMNW3MkCSBWTgKrbg93UZ Z3+ZpYqW8WQ7y8iB0/GU+S1Zkf0xiw0EpwHAnYrGPxB9pX6icWwGw0ECG7F1/N85vCud 1mCw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=QCBYE/AD/BvL6op5scnwP5wjSjqsrmapht1Ra223I1c=; fh=MzkLisCifhgq/k6fp0tHJmZXI+Ls6YJYCA+X6TCSPfM=; b=RYLlk4lj2zlEkEYhf/Fkt5ijp2w6H+6lcvCHc6UjT9tkABOZOyKzz4cJT2WexvkC2n AAaOrLD2jnIAXkUawMUreo2z6mBRB9WQ4m1WPjl53R1b/p/U3dR7N/MqW46K1xJMVvH8 K85BxEyec0m6ZEa3maoZSjxE8YT4Zy/rb3NWQsIq9CVin+wulDhfIq7EtLaW0BodQQRa NCJb8cEwUv7trO/8jhESQRT1XdyDS2kHp1+BDtLsxmwuWogGQWiC/IJT7nsnf9HNJw0H yE5twU2rTg8RJtuvBhTY/EYzfKkeyEXJ7fsws06uqhB0chU7EACokXnDGTG66Gwy6hYd MflQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=UwsuHlGc; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-65877-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65877-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=2; AJvYcCVYxueJLuBe8EeQYYezCQQ7et4fXz6s53I6OgDsjFhcpioLb5JqKMEJ8PCpV8wRYBm8T5KxZww9Jbtqy19M/w14qMBVzdqOXpWt1XeOYQ== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id f1-20020a170902684100b001db29e4bbd5si3911685pln.281.2024.02.14.11.27.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 11:27:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-65877-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=UwsuHlGc; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-65877-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65877-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id BD01C281AFB for ; Wed, 14 Feb 2024 19:24:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E161813B7B8; Wed, 14 Feb 2024 19:24:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="UwsuHlGc" Received: from mail-yb1-f171.google.com (mail-yb1-f171.google.com [209.85.219.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4AB2C13A875 for ; Wed, 14 Feb 2024 19:24:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707938678; cv=none; b=leUTMiDi3Dh6cRnU1a12kGIpW03lLSk4W3m8eCeICPlwooaVWShpb0ckTt6pwGaBGKDMezwEMAtNifGcxoIQ1j5FdOyilA+R1Xj1rxrVakW0jY0/ip6+i1LLZwS7knGIxCWJghnWfZFDS5PctZabileA2kfyi122ab0PifOGIaE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707938678; c=relaxed/simple; bh=S0A1kfhRzOuiQ1TlmH8X2A+T0pY8dnMRCMj0SI+jFYY=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=RDyjYoM4gWr4LCA6ljvzLamjCiqth1l6hFef2qsNnMZLbFC0sM3Or2BYPk9jNBAPEC4FmJbtMzMQjzOPrNbDckpOGyQpanv2xWsWmBO0Pcck7JxTdEhCfKPHKeB3rJ1JZD1bV6M/H0Jm+sgEE8XZtypDSN/zRvkZq2aP3RjLANk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=UwsuHlGc; arc=none smtp.client-ip=209.85.219.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-yb1-f171.google.com with SMTP id 3f1490d57ef6-dcbf82cdf05so9032276.2 for ; Wed, 14 Feb 2024 11:24:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707938675; x=1708543475; darn=vger.kernel.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=UwsuHlGcrhXjhdyz7FsaHAoTBX0zVMz5qXtPM2OUj55wrNZvLqHXFw+eWmQICcNqD2 mkRIzvQEt/wyfA87b6KzFPbtednd9Wmn4PYhx1ZSYaIQ3a9tTgY/ASdL/7qnbOlWxf+c DeW0BYZFVxVxzLKtQqgf5JqXwApgR9aXf6eXe00HuM3qIUBz3mMid3IyuF5oqOk9dxEA aWxa6nX0QA3VPyIIH1G820sazWtnbnvG3QIr2VkjFBstjRyavNejipQ18gjPiU6Xq8YY Ow4V+/UvoV9CFC+8Ocfs3i8DP341meEB5WlQU0bq6ogkSqOXE3P/pDdaXHBawmv36DDf zcZQ== 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=gDvnN9qhlwXo0L11sOczYeDlYE+5c+DfC1vOvNtsijJbXUqStq4QMdzTOxnIozOawa Rx0UBKeDEq77enO9iyC6WLqsU3HloX0rnjA/QmQkZYbq0rQb5gInRWJ8p+utZffV38dw MMlHP75GV8bflWnrkBNl/QoSczBjqpIs7RUnSpNI1xWIJCKpQEVjViIZo/D5ETU41ayg 9Av/NPTYMy7vLxECYiY2RBl0kTwHWR3P5wXjU2nlqG3V3/1Ih6GYYjz5kGKArwidNYva fxUY7ECw0XaVHj0svCPuWq4kcjDd9XOWLzjtoZI/olDuhTp5CONZCTg4R1rJBbfnEy1u 4A0A== X-Forwarded-Encrypted: i=1; AJvYcCUZX/y6qmpYPlk+q7084rgogEguVXXPyHO5ky8jWx/huv1fy1gCXYs4j6Ewdn5YDioEJJVYN2waI0SJRud2nOdHyiKXMbBGxin50vw1 X-Gm-Message-State: AOJu0Yxfm2CyUy3cMnATsrd+hFuoUqoRQKP6xCfu/w8F/UdFzcBFSIvD B/POBGsoTSBVrJqA1Refodph6S4r1MGm+KRGo6Pzj4cTXMKAAlTc83fhukdy6vbO2NMYKWj3RDX +rsd9HnTXyXbJJkGqKEpNqr8kjCqrbzjgUtQr 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) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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.