Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp127135ybv; Wed, 5 Feb 2020 02:35:06 -0800 (PST) X-Google-Smtp-Source: APXvYqyppg20+xrqcY5EHQRFQBfIUs62DYep861VaenkErkFOx4bLNZ0MdI6HcFfo6oOw+TNNmK4 X-Received: by 2002:a05:6830:1050:: with SMTP id b16mr25876278otp.140.1580898906399; Wed, 05 Feb 2020 02:35:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580898906; cv=none; d=google.com; s=arc-20160816; b=OWGfzNl2BcP1xs1jgXYRR3cntWzEH53koyT6jxPWB+57qmsO30LmCecgpWT2oAP10H Py9p8UDbaJyjHi+GPfKwtkLMSKJRcxwnyJ8ofCsKoHyChEBALUnZ+vTbccv9aNOq2Zde Nr8vDM3yw5n1R9umfDoeOVHoZMZ5e9Mda11LYaN/fAgtrV3vRaPQjw1FEHUqwrhzkNJG eBvM7q8k9rJOI3CXslvHT0Q0IPlFqoaZh68Qb6GnZ8Of/L/QfE1PR1ADW41WLrvvB6yt /o8YgsGgco5VuDVUna6iFO213G6r8k/6bkNhYrWj5/WQdx69ehy9ZRAKBisiCtLMzg1o fH0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=fMJo0Joxo+pl/mB5o3Pd3oM2dXap9Kiay0KNytUxRsU=; b=dqyT9zRywTj1rlVXqeBRP0zUkeW+wcFzKRYwDiiMmbItZXg1v3RC6VkScTaAlvkbY9 kHZg1yx83GLVZGXIUfd4n4T98q2g6xNW17hxO6O1fdha85+v156rGmLAOAVIXlv1FOwD 7motHjWFpHtqjviC8A4VyQTgOYIqHllIW2VJm1MMA8dbyK2dTr4IG3WSR71NU5G8wljg vQV2txrGCHUeM3J9QHhLdXhcTiURYtwpLux7cJyq5vQLLzb5tuWxEGgpoY7r74OAjNhO E/8NJPqTz0a0UE5vi9Ff25tTLFcfdCPiC1sAtL5a1z/xybdnfXH20qdunAj+6SeTKzSW us0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZIWxRiOI; 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 m82si11268505oig.129.2020.02.05.02.34.47; Wed, 05 Feb 2020 02:35:06 -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=ZIWxRiOI; 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 S1728273AbgBEKdw (ORCPT + 99 others); Wed, 5 Feb 2020 05:33:52 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:24658 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727771AbgBEKdv (ORCPT ); Wed, 5 Feb 2020 05:33:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580898829; 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=fMJo0Joxo+pl/mB5o3Pd3oM2dXap9Kiay0KNytUxRsU=; b=ZIWxRiOIzLW96aEkYuzKP+c8c6Yr4VUb/c/lPxeAgEQfDfkgOe5MfIc00azpJg+CofmS5H oFRmCVrbW2lAeXJYCkJvCYyvfywqE3Z8VW1XF1CPlZKOc6I3ZkOkPmGu/0ynXMJh1yC7i+ B9iSR9oVlUUGUgqROv65tADe6ktU4rY= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-38-Kv2sm9_INeacVasvVJJF4A-1; Wed, 05 Feb 2020 05:33:48 -0500 X-MC-Unique: Kv2sm9_INeacVasvVJJF4A-1 Received: by mail-qk1-f200.google.com with SMTP id q2so944071qkq.19 for ; Wed, 05 Feb 2020 02:33:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=fMJo0Joxo+pl/mB5o3Pd3oM2dXap9Kiay0KNytUxRsU=; b=fhk2m4m7Wl+lz8/GrrKgt8iDJeTsCEfQi9J1lfM7/tsWOuq5Tqjrwc7SGYw6H7BM4D 00rThA/cxo8EjUfxmr97IoS1aD5ZPG8EV8JXzhEHujB+SWUoK7pGU8dJcxDhl1mHiCPg 2ZkWU8WBkxlpC1xSIMh+CZVYXycOtv49UDpOJLuImKvRe/GThmFAARJuH8FKwL5I24iv 3a89bzt34429Ws+ZyO9zG+6xy0YhANGNCg/OZTxpZjS/K9zjV5zYBy5fjMlW4bUMQM1J PwnShnsXNvpoOEJfEx0D9aWKEkDADllguK8Y2D6pz/Kggi1bcprLKby2QZM7ynntY6CY 0kpg== X-Gm-Message-State: APjAAAWk/HD/vl33NVwblQIz8PjVz+/BXJMhXij3Ppxy1PnY6W13o88L D6KpDTjdjShIVPHLvJ4qxU5T0Z5tsEB/QahVH+FQJlUr04zhfy/JUsDCpK53Ih7PmN+pm6lpfM+ WU3Lu9qz7KJ4uD5hce0M77Q0T X-Received: by 2002:a37:6853:: with SMTP id d80mr4494822qkc.57.1580898827681; Wed, 05 Feb 2020 02:33:47 -0800 (PST) X-Received: by 2002:a37:6853:: with SMTP id d80mr4494800qkc.57.1580898827421; Wed, 05 Feb 2020 02:33:47 -0800 (PST) Received: from redhat.com (bzq-79-176-41-183.red.bezeqint.net. [79.176.41.183]) by smtp.gmail.com with ESMTPSA id p50sm13949401qtf.5.2020.02.05.02.33.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Feb 2020 02:33:46 -0800 (PST) Date: Wed, 5 Feb 2020 05:33:40 -0500 From: "Michael S. Tsirkin" To: Shahaf Shuler Cc: Jason Wang , Tiwei Bie , "linux-kernel@vger.kernel.org" , "kvm@vger.kernel.org" , "virtualization@lists.linux-foundation.org" , "netdev@vger.kernel.org" , Jason Gunthorpe , "rob.miller@broadcom.com" , "haotian.wang@sifive.com" , "eperezma@redhat.com" , "lulu@redhat.com" , Parav Pandit , "rdunlap@infradead.org" , "hch@infradead.org" , Jiri Pirko , "hanand@xilinx.com" , "mhabets@solarflare.com" , "maxime.coquelin@redhat.com" , "lingshan.zhu@intel.com" , "dan.daly@intel.com" , "cunming.liang@intel.com" , "zhihong.wang@intel.com" Subject: Re: [PATCH] vhost: introduce vDPA based backend Message-ID: <20200205053129-mutt-send-email-mst@kernel.org> References: <20200131033651.103534-1-tiwei.bie@intel.com> <7aab2892-bb19-a06a-a6d3-9c28bc4c3400@redhat.com> <20200205020247.GA368700@___> <112858a4-1a01-f4d7-e41a-1afaaa1cad45@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 05, 2020 at 09:30:14AM +0000, Shahaf Shuler wrote: > Wednesday, February 5, 2020 9:50 AM, Jason Wang: > > Subject: Re: [PATCH] vhost: introduce vDPA based backend > > On 2020/2/5 下午3:15, Shahaf Shuler wrote: > > > Wednesday, February 5, 2020 4:03 AM, Tiwei Bie: > > >> Subject: Re: [PATCH] vhost: introduce vDPA based backend > > >> > > >> On Tue, Feb 04, 2020 at 11:30:11AM +0800, Jason Wang wrote: > > >>> On 2020/1/31 上午11:36, Tiwei Bie wrote: > > >>>> This patch introduces a vDPA based vhost backend. This backend is > > >>>> built on top of the same interface defined in virtio-vDPA and > > >>>> provides a generic vhost interface for userspace to accelerate the > > >>>> virtio devices in guest. > > >>>> > > >>>> This backend is implemented as a vDPA device driver on top of the > > >>>> same ops used in virtio-vDPA. It will create char device entry > > >>>> named vhost-vdpa/$vdpa_device_index for userspace to use. > > Userspace > > >>>> can use vhost ioctls on top of this char device to setup the backend. > > >>>> > > >>>> Signed-off-by: Tiwei Bie > > > [...] > > > > > >>>> +static long vhost_vdpa_do_dma_mapping(struct vhost_vdpa *v) { > > >>>> + /* TODO: fix this */ > > >>> > > >>> Before trying to do this it looks to me we need the following during > > >>> the probe > > >>> > > >>> 1) if set_map() is not supported by the vDPA device probe the IOMMU > > >>> that is supported by the vDPA device > > >>> 2) allocate IOMMU domain > > >>> > > >>> And then: > > >>> > > >>> 3) pin pages through GUP and do proper accounting > > >>> 4) store GPA->HPA mapping in the umem > > >>> 5) generate diffs of memory table and using IOMMU API to setup the > > >>> dma mapping in this method > > >>> > > >>> For 1), I'm not sure parent is sufficient for to doing this or need > > >>> to introduce new API like iommu_device in mdev. > > >> Agree. We may also need to introduce something like the iommu_device. > > >> > > > Would it be better for the map/umnap logic to happen inside each device ? > > > Devices that needs the IOMMU will call iommu APIs from inside the driver > > callback. > > > > > > Technically, this can work. But if it can be done by vhost-vpda it will make the > > vDPA driver more compact and easier to be implemented. > > Need to see the layering of such proposal but am not sure. > Vhost-vdpa is generic framework, while the DMA mapping is vendor specific. > Maybe vhost-vdpa can have some shared code needed to operate on iommu, so drivers can re-use it. to me it seems simpler than exposing a new iommu device. > > > > > > > > Devices that has other ways to do the DMA mapping will call the > > proprietary APIs. > > > > > > To confirm, do you prefer: > > > > 1) map/unmap > > It is not only that. AFAIR there also flush and invalidate calls, right? > > > > > or > > > > 2) pass all maps at one time? > > To me this seems more straight forward. > It is correct that under hotplug and large number of memory segments > the driver will need to understand the diff (or not and just reload > the new configuration). > However, my assumption here is that memory > hotplug is heavy flow anyway, and the driver extra cycles will not be > that visible I think we can just allow both, after all vhost already has both interfaces ... We just need a flag that tells userspace whether it needs to update all maps aggressively or can wait for a fault. > > > > Thanks > > > > > > > >