Thread (38 messages) 38 messages, 8 authors, 2021-02-25

Re: [PATCH RFC] mm/madvise: introduce MADV_POPULATE to prefault/prealloc memory

From: Michal Hocko <mhocko@suse.com>
Date: 2021-02-22 14:09:04
Also in: linux-alpha, linux-arch, linux-mm, lkml

On Mon 22-02-21 13:59:55, David Hildenbrand wrote:
On 22.02.21 13:56, Michal Hocko wrote:
quoted
On Sat 20-02-21 10:12:26, David Hildenbrand wrote:
[...]
quoted
Thinking about MADV_POPULATE vs. MADV_POPULATE_WRITE I wonder if it would be
more versatile to break with existing MAP_POPULATE semantics and directly go
with

MADV_POPULATE_READ: simulate user space read access without actually
reading. Trigger a read fault if required.

MADV_POPULATE_WRITE: simulate user space write access without actually
writing. Trigger a write fault if required.

For my use case, I could use MADV_POPULATE_WRITE on anonymous memory and
RAM-backed files (shmem/hugetlb) - I would not have a minor fault when the
guest inside the VM first initializes memory. This mimics how QEMU currently
preallocates memory.

However, I would use MADV_POPULATE_READ on any !RAM-backed files where we
actually have to write-back to a (slow?) device. Dirtying everything
although the guest might not actually consume it in the near future might be
undesired.
Isn't what the current mm_populate does?
         if ((vma->vm_flags & (VM_WRITE | VM_SHARED)) == VM_WRITE)
                 gup_flags |= FOLL_WRITE;

So it will write fault to shared memory mappings but it will touch
others.
Ble, I have writen that opposit to the actual behavior. It will write
fault on writeable private mappings and only touch on read/only or
private mappings.
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.
-- 
Michal Hocko
SUSE Labs
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help