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 36624C54E49 for ; Tue, 27 Feb 2024 16:55:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A92296B00CD; Tue, 27 Feb 2024 11:55:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A19746B00CF; Tue, 27 Feb 2024 11:55:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8BA9A6B00D0; Tue, 27 Feb 2024 11:55:47 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 780B56B00CD for ; Tue, 27 Feb 2024 11:55:47 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 55BDD40AF4 for ; Tue, 27 Feb 2024 16:55:47 +0000 (UTC) X-FDA: 81838185534.02.76F71F1 Received: from mail-yw1-f173.google.com (mail-yw1-f173.google.com [209.85.128.173]) by imf27.hostedemail.com (Postfix) with ESMTP id 644E940017 for ; Tue, 27 Feb 2024 16:55:44 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=p5dWDyae; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf27.hostedemail.com: domain of surenb@google.com designates 209.85.128.173 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=1709052944; 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=WING8+ifDIdPqWo/GgNARqwiCxM6QeK8N+15oiAYs8U=; b=AkyAKrZzhlET0WVqKOG6LLSkaUYcXqR1LIggyMFRKyQzgK23hlyULRAlWY0sCQ1cgT1qWJ oMHplyMyNtiweUaFTrERp0+kWC/ehJo188KHq23xO2fnPOYaXjLDCsQCgVPn5FzeYW1w0E hGn5JZ1/IodEa5XCr6imZRVF1iQveZk= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=p5dWDyae; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf27.hostedemail.com: domain of surenb@google.com designates 209.85.128.173 as permitted sender) smtp.mailfrom=surenb@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709052944; a=rsa-sha256; cv=none; b=ObIvbto+Xb9OMo4iozV17Tn8lsaDdAPBypq4cGaRoCms/fcJicqzVh9/Uzt0o0q6KghMZF usu//6NLh5Fai7Vo9SXOuZ6v41IK4trwnyG1A84cLEeXVbjij02uRWVcUfsptBxAEVwru0 309+6MV2agveqnggMFM21jOCZIUFdHA= Received: by mail-yw1-f173.google.com with SMTP id 00721157ae682-60925c4235eso9423127b3.3 for ; Tue, 27 Feb 2024 08:55:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709052943; x=1709657743; 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=WING8+ifDIdPqWo/GgNARqwiCxM6QeK8N+15oiAYs8U=; b=p5dWDyae12MvSRFWISrUbd8up+iyDOjlQNsXloB6/nGidTIx8B/EK0lTbCM9u/ZrH2 BdawS2QJ5hJjnI56vqwCKCPAwka8EAqIs5om61WVc+CYN9gmbAu1BB9onGHkOLURISA+ QuawNCjb4UfEMQV9JmYvmcdRqx917KvC9b4QaC7+2fS/Pfn7/nNDl+0USOoOseV03xYu fyuiueVkdNP79cgrNqS7LDmsvpuJ4s7Wn/IA14VmJYkeAd9m4gRuS+uFc5FhxAGfSxPG 88jF02F5GGG6VdnoUSixNf1MgMp5rh6RBQ/jeF3IrzC4Fdp1aQ7gBSCR/1Hss9LSqKqF 3khg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709052943; x=1709657743; 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=WING8+ifDIdPqWo/GgNARqwiCxM6QeK8N+15oiAYs8U=; b=jmu0AE7aid6YDPhSx+bNeiyGRiSPc2lTcA4FO35UZmgCUN8hmpUh5Wj7NSri1VT/kq rgoAlq+6fYn3H+mxCEmgiiOZ78xETFIgtNJQjb69CojWoAjlBpEFt56kQMd0H6CaC0ls Qw9fxShR5oHmLzpQheZxa2QXtQ6TZA0wPcg6NXmM9O1nwUBlWRhIm0cvG/8Z1KHFm4DK +B0vk91EGj0m0wzUffd252XHCuHNJWdty2K7D9+LzWqbm9JisooYzHDZ/iYyDqRg5Qg5 KR5Q3eXRkTuwBYx1T3ttitXQe3GiMR66bgD3UYgdyN3AcT6IXGVIQCMeG6snpwhQU2vW ggYQ== X-Forwarded-Encrypted: i=1; AJvYcCWyojOcf6eWu3HRn3pQsPbVsBpSz7mJhvPk1aPpXPyy60jrAEmBBoOb6ewdeMTCtSY3cb8w8i5/dr0AuO+Kt4pyOEA= X-Gm-Message-State: AOJu0YzUY7mQm9kVv2bcbaJTvCE8+nwRBOwgvZNaWgsjKob9qpbkkcGH GROnPKYwJUM0H0XLLnGlzOEr5iFbRnWrOC3GcclOV9vyNE02rZxuxbTXXUOescELpHbkA5xDacZ 1Hb7D/iPBw1yjgKj70sl5S7P301XKGQ+/ivrJ X-Google-Smtp-Source: AGHT+IFx4IMLdqGd5Fz34j1UAm6oDJfltAQpGSG6yeY6HBGKjoGVypF3GR4a4leI/V5eKU8dpRmwS6ivB2dTqeub54A= X-Received: by 2002:a81:e245:0:b0:609:2857:af0 with SMTP id z5-20020a81e245000000b0060928570af0mr1933120ywl.25.1709052942967; Tue, 27 Feb 2024 08:55:42 -0800 (PST) MIME-Version: 1.0 References: <20240221194052.927623-1-surenb@google.com> <20240221194052.927623-16-surenb@google.com> <72cc5f0b-90cc-48a8-a026-412fa1186acd@suse.cz> In-Reply-To: <72cc5f0b-90cc-48a8-a026-412fa1186acd@suse.cz> From: Suren Baghdasaryan Date: Tue, 27 Feb 2024 08:55:32 -0800 Message-ID: Subject: Re: [PATCH v4 15/36] lib: introduce support for page allocation tagging To: Vlastimil Babka Cc: akpm@linux-foundation.org, kent.overstreet@linux.dev, mhocko@suse.com, hannes@cmpxchg.org, roman.gushchin@linux.dev, mgorman@suse.de, dave@stgolabs.net, willy@infradead.org, liam.howlett@oracle.com, penguin-kernel@i-love.sakura.ne.jp, 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, 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, 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-Rspamd-Queue-Id: 644E940017 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: iny37zn9kwowjekue7kwbfca6wc67bwf X-HE-Tag: 1709052944-641059 X-HE-Meta: U2FsdGVkX18bfdgcC3fhFQ5lnq2PjPemkPPTxn0UKykgg2MEK+jEEOsIV8J7+29Ih1COwpmzRD6Vk0nDiOdG5GRdh1xTacSBfsFntu4Qsl6FMn1U5oeubhi5Hu5MP+KQMRbZi8T1UDenJEjZBTdyP1P9NLUA0jCQUSOcrKcGgMJ4DU95EO7yKlir3HOdznej2ZPVadWwUpLvIle+OyP614okbcR8qovcY5cV36T+A8eNm9/w+9XMHLnF7HKIetsId52fDk1VrNktBP4ZP8A92pLDHX3Vo1pNPODdyCeuniZX3POeRrjYu0Sf5myIIiuqaMsM1EOcF4jLDuO8RpSk48AyxEtNpxbCP8tNcQkh9mErWdNSsoXAxhBe/tsHBZHK9RmHjfV/IuoXa702k19ixV7bqcNYwX9SXQ9VFghu3RWFlDzuiAovVF4dbQnIxSgS/dlk7ozc6OoGAd8N2WuTjv9dmeMRftvLjJ4y5ruYujpG80tVQi14fJ7uwFg7AhdS5a4rmdt2g8+hdaJY09zkNv4HPjwoutHUYaP19DuUrzU4SPB3v0z/brxh5gDlMREwS/o1WmiurmD5EJxCk/MEsrpQDpzisj2evz5c2CEzsanSn7TmDMeqJXsPN6sxRTJ0YvTeez4VK6Hnuou1hIQ8SSgy44W2UI8FAhSN5JP5+LXrPyN79O3s7H7nADeE6xP2ujfuxKvirmZxnQhd0J6dKL/qnFsaGNvVuTEQpV87FwjlXq0pn+2kDTXk57TAEmEIwERfyP0q5JCgfLS70Db1ZNKnybwFJUibaENh1/8ONecxNwIR1fSEA4+7oMOn0Jzauee/bL3klcSx5O5Tk37KSn/8I51Z+KQG3AG9TwSaMtLsIhJoq/C2CcchK4v8GQdCxyxJ8y6UdHfLAHwlSrxJmnSgRCSClBTCj07rqFLDL+wzeTwCnMYUcuKb2qL3rDhIkTh90JCi7o9lS/obbnn XBfeF9e1 6c/KcOtvjc4epHhHwhW7X1dp7TxJX4rWGyslK2/IAVTg6e+QIXUn6O8KecNSqftmkjSaYZSiMt5hnMnwbzQnVqhmP+3ouhuKuG7lv0Op3/1B/3dsK336ntkDMAp5rz7v0NZ0padssiePL1qpXKr/4ayw2R9SJJXPxtl/Vjkl5N3n8vySUlPg5G4Su6Vz7xv7rG6gum8WPE+WLWac5ldW0YhGt/UnMY7W9c4JfVwPvbhZ/4tH8fPbPnAfod64Vj+YrlPSsrUyROStYE+HRhqSqdUS7oTRFbWk9LTy0XtHe+umqhbWVvAbDaoeQCLEnJZaytZ7QU2CdHTA/aEhlII2KDXKfcuyqVJnGals/e5QsorZbo8cWeKQ4zqldk2p1nGwifD/s46LbFHe1NGU= 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 Tue, Feb 27, 2024 at 1:30=E2=80=AFAM Vlastimil Babka wr= ote: > > > > On 2/26/24 18:11, Suren Baghdasaryan wrote: > > On Mon, Feb 26, 2024 at 9:07=E2=80=AFAM Vlastimil Babka wrote: > >> > >> On 2/21/24 20:40, Suren Baghdasaryan wrote: > >>> Introduce helper functions to easily instrument page allocators by > >>> storing a pointer to the allocation tag associated with the code that > >>> allocated the page in a page_ext field. > >>> > >>> Signed-off-by: Suren Baghdasaryan > >>> Co-developed-by: Kent Overstreet > >>> Signed-off-by: Kent Overstreet > >> > >> The static key usage seems fine now. Even if the page_ext overhead is = still > >> always paid when compiled in, you mention in the cover letter there's = a plan > >> for boot-time toggle later, so > > > > Yes, I already have a simple patch for that to be included in the next > > revision: https://github.com/torvalds/linux/commit/7ca367e80232345f471b= 77b3ea71cf82faf50954 > > This opt-out logic would require a distro kernel with allocation > profiling compiled-in to ship together with something that modifies > kernel command line to disable it by default, so it's not very > practical. Could the CONFIG_MEM_ALLOC_PROFILING_ENABLED_BY_DEFAULT be > turned into having 3 possible choices, where one of them would > initialize mem_profiling_enabled to false? I was thinking about a similar approach of having the early boot parameter to be a tri-state with "0 | 1 | Never". The default option would be "Never" if CONFIG_MEM_ALLOC_PROFILING_ENABLED_BY_DEFAULT=3Dn and "1" if CONFIG_MEM_ALLOC_PROFILING_ENABLED_BY_DEFAULT=3Dy. Would that solve the problem for distributions? > > Or, taking a step back, is it going to be a common usecase to pay the > memory overhead unconditionally, but only enable the profiling later > during runtime? I think that would be the option one would use in the early deployments, to be able to enable the feature on specific devices without a reboot. Pasha brought up also an option when we disable the feature initially (via early boot option) but can enable it and reboot the system that will come up with enabled option. As Kent mentioned, he has been working on a pointer compression mechanism to cut the overhead of each codtag reference from one pointer (8 bytes) to 2 bytes index. I'm yet to check the performance but if that works and we can fit this index into page flags, that would completely eliminate dependency on page_ext and this memory overhead will be gone. This mechanism is not mature enough and I don't want to include these optimizations into the initial patchset, that's why it's not included in this patchset. > Also what happens if someone would enable and disable it > multiple times during one boot? Would the statistics get all skewed > because some frees would be not accounted while it's disabled? Yes and this was discussed during last LSFMM when the runtime control was brought up for the first time. That loss of accounting while the feature is disabled seems to be expected and acceptable. One could snapshot the state before re-enabling the feature and then compare later results with the initial snapshot to figure out the allocation growth. > > >> > >> Reviewed-by: Vlastimil Babka > > > > Thanks! > > > >> > >> > > -- > To unsubscribe from this group and stop receiving emails from it, send an= email to kernel-team+unsubscribe@android.com. >