mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-09-06 09:55:55 +00:00
memory: avoid updating ioeventfds for some address_space
When updating ioeventfds, we need to iterate all address spaces, but some address spaces do not register eventfd_add|del call when memory_listener_register() and they do nothing when updating ioeventfds. So we can skip these AS in address_space_update_ioeventfds(). The overhead of memory_region_transaction_commit() can be significantly reduced. For example, a VM with 8 vhost net devices and each one has 64 vectors, can reduce the time spent on memory_region_transaction_commit by 20%. Message-ID: <20230830032906.12488-1-hongmianquan@bytedance.com> Reviewed-by: Peter Xu <peterx@redhat.com> Signed-off-by: hongmianquan <hongmianquan@bytedance.com> Signed-off-by: David Hildenbrand <david@redhat.com>
This commit is contained in:
parent
41ddcd2308
commit
544cff46c0
|
@ -1095,6 +1095,7 @@ struct AddressSpace {
|
||||||
struct FlatView *current_map;
|
struct FlatView *current_map;
|
||||||
|
|
||||||
int ioeventfd_nb;
|
int ioeventfd_nb;
|
||||||
|
int ioeventfd_notifiers;
|
||||||
struct MemoryRegionIoeventfd *ioeventfds;
|
struct MemoryRegionIoeventfd *ioeventfds;
|
||||||
QTAILQ_HEAD(, MemoryListener) listeners;
|
QTAILQ_HEAD(, MemoryListener) listeners;
|
||||||
QTAILQ_ENTRY(AddressSpace) address_spaces_link;
|
QTAILQ_ENTRY(AddressSpace) address_spaces_link;
|
||||||
|
|
|
@ -842,6 +842,10 @@ static void address_space_update_ioeventfds(AddressSpace *as)
|
||||||
AddrRange tmp;
|
AddrRange tmp;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
|
if (!as->ioeventfd_notifiers) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* It is likely that the number of ioeventfds hasn't changed much, so use
|
* It is likely that the number of ioeventfds hasn't changed much, so use
|
||||||
* the previous size as the starting value, with some headroom to avoid
|
* the previous size as the starting value, with some headroom to avoid
|
||||||
|
@ -3075,6 +3079,10 @@ void memory_listener_register(MemoryListener *listener, AddressSpace *as)
|
||||||
}
|
}
|
||||||
|
|
||||||
listener_add_address_space(listener, as);
|
listener_add_address_space(listener, as);
|
||||||
|
|
||||||
|
if (listener->eventfd_add || listener->eventfd_del) {
|
||||||
|
as->ioeventfd_notifiers++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void memory_listener_unregister(MemoryListener *listener)
|
void memory_listener_unregister(MemoryListener *listener)
|
||||||
|
@ -3083,6 +3091,10 @@ void memory_listener_unregister(MemoryListener *listener)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (listener->eventfd_add || listener->eventfd_del) {
|
||||||
|
listener->address_space->ioeventfd_notifiers--;
|
||||||
|
}
|
||||||
|
|
||||||
listener_del_address_space(listener, listener->address_space);
|
listener_del_address_space(listener, listener->address_space);
|
||||||
QTAILQ_REMOVE(&memory_listeners, listener, link);
|
QTAILQ_REMOVE(&memory_listeners, listener, link);
|
||||||
QTAILQ_REMOVE(&listener->address_space->listeners, listener, link_as);
|
QTAILQ_REMOVE(&listener->address_space->listeners, listener, link_as);
|
||||||
|
|
Loading…
Reference in a new issue