From: David Hildenbrand <david@redhat.com>
To: Michal Hocko <mhocko@suse.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
Andrew Morton <akpm@linux-foundation.org>,
Arnd Bergmann <arnd@arndb.de>, Oscar Salvador <osalvador@suse.de>,
Matthew Wilcox <willy@infradead.org>,
Andrea Arcangeli <aarcange@redhat.com>,
Minchan Kim <minchan@kernel.org>, Jann Horn <jannh@google.com>,
Jason Gunthorpe <jgg@ziepe.ca>,
Dave Hansen <dave.hansen@intel.com>,
Hugh Dickins <hughd@google.com>, Rik van Riel <riel@surriel.com>,
"Michael S . Tsirkin" <mst@redhat.com>,
"Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>,
Vlastimil Babka <vbabka@suse.cz>,
Richard Henderson <rth@twiddle.net>,
Ivan Kokshaysky <ink@jurassic.park.msu.ru>,
Matt Turner <mattst88@gmail.com>,
Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
"James E.J. Bottomley" <James.Bottomley@hansenpartnership.com>,
Helge Deller <deller@gmx.de>, Chris Zankel <chris@zankel.net>,
Max Filippov <jcmvbkbc@gmail.com>,
linux-alpha@vger.kernel.org, linux-mips@vger.kernel.org,
linux-parisc@vger.kernel.org, linux-xtensa@linux-xtensa.org,
linux-arch@vger.kernel.org
Subject: Re: [PATCH RFC] mm/madvise: introduce MADV_POPULATE to prefault/prealloc memory
Date: Mon, 22 Feb 2021 16:30:47 +0100 [thread overview]
Message-ID: <7d7d2213-92a4-0419-20ad-bba7071a279c@redhat.com> (raw)
In-Reply-To: <YDO5d+pbPBsjv13T@dhcp22.suse.cz>
On 22.02.21 15:02, Michal Hocko wrote:
> On Mon 22-02-21 14:22:37, David Hildenbrand wrote:
>>>> Exactly. But for hugetlbfs/shmem ("!RAM-backed files") this is not what we
>>>> want.
>>>
>>> OK, then I must have misread your requirements. Maybe I just got lost in
>>> all the combinations you have listed.
>>
>> Another special case could be dax/pmem I think. You might want to fault it
>> in readable/writable but not perform an actual read/write unless really
>> required.
>>
>> QEMU phrases this as "don't cause wear on the storage backing".
>
> Sorry for being dense here but I still do not follow. If you do not want
> to read then what do you want to populate from? Only map if it is in the
In the context of VMs it's usually rather a mean to preallocate backend
storage - which would also happen on read access. See below on case 4).
> page cache?
Let's try to untangle my thoughts regarding VMs. We could have as
backend storage for our VM:
1) Anonymous memory
2) hugetlbfs (private/shared)
3) tmpfs/shmem (private/shared)
4) Ordinary files (shared)
5) DAX/PMEM (shared)
Excluding special cases (hypervisor upgrades with 2) and 3) ), we expect
to have pre-existing content in files only in 4) and 5). 4) and 5) might
be used as NVDIMM backend for a guest, or as DIMM backend.
The first access of our VM to memory could be
a) Write: the usual case when exposed as RAM/DIMM to out guest.
b) Read: possible case when exposed as an NVDIMM to our guest (we don't
know). But eventually, we might write to (parts of) NVDIMMs later.
We "preallocate"/"populate" memory of our VM so that
- We know we have sufficient backend storage (esp. hugetlbfs, shmem,
files) - so we don't randomly crash the VM. My most important use
case.
- We avoid page faults (including page zeroing!) at runtime. Especially
relevant for RT workloads.
With 1), 2), and 3) we want to have pages faulted in writable - we
expect that our guest will write to that memory. MADV_POPULATE would do
that only for 1), and MAP_PRIVATE of 2). For the shared parts, we would
want MADV_POPULATE_WRITE semantics.
With 5), we already had complaints that preallcoation in QEMU takes a
long time - because we end up actually reading/writing slow PMEM
(libvirt now disables preallcoation for that reason, which makes sense).
However, MADV_POPULATE_WRITE would help to prefault without actually
reading/writing pmem - if we want to avoid any minor faults.
With 4), I think we primarily prealloc/prefault to make sure we have
sufficient backend storage. fallocate() might do a better job just for
the allocation. But if there is sufficient RAM it might make sense to
prefault all guest RAM at least readable - then we only have a minor
fault when the VM writes to it and might avoid having to go to disk.
Prefaulting everything writable means that we *have to* write back all
guest RAM even if the guest never accessed it. So I think there are
cases where MADV_POPULATE_READ (current MADV_POPULATE) semantics could
make sense.
--
Thanks,
David / dhildenb
next prev parent reply other threads:[~2021-02-22 15:31 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-17 15:48 [PATCH RFC] mm/madvise: introduce MADV_POPULATE to prefault/prealloc memory David Hildenbrand
2021-02-17 16:46 ` Dave Hansen
2021-02-17 17:06 ` David Hildenbrand
2021-02-17 17:21 ` Vlastimil Babka
2021-02-18 11:07 ` Rolf Eike Beer
2021-02-18 11:27 ` David Hildenbrand
2021-02-18 10:25 ` Michal Hocko
2021-02-18 10:44 ` David Hildenbrand
2021-02-18 10:54 ` David Hildenbrand
2021-02-18 11:28 ` Michal Hocko
2021-02-18 11:27 ` Michal Hocko
2021-02-18 11:38 ` David Hildenbrand
2021-02-18 12:22 ` [PATCH RFC] madvise.2: Document MADV_POPULATE David Hildenbrand
2021-02-18 22:59 ` [PATCH RFC] mm/madvise: introduce MADV_POPULATE to prefault/prealloc memory Peter Xu
2021-02-19 8:20 ` David Hildenbrand
2021-02-19 16:31 ` Peter Xu
2021-02-19 17:13 ` David Hildenbrand
2021-02-19 19:14 ` David Hildenbrand
2021-02-19 19:25 ` Mike Kravetz
2021-02-20 9:01 ` David Hildenbrand
2021-02-19 19:23 ` Peter Xu
2021-02-19 20:04 ` David Hildenbrand
2021-02-22 12:46 ` Michal Hocko
2021-02-22 12:52 ` David Hildenbrand
2021-02-19 10:35 ` Michal Hocko
2021-02-19 10:43 ` David Hildenbrand
2021-02-19 11:04 ` Michal Hocko
2021-02-19 11:10 ` David Hildenbrand
2021-02-20 9:12 ` David Hildenbrand
2021-02-22 12:56 ` Michal Hocko
2021-02-22 12:59 ` David Hildenbrand
2021-02-22 13:19 ` Michal Hocko
2021-02-22 13:22 ` David Hildenbrand
2021-02-22 14:02 ` Michal Hocko
2021-02-22 15:30 ` David Hildenbrand [this message]
2021-02-24 14:25 ` David Hildenbrand
2021-02-24 14:38 ` David Hildenbrand
2021-02-25 8:41 ` David Hildenbrand
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=7d7d2213-92a4-0419-20ad-bba7071a279c@redhat.com \
--to=david@redhat.com \
--cc=James.Bottomley@hansenpartnership.com \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=chris@zankel.net \
--cc=dave.hansen@intel.com \
--cc=deller@gmx.de \
--cc=hughd@google.com \
--cc=ink@jurassic.park.msu.ru \
--cc=jannh@google.com \
--cc=jcmvbkbc@gmail.com \
--cc=jgg@ziepe.ca \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-alpha@vger.kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-parisc@vger.kernel.org \
--cc=linux-xtensa@linux-xtensa.org \
--cc=mattst88@gmail.com \
--cc=mhocko@suse.com \
--cc=minchan@kernel.org \
--cc=mst@redhat.com \
--cc=osalvador@suse.de \
--cc=riel@surriel.com \
--cc=rth@twiddle.net \
--cc=tsbogend@alpha.franken.de \
--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;
as well as URLs for NNTP newsgroup(s).