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 5B74DC43219 for ; Sun, 6 Nov 2022 16:52:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D21D280008; Sun, 6 Nov 2022 11:52:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CAB1D80007; Sun, 6 Nov 2022 11:52:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B245E80008; Sun, 6 Nov 2022 11:52:16 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 9F5C180007 for ; Sun, 6 Nov 2022 11:52:16 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 6DFE21A04E0 for ; Sun, 6 Nov 2022 16:52:16 +0000 (UTC) X-FDA: 80103610272.10.59174DA Received: from wnew4-smtp.messagingengine.com (wnew4-smtp.messagingengine.com [64.147.123.18]) by imf22.hostedemail.com (Postfix) with ESMTP id BB80AC0002 for ; Sun, 6 Nov 2022 16:52:15 +0000 (UTC) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailnew.west.internal (Postfix) with ESMTP id 21A562B063E5; Sun, 6 Nov 2022 11:52:09 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Sun, 06 Nov 2022 11:52:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov.name; h=cc:cc:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1667753528; x=1667760728; bh=ML PScbiT/w3JaMANBBCz19l6qnUEijiodsNSPwsmFvA=; b=Rvl+sXfWlxBEW89l4i EWsJsiMNFACOwsfH87VIaAq1cWAAbzliMtdvQGSvVadVW2Qe9nCccio18LVhn6ds EfBqOKtSdRvhddLy7p8b+hhvLiHsV3jtvIVgr5QJHOXRvDfPHuE3BIikbsptqIBu hmt6Yf998GGXvngq2aM7u0PMcHjyGg+Ra9UKLqtOaS6Uq9d0wgCXEBWqPIHFvoH8 LLzkUgL1AzPe+egCmvIWwnF/blrPT/GWVyEbm7PsR8COZ52yM+eIvrO0bog4qOd7 jEzC9SqMgtywysSkT/n6UC/zvyki3goOoq4A8kKoF9XsWt/O2wzmU7t1493cIQ8d nnlw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1667753528; x=1667760728; bh=MLPScbiT/w3JaMANBBCz19l6qnUE ijiodsNSPwsmFvA=; b=h07AGaYuROhwH49JjCcdYVg+80f1ZOjXBDYzvRAYDFbO wR74v7wGdecSj6zlx4O+8Nqk2ynI/PsQPLplQOQtgpHb6igzOII4X0LTs3eeOmpj F7WYZb5OcynKVu/vkI/udT12Z3S0rx1ayvRpsZR1/u2QabaPzQH6gBIAJtOueU5S SeLqulavBuyYo91FdS0FRZFw+R4+Vo+Jg1sy+knrB32IOXGaVTbXaESppH1Bhcz+ P9g8vzXpYXmsB2+UWpQhTh+WrsVEJ9aNxxfPktzeZ9jXRkvxMspaxyYf7OyTHTD+ 0fNk75syjMBFLWs+R9EUYTzOu2h4ZllGYRqhFxVzVQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrvdeigdekjecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvvefukfhfgggtuggjsehttddttddttddvnecuhfhrohhmpedfmfhirhhi lhhlucetrdcuufhhuhhtvghmohhvfdcuoehkihhrihhllhesshhhuhhtvghmohhvrdhnrg hmvgeqnecuggftrfgrthhtvghrnhephfeigefhtdefhedtfedthefghedutddvueehtedt tdehjeeukeejgeeuiedvkedtnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomhepkhhirhhilhhlsehshhhuthgvmhhovhdrnhgrmhgv X-ME-Proxy: Feedback-ID: ie3994620:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 6 Nov 2022 11:52:06 -0500 (EST) Received: by box.shutemov.name (Postfix, from userid 1000) id 3198E104149; Sun, 6 Nov 2022 19:52:04 +0300 (+03) Date: Sun, 6 Nov 2022 19:52:04 +0300 From: "Kirill A. Shutemov" To: Pasha Tatashin Cc: corbet@lwn.net, akpm@linux-foundation.org, hughd@google.com, hannes@cmpxchg.org, david@redhat.com, vincent.whitchurch@axis.com, seanjc@google.com, rppt@kernel.org, shy828301@gmail.com, paul.gortmaker@windriver.com, peterx@redhat.com, vbabka@suse.cz, Liam.Howlett@oracle.com, ccross@google.com, willy@infradead.org, arnd@arndb.de, cgel.zte@gmail.com, yuzhao@google.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH] mm: anonymous shared memory naming Message-ID: <20221106165204.odb7febmnykhna2h@box.shutemov.name> References: <20221105025342.3130038-1-pasha.tatashin@soleen.com> <20221106133351.ukb5quoizkkzyrge@box.shutemov.name> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=shutemov.name header.s=fm2 header.b=Rvl+sXfW; dkim=pass header.d=messagingengine.com header.s=fm3 header.b=h07AGaYu; spf=pass (imf22.hostedemail.com: domain of kirill@shutemov.name designates 64.147.123.18 as permitted sender) smtp.mailfrom=kirill@shutemov.name; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1667753536; a=rsa-sha256; cv=none; b=j9F+/d6h4hdK8BdIAD3gXoCsIGReF9ArfxSHNOS6TUVLtl5d3RcjwFBRaG/PP2reX/tcBx HcIgbedIlmZ6j5b9/BVMue/0WXHbpXhlRkxxzeHfLNBBT4r9pDe4JmgR7+CJZ8uZESxoEb aIG11YZ7+nM30Evn1s6AuSD4p+nRzmU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667753536; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=MLPScbiT/w3JaMANBBCz19l6qnUEijiodsNSPwsmFvA=; b=PAl+cid+IwWfkMATZeFP2DftTyzteh1SJ9Qv+koBQvcIBvysOIlkYaLBD6i69XeOBnGYfx EvPCfdrf4e351Zzs2D+nhhf4/bqzbYsVYCIjLLTZszbCUnxiN5SB6XGb/uG0kdp8o4pLeb jBKyM5JBZnQwqxmn88Kbzfglkk4ZoUE= X-Stat-Signature: zhk1zkwrdjhp319dou5ak33k8yrmi7ga X-Rspamd-Queue-Id: BB80AC0002 Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=shutemov.name header.s=fm2 header.b=Rvl+sXfW; dkim=pass header.d=messagingengine.com header.s=fm3 header.b=h07AGaYu; spf=pass (imf22.hostedemail.com: domain of kirill@shutemov.name designates 64.147.123.18 as permitted sender) smtp.mailfrom=kirill@shutemov.name; dmarc=none X-Rspam-User: X-Rspamd-Server: rspam12 X-HE-Tag: 1667753535-172504 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 Sun, Nov 06, 2022 at 08:45:44AM -0500, Pasha Tatashin wrote: > On Sun, Nov 6, 2022 at 8:34 AM Kirill A. Shutemov wrote: > > > > On Sat, Nov 05, 2022 at 02:53:42AM +0000, Pasha Tatashin wrote: > > > Since: > > > commit 9a10064f5625 ("mm: add a field to store names for private anonymous > > > memory") > > > > > > We can set names for private anonymous memory but not for shared > > > anonymous memory. However, naming shared anonymous memory just as > > > useful for tracking purposes. > > > > > > Extend the functionality to be able to set names for shared anon. > > > > > > / [anon_shmem:] an anonymous shared memory mapping that has > > > been named by userspace > > > > > > Sample output: > > > share = mmap(NULL, SIZE, PROT_READ | PROT_WRITE, > > > MAP_SHARED | MAP_ANONYMOUS, -1, 0); > > > rv = prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, > > > share, SIZE, "shared anon"); > > > > > > /proc//maps (and smaps): > > > 7fc8e2b4c000-7fc8f2b4c000 rw-s 00000000 00:01 1024 > > > /dev/zero (deleted) [anon_shmem:shared anon] > > > > > > pmap $(pgrep a.out) > > > 254: pub/a.out > > > 000056093fab2000 4K r---- a.out > > > 000056093fab3000 4K r-x-- a.out > > > 000056093fab4000 4K r---- a.out > > > 000056093fab5000 4K r---- a.out > > > 000056093fab6000 4K rw--- a.out > > > 000056093fdeb000 132K rw--- [ anon ] > > > 00007fc8e2b4c000 262144K rw-s- zero (deleted) [anon_shmem:shared anon] > > > > > > Signed-off-by: Pasha Tatashin > > > --- > > > Documentation/filesystems/proc.rst | 4 +++- > > > fs/proc/task_mmu.c | 7 ++++--- > > > include/linux/mm.h | 2 ++ > > > include/linux/mm_types.h | 27 +++++++++++++-------------- > > > mm/madvise.c | 7 ++----- > > > mm/shmem.c | 13 +++++++++++-- > > > 6 files changed, 35 insertions(+), 25 deletions(-) > > > > > > diff --git a/Documentation/filesystems/proc.rst b/Documentation/filesystems/proc.rst > > > index 898c99eae8e4..8f1e68460da5 100644 > > > --- a/Documentation/filesystems/proc.rst > > > +++ b/Documentation/filesystems/proc.rst > > > @@ -431,8 +431,10 @@ is not associated with a file: > > > [stack] the stack of the main process > > > [vdso] the "virtual dynamic shared object", > > > the kernel system call handler > > > - [anon:] an anonymous mapping that has been > > > + [anon:] a private anonymous mapping that has been > > > named by userspace > > > + path [anon_shmem:] an anonymous shared memory mapping that has > > > + been named by userspace > > > > I expect it to break existing parsers. If the field starts with '/' it is > > reasonable to assume the rest of the string to be a path, but it is not > > the case now. > > This is actually exactly why I kept the "path" part. It stays the same > as today for anon-shared memory, but prevents pmap to change > anon-shared memory from showing it as simply [anon]. > > Here is what we have today in /proc//maps (and smaps): > 7fc8e2b4c000-7fc8f2b4c000 rw-s 00000000 00:01 1024 /dev/zero (deleted) > > So, the path points to /dev/zero but appended with (deleted) mark. The > pmap shows the same thing, as it is looking for leading '/' to > determine that this is a path. > > With my change the above changes only when user specifically changed > the name like this: > > 7fc8e2b4c000-7fc8f2b4c000 rw-s 00000000 00:01 1024 /dev/zero > (deleted) [USER-SPECIFIED-NAME] > > So, the path stays, the (deleted) mark stays, and a name is added. Okay, fair enough. -- Kiryl Shutsemau / Kirill A. Shutemov