linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Yang Shi <yang@os.amperecomputing.com>
To: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: arnd@arndb.de, gregkh@linuxfoundation.org,
	Liam.Howlett@oracle.com, vbabka@suse.cz, jannh@google.com,
	willy@infradead.org, liushixin2@huawei.com,
	akpm@linux-foundation.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] /dev/zero: make private mapping full anonymous mapping
Date: Wed, 15 Jan 2025 13:29:19 -0800	[thread overview]
Message-ID: <0c7fb1b2-4f08-4017-a27c-cc0cb4da4a93@os.amperecomputing.com> (raw)
In-Reply-To: <f7ce93be-c9dd-4d5f-b048-3c42c9319264@lucifer.local>


>> I just thought of named anonymous VMA may help. We can give the private
>> /dev/zero mapping a name, for example, just "/dev/zero". However,
>> "[anon:/dev/zero]" will show up in smaps/maps. We can't keep the device
>> numbers and inode number either, but it seems it can tell the user this
>> mapping comes from /dev/zero, and it also explicitly tells us it is
>> specially treated by kernel. Hopefully setting anon_name is permitted.
> But then that'd require CONFIG_ANON_VMA_NAME unfortunately :(

Yes.

>
> I think this maps thing is the killer here really.
>
> It'd be nice to -specifically- have a means of expressing this kind of VMA,
> we have a means of setting a VMA anon, so maybe we can 'set a VMA to
> /dev/zero' and somehow explicitly know that we've done this and identify
> this special case.
>
> I'm not sure that the .mmap callback is the right place to do this and I"m
> not sure how exactly this would work but this could be workable.

A couple of potential approaches off the top of my head:
   - A new vm flag
   - Use vm_private_data

Both of them have pros and cons. The vm flag is simple enough, but it 
needs to consume one bit for just one usecase. The vm_private_data is a 
void pointer and a lot drivers use it to store driver specific data 
structures, so using the pointer in a generic path (for example, smaps) 
to tell us whether it is /dev/zero is not easy. We may be able to have a 
special encoding to it, for example, set the last bit (the trick is not 
unusual in core mm code).

>
> I agree the actual offset into the zero page is of no relevance and no
> _sane_ user will care, but this way we could put /dev/zero in [s]maps,
> treat this VMA as anon, but also add semantic information about the
> existence of this weird corner case.
>



  reply	other threads:[~2025-01-15 21:29 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-13 22:30 Yang Shi
2025-01-14 12:05 ` Lorenzo Stoakes
2025-01-14 16:53   ` Yang Shi
2025-01-14 18:14     ` Lorenzo Stoakes
2025-01-14 18:19       ` Lorenzo Stoakes
2025-01-14 18:21         ` Lorenzo Stoakes
2025-01-14 18:22         ` Matthew Wilcox
2025-01-14 18:26           ` Lorenzo Stoakes
2025-01-14 18:32       ` Jann Horn
2025-01-14 18:38         ` Lorenzo Stoakes
2025-01-14 19:03       ` Yang Shi
2025-01-14 19:13         ` Lorenzo Stoakes
2025-01-14 21:24           ` Yang Shi
2025-01-15 12:10             ` Lorenzo Stoakes
2025-01-15 21:29               ` Yang Shi [this message]
2025-01-15 22:05                 ` Christoph Lameter (Ampere)
2025-01-14 13:01 ` David Hildenbrand
2025-01-14 14:52   ` Lorenzo Stoakes
2025-01-14 15:06     ` David Hildenbrand
2025-01-14 17:01       ` Yang Shi
2025-01-14 17:23         ` David Hildenbrand
2025-01-14 17:38           ` Yang Shi
2025-01-14 17:46             ` David Hildenbrand
2025-01-14 18:05               ` Yang Shi
2025-01-14 17:02       ` David Hildenbrand
2025-01-14 17:20         ` Yang Shi
2025-01-14 17:24           ` David Hildenbrand
2025-01-28  3:14 ` kernel test robot
2025-01-31 18:38   ` Yang Shi
2025-02-06  8:02     ` Oliver Sang
2025-02-07 18:10       ` Yang Shi
2025-02-13  2:04         ` Oliver Sang
2025-02-14 22:53           ` Yang Shi
2025-02-18  6:30             ` Oliver Sang
2025-02-19  1:12               ` Yang Shi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0c7fb1b2-4f08-4017-a27c-cc0cb4da4a93@os.amperecomputing.com \
    --to=yang@os.amperecomputing.com \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=jannh@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=liushixin2@huawei.com \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=vbabka@suse.cz \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox