mirror of
https://github.com/mii443/qemu.git
synced 2025-08-22 15:15:46 +00:00
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>
This commit is contained in:
committed by
David Hildenbrand
parent
540a1abbf0
commit
04accf43df
@ -20,6 +20,7 @@
|
||||
#include "qom/object_interfaces.h"
|
||||
#include "qemu/mmap-alloc.h"
|
||||
#include "qemu/madvise.h"
|
||||
#include "hw/qdev-core.h"
|
||||
|
||||
#ifdef CONFIG_NUMA
|
||||
#include <numaif.h>
|
||||
@ -237,7 +238,7 @@ static void host_memory_backend_set_prealloc(Object *obj, bool value,
|
||||
uint64_t sz = memory_region_size(&backend->mr);
|
||||
|
||||
if (!qemu_prealloc_mem(fd, ptr, sz, backend->prealloc_threads,
|
||||
backend->prealloc_context, errp)) {
|
||||
backend->prealloc_context, false, errp)) {
|
||||
return;
|
||||
}
|
||||
backend->prealloc = true;
|
||||
@ -323,6 +324,7 @@ host_memory_backend_memory_complete(UserCreatable *uc, Error **errp)
|
||||
HostMemoryBackendClass *bc = MEMORY_BACKEND_GET_CLASS(uc);
|
||||
void *ptr;
|
||||
uint64_t sz;
|
||||
bool async = !phase_check(PHASE_LATE_BACKENDS_CREATED);
|
||||
|
||||
if (!bc->alloc) {
|
||||
return;
|
||||
@ -402,7 +404,8 @@ host_memory_backend_memory_complete(UserCreatable *uc, Error **errp)
|
||||
if (backend->prealloc && !qemu_prealloc_mem(memory_region_get_fd(&backend->mr),
|
||||
ptr, sz,
|
||||
backend->prealloc_threads,
|
||||
backend->prealloc_context, errp)) {
|
||||
backend->prealloc_context,
|
||||
async, errp)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user