From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.4 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 43D3CC433DB for ; Wed, 30 Dec 2020 08:41:55 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BBA8B216C4 for ; Wed, 30 Dec 2020 08:41:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BBA8B216C4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id BFF858D00A3; Wed, 30 Dec 2020 03:41:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BB12D8D00A4; Wed, 30 Dec 2020 03:41:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A9F448D00A3; Wed, 30 Dec 2020 03:41:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0213.hostedemail.com [216.40.44.213]) by kanga.kvack.org (Postfix) with ESMTP id 9085F8D007F for ; Wed, 30 Dec 2020 03:41:53 -0500 (EST) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 4D97D8249980 for ; Wed, 30 Dec 2020 08:41:53 +0000 (UTC) X-FDA: 77649305706.27.cub99_4c09631274a3 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin27.hostedemail.com (Postfix) with ESMTP id 365863D66B for ; Wed, 30 Dec 2020 08:41:53 +0000 (UTC) X-HE-Tag: cub99_4c09631274a3 X-Filterd-Recvd-Size: 6467 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf49.hostedemail.com (Postfix) with ESMTP for ; Wed, 30 Dec 2020 08:41:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1609317712; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Nxql4zOLePCw/DPHwTjONsd++E57uymBDbcJD4zzipA=; b=OhOqWw3WifJB2JVgm8HzWh1X4a6BDthgVEkfpWDGnfLjQI7DZxxwrLtfOuglkGp07jzVNh c5I44SOeFAQOe5LBj9VjXC0QEBFD3BwRBwozgibur8nNZI7uf5cBMcOfW4sLpwUoN2zF6Y fMFS7Sn0KtWHWwa6qKIeuONmoX8T1+Y= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-433-zpv0_H9vOcyfBsFlNAK1zg-1; Wed, 30 Dec 2020 03:41:47 -0500 X-MC-Unique: zpv0_H9vOcyfBsFlNAK1zg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2C8FB180A08A; Wed, 30 Dec 2020 08:41:45 +0000 (UTC) Received: from [10.72.13.30] (ovpn-13-30.pek2.redhat.com [10.72.13.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7751E5D6AB; Wed, 30 Dec 2020 08:41:32 +0000 (UTC) Subject: Re: [RFC v2 09/13] vduse: Add support for processing vhost iotlb message To: Yongji Xie Cc: "Michael S. Tsirkin" , Stefan Hajnoczi , sgarzare@redhat.com, Parav Pandit , akpm@linux-foundation.org, Randy Dunlap , Matthew Wilcox , viro@zeniv.linux.org.uk, axboe@kernel.dk, bcrl@kvack.org, corbet@lwn.net, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, kvm@vger.kernel.org, linux-aio@kvack.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org References: <20201222145221.711-1-xieyongji@bytedance.com> <0e6faf9c-117a-e23c-8d6d-488d0ec37412@redhat.com> <2b24398c-e6d9-14ec-2c0d-c303d528e377@redhat.com> <1356137727.40748805.1609233068675.JavaMail.zimbra@redhat.com> From: Jason Wang Message-ID: <3fc6a132-9fc2-c4e2-7fb1-b5a8bfb771fa@redhat.com> Date: Wed, 30 Dec 2020 16:41:30 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 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 wrot= e: >>>> >>>> ----- Original Message ----- >>>>> On Mon, Dec 28, 2020 at 4:43 PM Jason Wang wr= ote: >>>>>> 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_IOTLB_IN= VALIDATE >>>>>>>> is expected to be synchronous. This need to be solved by tweakin= g the >>>>>>>> current VDUSE API or we can re-visit to go with descriptors rela= ying >>>>>>>> first. >>>>>>>> >>>>>>> Actually all vdpa related operations are synchronous in current >>>>>>> implementation. The ops.set_map/dma_map/dma_unmap should not retu= rn >>>>>>> until the VDUSE_UPDATE_IOTLB/VDUSE_INVALIDATE_IOTLB message is re= plied >>>>>>> by userspace. Could it solve this problem? >>>>>> I was thinking whether or not we need to generate IOTLB_INVALI= DATE >>>>>> 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 during >>>>> consistent dma unmapping. Maybe we can document it to make sure 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 or 2) >>>> coherent DMA? >>>> >>>> For 1) you probably need a workqueue to do that since dma unmap can >>>> be done in irq or bh context. And if usrspace does't do the unmap, i= t >>>> 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 case > 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=20 IOTLB_UNMAP and vmalloc(). > >>> It's true that userspace can >>> access the dma buffer if userspace doesn't do the unmap. But the dma >>> pages would not be freed and reused unless user space called munmap() >>> for them. >> >> I wonder whether or not we could recycle IOVA in this case to avoid th= e >> IOTLB_UMAP message. >> > We can achieve that if we use vmalloc() to do allocation for the > bounce buffer which can be used in coherent DMA mapping case. But > looks like we still have no way to avoid the IOTLB_UMAP message in > vhost-vdpa case. I think that's fine. For virtio-vdpa, from VDUSE userspace perspective,=20 it works like a driver that is using SWIOTLB in this case. Thanks > > Thanks, > Yongji >