On 2018å04æ25æ 13:15, Tiwei Bie wrote:
+ÂÂÂ /* We're using some buffers from the free list. */
+ÂÂÂ vq->vq.num_free -= descs_used;
+
+ÂÂÂ /* Update free pointer */
+ÂÂÂ if (indirect) {
+ÂÂÂÂÂÂÂ n = head + 1;
+ÂÂÂÂÂÂÂ if (n >= vq->vring_packed.num) {
+ÂÂÂÂÂÂÂÂÂÂÂ n = 0;
+ÂÂÂÂÂÂÂÂÂÂÂ vq->wrap_counter ^= 1;
+ÂÂÂÂÂÂÂ }
+ÂÂÂÂÂÂÂ vq->next_avail_idx = n;
+ÂÂÂ } else
+ÂÂÂÂÂÂÂ vq->next_avail_idx = i;
During testing zerocopy (out of order completion), I found driver may submit two identical buffer id to vhost. So the above code may not work well.
Consider the case that driver adds 3 buffer and virtqueue size is 8.
a) id = 0,count = 2,next_avail = 2
b) id = 2,count = 4,next_avail = 2
c) id = 4,count = 2,next_avail = 0
if packet b is done before packet a, driver may think buffer id 0 is available and try to use it if even if the real buffer 0 was not done.
Thanks
_______________________________________________
Virtualization mailing list
Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linuxfoundation.org/mailman/listinfo/virtualization