Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp261596rwb; Sun, 6 Nov 2022 05:45:42 -0800 (PST) X-Google-Smtp-Source: AMsMyM5DohAn+kZdB9J9XMwk0UzxAsR7t8TAyRKiAYkr3maTM94yEf/4v1OEZhqvV49QKARL+qea X-Received: by 2002:a17:906:ce5a:b0:7ae:1e53:3f97 with SMTP id se26-20020a170906ce5a00b007ae1e533f97mr414399ejb.169.1667742342591; Sun, 06 Nov 2022 05:45:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667742342; cv=none; d=google.com; s=arc-20160816; b=jk8yYTaZcqCOU83grCrNvDhC2gojUaN318rYBNeMU6kCj23+Mc9NPjJTuOIaT42E6j efcWc5CKd+/I7QOFMjqTqqIbB+Y4/af4X4MniYoaCX3drrlZTYNkqee0tSKJ0MKcb0Ha ml1vaVW3YYnAK/LlwziVm0VbJe8QheRZJmCvSTq6T8Y1SCmYep+SAq8WRoxkv401rvrQ zvU1X6cmssbzSbOp6BqmXayQm0sqkECPS2OURIEyYhj+7uIYOpHOgUNDKk/MnyqQh+71 6L+m0f9lFAfQYzoOsBcq3B6+oBf0foTCoHX5Mrwnyp+YZOji91J9JosAK00H47PDAYen op5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:feedback-id :dkim-signature:dkim-signature; bh=qW0kL8NboCk/b+RHJv96xFs8vnUwrO9Z41lcOwMOB8E=; b=tiz0sGDvaBlpIUdb2RNDshH2pFxwA3kh+BSySruGUFKvaJ4cG9OPSXJFzknCIW5ujL 5uW9n4Ke44dx1EIuxbV/MDZbK019LGPjORNjkB7JuRO9Z1SnGKeuTeU06tOJZNqQtbSK TdSQjZ3oOlPv6DalZIR7oYDVKA7SZAglwrJXhWks47cTMoKlyTmKpCacy8Z0MJebc7Np FLpB2ESNiBRoNYxO1vgLbIbfdYo7D4RslGvxFg+sEGmomCvka0vQvbQuGGla3QvDVlKq E42SWrJfKtx5EU2zS7+aZfr2xgV/A0fbmVHvRBJAYhHH1pZGUKKMmyjumYTN8OPcy+3f vh6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov.name header.s=fm2 header.b=ZAaJqrKd; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b="TgL/lROl"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sd16-20020a1709076e1000b007ae5ccae236si3812746ejc.90.2022.11.06.05.45.18; Sun, 06 Nov 2022 05:45:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@shutemov.name header.s=fm2 header.b=ZAaJqrKd; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b="TgL/lROl"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229968AbiKFNeF (ORCPT + 97 others); Sun, 6 Nov 2022 08:34:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229804AbiKFNeD (ORCPT ); Sun, 6 Nov 2022 08:34:03 -0500 Received: from wnew2-smtp.messagingengine.com (wnew2-smtp.messagingengine.com [64.147.123.27]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86D29DFFF; Sun, 6 Nov 2022 05:34:02 -0800 (PST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailnew.west.internal (Postfix) with ESMTP id 6DE8A2B06280; Sun, 6 Nov 2022 08:33:57 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Sun, 06 Nov 2022 08:33:59 -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=1667741636; x=1667748836; bh=qW 0kL8NboCk/b+RHJv96xFs8vnUwrO9Z41lcOwMOB8E=; b=ZAaJqrKdI5LhW2lFri kvU1FsfUECIQD9N8sO7JXPk8AqgarmIjBf+YEbsbOBO8ubzBbwNrBPkd5jYkzzJY ScC2Em7YUEr+g6D9JnWHxanDgRisCrQoUvP9pdIfmkY+N21MIxJZOsLa0BME7eZB j09FtiK+ieMxgJOBIWdL+qMtTzGGivauJ0ZrqIsDrAGok6TOFnlYQvQj5GGIQ3kA wsOeSnWjNdGs/h0GmFbJC9BV8Zp4K/DLenbli05o3q/zHrVAHuCMipaqioURUMJ2 ktmLmrFICYnTCcGTZYZ4Ime9E3Q4xCp/6vdwevnOkPb4nZAGtEmr1Q5ptRxcqELk UQFA== 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=1667741636; x=1667748836; bh=qW0kL8NboCk/b+RHJv96xFs8vnUw rO9Z41lcOwMOB8E=; b=TgL/lROlUJEFEFXtcXVtI1Y26EuNQSY3CAROZ9yWyNYn V7zu+k7LtQDQYTYWU3XvCzOo66JkWwLPBcImgww1xw8fL7zW3srwY2b8A7hoMR9V hAhSbL/S7Fr8DptVpO3zfcjn+4uCVGZm+e6/og0B0oYjdKBCWKXpzCzskNz9JIJ/ y41qabStDHrCW3yW/fF1gCM6yGRcC73hJrIlEiRKZQsJCn5hCdj3FGwBpWXmm9M7 zsQRihm/mZc5K/vWAFhGbBWFp7M1w+VEY5aHQPysbBN9gSm/UAAKHUW/1US5TdpC tN3YKlfyGVlJ6kTlUfijHrOeg3DdqPUjFzu7nUR1vw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrvdeigdegjecutefuodetggdotefrodftvf 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 08:33:55 -0500 (EST) Received: by box.shutemov.name (Postfix, from userid 1000) id 5A2BB104149; Sun, 6 Nov 2022 16:33:51 +0300 (+03) Date: Sun, 6 Nov 2022 16:33:51 +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: <20221106133351.ukb5quoizkkzyrge@box.shutemov.name> References: <20221105025342.3130038-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221105025342.3130038-1-pasha.tatashin@soleen.com> X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. -- Kiryl Shutsemau / Kirill A. Shutemov