On Mon, Aug 16, 2021 at 11:47:34AM +0200, David Hildenbrand wrote: > Let's sense support and use it for preallocation. MADV_POPULATE_WRITE > does not require a SIGBUS handler, doesn't actually touch page content, > and avoids context switches; it is, therefore, faster and easier to handle > than our current approach. > > While MADV_POPULATE_WRITE is, in general, faster than manual > prefaulting, and especially faster with 4k pages, there is still value in > prefaulting using multiple threads to speed up preallocation. > > More details on MADV_POPULATE_WRITE can be found in the Linux commits > 4ca9b3859dac ("mm/madvise: introduce MADV_POPULATE_(READ|WRITE) to prefault > page tables") and eb2faa513c24 ("mm/madvise: report SIGBUS as -EFAULT for > MADV_POPULATE_(READ|WRITE)"), and in the man page proposal [1]. > > This resolves the TODO in do_touch_pages(). > > In the future, we might want to look into using fallocate(), eventually > combined with MADV_POPULATE_READ, when dealing with shared file/fd > mappings and not caring about memory bindings. > > [1] https://lkml.kernel.org/r/20210816081922.5155-1-da...@redhat.com > > Reviewed-by: Pankaj Gupta <pankaj.gu...@ionos.com> > Signed-off-by: David Hildenbrand <da...@redhat.com> > --- > include/qemu/osdep.h | 7 ++++ > util/oslib-posix.c | 83 +++++++++++++++++++++++++++++++++----------- > 2 files changed, 69 insertions(+), 21 deletions(-)
Reviewed-by: Daniel P. Berrangé <berra...@redhat.com> Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|