On Thu, Sep 12, 2024 at 3:43 PM Xuan Zhuo <xuanzhuo@xxxxxxxxxxxxxxxxx> wrote: > > On Wed, 11 Sep 2024 11:54:25 +0800, Jason Wang <jasowang@xxxxxxxxxx> wrote: > > On Tue, Aug 20, 2024 at 3:33 PM Xuan Zhuo <xuanzhuo@xxxxxxxxxxxxxxxxx> wrote: > > > > > > The current configuration sets the virtqueue (vq) to premapped mode, > > > implying that all buffers submitted to this queue must be mapped ahead > > > of time. This presents a challenge for the virtnet send queue (sq): the > > > virtnet driver would be required to keep track of dma information for vq > > > size * 17, which can be substantial. However, if the premapped mode were > > > applied on a per-buffer basis, the complexity would be greatly reduced. > > > With AF_XDP enabled, AF_XDP buffers would become premapped, while kernel > > > skb buffers could remain unmapped. > > > > Is this only applied to TX or both TX and RX. > > > For rx, if you mean per-buffer dma buffer, I think it is yes, > rx can reuse this. If you mean should we do premapped for the > normal rx buffers, I think we should, that can reduce the > dma map operations. > > > > > > > > > > We can distinguish them by sg_page(sg), When sg_page(sg) is NULL, this > > > indicates that the driver has performed DMA mapping in advance, allowing > > > the Virtio core to directly utilize sg_dma_address(sg) without > > > conducting any internal DMA mapping. > > > > This seems conflict with the code below? > > > > #define sg_is_premapped(sg) (!sg_page(sg)) > > Sorry, I do not get for you. > > The key point is that the sg->page is setted by driver. Ok, I forget that but let's document this assumption in the changelog. > > So I mean if the driver sets sg->page = NULL, then for this sg, > the virtio core can skip dma mapping. If the driver sets > sg->page to the page of the buffer, then the virtio core should > do dma mapping for this sg. > Ok, let's describe this in the changelog. Thanks