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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5F867C433F5 for ; Thu, 7 Oct 2021 16:43:28 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0A0F361090 for ; Thu, 7 Oct 2021 16:43:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0A0F361090 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 9A56D900002; Thu, 7 Oct 2021 12:43:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 954C26B0071; Thu, 7 Oct 2021 12:43:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 81CC9900002; Thu, 7 Oct 2021 12:43:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0120.hostedemail.com [216.40.44.120]) by kanga.kvack.org (Postfix) with ESMTP id 726A86B006C for ; Thu, 7 Oct 2021 12:43:27 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 3A47F39B91 for ; Thu, 7 Oct 2021 16:43:27 +0000 (UTC) X-FDA: 78670212054.23.B5C4DBD Received: from mail-yb1-f182.google.com (mail-yb1-f182.google.com [209.85.219.182]) by imf09.hostedemail.com (Postfix) with ESMTP id E6EA930008C0 for ; Thu, 7 Oct 2021 16:43:26 +0000 (UTC) Received: by mail-yb1-f182.google.com with SMTP id z5so14812947ybj.2 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=Z6/ZtmJDYBvPtt5cafyed1rGcNRJZHcPvexxFOuFbOui6QDLsxZTfJwU/Z09Cdcj9b 8tKbO007h0Ff7dExaTkEhYTFp0oFhTlP8YYDYR200Wv0RiySl6NXT+ncW1fDijGGLeBh VIILdtkkkn42Y0S0tnb3tcIQPWiEU24oMdmabBJXJ1qtmkBBtrJXgx7HxM1WHvBdav+j Cgq14nSSc08MZeChFtp0aRyf3B/DdtJoZL/syd793+Sa6R1fgUGnl9QAutCMhoHqyL25 ndo/BcH/TXPLYjLK5Mshh2/IxseD19y74DRM+EPghF5FrL6USJSELL7++Ig/2E7ztlzk 7QHA== X-Gm-Message-State: AOAM532GEuF9LJHGIVaSp7Q3DjBlWVdlMPkP/nSY/ERTaD3APud1lAg6 zczspfYzYrR8DQtYfsw7+ozEzRNeh/QmJX3OO9gEsQ== X-Google-Smtp-Source: ABdhPJx2Hl6g/cZpIzwNX4cGshqHlY1IlMWsD0hSL7XbGg/JjUBjXh8IjPlQ+3QwPgdKW+4jVMtczDqOv9eU5AiWJCA= 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" X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: E6EA930008C0 X-Stat-Signature: z9761dsubtmg7p9n4z4jofxxp5t9e1au Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=lSQNJhkP; spf=pass (imf09.hostedemail.com: domain of surenb@google.com designates 209.85.219.182 as permitted sender) smtp.mailfrom=surenb@google.com; dmarc=pass (policy=reject) header.from=google.com X-HE-Tag: 1633625006-935493 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: 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