Received: by 10.213.65.68 with SMTP id h4csp35424imn; Thu, 5 Apr 2018 17:12:42 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/5FQcNLzuKvShA67YEY6AN7DwFBB4JCQC1aIa/Sr1htxbCXIlbvaa/SIsXU7jTXwOMmLr2 X-Received: by 2002:a17:902:6a89:: with SMTP id n9-v6mr25223318plk.51.1522973562008; Thu, 05 Apr 2018 17:12:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522973561; cv=none; d=google.com; s=arc-20160816; b=TeVdUQ2Z5YsQDcUw9GE2Kzc1FWulytuGEsstt4N5T+8UJNTjpqDvuMbZ9VSLOInLvB B1Tj8I6o8zq9bk+uL+yRNvJ0rH+0F7j9hGrj9ZvwZbi+XcwpUuEza2JdViRc/2CUP8aV uAUgs3ALS3yqo+IVVfRzvddmOUjsObbFxiqzHQ9dC6/2SZ0xBIyt4IYabA7TW9jq67xK A6fNm4ZCmjoOHbjyj/qqdhunvPpWXYh18ufZhGfL3ReriGVQ7M8Z/VK2PN3HCTG3dzoW KY2Y/GKfwq9ODB6ev1dvzbaIyGYyhEAROIuX4W62aKvgZGlC59azxQSdiGe06YV72vvf 0gXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=0SpPYy8mrPsy7j8s2p0skeQknvhaBcBR+FRUdi0ydNg=; b=S6Xf5K9JXR+lscIk5lWQhf5IpnQZORo7pZv58iPMZD6V6NiBTbSlFfFIsw23jsDu+0 yPnMJ1PRN+CuuAIYMG1QnJxh3RTJxTaqO/7AqlVM2n4dMDBUPZIYcCo5XObqLJrPiRLQ b1xHZvHNePvPGgOr5dhWMIvkewQ88XWo7RHo6ieQRWwzra/245yrIeECKUHF5JuH/s90 IQqPeftf/jnxmr4qk1/GlzZFsQjurP+0L8Lk/fxp4UGOB23w/XfAX6Lte+TB0QRtYY3U U1wDDaBujG+lKKx4OR2yotTX+b3VYzt+B/KFSdQN6Xyrw8qCwYnV9vXyzW2BrTydE4qq YzTw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a24si3356092pff.256.2018.04.05.17.12.27; Thu, 05 Apr 2018 17:12:41 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751399AbeDFALW (ORCPT + 99 others); Thu, 5 Apr 2018 20:11:22 -0400 Received: from mga04.intel.com ([192.55.52.120]:29075 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751262AbeDFALU (ORCPT ); Thu, 5 Apr 2018 20:11:20 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Apr 2018 17:11:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,413,1517904000"; d="scan'208";a="29906701" Received: from mdroper-desk.fm.intel.com (HELO mdroper-desk.amr.corp.intel.com) ([10.1.134.220]) by fmsmga007.fm.intel.com with ESMTP; 05 Apr 2018 17:11:17 -0700 Date: Thu, 5 Apr 2018 17:11:17 -0700 From: Matt Roper To: Daniel Vetter Cc: Gerd Hoffmann , Oleksandr Andrushchenko , Dongwon Kim , dri-devel , Tomeu Vizoso , David Airlie , open list , qemu-devel@nongnu.org, "moderated list:DMA BUFFER SHARING FRAMEWORK" , "open list:DMA BUFFER SHARING FRAMEWORK" Subject: Re: [RfC PATCH] Add udmabuf misc device Message-ID: <20180406001117.GD31612@mdroper-desk.amr.corp.intel.com> References: <20180313154826.20436-1-kraxel@redhat.com> <20180313161035.GL4788@phenom.ffwll.local> <20180314080301.366zycak3whqvvqx@sirius.home.kraxel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 05, 2018 at 10:32:04PM +0200, Daniel Vetter wrote: > Pulling this out of the shadows again. > > We now also have xen-zcopy from Oleksandr and the hyper dmabuf stuff > from Matt and Dongwong. > > At least from the intel side there seems to be the idea to just have 1 > special device that can handle cross-gues/host sharing for all kinds > of hypervisors, so I guess you all need to work together :-) > > Or we throw out the idea that hyper dmabuf will be cross-hypervisor > (not sure how useful/reasonable that is, someone please convince me > one way or the other). > > Cheers, Daniel Dongwon (DW) is the one doing all the real work on hyper_dmabuf, but I'm familiar with the use cases he's trying to address, and I think there are a couple high-level goals of his work that are worth calling out as we discuss the various options for sharing buffers produced in one VM with a consumer running in another VM: * We should try to keep the interface/usage separate from the underlying hypervisor implementation details. I.e., in DW's design the sink/source drivers that handle the actual buffer passing in the two VM's should provide a generic interface that does not depend on a specific hypervisor. Behind the scenes there could be various implementations for specific hypervisors (Xen, KVM, ACRN, etc.), and some of those backends may have additional restrictions, but it would be best if userspace didn't have to know the specific hypervisor running on the system and could just query the general capabilities available to it. We've already got projects in flight that are wanting this functionality on Xen and ACRN today. * The general interface should be able to express sharing from any guest:guest, not just guest:host. Arbitrary G:G sharing might be something some hypervisors simply aren't able to support, but the userspace API itself shouldn't make assumptions or restrict that. I think ideally the sharing API would include some kind of query_targets interface that would return a list of VM's that your current OS is allowed to share with; that list would be depend on the policy established by the system integrator, but obviously wouldn't include targets that the hypervisor itself wouldn't be capable of handling. * A lot of the initial use cases are in the realm of graphics, but this shouldn't be a graphics-specific API. Buffers might contain other types of content as well (e.g., audio). Really the content producer could potentially be any driver (or userspace) running in the VM that knows how to import/export dma_buf's (or maybe just import given danvet's suggestion that we should make the sink driver do all the actual memory allocation for any buffers that may be shared). * We need to be able to handle cross-VM coordination of buffer usage as well, so I think we'd want to include fence forwarding support in the API as well to signal back and forth about production/consumption completion. And of course document really well what should happen if, for example, the entire VM you're sharing with/from dies. * The sharing API could be used to share multiple kinds of content in a single system. The sharing sink driver running in the content producer's VM should accept some additional metadata that will be passed over to the target VM as well. The sharing source driver running in the content consumer's VM would then be able to use this metadata to determine the purpose of a new buffer that arrives and filter/dispatch it to the appropriate consumer. For reference, the terminology I'm using is /----------\ dma_buf /------\ HV /--------\ dma_buf /----------\ | Producer |----------->| Sink | HV | Source |----------->| Consumer | \----------/ ioctls \------/ HV \--------/ uevents \----------/ In the realm of graphics, "Producer" could potentially be something like an EGL client that sends the buffer at context setup and then signals with fences on each SwapBuffers. "Consumer" could be a Wayland client that proxies the buffers into surfaces or dispatches them to other userspace software that's waiting for buffers. With the hyper_dmabuf approach, there's a lot of ABI details that need to be worked out and really clearly documented before we worry too much about the backend hypervisor-specific stuff. I'm not super familiar with xen-zcopy and udmabuf, but it sounds like they're approaching similar problems from slightly different directions, so we should make sure we can come up with something that satisfies everyone's requirements. Matt > > On Wed, Mar 14, 2018 at 9:03 AM, Gerd Hoffmann wrote: > > Hi, > > > >> Either mlock account (because it's mlocked defacto), and get_user_pages > >> won't do that for you. > >> > >> Or you write the full-blown userptr implementation, including mmu_notifier > >> support (see i915 or amdgpu), but that also requires Christian K?nigs > >> latest ->invalidate_mapping RFC for dma-buf (since atm exporting userptr > >> buffers is a no-go). > > > > I guess I'll look at mlock accounting for starters then. Easier for > > now, and leaves the door open to switch to userptr later as this should > > be transparent to userspace. > > > >> > Known issue: Driver API isn't complete yet. Need add some flags, for > >> > example to support read-only buffers. > >> > >> dma-buf has no concept of read-only. I don't think we can even enforce > >> that (not many iommus can enforce this iirc), so pretty much need to > >> require r/w memory. > > > > Ah, ok. Just saw the 'write' arg for get_user_pages_fast and figured we > > might support that, but if iommus can't handle that anyway it's > > pointless indeed. > > > >> > Cc: David Airlie > >> > Cc: Tomeu Vizoso > >> > Signed-off-by: Gerd Hoffmann > >> > >> btw there's also the hyperdmabuf stuff from the xen folks, but imo their > >> solution of forwarding the entire dma-buf api is over the top. This here > >> looks _much_ better, pls cc all the hyperdmabuf people on your next > >> version. > > > > Fun fact: googling for "hyperdmabuf" found me your mail and nothing else :-o > > (Trying "hyper dmabuf" instead worked better then). > > > > Yes, will cc them on the next version. Not sure it'll help much on xen > > though due to the memory management being very different. Basically xen > > owns the memory, not the kernel of the control domain (dom0), so > > creating dmabufs for guest memory chunks isn't that simple ... > > > > Also it's not clear whenever they really need guest -> guest exports or > > guest -> dom0 exports. > > > >> Overall I like the idea, but too lazy to review. > > > > Cool. General comments on the idea was all I was looking for for the > > moment. Spare yor review cycles for the next version ;) > > > >> Oh, some kselftests for this stuff would be lovely. > > > > I'll look into it. > > > > thanks, > > Gerd > > > > _______________________________________________ > > dri-devel mailing list > > dri-devel@lists.freedesktop.org > > https://lists.freedesktop.org/mailman/listinfo/dri-devel > > > > -- > Daniel Vetter > Software Engineer, Intel Corporation > +41 (0) 79 365 57 48 - http://blog.ffwll.ch -- Matt Roper Graphics Software Engineer IoTG Platform Enabling & Development Intel Corporation (916) 356-2795