Skip to content
  • Paolo Bonzini's avatar
    7258ed93
    throttle-groups: only start one coroutine from drained_begin · 7258ed93
    Paolo Bonzini authored
    
    
    Starting all waiting coroutines from bdrv_drain_all is unnecessary;
    throttle_group_co_io_limits_intercept calls schedule_next_request as
    soon as the coroutine restarts, which in turn will restart the next
    request if possible.
    
    If we only start the first request and let the coroutines dance from
    there the code is simpler and there is more reuse between
    throttle_group_config, throttle_group_restart_blk and timer_cb.  The
    next patch will benefit from this.
    
    We also stop accessing from throttle_group_restart_blk the
    blkp->throttled_reqs CoQueues even when there was no
    attached throttling group.  This worked but is not pretty.
    
    The only thing that can interrupt the dance is the QEMU_CLOCK_VIRTUAL
    timer when switching from one block device to the next, because the
    timer is set to "now + 1" but QEMU_CLOCK_VIRTUAL might not be running.
    Set that timer to point in the present ("now") rather than the future
    and things work.
    
    Reviewed-by: default avatarAlberto Garcia <berto@igalia.com>
    Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    Message-Id: <20170605123908.18777-8-pbonzini@redhat.com>
    Signed-off-by: default avatarFam Zheng <famz@redhat.com>
    7258ed93
    throttle-groups: only start one coroutine from drained_begin
    Paolo Bonzini authored
    
    
    Starting all waiting coroutines from bdrv_drain_all is unnecessary;
    throttle_group_co_io_limits_intercept calls schedule_next_request as
    soon as the coroutine restarts, which in turn will restart the next
    request if possible.
    
    If we only start the first request and let the coroutines dance from
    there the code is simpler and there is more reuse between
    throttle_group_config, throttle_group_restart_blk and timer_cb.  The
    next patch will benefit from this.
    
    We also stop accessing from throttle_group_restart_blk the
    blkp->throttled_reqs CoQueues even when there was no
    attached throttling group.  This worked but is not pretty.
    
    The only thing that can interrupt the dance is the QEMU_CLOCK_VIRTUAL
    timer when switching from one block device to the next, because the
    timer is set to "now + 1" but QEMU_CLOCK_VIRTUAL might not be running.
    Set that timer to point in the present ("now") rather than the future
    and things work.
    
    Reviewed-by: default avatarAlberto Garcia <berto@igalia.com>
    Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    Message-Id: <20170605123908.18777-8-pbonzini@redhat.com>
    Signed-off-by: default avatarFam Zheng <famz@redhat.com>
Loading