linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Yang Shi <yang@os.amperecomputing.com>
To: David Hildenbrand <david@redhat.com>,
	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: Tue, 14 Jan 2025 10:05:15 -0800	[thread overview]
Message-ID: <bcb807a3-7e33-4b69-84b5-9219d0524239@os.amperecomputing.com> (raw)
In-Reply-To: <c5503360-74ff-43e7-92b4-92e0f526e9ff@redhat.com>




On 1/14/25 9:46 AM, David Hildenbrand wrote:
> On 14.01.25 18:38, Yang Shi wrote:
>>
>>
>>
>> On 1/14/25 9:23 AM, David Hildenbrand wrote:
>>> On 14.01.25 18:01, Yang Shi wrote:
>>>>
>>>>
>>>>
>>>> On 1/14/25 7:06 AM, David Hildenbrand wrote:
>>>>> On 14.01.25 15:52, Lorenzo Stoakes wrote:
>>>>>> On Tue, Jan 14, 2025 at 02:01:32PM +0100, David Hildenbrand wrote:
>>>>>>> On 13.01.25 23:30, Yang Shi wrote:
>>>>>>>> When creating private mapping for /dev/zero, the driver makes 
>>>>>>>> it an
>>>>>>>> anonymous mapping by calling set_vma_anonymous(). But it just sets
>>>>>>>> vm_ops to NULL, vm_file is still valid and vm_pgoff is also file
>>>>>>>> offset.
>>>>>>>>
>>>>>>>> This is a special case and the VMA doesn't look like either
>>>>>>>> anonymous VMA
>>>>>>>> or file VMA.  It confused other kernel subsystem, for example,
>>>>>>>> khugepaged [1].
>>>>>>>>
>>>>>>>> It seems pointless to keep such special case. Making private
>>>>>>>> /dev/zero>
>>>>>>> mapping a full anonymous mapping doesn't change the semantic of
>>>>>>>> /dev/zero either.
>>>>>>>>
>>>>>>>> The user visible effect is the mapping entry shown in
>>>>>>>> /proc/<PID>/smaps
>>>>>>>> and /proc/<PID>/maps.
>>>>>>>>
>>>>>>>> Before the change:
>>>>>>>> ffffb7190000-ffffb7590000 rw-p 00001000 00:06
>>>>>>>> 8                          /dev/zero
>>>>>>>>
>>>>>>>> After the change:
>>>>>>>> ffffb6130000-ffffb6530000 rw-p 00000000 00:00 0
>>>>>>>>
>>>>>>>
>>>>>>> Hm, not sure about this. It's actually quite consistent to have 
>>>>>>> that
>>>>>>> output
>>>>>>> in smaps the way it is. You mapped a file at an offset, and it
>>>>>>> behaves like
>>>>>>> an anonymous mapping apart from that.
>>>>>>>
>>>>>>> Not sure if the buggy khugepaged thing is a good indicator to
>>>>>>> warrant this
>>>>>>> change.
>>>>
>>>> I admit this may be a concern, but I doubt who really care about it...
>>>>
>>>
>>> There is an example in the man page [1] about /proc/self/map_files/.
>>>
>>> I assume that will also change here.
>>
>> IIUC, that example is specific to "anonymous shared memory" created by
>> shared mapping of /dev/zero.
>
> Note that MAP_PRIVATE of /dev/zero will also make it appear in the 
> same way right now (I just tried).

Yes, I will add this in the commit log as another user visible change.

>
> The example is about MAP_FILE in general, not just MAP_SHARED IIUC.

MAP_FILE is actually ignored on Linux per 
https://man7.org/linux/man-pages/man2/mmap.2.html. It also says 
"(regions created with the MAP_ANON | MAP_SHARED flags)". Anyway it 
looks like this man page may be a little bit outdated. We can clean it 
up later.



  reply	other threads:[~2025-01-14 18:05 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
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 [this message]
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=bcb807a3-7e33-4b69-84b5-9219d0524239@os.amperecomputing.com \
    --to=yang@os.amperecomputing.com \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=david@redhat.com \
    --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