From: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
To: David Hildenbrand <david@redhat.com>
Cc: Lance Yang <ioworker0@gmail.com>,
akpm@linux-foundation.org, 21cnbao@gmail.com,
ryan.roberts@arm.com, dev.jain@arm.com, shy828301@gmail.com,
ziy@nvidia.com, libang.li@antgroup.com,
baolin.wang@linux.alibaba.com, linux-kernel@vger.kernel.org,
linux-mm@kvack.org, Liam.Howlett@oracle.com, vbabka@suse.cz,
jannh@google.com, Jason@zx2c4.com,
Mingzhe Yang <mingzhe.yang@ly.com>
Subject: Re: [PATCH 1/1] mm/mmap: allow MAP_DROPPABLE | MAP_PRIVATE in mmap()
Date: Mon, 20 Jan 2025 10:38:17 +0000 [thread overview]
Message-ID: <5118f207-8982-421c-a995-23798355f020@lucifer.local> (raw)
In-Reply-To: <52a45aa6-1554-4cb8-b8df-da601c4e18ca@redhat.com>
Agree with David, NACK.
On Mon, Jan 20, 2025 at 08:45:07AM +0100, David Hildenbrand wrote:
> On 20.01.25 02:26, Lance Yang wrote:
> > Currently, mmap() fails with `-EINVAL` when both MAP_DROPPABLE and
> > MAP_PRIVATE are specified. This behavior might be inconsistent, as the
> > implementation of MAP_DROPPABLE under the hood already includes the
> > semantics of MAP_PRIVATE. So, IMO, whether MAP_PRIVATE is explicitly
> > specified or not, it should work as expected.
> >
> > For example, when mmap() is called with `MAP_DROPPABLE | MAP_ANONYMOUS`,
> > it creates a private anonymous mapping. Users can verify this behavior
> > via `/proc/self/smaps`, where the resulting VMA is marked with the `dp`
> > (MAP_DROPPABLE) flag, and the `Private_*` fields confirm private memory
> > semantics. The output for a 2MiB mapping with these flags might look like:
>
> Note that "Private_" in the stats has *nothing* to do with MAP_PRIVATE.
>
> >
> > ```
> > f433ace00000-f433ad000000 rw-p 00000000 00:00 0
> > Size: 2048 kB
> > KernelPageSize: 4 kB
> > MMUPageSize: 4 kB
> > Rss: 2048 kB
> > Pss: 2048 kB
> > Pss_Dirty: 2048 kB
> > Shared_Clean: 0 kB
> > Shared_Dirty: 0 kB
> > Private_Clean: 0 kB
> > Private_Dirty: 2048 kB
> > Referenced: 2048 kB
> > Anonymous: 2048 kB
> > ...
> > VmFlags: rd wr mr mw me nr wf dd dp
> > ```
> >
> > This patch changes mmap() to allow the combination of `MAP_DROPPABLE |
> > MAP_PRIVATE`. For mmap(), at least one of MAP_PRIVATE or MAP_SHARED could
> > be explicitly specified, regardless of the combination with other `MAP_*`
> > flags.
> >
> > Fixes: 9651fcedf7b9 ("mm: add MAP_DROPPABLE for designating always lazily freeable mappings")
>
> "How about we just say that VM_DROPPABLE really is something separate
> from MAP_PRIVATE or MAP_SHARED..
Which is also how I view it. I -really- do not want to add a weird situation too
where people wonder whether _not_ setting MAP_PRIVATE infers some different
semantics.
This mode is aggregate in behaviour by design and intended to be _specifically_
asked for, not in conjection with other map flags.
>
> And then we make the rule be that VM_DROPPABLE is never dumped and
> always dropped on fork, just to make things simpler." [1]
Yup.
>
> [1] https://lore.kernel.org/linux-mm/CAHk-=wi=XvCZ9r897LjEb4ZarLzLtKN1p+Fyig+F2fmQDF8GSA@mail.gmail.com/
>
> So, nack from my side.
Also, mine.
>
> --
> Cheers,
>
> David / dhildenb
>
next prev parent reply other threads:[~2025-01-20 10:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-20 1:26 Lance Yang
2025-01-20 7:45 ` David Hildenbrand
2025-01-20 10:38 ` Lorenzo Stoakes [this message]
2025-01-20 13:32 ` Lance Yang
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=5118f207-8982-421c-a995-23798355f020@lucifer.local \
--to=lorenzo.stoakes@oracle.com \
--cc=21cnbao@gmail.com \
--cc=Jason@zx2c4.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=david@redhat.com \
--cc=dev.jain@arm.com \
--cc=ioworker0@gmail.com \
--cc=jannh@google.com \
--cc=libang.li@antgroup.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mingzhe.yang@ly.com \
--cc=ryan.roberts@arm.com \
--cc=shy828301@gmail.com \
--cc=vbabka@suse.cz \
--cc=ziy@nvidia.com \
/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