lkml.org 
[lkml]   [2018]   [May]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [RFC v3 4/5] virtio_ring: add event idx support in packed ring
From
Date


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

\
 
 \ /
  Last update: 2018-05-08 07:41    [W:0.102 / U:0.100 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site