• Paolo Bonzini's avatar
    AioContext: speed up aio_notify · 0ceb849b
    Paolo Bonzini authored
    In many cases, the call to event_notifier_set in aio_notify is unnecessary.
    In particular, if we are executing aio_dispatch, or if aio_poll is not
    blocking, we know that we will soon get to the next loop iteration (if
    necessary); the thread that hosts the AioContext's event loop does not
    need any nudging.
    
    The patch includes a Promela formal model that shows that this really
    works and does not need any further complication such as generation
    counts.  It needs a memory barrier though.
    
    The generation counts are not needed because any change to
    ctx->dispatching after the memory barrier is okay for aio_notify.
    If it changes from zero to one, it is the right thing to skip
    event_notifier_set.  If it changes from one to zero, the
    event_notifier_set is unnecessary but harmless.
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
    0ceb849b
aio-posix.c 7.57 KB