:Why vring size is limited to 1024?
Hi,
There exits packets loss when we do packet forwarding in VM, especially when we use dpdk to do the forwarding. By enlarging vring can alleviate the problem. But now vring size is limited to 1024 as follows:
VirtQueue *virtio_add_queue(VirtIODevice *vdev, int queue_size,
void (*handle_output)(VirtIODevice *, VirtQueue *))
{
...
if (i == VIRTIO_PCI_QUEUE_MAX || queue_size > VIRTQUEUE_MAX_SIZE)
abort();
}ps:#define VIRTQUEUE_MAX_SIZE 1024
I delete the judgement code, and set vring size to 2048, VM can be successfully started, and the network is ok too. So, Why vring size is limited to 1024 and what is the influence?
Thanks!
Signature · 2 lines
Best Wishes! Zhang Jie
Quoted 4 lines · Zhangjie (HZ)
Hi,
There exits packets loss when we do packet forwarding in VM, especially when we use dpdk to do the forwarding. By enlarging vring can alleviate the problem.
I think this has to do with the fact that dpdk disables checksum offloading, this has the side effect of disabling segmentation offloading.
Please fix dpdk to support checksum offloading, and I think the problem will go away.
Quoted 8 lines
But now vring size is limited to 1024 as follows:
VirtQueue *virtio_add_queue(VirtIODevice *vdev, intqueue_size,
void (*handle_output)(VirtIODevice *, VirtQueue *)){ ... if (i == VIRTIO_PCI_QUEUE_MAX || queue_size > VIRTQUEUE_MAX_SIZE) abort(); }
Quoted 6 lines
ps:#define
VIRTQUEUE_MAX_SIZE1024
I delete the judgement code, and set vring size to 2048, VM can be successfully started, and the network is ok too. So, Why vring size is limited to 1024 and what is the influence?Thanks!
There are several reason for this limit.
First guest has to allocate descriptor buffer which is 16 * vring size. With 1K size that is already 16K which might be tricky to allocate contigiously if memory is fragmented when device is added by hotplug.
The second issue is that we want to be able to implement
the device on top of linux kernel, and
a single descriptor might use all of
the virtqueue. In this case we wont to be able to pass the descriptor directly to linux as a single iov, since
that is limited to 1K entries.
Quoted 3 lines
Signature · 2 lines
Best Wishes! Zhang Jie
Thanks for your patient answer! :-)
Quoted 6 lines · Michael S. Tsirkin
Quoted 4 lines · Zhangjie (HZ)
Hi,
There exits packets loss when we do packet forwarding in VM, especially when we use dpdk to do the forwarding. By enlarging vring can alleviate the problem.
Quoted 6 lines
I think this has to do with the fact that dpdk disables checksum offloading, this has the side effect of disabling segmentation offloading.
Please fix dpdk to support checksum offloading, and I think the problem will go away.
In some application scene, loss of udp packets are not allowed,
and udp packets are always short than mtu.
So, we need to support high pps(eg.0.3M Packets/s) forwarding, and offloading cannot fix it.
Quoted 15 lines
Quoted 15 lines
But now vring size is limited to 1024 as follows:
VirtQueue *virtio_add_queue(VirtIODevice *vdev, intqueue_size,
void (*handle_output)(VirtIODevice *, VirtQueue *)){ ... if (i == VIRTIO_PCI_QUEUE_MAX || queue_size > VIRTQUEUE_MAX_SIZE) abort(); }ps:#define
VIRTQUEUE_MAX_SIZE1024
I delete the judgement code, and set vring size to 2048, VM can be successfully started, and the network is ok too. So, Why vring size is limited to 1024 and what is the influence?
Quoted 7 lines
Quoted 1 line
Thanks!
There are several reason for this limit.
First guest has to allocate descriptor buffer which is 16 * vring size. With 1K size that is already 16K which might be tricky to allocate contigiously if memory is fragmented when device is added by hotplug.
That is very
Quoted 6 lines
The second issue is that we want to be able to implement the device on top of linux kernel, and
a single descriptor might use all of
the virtqueue. In this case we wont to be able to pass the descriptor directly to linux as a single iov, since that is limited to 1K entries.
For the second issue, I wonder if it is ok to set vring size of virtio-net to large than 1024, as for net work, there is at most 18 pages for a skb, it will not exceed iov.
Quoted 6 lines
Quoted 4 lines
Signature · 3 lines
-- Best Wishes! Zhang Jie.
Signature · 2 lines
Best Wishes! Zhang Jie
Quoted 13 lines · Zhangjie (HZ)
Thanks for your patient answer! :-)
Quoted 10 lines · Michael S. Tsirkin
Quoted 4 lines · Zhangjie (HZ)
Hi,
There exits packets loss when we do packet forwarding in VM, especially when we use dpdk to do the forwarding. By enlarging vring can alleviate the problem.I think this has to do with the fact that dpdk disables checksum offloading, this has the side effect of disabling segmentation offloading.
Quoted 6 lines
Quoted 2 lines
Please fix dpdk to support checksum offloading, and I think the problem will go away.
In some application scene, loss of udp packets are not allowed,
and udp packets are always short than mtu.
So, we need to support high pps(eg.0.3M Packets/s) forwarding, and offloading cannot fix it.
That's the point. With UFO you get larger than MTU UDP packets:
http://www.linuxfoundation.org/collaborate/workgroups/networking/ufo
Additionally, checksum offloading reduces CPU utilization and reduces the number of data copies, allowing higher pps with smaller buffers.
It might look like queue depth helps performance for netperf, but in real-life workloads the latency under load will suffer, with more protocols implementing tunnelling on top of UDP such extreme bufferbloat will not be tolerated.
Quoted 41 lines
Quoted 15 lines
Quoted 15 lines
But now vring size is limited to 1024 as follows:
VirtQueue *virtio_add_queue(VirtIODevice *vdev, intqueue_size,
void (*handle_output)(VirtIODevice *, VirtQueue *)){ ... if (i == VIRTIO_PCI_QUEUE_MAX || queue_size > VIRTQUEUE_MAX_SIZE) abort(); }ps:#define
VIRTQUEUE_MAX_SIZE1024
I delete the judgement code, and set vring size to 2048, VM can be successfully started, and the network is ok too. So, Why vring size is limited to 1024 and what is the influence?Quoted 7 lines
Quoted 1 line
Thanks!
There are several reason for this limit.
First guest has to allocate descriptor buffer which is 16 * vring size. With 1K size that is already 16K which might be tricky to allocate contigiously if memory is fragmented when device is added by hotplug.That is very
Quoted 6 lines
The second issue is that we want to be able to implement the device on top of linux kernel, and
a single descriptor might use all of
the virtqueue. In this case we wont to be able to pass the descriptor directly to linux as a single iov, since that is limited to 1K entries.For the second issue, I wonder if it is ok to set vring size of virtio-net to large than 1024, as for net work, there is at most 18 pages for a skb, it will not exceed iov.
Quoted 6 lines
Quoted 4 lines
Signature · 3 lines
-- Best Wishes! Zhang Jie.
Signature · 2 lines
Best Wishes! Zhang Jie
MST, Thanks very much, I get it.
Quoted 16 lines · Michael S. Tsirkin
Quoted 15 lines · Zhangjie (HZ)
Thanks for your patient answer! :-)
Quoted 12 lines · Michael S. Tsirkin
Quoted 4 lines · Zhangjie (HZ)
Hi,
There exits packets loss when we do packet forwarding in VM, especially when we use dpdk to do the forwarding. By enlarging vring can alleviate the problem.I think this has to do with the fact that dpdk disables checksum offloading, this has the side effect of disabling segmentation offloading.
Please fix dpdk to support checksum offloading, and I think the problem will go away.
Quoted 7 lines
Quoted 4 lines
In some application scene, loss of udp packets are not allowed,
and udp packets are always short than mtu.
So, we need to support high pps(eg.0.3M Packets/s) forwarding, and offloading cannot fix it.That's the point. With UFO you get larger than MTU UDP packets:
http://www.linuxfoundation.org/collaborate/workgroups/networking/ufo
Then vm only do forwarding, and not create new packets itself.
As we can not gro normal udp packets, when udp packets come from the nic of host, ufo cannot work.
Quoted 53 lines
Additionally, checksum offloading reduces CPU utilization and reduces the number of data copies, allowing higher pps with smaller buffers.
It might look like queue depth helps performance for netperf, but in real-life workloads the latency under load will suffer, with more protocols implementing tunnelling on top of UDP such extreme bufferbloat will not be tolerated.
Quoted 29 lines
Quoted 15 lines
Quoted 15 lines
But now vring size is limited to 1024 as follows:
VirtQueue *virtio_add_queue(VirtIODevice *vdev, intqueue_size,
void (*handle_output)(VirtIODevice *, VirtQueue *)){ ... if (i == VIRTIO_PCI_QUEUE_MAX || queue_size > VIRTQUEUE_MAX_SIZE) abort(); }ps:#define
VIRTQUEUE_MAX_SIZE1024
I delete the judgement code, and set vring size to 2048, VM can be successfully started, and the network is ok too. So, Why vring size is limited to 1024 and what is the influence?Quoted 7 lines
Quoted 1 line
Thanks!
There are several reason for this limit.
First guest has to allocate descriptor buffer which is 16 * vring size. With 1K size that is already 16K which might be tricky to allocate contigiously if memory is fragmented when device is added by hotplug.That is very
Quoted 6 lines
The second issue is that we want to be able to implement the device on top of linux kernel, and
a single descriptor might use all of
the virtqueue. In this case we wont to be able to pass the descriptor directly to linux as a single iov, since that is limited to 1K entries.Quoted 12 lines
For the second issue, I wonder if it is ok to set vring size of virtio-net to large than 1024, as for net work, there is at most 18 pages for a skb, it will not exceed iov.
Quoted 6 lines
Quoted 4 lines
Signature · 3 lines
-- Best Wishes! Zhang Jie.
Signature · 2 lines
Best Wishes! Zhang Jie.
Signature · 2 lines
Best Wishes! Zhang Jie
Quoted 24 lines · Zhangjie (HZ)
MST, Thanks very much, I get it.
Quoted 21 lines · Michael S. Tsirkin
Quoted 19 lines · Zhangjie (HZ)
Thanks for your patient answer! :-)
Quoted 6 lines · Michael S. Tsirkin
Quoted 4 lines · Zhangjie (HZ)
Hi,
There exits packets loss when we do packet forwarding in VM, especially when we use dpdk to do the forwarding. By enlarging vring can alleviate the problem.Quoted 6 lines
I think this has to do with the fact that dpdk disables checksum offloading, this has the side effect of disabling segmentation offloading.
Please fix dpdk to support checksum offloading, and I think the problem will go away.
In some application scene, loss of udp packets are not allowed,
and udp packets are always short than mtu.
So, we need to support high pps(eg.0.3M Packets/s) forwarding, and offloading cannot fix it.
Quoted 4 lines
Quoted 2 lines
That's the point. With UFO you get larger than MTU UDP packets:
http://www.linuxfoundation.org/collaborate/workgroups/networking/ufoThen vm only do forwarding, and not create new packets itself.
As we can not gro normal udp packets, when udp packets come from the nic of host, ufo cannot work.
This is something I've been thinking about for a while now. We really should add GRO-like path for UDP, this isn't too different from UDP.
LRO can often work with UDP too, but linux discards too much info on LRO, but if you are doing drivers in userspace you might be able to support this.
Quoted 57 lines
Quoted 53 lines
Additionally, checksum offloading reduces CPU utilization and reduces the number of data copies, allowing higher pps with smaller buffers.
It might look like queue depth helps performance for netperf, but in real-life workloads the latency under load will suffer, with more protocols implementing tunnelling on top of UDP such extreme bufferbloat will not be tolerated.
Quoted 29 lines
Quoted 15 lines
Quoted 15 lines
But now vring size is limited to 1024 as follows:
VirtQueue *virtio_add_queue(VirtIODevice *vdev, intqueue_size,
void (*handle_output)(VirtIODevice *, VirtQueue *)){ ... if (i == VIRTIO_PCI_QUEUE_MAX || queue_size > VIRTQUEUE_MAX_SIZE) abort(); }ps:#define
VIRTQUEUE_MAX_SIZE1024
I delete the judgement code, and set vring size to 2048, VM can be successfully started, and the network is ok too. So, Why vring size is limited to 1024 and what is the influence?Quoted 7 lines
Quoted 1 line
Thanks!
There are several reason for this limit.
First guest has to allocate descriptor buffer which is 16 * vring size. With 1K size that is already 16K which might be tricky to allocate contigiously if memory is fragmented when device is added by hotplug.That is very
Quoted 6 lines
The second issue is that we want to be able to implement the device on top of linux kernel, and
a single descriptor might use all of
the virtqueue. In this case we wont to be able to pass the descriptor directly to linux as a single iov, since that is limited to 1K entries.Quoted 12 lines
For the second issue, I wonder if it is ok to set vring size of virtio-net to large than 1024, as for net work, there is at most 18 pages for a skb, it will not exceed iov.
Quoted 6 lines
Quoted 4 lines
Signature · 3 lines
-- Best Wishes! Zhang Jie.
Signature · 2 lines
Best Wishes! Zhang Jie.
Signature · 2 lines
Best Wishes! Zhang Jie
Quoted 4 lines · Michael S. Tsirkin
a single descriptor might use all of
the virtqueue. In this case we wont to be able to pass the descriptor directly to linux as a single iov, since
You could separate maximum request scatter/gather list size from the virtqueue size. They are totally unrelated - even now you can have a larger request by using indirect descriptors.
Quoted 3 lines · Avi Kivity
Quoted 1 line
You could separate maximum request scatter/gather list size from the virtqueue size. They are totally unrelated - even now you can have a larger request by using indirect descriptors.
Yes, there is no strong correlation between virtqueue size and iov form the code.
Signature · 2 lines
Best Wishes! Zhang Jie
Quoted 10 lines · Avi Kivity
Quoted 4 lines · Michael S. Tsirkin
a single descriptor might use all of
the virtqueue. In this case we wont to be able to pass the descriptor directly to linux as a single iov, sinceYou could separate maximum request scatter/gather list size from the virtqueue size. They are totally unrelated - even now you can have a larger request by using indirect descriptors.
We could add a feature to have a smaller or larger S/G length limit. Is this something useful?
Signature · 1 line
MST
Quoted 6 lines · Michael S. Tsirkin
Quoted 5 lines · Avi Kivity
Quoted 4 lines · Michael S. Tsirkin
a single descriptor might use all of
the virtqueue. In this case we wont to be able to pass the descriptor directly to linux as a single iov, since
Quoted 6 lines
Quoted 3 lines
You could separate maximum request scatter/gather list size from the virtqueue size. They are totally unrelated - even now you can have a larger request by using indirect descriptors.
We could add a feature to have a smaller or larger S/G length limit. Is this something useful?
Having a larger ring size is useful, esp. with zero-copy transmit, and you would need the sglist length limit in order to not require linearization on linux hosts. So the limit is not useful in itself, only indirectly.
Google cloud engine exposes virtio ring sizes of 16384.
Even more useful is getting rid of the desc array and instead passing descs inline in avail and used.
Quoted 15 lines · Avi Kivity
Quoted 6 lines · Michael S. Tsirkin
Quoted 5 lines · Avi Kivity
Quoted 4 lines · Michael S. Tsirkin
a single descriptor might use all of
the virtqueue. In this case we wont to be able to pass the descriptor directly to linux as a single iov, sinceQuoted 6 lines
Quoted 3 lines
You could separate maximum request scatter/gather list size from the virtqueue size. They are totally unrelated - even now you can have a larger request by using indirect descriptors.
We could add a feature to have a smaller or larger S/G length limit. Is this something useful?
Quoted 5 lines
Having a larger ring size is useful, esp. with zero-copy transmit, and you would need the sglist length limit in order to not require linearization on linux hosts. So the limit is not useful in itself, only indirectly.
Google cloud engine exposes virtio ring sizes of 16384.
OK this sounds useful, I'll queue this up for consideration. Thanks!
Quoted 2 lines
Even more useful is getting rid of the desc array and instead passing descs inline in avail and used.
You expect this to improve performance?
Quite possibly but this will have to be demonstrated.
Signature · 1 line
MST
Quoted 14 lines · Michael S. Tsirkin
Quoted 13 lines · Avi Kivity
Quoted 12 lines · Michael S. Tsirkin
Quoted 8 lines · Avi Kivity
Quoted 4 lines · Michael S. Tsirkin
a single descriptor might use all of
the virtqueue. In this case we wont to be able to pass the descriptor directly to linux as a single iov, sinceYou could separate maximum request scatter/gather list size from the virtqueue size. They are totally unrelated - even now you can have a larger request by using indirect descriptors.
We could add a feature to have a smaller or larger S/G length limit. Is this something useful?
Quoted 7 lines
Quoted 5 lines
Having a larger ring size is useful, esp. with zero-copy transmit, and you would need the sglist length limit in order to not require linearization on linux hosts. So the limit is not useful in itself, only indirectly.
Google cloud engine exposes virtio ring sizes of 16384.
OK this sounds useful, I'll queue this up for consideration. Thanks!
Thanks.
Quoted 5 lines
Quoted 2 lines
Even more useful is getting rid of the desc array and instead passing descs inline in avail and used.
You expect this to improve performance?
Quite possibly but this will have to be demonstrated.
The top vhost function in small packet workloads is vhost_get_vq_desc, and the top instruction within that (50%) is the one that reads the first 8 bytes of desc. It's a guaranteed cache line miss (and again on the guest side when it's time to reuse).
Inline descriptors will amortize the cache miss over 4 descriptors, and will allow the hardware to prefetch, since the descriptors are linear in memory.
Quoted 28 lines · Avi Kivity
Quoted 14 lines · Michael S. Tsirkin
Quoted 13 lines · Avi Kivity
Quoted 12 lines · Michael S. Tsirkin
Quoted 8 lines · Avi Kivity
Quoted 4 lines · Michael S. Tsirkin
a single descriptor might use all of
the virtqueue. In this case we wont to be able to pass the descriptor directly to linux as a single iov, sinceYou could separate maximum request scatter/gather list size from the virtqueue size. They are totally unrelated - even now you can have a larger request by using indirect descriptors.
We could add a feature to have a smaller or larger S/G length limit. Is this something useful?
Quoted 7 lines
Quoted 5 lines
Having a larger ring size is useful, esp. with zero-copy transmit, and you would need the sglist length limit in order to not require linearization on linux hosts. So the limit is not useful in itself, only indirectly.
Google cloud engine exposes virtio ring sizes of 16384.
OK this sounds useful, I'll queue this up for consideration. Thanks!
Thanks.
Quoted 2 lines
Quoted 2 lines
Even more useful is getting rid of the desc array and instead passing descs inline in avail and used.
Quoted 8 lines
Quoted 3 lines
You expect this to improve performance?
Quite possibly but this will have to be demonstrated.The top vhost function in small packet workloads is
vhost_get_vq_desc, and the top instruction within that (50%) is the one that reads the first 8 bytes of desc. It's a guaranteed cache line miss (and again on the guest side when it's time to reuse).
OK so basically what you are pointing out is that we get 5 accesses:
read of available head, read of available ring, read of descriptor, write of used ring, write of used ring head.
If processing is in-order, we could build a much simpler design, with a valid bit in the descriptor, cleared by host as descriptors are consumed.
Basically get rid of both used and available ring.
Sounds good in theory.
Quoted 2 lines
Inline descriptors will amortize the cache miss over 4 descriptors, and will allow the hardware to prefetch, since the descriptors are linear in memory.
If descriptors are used in order (as they are with current qemu) then aren't they amortized already?
Signature · 1 line
MST
Quoted 5 lines · Michael S. Tsirkin
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Even more useful is getting rid of the desc array and instead passing descs inline in avail and used.
You expect this to improve performance?
Quite possibly but this will have to be demonstrated.
Quoted 7 lines
Quoted 4 lines
The top vhost function in small packet workloads is
vhost_get_vq_desc, and the top instruction within that (50%) is the one that reads the first 8 bytes of desc. It's a guaranteed cache line miss (and again on the guest side when it's time to reuse).OK so basically what you are pointing out is that we get 5 accesses:
read of available head, read of available ring, read of descriptor, write of used ring, write of used ring head.
Right. And only read of descriptor is not amortized.
Quoted 5 lines
If processing is in-order, we could build a much simpler design, with a valid bit in the descriptor, cleared by host as descriptors are consumed.
Basically get rid of both used and available ring.
That only works if you don't allow reordering, which is never the case for block, and not the case for zero-copy net. It also has writers on both side of the ring.
The right design is to keep avail and used, but instead of making them rings of pointers to descs, make them rings of descs.
The host reads descs from avail, processes them, then writes them back on used (possibly out-of-order). The guest writes descs to avail and reads them back from used.
You'll probably have to add a 64-bit cookie to desc so you can complete without an additional lookup.
Quoted 8 lines
Sounds good in theory.
Quoted 2 lines
Inline descriptors will amortize the cache miss over 4 descriptors, and will allow the hardware to prefetch, since the descriptors are linear in memory.
If descriptors are used in order (as they are with current qemu) then aren't they amortized already?
Quoted 30 lines · Avi Kivity
Quoted 5 lines · Michael S. Tsirkin
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Even more useful is getting rid of the desc array and instead passing descs inline in avail and used.
You expect this to improve performance?
Quite possibly but this will have to be demonstrated.Quoted 7 lines
Quoted 4 lines
The top vhost function in small packet workloads is
vhost_get_vq_desc, and the top instruction within that (50%) is the one that reads the first 8 bytes of desc. It's a guaranteed cache line miss (and again on the guest side when it's time to reuse).OK so basically what you are pointing out is that we get 5 accesses:
read of available head, read of available ring, read of descriptor, write of used ring, write of used ring head.Right. And only read of descriptor is not amortized.
Quoted 5 lines
If processing is in-order, we could build a much simpler design, with a valid bit in the descriptor, cleared by host as descriptors are consumed.
Basically get rid of both used and available ring.
That only works if you don't allow reordering, which is never the case for block, and not the case for zero-copy net. It also has writers on both side of the ring.
The right design is to keep avail and used, but instead of making them rings of pointers to descs, make them rings of descs.
Quoted 6 lines
The host reads descs from avail, processes them, then writes them back on used (possibly out-of-order). The guest writes descs to avail and reads them back from used.
You'll probably have to add a 64-bit cookie to desc so you can complete without an additional lookup.
My old presentation from 2012 or so suggested something like this. We don't need a 64 bit cookie I think - a small 16 bit one should be enough.
Quoted 8 lines
Quoted 8 lines
Sounds good in theory.
Quoted 2 lines
Inline descriptors will amortize the cache miss over 4 descriptors, and will allow the hardware to prefetch, since the descriptors are linear in memory.
If descriptors are used in order (as they are with current qemu) then aren't they amortized already?
Quoted 32 lines · Michael S. Tsirkin
Quoted 31 lines · Avi Kivity
Quoted 5 lines · Michael S. Tsirkin
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Even more useful is getting rid of the desc array and instead passing descs inline in avail and used.
You expect this to improve performance?
Quite possibly but this will have to be demonstrated.Quoted 7 lines
Quoted 4 lines
The top vhost function in small packet workloads is
vhost_get_vq_desc, and the top instruction within that (50%) is the one that reads the first 8 bytes of desc. It's a guaranteed cache line miss (and again on the guest side when it's time to reuse).OK so basically what you are pointing out is that we get 5 accesses:
read of available head, read of available ring, read of descriptor, write of used ring, write of used ring head.Right. And only read of descriptor is not amortized.
Quoted 5 lines
If processing is in-order, we could build a much simpler design, with a valid bit in the descriptor, cleared by host as descriptors are consumed.
Basically get rid of both used and available ring.
That only works if you don't allow reordering, which is never the case for block, and not the case for zero-copy net. It also has writers on both side of the ring.
The right design is to keep avail and used, but instead of making them rings of pointers to descs, make them rings of descs.
The host reads descs from avail, processes them, then writes them back on used (possibly out-of-order). The guest writes descs to avail and reads them back from used.
Quoted 6 lines
Quoted 2 lines
You'll probably have to add a 64-bit cookie to desc so you can complete without an additional lookup.
My old presentation from 2012 or so suggested something like this. We don't need a 64 bit cookie I think - a small 16 bit one should be enough.
A 16 bit cookie means you need an extra table to hold the real request pointers.
With a 64-bit cookie you can store a pointer to the skbuff or bio in the ring itself, and avoid the extra lookup.
The extra lookup isn't the end of the world, since doesn't cross core boundaries, but it's worth avoiding.
Quoted 11 lines · Avi Kivity
My old presentation from 2012 or so suggested something like this.
Quoted 3 lines
We don't need a 64 bit cookie I think - a small 16 bit one should be enough.
A 16 bit cookie means you need an extra table to hold the real request pointers.
With a 64-bit cookie you can store a pointer to the skbuff or bio in the ring itself, and avoid the extra lookup.
The extra lookup isn't the end of the world, since doesn't cross core boundaries, but it's worth avoiding.
What you can do is have two types of descriptors: head and fragment
union desc {
struct head {
u16 nfrags
u16 flags
u64 cookie
}
struct frag {
u64 paddr
u16 flen
u16 flags
}
}so now a request length is 12*(nfrags+1).
You can be evil and steal some bits from paddr/cookie, and have each descriptor 8 bytes long.
btw, I also recommend storing things like vnet_hdr in the ring itself, instead of out-of-line in memory. Maybe the ring should just transport bytes and let the upper layer decide how it's formatted.
Quoted 6 lines · Michael S. Tsirkin
Quoted 3 lines
Inline descriptors will amortize the cache miss over 4 descriptors, and will allow the hardware to prefetch, since the descriptors are linear in memory.
If descriptors are used in order (as they are with current qemu) then aren't they amortized already?
The descriptors are only in-order for non-zero-copy net. They are out of order for block and zero-copy net.
(also, the guest has to be careful in how it allocates descriptors).