Thread (35 messages) 35 messages, 2 authors, 2024-04-08

Re: [PATCH vhost v6 06/10] virtio_ring: no store dma info when unmap is not needed

From: Jason Wang <hidden>
Date: 2024-03-29 03:16:50
Also in: virtualization

On Thu, Mar 28, 2024 at 3:42 PM Xuan Zhuo [off-list ref] wrote:
On Thu, 28 Mar 2024 15:06:33 +0800, Jason Wang [off-list ref] wrote:
quoted
On Wed, Mar 27, 2024 at 7:14 PM Xuan Zhuo [off-list ref] wrote:
quoted
As discussed:
http://lore.kernel.org/all/CACGkMEug-=C+VQhkMYSgUKMC==04m7-uem_yC21bgGkKZh845w@mail.gmail.com (local)

When the vq is premapped mode, the driver manages the dma
info is a good way.

So this commit make the virtio core not to store the dma
info and release the memory which is used to store the dma
info.

If the use_dma_api is false, the memory is also not allocated.

Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
---
 drivers/virtio/virtio_ring.c | 120 ++++++++++++++++++++++++++++-------
 1 file changed, 97 insertions(+), 23 deletions(-)
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index 1f7c96543d58..08e4f6e1d722 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -69,23 +69,26 @@

 struct vring_desc_state_split {
        void *data;                     /* Data for callback. */
-       struct vring_desc_extra *indir_desc;    /* Indirect descriptor, if any. */
+       struct vring_desc_dma *indir_desc;      /* Indirect descriptor, if any. */
 };

 struct vring_desc_state_packed {
        void *data;                     /* Data for callback. */
-       struct vring_desc_extra *indir_desc; /* Indirect descriptor, if any. */
+       struct vring_desc_dma *indir_desc; /* Indirect descriptor, if any. */
        u16 num;                        /* Descriptor list length. */
        u16 last;                       /* The last desc state in a list. */
 };

 struct vring_desc_extra {
-       dma_addr_t addr;                /* Descriptor DMA addr. */
-       u32 len;                        /* Descriptor length. */
        u16 flags;                      /* Descriptor flags. */
        u16 next;                       /* The next desc state in a list. */
 };

+struct vring_desc_dma {
+       dma_addr_t addr;                /* Descriptor DMA addr. */
+       u32 len;                        /* Descriptor length. */
This seems to be odd, flag should be part of dma info.
flags contains F_NEXT, that is used by detach when no dma info.
Right, so it is needed for hardening.
quoted
To reduce the changeset, I would split out next.
Do you mean split this patch set?
No, then this patch looks ok.

Thanks
Thanks


quoted
Thank
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help