util/oslib-posix: Avoid creating a single thread with MADV_POPULATE_WRITE

Let's simplify the case when we only want a single thread and don't have
to mess with signal handlers.

Reviewed-by: Pankaj Gupta <pankaj.gupta@ionos.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20211217134611.31172-6-david@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
David Hildenbrand 2021-12-17 14:46:08 +01:00 committed by Michael S. Tsirkin
parent 89aec6411c
commit ac86e5c37d

View File

@ -564,6 +564,14 @@ static int touch_all_pages(char *area, size_t hpagesize, size_t numpages,
}
if (use_madv_populate_write) {
/* Avoid creating a single thread for MADV_POPULATE_WRITE */
if (context.num_threads == 1) {
if (qemu_madvise(area, hpagesize * numpages,
QEMU_MADV_POPULATE_WRITE)) {
return -errno;
}
return 0;
}
touch_fn = do_madv_populate_write_pages;
} else {
touch_fn = do_touch_pages;