On Wed, Apr 11, 2018 at 08:59:32AM +0300, Oleksandr Andrushchenko wrote:This is the exact use-case I was referring to while saying
On 04/10/2018 08:26 PM, Dongwon Kim wrote:Erm, why do you need importer capability for this use-case?
On Tue, Apr 10, 2018 at 09:37:53AM +0300, Oleksandr Andrushchenko wrote:Yes, I saw this. But this limits the use-cases so much.
On 04/06/2018 09:57 PM, Dongwon Kim wrote:Another thing is danvet was kind of against to the idea of importing existing
On Fri, Apr 06, 2018 at 03:36:03PM +0300, Oleksandr Andrushchenko wrote:
On 04/06/2018 02:57 PM, Gerd Hoffmann wrote:xen z-copy solution is pretty similar fundamentally to hyper_dmabuf
Hi,Thank you for your input, I'm just trying to figure out
Well, udmabuf route isn't fully clear yet, but yes.I fail to see any common ground for xen-zcopy and udmabuf ...Does the above mean you can assume that xen-zcopy and udmabuf
can co-exist as two different solutions?
See also gvt (intel vgpu), where the hypervisor interface is abstracted
away into a separate kernel modules even though most of the actual vgpu
emulation code is common.
which of the three z-copy solutions intersect and how much
And what about hyper-dmabuf?
in terms of these core sharing feature:
1. the sharing process - import prime/dmabuf from the producer -> extract
underlying pages and get those shared -> return references for shared pages
dmabuf/prime buffer and forward it to the other domain due to synchronization
issues. He proposed to make hyper_dmabuf only work as an exporter so that it
can have a full control over the buffer. I think we need to talk about this
further as well.
For instance, running Android as a Guest (which uses ION to allocate
buffers) means that finally HW composer will import dma-buf into
the DRM driver. Then, in case of xen-front for example, it needs to be
shared with the backend (Host side). Of course, we can change user-space
to make xen-front allocate the buffers (make it exporter), but what we try
to avoid is to change user-space which in normal world would have remain
unchanged otherwise.
So, I do think we have to support this use-case and just have to understand
the complexity.
guest1 -> ION -> xen-front -> hypervisor -> guest 2 -> xen-zcopy exposes
that dma-buf -> import to the real display hw
No where in this chain do you need xen-zcopy to be able to import a
dma-buf (within linux, it needs to import a bunch of pages from the
hypervisor).
Now if your plan is to use xen-zcopy in the guest1 instead of xen-front,
then you indeed need to import.
But that imo doesn't make sense:xen-zcopy is a helper driver which doesn't handle page flips
- xen-front gives you clearly defined flip events you can forward to the
hypervisor. xen-zcopy would need to add that again.
Same forAgain, here you are talking of something which is implemented in
hyperdmabuf (and really we're not going to shuffle struct dma_fence over
the wire in a generic fashion between hypervisor guests).
- xen-front already has the idea of pixel format for the buffer (and any
other metadata). Again, xen-zcopy and hyperdmabuf lack that, would need
to add it shoehorned in somehow.
So, we now know that xen-zcopy was not meant to handle page flips,
Ofc you won't be able to shovel sound or media stream data over to another
guest like this, but that's what you have xen-v4l and xen-sound or
whatever else for. Trying to make a new uapi, which means userspace must
be changed for all the different use-case, instead of reusing standard
linux driver uapi (which just happens to send the data to another
hypervisor guest instead of real hw) imo just doesn't make much sense.
Also, at least for the gpu subsystem: Any new uapi must have full
userspace available for it, see:
https://dri.freedesktop.org/docs/drm/gpu/drm-uapi.html#open-source-userspace-requirements
Adding more uapi is definitely the most painful way to fix a use-case.
Personally I'd go as far and also change the xen-zcopy side on the
receiving guest to use some standard linux uapi. E.g. you could write an
output v4l driver to receive the frames from guest1.
I was just referring to accounting stuff already implemented in the DRM core,
Hm, not sure what tracking you refer to here all ... I got lost in all thedanvet, can you comment on this topic?The synchronization is done with displif protocol [1]
Yeah, understood xen-zcopy works ok with your use case. But I am just curious2. the page sharing mechanism - it uses Xen-grant-table.Well, this is true. And at the same time this is just a matter
And to give you a quick summary of differences as far as I understand
between two implementations (please correct me if I am wrong, Oleksandr.)
1. xen-zcopy is DRM specific - can import only DRM prime buffer
while hyper_dmabuf can export any dmabuf regardless of originator
of extending the API: xen-zcopy is a helper driver designed for
xen-front/back use-case, so this is why it only has DRM PRIME API
2. xen-zcopy doesn't seem to have dma-buf synchronization between two VMsThis is true. Again, this is because of the use-cases it covers.
while (as danvet called it as remote dmabuf api sharing) hyper_dmabuf sends
out synchronization message to the exporting VM for synchronization.
But having synchronization for a generic solution seems to be a good idea.
if it is ok not to have any inter-domain synchronization in this sharing model.
The buffer being shared is technically dma-buf and originator needs to be ableAs I am working in DRM terms the tracking is done by the DRM core
to keep track of it.
for me for free. (This might be one of the reasons Daniel sees DRM
based implementation fit very good from code-reuse POV).
replies while catching up.
I do understand that adding new UAPI is not good for many reasons.Again, why do you want to create new uapi for this? Given the very strictNot to mislead you: one grant ref is passed via displif protocol,You are right. Thanks for correction.;)3. 1-level references - when using grant-table for sharing pages, there willTo be precise, grant ref is 4 bytes
be same # of refs (each 8 byte)
ok, good to know. I will look into its implementation in more details but isas # of shared pages, which is passed toThe reason for that is that xen-zcopy is a helper driver, e.g.
the userspace to be shared with importing VM in case of xen-zcopy.
the grant references come from the display backend [1], which implements
Xen display protocol [2]. So, effectively the backend extracts references
from frontend's requests and passes those to xen-zcopy as an array
of refs.
ComparedIn the protocol [2] only one reference to the gref directory is passed
to this, hyper_dmabuf does multiple level addressing to generate only one
reference id that represents all shared pages.
between VMs
(and the gref directory is a single-linked list of shared pages containing
all
of the grefs of the buffer).
this gref directory (chained grefs) something that can be used for any general
memory sharing use case or is it jsut for xen-display (in current code base)?
but the page it's referencing contains the rest of the grant refs.
As to if this can be used for any memory: yes. It is the same for
sndif and displif Xen protocols, but defined twice as strictly speaking
sndif and displif are two separate protocols.
While reviewing your RFC v2 one of the comments I had [2] was that if we
can start from defining such a generic protocol for hyper-dmabuf.
It can be a header file, which not only has the description part
(which then become a part of Documentation/...rst file), but also defines
all the required constants for requests, responses, defines message formats,
state diagrams etc. all at one place. Of course this protocol must not be
Xen specific, but be OS/hypervisor agnostic.
Having that will trigger a new round of discussion, so we have it all
designed
and discussed before we start implementing.
Besides the protocol we have to design UAPI part as well and make sure
the hyper-dmabuf is not only accessible from user-space, but there will be
number
of kernel-space users as well.
requirements we have for new uapi (see above link), it's the toughest way
to get any kind of support in.
On my side there are only 2 use-cases, Guest2 only:
That's why I had essentially zero big questions for xen-front (except some
implementation improvements, and stuff to make sure xen-front actually
implements the real uapi semantics instead of its own), and why I'm asking
much more questions on this stuff here.
Imo code reuse is overrated. Adding new uapi is what freaks me out hereWell, I would love we reuse the code that I have, but I alsoI think it is possible to use your functions for memory sharing part in4. inter VM messaging (hype_dmabuf only) - hyper_dmabuf has inter-vm msgThis is true, xen-zcopy has no means for inter VM sync and meta-data,
communication defined for dmabuf synchronization and private data (meta
info that Matt Roper mentioned) exchange.
simply because it doesn't have any code for inter VM exchange in it,
e.g. the inter VM protocol is handled by the backend [1].
5. driver-to-driver notification (hyper_dmabuf only) - importing VM getsAgain, xen-zcopy is decoupled from inter VM communication
notified when newdmabuf is exported from other VM - uevent can be optionally
generated when this happens.
6. structure - hyper_dmabuf is targetting to provide a generic solution for
inter-domain dmabuf sharing for most hypervisors, which is why it has two
layers as mattrope mentioned, front-end that contains standard API and backend
that is specific to hypervisor.
Thank you, I'll have a lookwe started with simple dma-buf sharing but realized there are manyNo idea, didn't look at it in detail.
Looks pretty complex from a distant view. Maybe because it tries to
build a communication framework using dma-bufs instead of a simple
dma-buf passing mechanism.
things we need to consider in real use-case, so we added communication
, notification and dma-buf synchronization then re-structured it to
front-end and back-end (this made things more compicated..) since Xen
was not our only target. Also, we thought passing the reference for the
buffer (hyper_dmabuf_id) is not secure so added uvent mechanism later.
Yes, I am looking at it now, trying to figure out the full storyOne example is actually in github. If you want take a look at it, please
and its implementation. BTW, Intel guys were about to share some
test application for hyper-dmabuf, maybe I have missed one.
It could probably better explain the use-cases and the complexity
they have in hyper-dmabuf.
visit:
https://github.com/downor/linux_hyper_dmabuf_test/tree/xen/simple_export
If you think of xen-zcopy as a library (which implements XenI think we can definitely collaborate. Especially, maybe we are using someLike xen-zcopy it seems to depend on the idea that the hypervisorSo, for xen-zcopy we were not trying to make it generic,
manages all memory it is easy for guests to share pages with the help of
the hypervisor.
it just solves display (dumb) zero-copying use-cases for Xen.
We implemented it as a DRM helper driver because we can't see any
other use-cases as of now.
For example, we also have Xen para-virtualized sound driver, but
its buffer memory usage is not comparable to what display wants
and it works somewhat differently (e.g. there is no "frame done"
event, so one can't tell when the sound buffer can be "flipped").
At the same time, we do not use virtio-gpu, so this could probably
be one more candidate for shared dma-bufs some day.
Which simply isn't the case on kvm.Hm, I can imagine that: xen-zcopy could be a library code for hyper-dmabuf
hyper-dmabuf and xen-zcopy could maybe share code, or hyper-dmabuf build
on top of xen-zcopy.
in terms of implementing all that page sharing fun in multiple directions,
e.g. Host->Guest, Guest->Host, Guest<->Guest.
But I'll let Matt and Dongwon to comment on that.
outdated sharing mechanism/grant-table mechanism in our Xen backend (thanks
for bringing that up Oleksandr). However, the question is once we collaborate
somehow, can xen-zcopy's usecase use the standard API that hyper_dmabuf
provides? I don't think we need different IOCTLs that do the same in the final
solution.
grant references mangling) and DRM PRIME wrapper on top of that
library, we can probably define proper API for that library,
so both xen-zcopy and hyper-dmabuf can use it. What is more, I am
about to start upstreaming Xen para-virtualized sound device driver soon,
which also uses similar code and gref passing mechanism [3].
(Actually, I was about to upstream drm/xen-front, drm/xen-zcopy and
snd/xen-front and then propose a Xen helper library for sharing big buffers,
so common code of the above drivers can use the same code w/o code
duplication)
hyper_dmabuf's backend (this 'backend' means the layer that does page sharing
and inter-vm communication with xen-specific way.), so why don't we work on
"Xen helper library for sharing big buffers" first while we continue our
discussion on the common API layer that can cover any dmabuf sharing cases.
understand that it was limited by my use-cases. So, I do not
insist we have to ;)
If we start designing and discussing hyper-dmabuf protocol we of course
can work on this helper library in parallel.
:-)
If we end up with duplicated implementations, even in upstream, meh, not
great, but also ok. New uapi, and in a similar way, new hypervisor api
like the dma-buf forwarding that hyperdmabuf does is the kind of thing
that will lock us in for 10+ years (if we make a mistake).
Please don't start with the protocol. Instead start with the concreteSo, if you can start designing the protocol we may have a dedicated mailThank you,Either way is fine with me.
Oleksandr
P.S. All, is it a good idea to move this out of udmabuf thread into a
dedicated one?
thread for that. I will try to help with the protocol as much as I can
use-cases, and then figure out why exactly you need new uapi. Once we have
that answered, we can start thinking about fleshing out the details.
Cheers, DanielThank you,
[1] https://github.com/xen-troops/displ_be[1] https://elixir.bootlin.com/linux/v4.16-rc7/source/include/xen/interface/io/displif.h[1] https://github.com/xen-troops/displ_becheers,Thank you,
Gerd
Oleksandr
P.S. Sorry for making your original mail thread to discuss things much
broader than your RFC...
[2] https://elixir.bootlin.com/linux/v4.16-rc7/source/include/xen/interface/io/displif.h#L484
[3] https://elixir.bootlin.com/linux/v4.16-rc7/source/include/xen/interface/io/sndif.h
[2]
https://lists.xenproject.org/archives/html/xen-devel/2018-04/msg00685.html
_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel