Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2042834rbb; Tue, 27 Feb 2024 08:56:03 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX+pNNFD/gFz9oEsclM7IveyUdA/jFOE/UqRIKpreRoqKq6MCrMqVRF1IYfel9Dopz/lLXdQ02K1gaiQ73dYDUYKC7MzDRDLi16lTM5dA== X-Google-Smtp-Source: AGHT+IF6ezJ2gYg0BIIohfaL3MF+6UoXYUjmkbqVci4JbMpvjln97XbkIagZSd+Ds1P3N0ScTgp3 X-Received: by 2002:a5b:48b:0:b0:dc7:4790:1b70 with SMTP id n11-20020a5b048b000000b00dc747901b70mr3498ybp.54.1709052962862; Tue, 27 Feb 2024 08:56:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709052962; cv=pass; d=google.com; s=arc-20160816; b=aba0RP6qdjmxaY3ZLjvArqMIHSM7vbqQUo8W64bBKVCKMQ6r5Qx1EXibdYDut6dk8t fxFzncuHBvYcFsIEhzQVNmL6oInbr7yE4Ae3LdHSI9MfzGw+0BdakuVfqY/UGeePl0sh lEGyx4n+vtOKWz+XkLkUqI1bHjFzBBS2PqH66MBtALWt5siZX3Zrhk+LhL/sxNGAL4UK HRbu2VUj8oxtOCtGe0PKllJf17bIyILVZ/upZGIhbP0ogVL8SSfsTAhWu8iuT9f2awym 5YQjofnYCFO483qXsAhgxlnTUdWpr4YOXGAP+5lPV5uxREf/MmT41GGAXc1DT1n86Ba6 SjiQ== 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=WING8+ifDIdPqWo/GgNARqwiCxM6QeK8N+15oiAYs8U=; fh=k6sgNp7YYJTcvvWNwhYdWwMcLsAdroxn78aY3e2+Hy8=; b=gKIChfQWoFL87whanlHoEbGC51v12x8riKbgoow5I/i9XqYyjj6dBksByqzY+i3XsJ hxXjCErKbD8NRIwx0p8Loxd58T5MfoNBZvhIc2koMktRHp+Oknj8zJ7oxQXFxY91bSXa 1ReH1QGPMVl9tvSMhvA7Xkh5bzTNzsT1QFa3d2r7zkbptNUFIq1EKUV6gYkLioi1SMyU 8dVVgM26KpLlm/tmtKkYdg0gIB82XZBwm2gm6tAxdUOED931bq2yWFO/nawxxt0HiMvy oCVUuHcfuQN3ZgyP4pSA3sWDk8TlIO2UOk2JhYPORkyOsEQM0XK9CaVMdUR1+pBAtVul lwaQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=0bqFZOxi; 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-83660-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83660-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d10-20020ac85d8a000000b0042e74a36807si8228816qtx.555.2024.02.27.08.56.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 08:56:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-83660-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=0bqFZOxi; 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-83660-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83660-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 87FD71C230FC for ; Tue, 27 Feb 2024 16:56:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 703C0208B0; Tue, 27 Feb 2024 16:55:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="0bqFZOxi" Received: from mail-yw1-f170.google.com (mail-yw1-f170.google.com [209.85.128.170]) (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 568B1208CE for ; Tue, 27 Feb 2024 16:55:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709052947; cv=none; b=qM6mXRzKKm1fa4HPRdLadDVrAwONHqneXJ8jTpu3EmJr1nui4gPdgKgGsmo+Z25AOpOv7vVRmIT5yjtyWVqsK4+QLlvwRe060lPqmohPgWXZiwjZmz3PoE6ahQpmVIdJ3sBrorc/+VgFP7G5CYzfm56q6o7ni8TAvkrbSWfd868= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709052947; c=relaxed/simple; bh=WING8+ifDIdPqWo/GgNARqwiCxM6QeK8N+15oiAYs8U=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=iXL3MCDqrLx1MKpvHUM9EiUqaOl7j+DctrhxFqwgQw5JM7SOwPgOICyfHzdAuNm6OZUUqcDqqJRx7RXTbquHIKsVYn1oTRwnABpDt64Ae1PEB4En0NYzpyE3EUVJ8oQZBFQtIKfqtaTUfhrTGCaH8Vaz1flLl7M3cs92BnGvLP4= 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=0bqFZOxi; arc=none smtp.client-ip=209.85.128.170 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-yw1-f170.google.com with SMTP id 00721157ae682-60925c4235eso9423067b3.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=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=WING8+ifDIdPqWo/GgNARqwiCxM6QeK8N+15oiAYs8U=; b=0bqFZOxifsJ5NMk/8m7O9TZYcXJ4ZOagI0CeK7ew9Up7vZXassuRVZgV3R/hAaURqv yipQfkJyTGrMRfSjlRKrdq4rMXzq+EopO8mvVXBysaMoXgk8PNFQW+b8ncZMj9oYX/ug 4KoRGbpZ7K/nMqn/kBhm0MJzWddgZMP/DRsBPrqhGzjEW+JFM4cP38yDFRQZI5+Vhg5s FiESy5ktg21UABE/kurAAaft0GtHZkORBxkm2W74qjQFqXkvTOvIvTBo3qiZg5Z1OXFV pzPo+VVQkodHYXIDfqiADzhsKkEboRV1fWgLjk3rDQ3UyI8O19BWJwc5Ewki5YStBmlf qemQ== 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=gIMTKI9DyIIrFRsYJ6j5YukSi1AV4WnDoMJ+DxpcLILm3QoKDhusIBSxwU8y9db4by 2EnXhfX1VxwOx6yg9/ZxcFFhRHkXI5zi5B0NV8hMvMdijSYi1Wx3s++IDV8BNZVKuwdy Pmmz+SjjWWDqWg+e7uUdm1xBP42eq2AklnaLkM4ZqhzkYSB7djpR8RECc4CqguMZz6HO 16ybrEr5Xj2LVACtWjyIr/i77uco2rBc9jDToYhWGXB7wdMQYPn0vPHegYYDvuEM9Yb1 2JfNqGXEWbgSfqrRVqUZ6OskOQP3Cz/qAgqhEgW+BQwmAL1Wjp6kaOs4HBEIGSxmhK+L AcDQ== X-Forwarded-Encrypted: i=1; AJvYcCXdSt7lv0BcTly3tn1F9cLIAzp5NdIkWmOMS5HlP+Iv0+ALd3w3vBvp37YPF2+MkuCxaas25Bp4UDqizddbESRF0sprosGWXjcAHP14 X-Gm-Message-State: AOJu0YzlBxnRflS4BOZ/CTKt7zKKg1oCnMGXjRjan2lQhUD18Vz6b+hC Cf53q3bL7Zl8ojmB3exPoNZrbx0MSLsyobq5hXIfyk83FJTiS7f4LOUNhjpoNsh3+g9DaQAndFC uoazjnjpFB7rKlTIVP/iv6q2nxt6BMdx1ezKv 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) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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. >