[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-netdev
Subject:    Re: Re: [RFC v2 09/13] vduse: Add support for processing vhost iotlb message
From:       Yongji Xie <xieyongji () bytedance ! com>
Date:       2020-12-31 8:00:38
Message-ID: CACycT3td8uSZOANdteP89y5NFY6KbaNPdyen3QRX4UP2xKTWnA () mail ! gmail ! com
[Download RAW message or body]

On Thu, Dec 31, 2020 at 3:12 PM Jason Wang <jasowang@redhat.com> wrote:
>
>
> On 2020/12/31 =E4=B8=8B=E5=8D=882:52, Yongji Xie wrote:
> > On Thu, Dec 31, 2020 at 1:50 PM Jason Wang <jasowang@redhat.com> wrote:
> >>
> >> On 2020/12/31 =E4=B8=8B=E5=8D=881:15, Yongji Xie wrote:
> >>> On Thu, Dec 31, 2020 at 10:49 AM Jason Wang <jasowang@redhat.com> wro=
te:
> >>>> On 2020/12/30 =E4=B8=8B=E5=8D=886:12, Yongji Xie wrote:
> >>>>> On Wed, Dec 30, 2020 at 4:41 PM Jason Wang <jasowang@redhat.com> wr=
ote:
> >>>>>> On 2020/12/30 =E4=B8=8B=E5=8D=883:09, Yongji Xie wrote:
> >>>>>>> On Wed, Dec 30, 2020 at 2:11 PM Jason Wang <jasowang@redhat.com> =
wrote:
> >>>>>>>> On 2020/12/29 =E4=B8=8B=E5=8D=886:26, Yongji Xie wrote:
> >>>>>>>>> On Tue, Dec 29, 2020 at 5:11 PM Jason Wang <jasowang@redhat.com=
> wrote:
> >>>>>>>>>> ----- Original Message -----
> >>>>>>>>>>> On Mon, Dec 28, 2020 at 4:43 PM Jason Wang <jasowang@redhat.c=
om> wrote:
> >>>>>>>>>>>> On 2020/12/28 =E4=B8=8B=E5=8D=884:14, Yongji Xie wrote:
> >>>>>>>>>>>>>> I see. So all the above two questions are because VHOST_IO=
TLB_INVALIDATE
> >>>>>>>>>>>>>> is expected to be synchronous. This need to be solved by t=
weaking the
> >>>>>>>>>>>>>> current VDUSE API or we can re-visit to go with descriptor=
s relaying
> >>>>>>>>>>>>>> first.
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>> Actually all vdpa related operations are synchronous in cur=
rent
> >>>>>>>>>>>>> implementation. The ops.set_map/dma_map/dma_unmap should no=
t return
> >>>>>>>>>>>>> until the VDUSE_UPDATE_IOTLB/VDUSE_INVALIDATE_IOTLB message=
 is replied
> >>>>>>>>>>>>> by userspace. Could it solve this problem?
> >>>>>>>>>>>>        I was thinking whether or not we need to generate IOT=
LB_INVALIDATE
> >>>>>>>>>>>> message to VDUSE during dma_unmap (vduse_dev_unmap_page).
> >>>>>>>>>>>>
> >>>>>>>>>>>> If we don't, we're probably fine.
> >>>>>>>>>>>>
> >>>>>>>>>>> It seems not feasible. This message will be also used in the
> >>>>>>>>>>> virtio-vdpa case to notify userspace to unmap some pages duri=
ng
> >>>>>>>>>>> consistent dma unmapping. Maybe we can document it to make su=
re the
> >>>>>>>>>>> users can handle the message correctly.
> >>>>>>>>>> Just to make sure I understand your point.
> >>>>>>>>>>
> >>>>>>>>>> Do you mean you plan to notify the unmap of 1) streaming DMA o=
r 2)
> >>>>>>>>>> coherent DMA?
> >>>>>>>>>>
> >>>>>>>>>> For 1) you probably need a workqueue to do that since dma unma=
p can
> >>>>>>>>>> be done in irq or bh context. And if usrspace does't do the un=
map, it
> >>>>>>>>>> can still access the bounce buffer (if you don't zap pte)?
> >>>>>>>>>>
> >>>>>>>>> I plan to do it in the coherent DMA case.
> >>>>>>>> Any reason for treating coherent DMA differently?
> >>>>>>>>
> >>>>>>> Now the memory of the bounce buffer is allocated page by page in =
the
> >>>>>>> page fault handler. So it can't be used in coherent DMA mapping c=
ase
> >>>>>>> which needs some memory with contiguous virtual addresses. I can =
use
> >>>>>>> vmalloc() to do allocation for the bounce buffer instead. But it =
might
> >>>>>>> cause some memory waste. Any suggestion?
> >>>>>> I may miss something. But I don't see a relationship between the
> >>>>>> IOTLB_UNMAP and vmalloc().
> >>>>>>
> >>>>> In the vmalloc() case, the coherent DMA page will be taken from the
> >>>>> memory allocated by vmalloc(). So IOTLB_UNMAP is not needed anymore
> >>>>> during coherent DMA unmapping because those vmalloc'ed memory which
> >>>>> has been mapped into userspace address space during initialization =
can
> >>>>> be reused. And userspace should not unmap the region until we destr=
oy
> >>>>> the device.
> >>>> Just to make sure I understand. My understanding is that IOTLB_UNMAP=
 is
> >>>> only needed when there's a change the mapping from IOVA to page.
> >>>>
> >>> Yes, that's true.
> >>>
> >>>> So if we stick to the mapping, e.g during dma_unmap, we just put IOV=
A to
> >>>> free list to be used by the next IOVA allocating. IOTLB_UNMAP could =
be
> >>>> avoided.
> >>>>
> >>>> So we are not limited by how the pages are actually allocated?
> >>>>
> >>> In coherent DMA cases, we need to return some memory with contiguous
> >>> kernel virtual addresses. That is the reason why we need vmalloc()
> >>> here. If we allocate the memory page by page, the corresponding kerne=
l
> >>> virtual addresses in a contiguous IOVA range might not be contiguous.
> >>
> >> Yes, but we can do that as what has been done in the series
> >> (alloc_pages_exact()). Or do you mean it would be a little bit hard to
> >> recycle IOVA/pages here?
> >>
> > Yes, it might be hard to reuse the memory. For example, we firstly
> > allocate 1 IOVA/page during dma_map, then the IOVA is freed during
> > dma_unmap. Actually we can't reuse this single page if we need a
> > two-pages area in the next IOVA allocating. So the best way is using
> > IOTLB_UNMAP to free this single page during dma_unmap too.
> >
> > Thanks,
> > Yongji
>
>
> I get you now. Then I agree that let's go with IOTLB_UNMAP.
>

Fine, will do it.

Thanks,
Yongji
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic