diff options
author | Mark Kanda <mark.kanda@oracle.com> | 2024-01-31 10:53:27 -0600 |
---|---|---|
committer | David Hildenbrand <david@redhat.com> | 2024-02-06 08:15:22 +0100 |
commit | 04accf43df83aa10f06f7dbda3ecf0db97f0c5a6 (patch) | |
tree | c5668fe7f5ae98622af2f69ac4f2a97ff219a97a /include | |
parent | 540a1abbf0b243e4cfb4333c5d30a041f7080ba4 (diff) | |
download | qemu-04accf43df83aa10f06f7dbda3ecf0db97f0c5a6.zip qemu-04accf43df83aa10f06f7dbda3ecf0db97f0c5a6.tar.gz qemu-04accf43df83aa10f06f7dbda3ecf0db97f0c5a6.tar.bz2 |
oslib-posix: initialize backend memory objects in parallel
QEMU initializes preallocated backend memory as the objects are parsed from
the command line. This is not optimal in some cases (e.g. memory spanning
multiple NUMA nodes) because the memory objects are initialized in series.
Allow the initialization to occur in parallel (asynchronously). In order to
ensure optimal thread placement, asynchronous initialization requires prealloc
context threads to be in use.
Signed-off-by: Mark Kanda <mark.kanda@oracle.com>
Message-ID: <20240131165327.3154970-2-mark.kanda@oracle.com>
Tested-by: Mario Casquero <mcasquer@redhat.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/hw/qdev-core.h | 5 | ||||
-rw-r--r-- | include/qemu/osdep.h | 18 |
2 files changed, 22 insertions, 1 deletions
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index d47536e..9228e96 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -1084,6 +1084,11 @@ typedef enum MachineInitPhase { PHASE_ACCEL_CREATED, /* + * Late backend objects have been created and initialized. + */ + PHASE_LATE_BACKENDS_CREATED, + + /* * machine_class->init has been called, thus creating any embedded * devices and validating machine properties. Devices created at * this time are considered to be cold-plugged. diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index c9692cc..7d359da 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -680,6 +680,8 @@ typedef struct ThreadContext ThreadContext; * @area: start address of the are to preallocate * @sz: the size of the area to preallocate * @max_threads: maximum number of threads to use + * @tc: prealloc context threads pointer, NULL if not in use + * @async: request asynchronous preallocation, requires @tc * @errp: returns an error if this function fails * * Preallocate memory (populate/prefault page tables writable) for the virtual @@ -687,10 +689,24 @@ typedef struct ThreadContext ThreadContext; * each page in the area was faulted in writable at least once, for example, * after allocating file blocks for mapped files. * + * When setting @async, allocation might be performed asynchronously. + * qemu_finish_async_prealloc_mem() must be called to finish any asynchronous + * preallocation. + * * Return: true on success, else false setting @errp with error. */ bool qemu_prealloc_mem(int fd, char *area, size_t sz, int max_threads, - ThreadContext *tc, Error **errp); + ThreadContext *tc, bool async, Error **errp); + +/** + * qemu_finish_async_prealloc_mem: + * @errp: returns an error if this function fails + * + * Finish all outstanding asynchronous memory preallocation. + * + * Return: true on success, else false setting @errp with error. + */ +bool qemu_finish_async_prealloc_mem(Error **errp); /** * qemu_get_pid_name: |