Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2336525ybl; Mon, 20 Jan 2020 00:45:22 -0800 (PST) X-Google-Smtp-Source: APXvYqwSFNAg1sPcio/xQ6btknTta9ikuB9lYc9HjcFrPrR1tMl5k3j9/CuCHG4zeURGj1eczKM8 X-Received: by 2002:aca:8d5:: with SMTP id 204mr11694726oii.141.1579509921864; Mon, 20 Jan 2020 00:45:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579509921; cv=none; d=google.com; s=arc-20160816; b=Y62f3yBNELU3mghJH3fUybX2h5BnG/SnesIdCK+Scw2KaJL0F1Me7D8znLNz4tp+9B 0Ng4VGSRT8dEuZu5xbwU+w44IEDDunvdXULyvjFXhzVRrUZA6QilucHYRIbldVEWyPTd GdsV7vhOOrAU26VHjbvq+MDuWYG3KfNgB8UubMjBIxFYSkEuNsXwIi2mainZOZMH1raG Z93Lk03aGnqEf3ZX5qs4iJDQj0VIc0udpeWyt+Jcjtbi25YOeskAi7h0Xz8n4dsiRRCX l+KIW1EKKXLlma59oz8eZ/OERK8tQY2r+/K4cibnZRAyjBcWvrY+1zYz6l3v2bzSLdJL d8fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=NaXsioYjljuVY6jZb4aFMxl3jkckcuLg1JicxfVLDqk=; b=hBswZjrfd4BjQuuOiQtgu6/3Hv76dRTJjReUic6nv6PZfwETEpcHSrM3mf1ae5X/Xl y+oannbyrOIg7TvghEc2F7v00HyxEvWJB25RhyJW/x2ma87BXa19uHNk+d5ksqyp9Npy vHjda5jJxIWVhZ/fPIWGrWCk30F5nFTVtpaLW62bMQMF0bm6ILotsgcbFJ7Vb1Fm32+3 rljtNNd/xknBIJLo9OoMyhl30n05ovFXGvaZ2qVaY+y5MBhXbq8ECAZHnh0UZSl4OqIr PzYoCj9fFeeCN0ACD+Gzu94OafAEPp9qrVFQb8bBLDXd3gHK1Qxhi8b88vSg58KNrsw0 po7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bY+YZNNZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b4si17356652oib.70.2020.01.20.00.45.09; Mon, 20 Jan 2020 00:45:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bY+YZNNZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726974AbgATIoR (ORCPT + 99 others); Mon, 20 Jan 2020 03:44:17 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:56992 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725872AbgATIoR (ORCPT ); Mon, 20 Jan 2020 03:44:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579509855; 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=NaXsioYjljuVY6jZb4aFMxl3jkckcuLg1JicxfVLDqk=; b=bY+YZNNZR7kqxotMZLFNxFshZfuQwpll3OmWdIUXznhwqCEEl5LUyl9KIb7LvjaGWsIhls gQ6Rqe9YXfoznJOFdMIoBP28rb45SiqPHGh2jmdg0gxSK5PphP0uoK9USa0A7GsxWz5UHE BnZ1DQ43AxTWJqoT0J00M7uOqr2mG/M= 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-264-bGkbTfTSOqe8wSHGCrl1cw-1; Mon, 20 Jan 2020 03:44:14 -0500 X-MC-Unique: bGkbTfTSOqe8wSHGCrl1cw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E3508800D50; Mon, 20 Jan 2020 08:44:11 +0000 (UTC) Received: from [10.72.12.173] (ovpn-12-173.pek2.redhat.com [10.72.12.173]) by smtp.corp.redhat.com (Postfix) with ESMTP id C7B53272A1; Mon, 20 Jan 2020 08:43:55 +0000 (UTC) Subject: Re: [PATCH 3/5] vDPA: introduce vDPA bus To: Shahaf Shuler , Rob Miller Cc: "Michael S. Tsirkin" , "linux-kernel@vger.kernel.org" , "kvm@vger.kernel.org" , "virtualization@lists.linux-foundation.org" , Netdev , "Bie, Tiwei" , Jason Gunthorpe , "maxime.coquelin@redhat.com" , "Liang, Cunming" , "Wang, Zhihong" , "Wang, Xiao W" , "haotian.wang@sifive.com" , "Zhu, Lingshan" , "eperezma@redhat.com" , "lulu@redhat.com" , Parav Pandit , "Tian, Kevin" , "stefanha@redhat.com" , "rdunlap@infradead.org" , "hch@infradead.org" , Ariel Adam , "jakub.kicinski@netronome.com" , Jiri Pirko , "hanand@xilinx.com" , "mhabets@solarflare.com" References: <20200116124231.20253-1-jasowang@redhat.com> <20200116124231.20253-4-jasowang@redhat.com> <20200117070324-mutt-send-email-mst@kernel.org> <239b042c-2d9e-0eec-a1ef-b03b7e2c5419@redhat.com> From: Jason Wang Message-ID: Date: Mon, 20 Jan 2020 16:43:53 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.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.84 on 10.5.11.23 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020/1/19 =E4=B8=8B=E5=8D=885:07, Shahaf Shuler wrote: > Friday, January 17, 2020 4:13 PM, Rob Miller: > Subject: Re: [PATCH 3/5] vDPA: introduce vDPA bus >>> On 2020/1/17 =E4=B8=8B=E5=8D=888:13, Michael S. Tsirkin wrote: >>>> On Thu, Jan 16, 2020 at 08:42:29PM +0800, Jason Wang wrote: > [...] > >>>> + * @set_map:=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 Set device memory mapping, optional >>>> + *=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 and only needed for device that using >>>> + *=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 device specific DMA translation >>>> + *=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 (on-chip IOMMU) >>>> + *=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 @vdev: vdpa device >>>> + *=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 @iotlb: vhost memory mapping to be >>>> + *=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 used by the vDPA >>>> + *=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 Returns integer: success (0) or error (< 0) >>> OK so any change just swaps in a completely new mapping? >>> Wouldn't this make minor changes such as memory hotplug >>> quite expensive? > What is the concern? Traversing the rb tree or fully replace the on-chi= p IOMMU translations? > If the latest, then I think we can take such optimization on the driver= level (i.e. to update only the diff between the two mapping). This is similar to the design of platform IOMMU part of vhost-vdpa. We=20 decide to send diffs to platform IOMMU there. If it's ok to do that in=20 driver, we can replace set_map with incremental API like map()/unmap(). Then driver need to maintain rbtree itself. > If the first one, then I think memory hotplug is a heavy flow regardles= s. Do you think the extra cycles for the tree traverse will be visible in= any way? I think if the driver can pause the DMA during the time for setting up=20 new mapping, it should be fine. > =20 > >> My understanding is that the incremental updating of the on chip IOMMU >> may degrade the=C2=A0 performance. So vendor vDPA drivers may want to = know >> all the mappings at once. > Yes exact. For Mellanox case for instance many optimization can be perf= ormed on a given memory layout. > >> Technically, we can keep the incremental API >> here and let the vendor vDPA drivers to record the full mapping >> internally which may slightly increase the complexity of vendor driver= . > What will be the trigger for the driver to know it received the last ma= pping on this series and it can now push it to the on-chip IOMMU? For GPA->HVA(HPA) mapping, we can have flag for this. But for GIOVA_>HVA(HPA) mapping which could be changed by guest, it=20 looks to me there's no concept of "last mapping" there. I guess in this=20 case, mappings needs to be set from the ground. This could be expensive=20 but consider most application uses static mappings (e.g dpdk in guest).=20 It should be ok. Thanks > >> We need more inputs from vendors here. >> >> Thanks >