Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp453269pxb; Wed, 6 Oct 2021 08:25:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzl+aJsi7WCNMpsJa7uw1YfUDGccKs7qLoXA6402QFWCHCeYe3ehUsy/n5S7R0oTVfGRN4L X-Received: by 2002:a50:fc06:: with SMTP id i6mr18969081edr.370.1633533919137; Wed, 06 Oct 2021 08:25:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633533919; cv=none; d=google.com; s=arc-20160816; b=MD5Bhzf+EiwxA5QueoJXtS7JqIzRXEBEwWiQauPKOaF5zhU6VXAlmbeImQzI06T2oV nDBzb93C7fXBN8ogtMcPIKFAHiG7ItJWKYasSo2uLidoEOv8H1Mq1rF1B7QH3vRJSJVW 0m2lZz37mofj5nNyeLMb1MtyF2GHt4ovYzxHlOdgiblr0age8TmzfFXt+YJu0ZRhVaWf Mgrn1Yq/kyP/xxdsJ+QF3iTzB3EKZtY9cTFmNr129z7XYh5Ehkr+dmQas8ElvSHws10x S2ZDw/hY2iiyTExdiDvrr3AMMipgHZ+wS02ZV9OBgc1vUNvBKgsui18XJYruwmAYOKfT kraw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=ToWLSh1nym/rn5R/pSIAH+olMraiA1xkOFeogqJaaLs=; b=fCUiPpvKR3IOTYPgnRxV7KxBnI/fPRRf5jiYOgEgAzEQDnnykqrT5cYGMYhefuQcfq tCqmdcAFR03R4qIa/AYZfWXks7LPWk8jxNd5pvKekJwfmzTnsHh9OMKXr2csT9igNQyP Kd2D6VIiJ1yX4ts4qbWyMKmbG/Zfw7rkmOBRhfHOJSlCbiprPIn74qtxmQqiF/GHmaYZ XrVXykD2f6aNzr07CZ8UN34u+u6Vaa72H8TwpAxXXBHcDwOCA1AmqyCw8Z0fxZDTbQC7 3iL7ZisRmg6pOGfhNo7LubQXNDRtdMyJvp3veLeglvmWpZf5l3jPQLJ0RPvM/1SzM5hX LyJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=f9kn9JCx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d23si8544014edv.287.2021.10.06.08.24.54; Wed, 06 Oct 2021 08:25:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=f9kn9JCx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S238994AbhJFPWZ (ORCPT + 99 others); Wed, 6 Oct 2021 11:22:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238923AbhJFPWY (ORCPT ); Wed, 6 Oct 2021 11:22:24 -0400 Received: from mail-yb1-xb34.google.com (mail-yb1-xb34.google.com [IPv6:2607:f8b0:4864:20::b34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72689C061753 for ; Wed, 6 Oct 2021 08:20:32 -0700 (PDT) Received: by mail-yb1-xb34.google.com with SMTP id u32so6197682ybd.9 for ; Wed, 06 Oct 2021 08:20:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ToWLSh1nym/rn5R/pSIAH+olMraiA1xkOFeogqJaaLs=; b=f9kn9JCx2oUBAwY8E2iW/mbf7AvxnjIXVRaac9UV50eeIWLqUTCWu0BV3L74owunwZ T8+Ksi5PO1UrZo7J2XqHRGiNW3/QgmcjUvcNnegrQMOjspJwLlWRfGdXHYBbE3rWHFYT S5HR7U+eS+bLsWztsK+kURy3vTEiXFEwh+pGSta6oNHQNPLwhb44AARlY/BokOnZ8PT3 fRkA+WKzmNJyGLRRzch90e6kNwJ0x5Tb1XAfePiZXDH+a5NenIaapda/NDaFLES+s62d 5T0tvNJCfu0HEP2gi7mvJw5gLrUCYZCyQ+xFv77F6JuWgCYj94+gOqouoXSP/PgcHZFX 3xtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ToWLSh1nym/rn5R/pSIAH+olMraiA1xkOFeogqJaaLs=; b=MkvfTe/VHA20WyqQOdqPxrWdPKiGPRDhdV5avvoCQqbuxbmNpecK2IXuc1k785k2iN 1cslXBly531yvrz3z5CTUga0QvXic3a9O5f1Rs4sCZs7MMpWg3kDdG2kjbGXTx24ttx8 w43WJ1KH6C1c5DBnctcWwWB6vFzpIPmb3hTW69+4Jsbs3ffmf4JiHmYdN3lq8ga6IB28 2rkpjSSLB9aK8RIRXYbx7xGS/m475Kwnv23XNm1TaLl38tjNQYJXKRFdnzv6AKlcoJ4y MSHuS9w8v3iFPquZWcSp/L1RMJG/t04urGfESJ8mBWE/KPXDQMYjtQGkleJQWwkecA9P 90KA== X-Gm-Message-State: AOAM532bd09W8pvOKcTd02VX8k0+bvbswj5I0ypE04WUR2TIv0LNfNtZ hBIrOR0ix7QLmpV2Hn8WWcBJauXLo2akZyZbe3nQEQ== X-Received: by 2002:a25:3:: with SMTP id 3mr29846057yba.418.1633533631382; Wed, 06 Oct 2021 08:20:31 -0700 (PDT) MIME-Version: 1.0 References: <20211001205657.815551-1-surenb@google.com> <20211001205657.815551-3-surenb@google.com> <20211005184211.GA19804@duo.ucw.cz> <20211005200411.GB19804@duo.ucw.cz> <6b15c682-72eb-724d-bc43-36ae6b79b91a@redhat.com> <192438ab-a095-d441-6843-432fbbb8e38a@redhat.com> In-Reply-To: <192438ab-a095-d441-6843-432fbbb8e38a@redhat.com> From: Suren Baghdasaryan Date: Wed, 6 Oct 2021 08:20:20 -0700 Message-ID: Subject: Re: [PATCH v10 3/3] mm: add anonymous vma name refcounting To: David Hildenbrand Cc: Michal Hocko , John Hubbard , Pavel Machek , Andrew Morton , Colin Cross , Sumit Semwal , Dave Hansen , Kees Cook , Matthew Wilcox , "Kirill A . Shutemov" , Vlastimil Babka , Johannes Weiner , Jonathan Corbet , Al Viro , Randy Dunlap , Kalesh Singh , Peter Xu , rppt@kernel.org, Peter Zijlstra , Catalin Marinas , vincenzo.frascino@arm.com, =?UTF-8?B?Q2hpbndlbiBDaGFuZyAo5by16Yym5paHKQ==?= , Axel Rasmussen , Andrea Arcangeli , Jann Horn , apopple@nvidia.com, Yu Zhao , Will Deacon , fenghua.yu@intel.com, thunder.leizhen@huawei.com, Hugh Dickins , feng.tang@intel.com, Jason Gunthorpe , Roman Gushchin , Thomas Gleixner , krisman@collabora.com, chris.hyser@oracle.com, Peter Collingbourne , "Eric W. Biederman" , Jens Axboe , legion@kernel.org, Rolf Eike Beer , Cyrill Gorcunov , Muchun Song , Viresh Kumar , Thomas Cedeno , sashal@kernel.org, cxfcosmos@gmail.com, Rasmus Villemoes , LKML , linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm , kernel-team Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 6, 2021 at 8:08 AM David Hildenbrand wrote: > > On 06.10.21 17:01, Suren Baghdasaryan wrote: > > On Wed, Oct 6, 2021 at 2:27 AM David Hildenbrand wrote: > >> > >> On 06.10.21 10:27, Michal Hocko wrote: > >>> On Tue 05-10-21 23:57:36, John Hubbard wrote: > >>> [...] > >>>> 1) Yes, just leave the strings in the kernel, that's simple and > >>>> it works, and the alternatives don't really help your case nearly > >>>> enough. > >>> > >>> I do not have a strong opinion. Strings are easier to use but they > >>> are more involved and the necessity of kref approach just underlines > >>> that. There are going to be new allocations and that always can lead > >>> to surprising side effects. These are small (80B at maximum) so the > >>> overall footpring shouldn't all that large by default but it can grow > >>> quite large with a very high max_map_count. There are workloads which > >>> really require the default to be set high (e.g. heavy mremap users). So > >>> if anything all those should be __GFP_ACCOUNT and memcg accounted. > >>> > >>> I do agree that numbers are just much more simpler from accounting, > >>> performance and implementation POV. > >> > >> +1 > >> > >> I can understand that having a string can be quite beneficial e.g., when > >> dumping mmaps. If only user space knows the id <-> string mapping, that > >> can be quite tricky. > >> > >> However, I also do wonder if there would be a way to standardize/reserve > >> ids, such that a given id always corresponds to a specific user. If we > >> use an uint64_t for an id, there would be plenty room to reserve ids ... > >> > >> I'd really prefer if we can avoid using strings and instead using ids. > > > > I wish it was that simple and for some names like [anon:.bss] or > > [anon:dalvik-zygote space] reserving a unique id would work, however > > some names like [anon:dalvik-/system/framework/boot-core-icu4j.art] > > are generated dynamically at runtime and include package name. > > Valuable information Yeah, I should have described it clearer the first time around. > > > Packages are constantly evolving, new ones are developed, names can > > change, etc. So assigning a unique id for these names is not really > > feasible. > > So, you'd actually want to generate/reserve an id for a given string at > runtime, assign that id to the VMA, and have a way to match id <-> > string somehow? If we go with ids then yes, that is what we would have to do. > That reservation service could be inside the kernel or even (better?) in > user space. The service could for example de-duplicates strings. Yes but it would require an IPC call to that service potentially on every mmap() when we want to name a mapped vma. This would be prohibitive. Even on consumption side, instead of just dumping /proc/$pid/maps we would have to parse the file and convert all [anon:id] into [anon:name] with each conversion requiring an IPC call (assuming no id->name pair caching on the client side). > My question would be, if we really have to expose these strings to the > kernel, or if an id is sufficient. Sure, it would move complexity to > user space, but keeping complexity out of the kernel is usually a good idea. My worry here is not the additional complexity on the userspace side but the performance hit we would have to endure due to these conversions. > -- > Thanks, > > David / dhildenb >