diff options
| author | David Hildenbrand <david@redhat.com> | 2021-12-17 14:46:08 +0100 |
|---|---|---|
| committer | Michael S. Tsirkin <mst@redhat.com> | 2022-01-07 05:19:55 -0500 |
| commit | ac86e5c37df4963846d1a2e999696bb5031a99cd (patch) | |
| tree | 341f6fb962b414e4d610e05b031d2c379e7b7a69 /util/oslib-posix.c | |
| parent | 89aec6411c429adb662c53c94a986a5397961a7f (diff) | |
| download | focaccia-qemu-ac86e5c37df4963846d1a2e999696bb5031a99cd.tar.gz focaccia-qemu-ac86e5c37df4963846d1a2e999696bb5031a99cd.zip | |
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>
Diffstat (limited to 'util/oslib-posix.c')
| -rw-r--r-- | util/oslib-posix.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/util/oslib-posix.c b/util/oslib-posix.c index 67c08a425e..efa4f96d56 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -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; |