Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp1724411pxb; Thu, 7 Oct 2021 13:48:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzugeTCvTl65D8yo3Ie0EETMbr6hT96o8kS419DIDhpxEuIyY/XUiU6k9sDLDSUq59iywkU X-Received: by 2002:a17:907:75f5:: with SMTP id jz21mr8521188ejc.345.1633639734234; Thu, 07 Oct 2021 13:48:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633639734; cv=none; d=google.com; s=arc-20160816; b=NqkvxPMzbrA2ZL/NKuXSrrUkU01a+4RVbpMxjxWKYmHJvjUZ+YMjS3HHyV8bpotoA0 hhnusLmMjECZOY28htFUXaXVPdFIjv8QlObJUa/daBUs+Bf0ITzCsc42K2/InjiY5a8Y RB4bnKAqYFJAlwEnBNPLd0bjFbr2xRPOgskH5IPF4XQ/C6jEjY7j3iWStffvZbirNT+E l9mz6AOmolAnxwPMToSp9nlqeWY4ras1SFrgrichYFLohsN8A9Nqh50lbebBigaaZu7Z Nb0T5LiUK0ZmCuuas19yMUYyp4TQZB2Uh0c47V3kJ4jkHQL/SPYD0Qu8dsIy0eKwslvq 62ug== 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=BMUFD3KuFSgPveAs2xgT5F7+weHss6O3rW280Ex8iiE=; b=BpI63FzuPPlYZ8JJlQnxGMlPGFhHgxL7laUhYvKe/3S6ErbXrOqVA98pqy0ANTRFy/ f2OJijdzWpBy03espkgj6QVHw9AnaOMz/7D/8Bdjcaw7kHecw7kkTKyDhQhppyf/Fnn0 vI3v9a1wvCF2EshaSQTZ2o9E60+9+frvklAsjuhyPUH37Ym5bfm+GwsxT1CXGRruUHju /gVdoYRrLKJAk4bJL8/2Z7MiEXsaYNIVNMijPjzMfjmHQAQsDpl0ArvYOHIM3Ir7of/h WHm1OAoNb61TTAovN5dUJRBXVtGdHurojs+VjhSp5ytxug5Pankn4Pz+Lci0+IqV6j72 Xbjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=lSQNJhkP; 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 ja7si462890ejc.324.2021.10.07.13.48.30; Thu, 07 Oct 2021 13:48:54 -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=lSQNJhkP; 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 S242734AbhJGQpV (ORCPT + 99 others); Thu, 7 Oct 2021 12:45:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242755AbhJGQpU (ORCPT ); Thu, 7 Oct 2021 12:45:20 -0400 Received: from mail-yb1-xb2a.google.com (mail-yb1-xb2a.google.com [IPv6:2607:f8b0:4864:20::b2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE2ECC061570 for ; Thu, 7 Oct 2021 09:43:26 -0700 (PDT) Received: by mail-yb1-xb2a.google.com with SMTP id a7so14776298yba.6 for ; Thu, 07 Oct 2021 09:43:26 -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=BMUFD3KuFSgPveAs2xgT5F7+weHss6O3rW280Ex8iiE=; b=lSQNJhkP1akawNeEgKpbf1BUyWr8N8n+Trr+s3eMnruRatkQr6Q06I8yMRKTPvr8X+ +i4AxqTgEfV/AzU5lGikKA468GOEAorD5DFxunVlJqCX/UvZv5zhuULnxKdsnxnS0SxN QnteEHOQRCGYbGP4DBHUlS2Di88ECvyjaoe3J39oCwGJ3T1641DVsLKL0e3Xdn/JZvdT QW8KYgfLJfCquy5oaNivhPTCHKVnF7UTeoh3qqdwRxVDhHE9jzYWjgteVrnsAJCab9QP VqCuBcMfyEnxRQ7JoJ0VlLNNDs1E1PNw43km2LYLuUdvGBMWkNdS9YmCGx8k8D6Q2m+T qVVw== 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=BMUFD3KuFSgPveAs2xgT5F7+weHss6O3rW280Ex8iiE=; b=E7UnynDLlNJvnjVqAx9valB+C17EHIka6DyF97q8byQij9rDNpFzRdFiGXQwZ9RX0k zhHvCP5I/UksNcMDyNCTfnvzA8PsToudtCQnROgJ943CCLBr1G5S/W2+q/aw5qpuJ7OD 4TJ4b3SBsl/1qt2Cz2/0g+qpt2DRlrk8FYj+MAgvyjEs9ZjS6012K5YQF0nx9LbJ91LQ QKI82LY0Zp6YxzafG95g9kl2Ld/vRQXHKRCXubVbvhYg5E+qb36wRYtt7fgzzQJyxjYP TxmWbwCGYheKkolW6RGXNstFcG3jZCLao6E909cU7ahpjt2c4qAdiYBnvCiiKf/D7PEK 9p7A== X-Gm-Message-State: AOAM533lAJSiNIn446sGpsi50Y5LS58xExct0riOT3/0BpXUUyH01XfE 3ns0kQgbSnKqPGwp1YZ1PqccL215U0ZsMXlDR4J3rA== X-Received: by 2002:a25:552:: with SMTP id 79mr5793280ybf.202.1633625005752; Thu, 07 Oct 2021 09:43:25 -0700 (PDT) MIME-Version: 1.0 References: <20211005184211.GA19804@duo.ucw.cz> <20211005200411.GB19804@duo.ucw.cz> <6b15c682-72eb-724d-bc43-36ae6b79b91a@redhat.com> In-Reply-To: From: Suren Baghdasaryan Date: Thu, 7 Oct 2021 09:43:14 -0700 Message-ID: Subject: Re: [PATCH v10 3/3] mm: add anonymous vma name refcounting To: Michal Hocko Cc: David Hildenbrand , 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 Thu, Oct 7, 2021 at 9:37 AM Michal Hocko wrote: > > On Thu 07-10-21 08:45:21, Suren Baghdasaryan wrote: > > On Thu, Oct 7, 2021 at 12:59 AM Michal Hocko wrote: > > > > > > On Wed 06-10-21 08:01:56, 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. > > > > Packages are constantly evolving, new ones are developed, names can > > > > change, etc. So assigning a unique id for these names is not really > > > > feasible. > > > > > > I still do not follow. If you need a globaly consistent naming then > > > you need clear rules for that, no matter whether that is number or a > > > file. How do you handle this with strings currently? > > > > Some names represent standard categories, some are unique. A simple > > tool could calculate and report the total for each name, a more > > advanced tool might recognize some standard names and process them > > differently. From kernel's POV, it's just a name used by the userspace > > to categorize anonymous memory areas. > > OK, so there is no real authority or any real naming convention. You > just hope that applications will behave so that the consumer of those > names can make proper calls. Correct? > > In that case the same applies to numbers and I do not see any strong > argument for strings other than it is more pleasing to a human eye when > reading the file. And that doesn't sound like a strong argument to make > the kernel more complicated. Functionally both approaches are equal from > a practical POV. I don't think that's correct. Names like [anon:.bss], [anon:dalvik-zygote space] and [anon:dalvik-/system/framework/boot-core-icu4j.art] provide user with actionable information about the use of that memory or the allocator using it. Names like [anon:1], [anon:2] and [anon:3] do not convey any valuable information for the user until they are converted into descriptive names. > -- > Michal Hocko > SUSE Labs