This patch has been successfully tested by QE. After configuring two memory-backends with preallocation context objects, binded to two host nodes; the result is QEMU being at least three times faster than before.
# time /usr/libexec/qemu-kvm -M q35 -m 16G,maxmem=32G -numa node,memdev=mem0,nodeid=0 -numa node,memdev=mem1,nodeid=1 -object thread-context,id=tc1,node-affinity=0 -object thread-context,id=tc2,node-affinity=1 -object memory-backend-ram,id=mem0,size=8G,policy=bind,host-nodes=0 -object memory-backend-ram,id=mem1,size=8G,policy=bind,host-nodes=1 -nographic -monitor stdio QEMU 8.2.0 monitor - type 'help' for more information qemu-kvm: cannot use stdio by multiple character devices qemu-kvm: could not connect serial device to character backend 'stdio' real 0m0.038s user 0m0.013s sys 0m0.005s # time /home/qemu/build/qemu-system-x86_64 -M q35 -m 16G,maxmem=32G -numa node,memdev=mem0,nodeid=0 -numa node,memdev=mem1,nodeid=1 -object thread-context,id=tc1,node-affinity=0 -object thread-context,id=tc2,node-affinity=1 -object memory-backend-ram,id=mem0,size=8G,policy=bind,host-nodes=0 -object memory-backend-ram,id=mem1,size=8G,policy=bind,host-nodes=1 -nographic -monitor stdio QEMU 8.2.50 monitor - type 'help' for more information qemu-system-x86_64: cannot use stdio by multiple character devices qemu-system-x86_64: could not connect serial device to character backend 'stdio' real 0m0.012s user 0m0.006s sys 0m0.007s Tested-by: Mario Casquero <mcasq...@redhat.com> On Wed, Jan 31, 2024 at 7:24 PM David Hildenbrand <da...@redhat.com> wrote: > > On 31.01.24 17:53, Mark Kanda wrote: > > 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.ka...@oracle.com> > > Signed-off-by: David Hildenbrand <da...@redhat.com> > > --- > > So, this LGTM. There might be ways to not rely on phases to achieve what > we want to achieve (e.g., let the machine set an internal property on > memory backends we create from the cmdline), but this should do as well. > > I'll wait a bit for more feedback. If there is none, I'll route this > through my tree (after doing a quick sanity test). > > Thanks! > > -- > Cheers, > > David / dhildenb > >