[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20221106133351.ukb5quoizkkzyrge@box.shutemov.name>
Date: Sun, 6 Nov 2022 16:33:51 +0300
From: "Kirill A. Shutemov" <kirill@...temov.name>
To: Pasha Tatashin <pasha.tatashin@...een.com>
Cc: corbet@....net, akpm@...ux-foundation.org, hughd@...gle.com,
hannes@...xchg.org, david@...hat.com, vincent.whitchurch@...s.com,
seanjc@...gle.com, rppt@...nel.org, shy828301@...il.com,
paul.gortmaker@...driver.com, peterx@...hat.com, vbabka@...e.cz,
Liam.Howlett@...cle.com, ccross@...gle.com, willy@...radead.org,
arnd@...db.de, cgel.zte@...il.com, yuzhao@...gle.com,
linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org,
linux-doc@...r.kernel.org, linux-mm@...ck.org
Subject: Re: [PATCH] mm: anonymous shared memory naming
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:<name>] 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/<pid>/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 <pasha.tatashin@...een.com>
> ---
> 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:<name>] an anonymous mapping that has been
> + [anon:<name>] a private anonymous mapping that has been
> named by userspace
> + path [anon_shmem:<name>] 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
Powered by blists - more mailing lists