<div dir="ltr">Hi Marc,<div>Currently the block job handling needs to be sorted out before events can assume independent handling from RPC contexts. <span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">Sorry, I have not been able to revisit this in the past 2 months, but this is something I would very much like to fix. I will try looking up the exact dependency of the block layer so that this series could make some progress.</span></div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><br></span></div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">regards,</span></div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">Prerna</span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 21, 2018 at 1:24 PM, Marc Hartmayer <span dir="ltr"><<a href="mailto:mhartmay@linux.vnet.ibm.com" target="_blank">mhartmay@linux.vnet.ibm.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Tue, Oct 24, 2017 at 07:34 PM +0200, Prerna Saxena <<a href="mailto:saxenap.ltc@gmail.com">saxenap.ltc@gmail.com</a>> wrote:<br>
</span><div><div class="h5">> As noted in<br>
> <a href="https://www.redhat.com/archives/libvir-list/2017-May/msg00016.html" rel="noreferrer" target="_blank">https://www.redhat.com/<wbr>archives/libvir-list/2017-May/<wbr>msg00016.html</a><br>
> libvirt-QEMU driver handles all async events from the main loop.<br>
> Each event handling needs the per-VM lock to make forward progress. In<br>
> the case where an async event is received for the same VM which has an<br>
> RPC running, the main loop is held up contending for the same lock.<br>
><br>
> This impacts scalability, and should be addressed on priority.<br>
><br>
> Note that libvirt does have a 2-step deferred handling for a few event<br>
> categories, but (1) That is insufficient since blockign happens before<br>
> the handler could disambiguate which one needs to be posted to this<br>
> other queue.<br>
> (2) There needs to be homogeniety.<br>
><br>
> The current series builds a framework for recording and handling VM<br>
> events.<br>
> It initializes per-VM event queue, and a global event queue pointing to<br>
> events from all the VMs. Event handling is staggered in 2 stages:<br>
> - When an event is received, it is enqueued in the per-VM queue as well<br>
>   as the global queues.<br>
> - The global queue is built into the QEMU Driver as a threadpool<br>
>   (currently with a single thread).<br>
> - Enqueuing of a new event triggers the global event worker thread, which<br>
>   then attempts to take a lock for this event's VM.<br>
>     - If the lock is available, the event worker runs the function handling<br>
>       this event type. Once done, it dequeues this event from the global<br>
>       as well as per-VM queues.<br>
>     - If the lock is unavailable(ie taken by RPC thread), the event worker<br>
>       thread leaves this as-is and picks up the next event.<br>
> - Once the RPC thread completes, it looks for events pertaining to the<br>
>   VM in the per-VM event queue. It then processes the events serially<br>
>   (holding the VM lock) until there are no more events remaining for<br>
>   this VM. At this point, the per-VM lock is relinquished.<br>
><br>
> Patch Series status:<br>
> Strictly RFC only. No compilation issues. I have not had a chance to<br>
> (stress) test it after rebase to latest master.<br>
> Note that documentation and test coverage is TBD, since a few open<br>
> points remain.<br>
><br>
> Known issues/ caveats:<br>
> - RPC handling time will become non-deterministic.<br>
> - An event will only be "notified" to a client once the RPC for same VM completes.<br>
> - Needs careful consideration in all cases where a QMP event is used to<br>
>   "signal" an RPC thread, else will deadlock.<br>
><br>
> Will be happy to drive more discussion in the community and completely<br>
> implement it.<br>
><br>
> Prerna Saxena (8):<br>
>   Introduce virObjectTrylock()<br>
>   QEMU Event handling: Introduce async event helpers in qemu_event.[ch]<br>
>   Setup global and per-VM event queues. Also initialize per-VM queues<br>
>     when libvirt reconnects to an existing VM.<br>
>   Events: Allow monitor to "enqueue" events to a queue. Also introduce a<br>
>     framework of handlers for each event type, that can be called when<br>
>     the handler is running an event.<br>
>   Events: Plumb event handling calls before a domain's APIs complete.<br>
>   Code refactor: Move helper functions of doCoreDump*, syncNicRxFilter*,<br>
>     and qemuOpenFile* to qemu_process.[ch]<br>
>   Fold back the 2-stage event implementation for a few events :<br>
>     Watchdog, Monitor EOF, Serial changed, Guest panic, Nic RX filter<br>
>     changed .. into single level.<br>
>   Initialize the per-VM event queues in context of domain init.<br>
><br>
>  src/Makefile.am              |    1 +<br>
>  src/conf/domain_conf.h       |    3 +<br>
>  src/libvirt_private.syms     |    1 +<br>
>  src/qemu/qemu_conf.h         |    4 +<br>
>  src/qemu/qemu_driver.c       | 1710 +++++++-----------------------<wbr>-----<br>
>  src/qemu/qemu_event.c        |  317 +++++++<br>
>  src/qemu/qemu_event.h        |  231 +++++<br>
>  src/qemu/qemu_monitor.c      |  592 ++++++++++--<br>
>  src/qemu/qemu_monitor.h      |   80 +-<br>
>  src/qemu/qemu_monitor_json.c |  291 +++---<br>
>  src/qemu/qemu_process.c      | 2031 ++++++++++++++++++++++++++++++<wbr>++++--------<br>
>  src/qemu/qemu_process.h      |   88 ++<br>
>  src/util/virobject.c         |   26 +<br>
>  src/util/virobject.h         |    4 +<br>
>  src/util/virthread.c         |    5 +<br>
>  src/util/virthread.h         |    1 +<br>
>  tests/qemumonitortestutils.c |    2 +-<br>
>  17 files changed, 3411 insertions(+), 1976 deletions(-)<br>
>  create mode 100644 src/qemu/qemu_event.c<br>
>  create mode 100644 src/qemu/qemu_event.h<br>
><br>
> --<br>
> 2.9.5<br>
><br>
</div></div><span class="">> --<br>
> libvir-list mailing list<br>
> <a href="mailto:libvir-list@redhat.com">libvir-list@redhat.com</a><br>
> <a href="https://www.redhat.com/mailman/listinfo/libvir-list" rel="noreferrer" target="_blank">https://www.redhat.com/<wbr>mailman/listinfo/libvir-list</a><br>
<br>
</span>Hey Prerna,<br>
<br>
any updates so far? :) I’m just curious about the status of this series<br>
as it would fix a performance problem we’ve.<br>
<br>
Thank you.<br>
<div class="HOEnZb"><div class="h5"><br>
Beste Grüße / Kind regards<br>
   Marc Hartmayer<br>
<br>
IBM Deutschland Research & Development GmbH<br>
Vorsitzende des Aufsichtsrats: Martina Koederitz<br>
Geschäftsführung: Dirk Wittkopp<br>
Sitz der Gesellschaft: Böblingen<br>
Registergericht: Amtsgericht Stuttgart, HRB 243294<br>
<br>
</div></div></blockquote></div><br></div>