Re: [RFC v3 4/5] virtio_ring: add event idx support in packed ring

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 2018年05月08日 11:05, Jason Wang wrote:

Because in virtqueue_enable_cb_delayed(), we may set an
event_off which is bigger than new and both of them have
wrapped. And in this case, although new is smaller than
event_off (i.e. the third param -- old), new shouldn't
add vq->num, and actually we are expecting a very big
idx diff.

Yes, so to calculate distance correctly between event and new, we just need to compare the warp counter and return false if it doesn't match without the need to try to add vq.num here.

Thanks

Sorry, looks like the following should work, we need add vq.num if used_wrap_counter does not match:

static bool vhost_vring_packed_need_event(struct vhost_virtqueue *vq,
                      __u16 off_wrap, __u16 new,
                      __u16 old)
{
    bool wrap = off_wrap >> 15;
    int off = off_wrap & ~(1 << 15);
    __u16 d1, d2;

    if (wrap != vq->used_wrap_counter)
        d1 = new + vq->num - off - 1;
    else
        d1 = new - off - 1;

    if (new > old)
        d2 = new - old;
    else
        d2 = new + vq->num - old;

    return d1 < d2;
}

Thanks

_______________________________________________
Virtualization mailing list
Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linuxfoundation.org/mailman/listinfo/virtualization




[Index of Archives]     [KVM Development]     [Libvirt Development]     [Libvirt Users]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux