Skip to contentSkip to conversation

Question on UAPI for fences

DISCUSSION Christian König 7 participants 19 messages Sep 12, 2014 – Sep 15, 2014

lore
Share & tools
lore
#0 lore raw

Hello everyone,

to allow concurrent buffer access by different engines beyond the multiple readers/single writer model that we currently use in radeon and other drivers we need some kind of synchonization object exposed to userspace.

My initial patch set for this used (or rather abused) zero sized GEM buffers as fence handles. This is obviously isn't the best way of doing this (to much overhead, rather ugly etc...), Jerome commented on this accordingly.

So what should a driver expose instead? Android sync points? Something else?

Please discuss and/or advise,
Christian.

#1 lore raw
Quoted 11 lines · Christian König

Hello everyone,

to allow concurrent buffer access by different engines beyond the multiple readers/single writer model that we currently use in radeon and other drivers we need some kind of synchonization object exposed to userspace.

My initial patch set for this used (or rather abused) zero sized GEM buffers as fence handles. This is obviously isn't the best way of doing this (to much overhead, rather ugly etc...), Jerome commented on this accordingly.

So what should a driver expose instead? Android sync points? Something else?

I think actually exposing the struct fence objects as a fd, using android syncpts (or at least something compatible to it) is the way to go. Problem is that it's super-hard to get the android guys out of hiding for this :(

Adding a bunch of people in the hopes that something sticks. -Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw
Quoted 11 lines · Daniel Vetter
Quoted 10 lines · Christian König

Hello everyone,

to allow concurrent buffer access by different engines beyond the multiple readers/single writer model that we currently use in radeon and other drivers we need some kind of synchonization object exposed to userspace.

My initial patch set for this used (or rather abused) zero sized GEM buffers as fence handles. This is obviously isn't the best way of doing this (to much overhead, rather ugly etc...), Jerome commented on this accordingly.

Quoted 7 lines
Quoted 1 line

So what should a driver expose instead? Android sync points? Something else?

I think actually exposing the struct fence objects as a fd, using android syncpts (or at least something compatible to it) is the way to go. Problem is that it's super-hard to get the android guys out of hiding for this :(

Adding a bunch of people in the hopes that something sticks.

More people.
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#3 lore raw
Quoted 14 lines · Daniel Vetter
Quoted 13 lines · Daniel Vetter
Quoted 11 lines · Christian König

Hello everyone,

to allow concurrent buffer access by different engines beyond the multiple readers/single writer model that we currently use in radeon and other drivers we need some kind of synchonization object exposed to userspace.

My initial patch set for this used (or rather abused) zero sized GEM buffers as fence handles. This is obviously isn't the best way of doing this (to much overhead, rather ugly etc...), Jerome commented on this accordingly.

So what should a driver expose instead? Android sync points? Something else?

Quoted 7 lines
Quoted 5 lines

I think actually exposing the struct fence objects as a fd, using android syncpts (or at least something compatible to it) is the way to go. Problem is that it's super-hard to get the android guys out of hiding for this :(

Adding a bunch of people in the hopes that something sticks.

More people.

Just to re-iterate, exposing such thing while still using command stream ioctl that use implicit synchronization is a waste and you can only get the lowest common denominator which is implicit synchronization. So i do not see the point of such api if you are not also adding a new cs ioctl with explicit contract that it does not do any kind of synchronization (it could be almost the exact same code modulo the do not wait for previous cmd to complete).

Also one thing that the Android sync point does not have, AFAICT, is a way to schedule synchronization as part of a cs ioctl so cpu never have to be involve for cmd stream that deal only one gpu (assuming the driver and hw can do such trick).

Cheers,
Jérôme

Quoted 5 lines

-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#4 lore raw
Quoted 23 lines · Jerome Glisse
Quoted 14 lines · Daniel Vetter
Quoted 13 lines · Daniel Vetter
Quoted 11 lines · Christian König

Hello everyone,

to allow concurrent buffer access by different engines beyond the multiple readers/single writer model that we currently use in radeon and other drivers we need some kind of synchonization object exposed to userspace.

My initial patch set for this used (or rather abused) zero sized GEM buffers as fence handles. This is obviously isn't the best way of doing this (to much overhead, rather ugly etc...), Jerome commented on this accordingly.

So what should a driver expose instead? Android sync points? Something else?

Quoted 7 lines
Quoted 5 lines

I think actually exposing the struct fence objects as a fd, using android syncpts (or at least something compatible to it) is the way to go. Problem is that it's super-hard to get the android guys out of hiding for this :(

Adding a bunch of people in the hopes that something sticks.

More people.

Quoted 7 lines

Just to re-iterate, exposing such thing while still using command stream ioctl that use implicit synchronization is a waste and you can only get the lowest common denominator which is implicit synchronization. So i do not see the point of such api if you are not also adding a new cs ioctl with explicit contract that it does not do any kind of synchronization (it could be almost the exact same code modulo the do not wait for previous cmd to complete).

I don't think we should cathegorically exclude this, since without some partial implicit/explicit world we'll never convert over to fences. Of course adding fences without any way to at least partially forgoe the implicit syncing is pointless. But that might be some other user (e.g. camera capture device) which needs explicit fences.

Quoted 4 lines

Also one thing that the Android sync point does not have, AFAICT, is a way to schedule synchronization as part of a cs ioctl so cpu never have to be involve for cmd stream that deal only one gpu (assuming the driver and hw can do such trick).

You need to integrate the android stuff with your (new) cs ioctl, with a input parameter for the fence fd to wait on before executing the cs and one that gets created to signal when it's all done.

Same goes for all the other places android wants sync objects, e.g. for synchronization before atomic flips and for signalling completion of the same.
-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#5 lore raw
In reply to Jerome Glisse
Quoted 23 lines · Jerome Glisse
Quoted 14 lines · Daniel Vetter
Quoted 13 lines · Daniel Vetter
Quoted 11 lines · Christian König

Hello everyone,

to allow concurrent buffer access by different engines beyond the multiple readers/single writer model that we currently use in radeon and other drivers we need some kind of synchonization object exposed to userspace.

My initial patch set for this used (or rather abused) zero sized GEM buffers as fence handles. This is obviously isn't the best way of doing this (to much overhead, rather ugly etc...), Jerome commented on this accordingly.

So what should a driver expose instead? Android sync points? Something else?

Quoted 7 lines
Quoted 5 lines

I think actually exposing the struct fence objects as a fd, using android syncpts (or at least something compatible to it) is the way to go. Problem is that it's super-hard to get the android guys out of hiding for this :(

Adding a bunch of people in the hopes that something sticks.

More people.

Quoted 7 lines

Just to re-iterate, exposing such thing while still using command stream ioctl that use implicit synchronization is a waste and you can only get the lowest common denominator which is implicit synchronization. So i do not see the point of such api if you are not also adding a new cs ioctl with explicit contract that it does not do any kind of synchronization (it could be almost the exact same code modulo the do not wait for previous cmd to complete).

Our thinking was to allow explicit sync from a single process, but implicitly sync between processes.

Alex

Quoted 14 lines

Also one thing that the Android sync point does not have, AFAICT, is a way to schedule synchronization as part of a cs ioctl so cpu never have to be involve for cmd stream that deal only one gpu (assuming the driver and hw can do such trick).

Cheers,
Jérôme

Quoted 5 lines

-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#6 lore raw
Quoted 32 lines · Alex Deucher
Quoted 23 lines · Jerome Glisse
Quoted 14 lines · Daniel Vetter
Quoted 13 lines · Daniel Vetter
Quoted 11 lines · Christian König

Hello everyone,

to allow concurrent buffer access by different engines beyond the multiple readers/single writer model that we currently use in radeon and other drivers we need some kind of synchonization object exposed to userspace.

My initial patch set for this used (or rather abused) zero sized GEM buffers as fence handles. This is obviously isn't the best way of doing this (to much overhead, rather ugly etc...), Jerome commented on this accordingly.

So what should a driver expose instead? Android sync points? Something else?

Quoted 7 lines
Quoted 5 lines

I think actually exposing the struct fence objects as a fd, using android syncpts (or at least something compatible to it) is the way to go. Problem is that it's super-hard to get the android guys out of hiding for this :(

Adding a bunch of people in the hopes that something sticks.

More people.

Quoted 7 lines

Just to re-iterate, exposing such thing while still using command stream ioctl that use implicit synchronization is a waste and you can only get the lowest common denominator which is implicit synchronization. So i do not see the point of such api if you are not also adding a new cs ioctl with explicit contract that it does not do any kind of synchronization (it could be almost the exact same code modulo the do not wait for previous cmd to complete).

Quoted 2 lines

Our thinking was to allow explicit sync from a single process, but implicitly sync between processes.

This is a BIG NAK if you are using the same ioctl as it would mean you are changing userspace API, well at least userspace expectation. Adding a new cs flag might do the trick but it should not be about inter-process, or any thing special, it's just implicit sync or no synchronization. Converting userspace is not that much of a big deal either, it can be broken into several step. Like mesa use explicit synchronization all time but ddx use implicit.

Cheers,
Jérôme

Quoted 21 lines

Alex

Quoted 18 lines

Also one thing that the Android sync point does not have, AFAICT, is a way to schedule synchronization as part of a cs ioctl so cpu never have to be involve for cmd stream that deal only one gpu (assuming the driver and hw can do such trick).

Cheers,
Jérôme

Quoted 5 lines

-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#7 lore raw
Quoted 36 lines · Jerome Glisse
Quoted 32 lines · Alex Deucher
Quoted 23 lines · Jerome Glisse
Quoted 14 lines · Daniel Vetter
Quoted 13 lines · Daniel Vetter
Quoted 11 lines · Christian König

Hello everyone,

to allow concurrent buffer access by different engines beyond the multiple readers/single writer model that we currently use in radeon and other drivers we need some kind of synchonization object exposed to userspace.

My initial patch set for this used (or rather abused) zero sized GEM buffers as fence handles. This is obviously isn't the best way of doing this (to much overhead, rather ugly etc...), Jerome commented on this accordingly.

So what should a driver expose instead? Android sync points? Something else?

Quoted 7 lines
Quoted 5 lines

I think actually exposing the struct fence objects as a fd, using android syncpts (or at least something compatible to it) is the way to go. Problem is that it's super-hard to get the android guys out of hiding for this :(

Adding a bunch of people in the hopes that something sticks.

More people.

Quoted 7 lines

Just to re-iterate, exposing such thing while still using command stream ioctl that use implicit synchronization is a waste and you can only get the lowest common denominator which is implicit synchronization. So i do not see the point of such api if you are not also adding a new cs ioctl with explicit contract that it does not do any kind of synchronization (it could be almost the exact same code modulo the do not wait for previous cmd to complete).

Quoted 2 lines

Our thinking was to allow explicit sync from a single process, but implicitly sync between processes.

Quoted 7 lines

This is a BIG NAK if you are using the same ioctl as it would mean you are changing userspace API, well at least userspace expectation. Adding a new cs flag might do the trick but it should not be about inter-process, or any thing special, it's just implicit sync or no synchronization. Converting userspace is not that much of a big deal either, it can be broken into several step. Like mesa use explicit synchronization all time but ddx use implicit.

Right, you'd have to explicitly ask for it to avoid breaking old userspace. My point was just that within a single process, it's quite easy to know exactly what you are doing and handle the synchronization yourself, while for inter-process there is an assumed implicit sync.

Alex

Quoted 25 lines

Cheers,
Jérôme

Quoted 21 lines

Alex

Quoted 18 lines

Also one thing that the Android sync point does not have, AFAICT, is a way to schedule synchronization as part of a cs ioctl so cpu never have to be involve for cmd stream that deal only one gpu (assuming the driver and hw can do such trick).

Cheers,
Jérôme

Quoted 5 lines

-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#8 lore raw
In reply to Jerome Glisse

Am 12.09.2014 um 17:33 schrieb Jerome Glisse:

Quoted 31 lines · Alex Deucher
Quoted 28 lines · Jerome Glisse
Quoted 19 lines · Daniel Vetter
Quoted 18 lines · Daniel Vetter
Quoted 17 lines · Christian König
Quoted 11 lines

Hello everyone,

to allow concurrent buffer access by different engines beyond the multiple readers/single writer model that we currently use in radeon and other drivers we need some kind of synchonization object exposed to userspace.

My initial patch set for this used (or rather abused) zero sized GEM buffers as fence handles. This is obviously isn't the best way of doing this (to much overhead, rather ugly etc...), Jerome commented on this accordingly.

So what should a driver expose instead? Android sync points? Something else?

I think actually exposing the struct fence objects as a fd, using android syncpts (or at least something compatible to it) is the way to go. Problem is that it's super-hard to get the android guys out of hiding for this :(

Adding a bunch of people in the hopes that something sticks.

Quoted 8 lines
Quoted 1 line

More people.

Just to re-iterate, exposing such thing while still using command stream ioctl that use implicit synchronization is a waste and you can only get the lowest common denominator which is implicit synchronization. So i do not see the point of such api if you are not also adding a new cs ioctl with explicit contract that it does not do any kind of synchronization (it could be almost the exact same code modulo the do not wait for previous cmd to complete).

Quoted 2 lines

Our thinking was to allow explicit sync from a single process, but implicitly sync between processes.

Quoted 7 lines

This is a BIG NAK if you are using the same ioctl as it would mean you are changing userspace API, well at least userspace expectation. Adding a new cs flag might do the trick but it should not be about inter-process, or any thing special, it's just implicit sync or no synchronization. Converting userspace is not that much of a big deal either, it can be broken into several step. Like mesa use explicit synchronization all time but ddx use implicit.

The thinking here is that we need to be backward compatible for DRI2/3 and support all kind of different use cases like old DDX and new Mesa, or old Mesa and new DDX etc...

So for my prototype if the kernel sees any access of a BO from two different clients it falls back to the old behavior of implicit synchronization of access to the same buffer object. That might not be the fastest approach, but is as far as I can see conservative and so should work under all conditions.

Apart from that the planning so far was that we just hide this feature behind a couple of command submission flags and new chunks.

Regards,
Christian.

Quoted 23 lines

Cheers,
Jérôme

Quoted 19 lines

Alex

Quoted 17 lines

Also one thing that the Android sync point does not have, AFAICT, is a way to schedule synchronization as part of a cs ioctl so cpu never have to be involve for cmd stream that deal only one gpu (assuming the driver and hw can do such trick).

Cheers,
Jérôme

Quoted 5 lines

-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#9 lore raw
Quoted 44 lines · Christian König

Am 12.09.2014 um 17:33 schrieb Jerome Glisse:

Quoted 31 lines · Alex Deucher
Quoted 28 lines · Jerome Glisse
Quoted 19 lines · Daniel Vetter
Quoted 18 lines · Daniel Vetter
Quoted 17 lines · Christian König
Quoted 11 lines

Hello everyone,

to allow concurrent buffer access by different engines beyond the multiple readers/single writer model that we currently use in radeon and other drivers we need some kind of synchonization object exposed to userspace.

My initial patch set for this used (or rather abused) zero sized GEM buffers as fence handles. This is obviously isn't the best way of doing this (to much overhead, rather ugly etc...), Jerome commented on this accordingly.

So what should a driver expose instead? Android sync points? Something else?

I think actually exposing the struct fence objects as a fd, using android syncpts (or at least something compatible to it) is the way to go. Problem is that it's super-hard to get the android guys out of hiding for this :(

Adding a bunch of people in the hopes that something sticks.

Quoted 8 lines
Quoted 1 line

More people.

Just to re-iterate, exposing such thing while still using command stream ioctl that use implicit synchronization is a waste and you can only get the lowest common denominator which is implicit synchronization. So i do not see the point of such api if you are not also adding a new cs ioctl with explicit contract that it does not do any kind of synchronization (it could be almost the exact same code modulo the do not wait for previous cmd to complete).

Quoted 2 lines

Our thinking was to allow explicit sync from a single process, but implicitly sync between processes.

Quoted 7 lines

This is a BIG NAK if you are using the same ioctl as it would mean you are changing userspace API, well at least userspace expectation. Adding a new cs flag might do the trick but it should not be about inter-process, or any thing special, it's just implicit sync or no synchronization. Converting userspace is not that much of a big deal either, it can be broken into several step. Like mesa use explicit synchronization all time but ddx use implicit.

The thinking here is that we need to be backward compatible for DRI2/3 and support all kind of different use cases like old DDX and new Mesa, or old Mesa and new DDX etc...

Quoted 8 lines

So for my prototype if the kernel sees any access of a BO from two different clients it falls back to the old behavior of implicit synchronization of access to the same buffer object. That might not be the fastest approach, but is as far as I can see conservative and so should work under all conditions.

Apart from that the planning so far was that we just hide this feature behind a couple of command submission flags and new chunks.

Just to reproduce IRC discussion, i think it's a lot simpler and not that complex. For explicit cs ioctl you do not wait for any previous fence of any of the buffer referenced in the cs ioctl, but you still associate a new fence with all the buffer object referenced in the cs ioctl. So if the next ioctl is an implicit sync ioctl it will wait properly and synchronize properly with previous explicit cs ioctl. Hence you can easily have a mix in userspace thing is you only get benefit once enough of your userspace is using explicit.

Note that you still need a way to have explicit cs ioctl to wait on a previos "explicit" fence so you need some api to expose fence per cs submission.

Cheers,
Jérôme

Quoted 28 lines

Regards,
Christian.

Quoted 23 lines

Cheers,
Jérôme

Quoted 19 lines

Alex

Quoted 17 lines

Also one thing that the Android sync point does not have, AFAICT, is a way to schedule synchronization as part of a cs ioctl so cpu never have to be involve for cmd stream that deal only one gpu (assuming the driver and hw can do such trick).

Cheers,
Jérôme

Quoted 5 lines

-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#11 lore raw
In reply to Christian König
Quoted 62 lines · Christian König

Am 12.09.2014 um 17:48 schrieb Jerome Glisse:

Quoted 52 lines · Christian König
Quoted 43 lines

Am 12.09.2014 um 17:33 schrieb Jerome Glisse:

Quoted 31 lines · Alex Deucher
Quoted 28 lines · Jerome Glisse
Quoted 19 lines · Daniel Vetter
Quoted 18 lines · Daniel Vetter
Quoted 17 lines · Christian König
Quoted 11 lines

Hello everyone,

to allow concurrent buffer access by different engines beyond the multiple readers/single writer model that we currently use in radeon and other drivers we need some kind of synchonization object exposed to userspace.

My initial patch set for this used (or rather abused) zero sized GEM buffers as fence handles. This is obviously isn't the best way of doing this (to much overhead, rather ugly etc...), Jerome commented on this accordingly.

So what should a driver expose instead? Android sync points? Something else?

I think actually exposing the struct fence objects as a fd, using android syncpts (or at least something compatible to it) is the way to go. Problem is that it's super-hard to get the android guys out of hiding for this :(

Adding a bunch of people in the hopes that something sticks.

Quoted 8 lines
Quoted 1 line

More people.

Just to re-iterate, exposing such thing while still using command stream ioctl that use implicit synchronization is a waste and you can only get the lowest common denominator which is implicit synchronization. So i do not see the point of such api if you are not also adding a new cs ioctl with explicit contract that it does not do any kind of synchronization (it could be almost the exact same code modulo the do not wait for previous cmd to complete).

Quoted 2 lines

Our thinking was to allow explicit sync from a single process, but implicitly sync between processes.

Quoted 7 lines

This is a BIG NAK if you are using the same ioctl as it would mean you are changing userspace API, well at least userspace expectation. Adding a new cs flag might do the trick but it should not be about inter-process, or any thing special, it's just implicit sync or no synchronization. Converting userspace is not that much of a big deal either, it can be broken into several step. Like mesa use explicit synchronization all time but ddx use implicit.

The thinking here is that we need to be backward compatible for DRI2/3 and support all kind of different use cases like old DDX and new Mesa, or old Mesa and new DDX etc...

Quoted 8 lines

So for my prototype if the kernel sees any access of a BO from two different clients it falls back to the old behavior of implicit synchronization of access to the same buffer object. That might not be the fastest approach, but is as far as I can see conservative and so should work under all conditions.

Apart from that the planning so far was that we just hide this feature behind a couple of command submission flags and new chunks.

Quoted 8 lines

Just to reproduce IRC discussion, i think it's a lot simpler and not that complex. For explicit cs ioctl you do not wait for any previous fence of any of the buffer referenced in the cs ioctl, but you still associate a new fence with all the buffer object referenced in the cs ioctl. So if the next ioctl is an implicit sync ioctl it will wait properly and synchronize properly with previous explicit cs ioctl. Hence you can easily have a mix in userspace thing is you only get benefit once enough of your userspace is using explicit.

Quoted 6 lines

Yes, that's exactly what my patches currently implement.

The only difference is that by current planning I implemented it as a per BO flag for the command submission, but that was just for testing. Having a single flag to switch between implicit and explicit synchronization for whole CS IOCTL would do equally well.

Doing it per BO sounds bogus to me. But otherwise yes we are in agreement. As Daniel said using fd is most likely the way we want to do it but this remains vague.

Quoted 47 lines
Quoted 4 lines

Note that you still need a way to have explicit cs ioctl to wait on a previos "explicit" fence so you need some api to expose fence per cs submission.

Exactly, that's what this mail thread is all about.

As Daniel correctly noted you need something like a functionality to get a fence as the result of a command submission as well as pass in a list of fences to wait for before beginning a command submission.

At least it looks like we are all on the same general line here, its just nobody has a good idea how the details should look like.

Regards,
Christian.

Quoted 29 lines

Cheers,
Jérôme

Quoted 25 lines

Regards,
Christian.

Quoted 22 lines

Cheers,
Jérôme

Quoted 19 lines

Alex

Quoted 17 lines

Also one thing that the Android sync point does not have, AFAICT, is a way to schedule synchronization as part of a cs ioctl so cpu never have to be involve for cmd stream that deal only one gpu (assuming the driver and hw can do such trick).

Cheers,
Jérôme

Quoted 5 lines

-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#12 lore raw
Quoted 2 lines

As Daniel said using fd is most likely the way we want to do it but this remains vague.

Separating the discussion if it should be an fd or not. Using an fd sounds fine to me in general, but I have some concerns as well.

For example what was the maximum number of opened FDs per process again? Could that become a problem? etc...

Please comment,
Christian.

Am 12.09.2014 um 18:03 schrieb Jerome Glisse:

Quoted 115 lines · Christian König
Quoted 61 lines

Am 12.09.2014 um 17:48 schrieb Jerome Glisse:

Quoted 52 lines · Christian König
Quoted 43 lines

Am 12.09.2014 um 17:33 schrieb Jerome Glisse:

Quoted 31 lines · Alex Deucher
Quoted 28 lines · Jerome Glisse
Quoted 19 lines · Daniel Vetter
Quoted 18 lines · Daniel Vetter
Quoted 17 lines · Christian König
Quoted 11 lines

Hello everyone,

to allow concurrent buffer access by different engines beyond the multiple readers/single writer model that we currently use in radeon and other drivers we need some kind of synchonization object exposed to userspace.

My initial patch set for this used (or rather abused) zero sized GEM buffers as fence handles. This is obviously isn't the best way of doing this (to much overhead, rather ugly etc...), Jerome commented on this accordingly.

So what should a driver expose instead? Android sync points? Something else?

I think actually exposing the struct fence objects as a fd, using android syncpts (or at least something compatible to it) is the way to go. Problem is that it's super-hard to get the android guys out of hiding for this :(

Adding a bunch of people in the hopes that something sticks.

Quoted 8 lines
Quoted 1 line

More people.

Just to re-iterate, exposing such thing while still using command stream ioctl that use implicit synchronization is a waste and you can only get the lowest common denominator which is implicit synchronization. So i do not see the point of such api if you are not also adding a new cs ioctl with explicit contract that it does not do any kind of synchronization (it could be almost the exact same code modulo the do not wait for previous cmd to complete).

Quoted 2 lines

Our thinking was to allow explicit sync from a single process, but implicitly sync between processes.

Quoted 7 lines

This is a BIG NAK if you are using the same ioctl as it would mean you are changing userspace API, well at least userspace expectation. Adding a new cs flag might do the trick but it should not be about inter-process, or any thing special, it's just implicit sync or no synchronization. Converting userspace is not that much of a big deal either, it can be broken into several step. Like mesa use explicit synchronization all time but ddx use implicit.

The thinking here is that we need to be backward compatible for DRI2/3 and support all kind of different use cases like old DDX and new Mesa, or old Mesa and new DDX etc...

Quoted 8 lines

So for my prototype if the kernel sees any access of a BO from two different clients it falls back to the old behavior of implicit synchronization of access to the same buffer object. That might not be the fastest approach, but is as far as I can see conservative and so should work under all conditions.

Apart from that the planning so far was that we just hide this feature behind a couple of command submission flags and new chunks.

Quoted 8 lines

Just to reproduce IRC discussion, i think it's a lot simpler and not that complex. For explicit cs ioctl you do not wait for any previous fence of any of the buffer referenced in the cs ioctl, but you still associate a new fence with all the buffer object referenced in the cs ioctl. So if the next ioctl is an implicit sync ioctl it will wait properly and synchronize properly with previous explicit cs ioctl. Hence you can easily have a mix in userspace thing is you only get benefit once enough of your userspace is using explicit.

Quoted 6 lines

Yes, that's exactly what my patches currently implement.

The only difference is that by current planning I implemented it as a per BO flag for the command submission, but that was just for testing. Having a single flag to switch between implicit and explicit synchronization for whole CS IOCTL would do equally well.

Doing it per BO sounds bogus to me. But otherwise yes we are in agreement. As Daniel said using fd is most likely the way we want to do it but this remains vague.

Quoted 43 lines
Quoted 3 lines

Note that you still need a way to have explicit cs ioctl to wait on a previos "explicit" fence so you need some api to expose fence per cs submission.

Exactly, that's what this mail thread is all about.

As Daniel correctly noted you need something like a functionality to get a fence as the result of a command submission as well as pass in a list of fences to wait for before beginning a command submission.

At least it looks like we are all on the same general line here, its just nobody has a good idea how the details should look like.

Regards,
Christian.

Quoted 28 lines

Cheers,
Jérôme

Quoted 25 lines

Regards,
Christian.

Quoted 22 lines

Cheers,
Jérôme

Quoted 19 lines

Alex

Quoted 17 lines

Also one thing that the Android sync point does not have, AFAICT, is a way to schedule synchronization as part of a cs ioctl so cpu never have to be involve for cmd stream that deal only one gpu (assuming the driver and hw can do such trick).

Cheers,
Jérôme

Quoted 5 lines

-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#10 lore raw
In reply to Jerome Glisse

Am 12.09.2014 um 17:48 schrieb Jerome Glisse:

Quoted 52 lines · Christian König
Quoted 43 lines

Am 12.09.2014 um 17:33 schrieb Jerome Glisse:

Quoted 31 lines · Alex Deucher
Quoted 28 lines · Jerome Glisse
Quoted 19 lines · Daniel Vetter
Quoted 18 lines · Daniel Vetter
Quoted 17 lines · Christian König
Quoted 11 lines

Hello everyone,

to allow concurrent buffer access by different engines beyond the multiple readers/single writer model that we currently use in radeon and other drivers we need some kind of synchonization object exposed to userspace.

My initial patch set for this used (or rather abused) zero sized GEM buffers as fence handles. This is obviously isn't the best way of doing this (to much overhead, rather ugly etc...), Jerome commented on this accordingly.

So what should a driver expose instead? Android sync points? Something else?

I think actually exposing the struct fence objects as a fd, using android syncpts (or at least something compatible to it) is the way to go. Problem is that it's super-hard to get the android guys out of hiding for this :(

Adding a bunch of people in the hopes that something sticks.

Quoted 8 lines
Quoted 1 line

More people.

Just to re-iterate, exposing such thing while still using command stream ioctl that use implicit synchronization is a waste and you can only get the lowest common denominator which is implicit synchronization. So i do not see the point of such api if you are not also adding a new cs ioctl with explicit contract that it does not do any kind of synchronization (it could be almost the exact same code modulo the do not wait for previous cmd to complete).

Quoted 2 lines

Our thinking was to allow explicit sync from a single process, but implicitly sync between processes.

Quoted 7 lines

This is a BIG NAK if you are using the same ioctl as it would mean you are changing userspace API, well at least userspace expectation. Adding a new cs flag might do the trick but it should not be about inter-process, or any thing special, it's just implicit sync or no synchronization. Converting userspace is not that much of a big deal either, it can be broken into several step. Like mesa use explicit synchronization all time but ddx use implicit.

The thinking here is that we need to be backward compatible for DRI2/3 and support all kind of different use cases like old DDX and new Mesa, or old Mesa and new DDX etc...

Quoted 8 lines

So for my prototype if the kernel sees any access of a BO from two different clients it falls back to the old behavior of implicit synchronization of access to the same buffer object. That might not be the fastest approach, but is as far as I can see conservative and so should work under all conditions.

Apart from that the planning so far was that we just hide this feature behind a couple of command submission flags and new chunks.

Quoted 8 lines

Just to reproduce IRC discussion, i think it's a lot simpler and not that complex. For explicit cs ioctl you do not wait for any previous fence of any of the buffer referenced in the cs ioctl, but you still associate a new fence with all the buffer object referenced in the cs ioctl. So if the next ioctl is an implicit sync ioctl it will wait properly and synchronize properly with previous explicit cs ioctl. Hence you can easily have a mix in userspace thing is you only get benefit once enough of your userspace is using explicit.

Yes, that's exactly what my patches currently implement.

The only difference is that by current planning I implemented it as a per BO flag for the command submission, but that was just for testing. Having a single flag to switch between implicit and explicit synchronization for whole CS IOCTL would do equally well.

Quoted 3 lines

Note that you still need a way to have explicit cs ioctl to wait on a previos "explicit" fence so you need some api to expose fence per cs submission.

Exactly, that's what this mail thread is all about.

As Daniel correctly noted you need something like a functionality to get a fence as the result of a command submission as well as pass in a list of fences to wait for before beginning a command submission.

At least it looks like we are all on the same general line here, its just nobody has a good idea how the details should look like.

Regards,
Christian.

Quoted 29 lines

Cheers,
Jérôme

Quoted 25 lines

Regards,
Christian.

Quoted 22 lines

Cheers,
Jérôme

Quoted 19 lines

Alex

Quoted 17 lines

Also one thing that the Android sync point does not have, AFAICT, is a way to schedule synchronization as part of a cs ioctl so cpu never have to be involve for cmd stream that deal only one gpu (assuming the driver and hw can do such trick).

Cheers,
Jérôme

Quoted 5 lines

-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#13 lore raw
In reply to Christian König
Quoted 1 line · Christian König

pass in a list of fences to wait for before beginning a command submission.

The Android implementation has a mechanism for combining multiple sync points into a brand new single sync pt. Thus APIs only ever need to take in a single fd not a list of them. If the user wants an operation to wait for multiple events to occur then it is up to them to request the combined version first. They can then happily close the individual fds that have been combined and only keep the one big one around. Indeed, even that fd can be closed once it has been passed on to some other API.

Doing such combining and cleaning up fds as soon as they have been passed on should keep each application's fd usage fairly small.

Quoted 126 lines · Christian König
Quoted 2 lines

As Daniel said using fd is most likely the way we want to do it but this remains vague.

Separating the discussion if it should be an fd or not. Using an fd sounds fine to me in general, but I have some concerns as well.

For example what was the maximum number of opened FDs per process again? Could that become a problem? etc...

Please comment,
Christian.

Am 12.09.2014 um 18:03 schrieb Jerome Glisse:

Quoted 115 lines · Christian König
Quoted 61 lines

Am 12.09.2014 um 17:48 schrieb Jerome Glisse:

Quoted 52 lines · Christian König
Quoted 43 lines

Am 12.09.2014 um 17:33 schrieb Jerome Glisse:

Quoted 31 lines · Alex Deucher
Quoted 28 lines · Jerome Glisse
Quoted 19 lines · Daniel Vetter
Quoted 18 lines · Daniel Vetter
Quoted 17 lines · Christian König
Quoted 11 lines

Hello everyone,

to allow concurrent buffer access by different engines beyond the multiple readers/single writer model that we currently use in radeon and other drivers we need some kind of synchonization object exposed to userspace.

My initial patch set for this used (or rather abused) zero sized GEM buffers as fence handles. This is obviously isn't the best way of doing this (to much overhead, rather ugly etc...), Jerome commented on this accordingly.

So what should a driver expose instead? Android sync points? Something else?

I think actually exposing the struct fence objects as a fd, using android syncpts (or at least something compatible to it) is the way to go. Problem is that it's super-hard to get the android guys out of hiding for this :(

Adding a bunch of people in the hopes that something sticks.

Quoted 8 lines
Quoted 1 line

More people.

Just to re-iterate, exposing such thing while still using command stream ioctl that use implicit synchronization is a waste and you can only get the lowest common denominator which is implicit synchronization. So i do not see the point of such api if you are not also adding a new cs ioctl with explicit contract that it does not do any kind of synchronization (it could be almost the exact same code modulo the do not wait for previous cmd to complete).

Quoted 2 lines

Our thinking was to allow explicit sync from a single process, but implicitly sync between processes.

Quoted 7 lines

This is a BIG NAK if you are using the same ioctl as it would mean you are changing userspace API, well at least userspace expectation. Adding a new cs flag might do the trick but it should not be about inter-process, or any thing special, it's just implicit sync or no synchronization. Converting userspace is not that much of a big deal either, it can be broken into several step. Like mesa use explicit synchronization all time but ddx use implicit.

The thinking here is that we need to be backward compatible for DRI2/3 and support all kind of different use cases like old DDX and new Mesa, or old Mesa and new DDX etc...

Quoted 8 lines

So for my prototype if the kernel sees any access of a BO from two different clients it falls back to the old behavior of implicit synchronization of access to the same buffer object. That might not be the fastest approach, but is as far as I can see conservative and so should work under all conditions.

Apart from that the planning so far was that we just hide this feature behind a couple of command submission flags and new chunks.

Quoted 8 lines

Just to reproduce IRC discussion, i think it's a lot simpler and not that complex. For explicit cs ioctl you do not wait for any previous fence of any of the buffer referenced in the cs ioctl, but you still associate a new fence with all the buffer object referenced in the cs ioctl. So if the next ioctl is an implicit sync ioctl it will wait properly and synchronize properly with previous explicit cs ioctl. Hence you can easily have a mix in userspace thing is you only get benefit once enough of your userspace is using explicit.

Quoted 6 lines

Yes, that's exactly what my patches currently implement.

The only difference is that by current planning I implemented it as a per BO flag for the command submission, but that was just for testing. Having a single flag to switch between implicit and explicit synchronization for whole CS IOCTL would do equally well.

Doing it per BO sounds bogus to me. But otherwise yes we are in agreement. As Daniel said using fd is most likely the way we want to do it but this remains vague.

Quoted 43 lines
Quoted 3 lines

Note that you still need a way to have explicit cs ioctl to wait on a previos "explicit" fence so you need some api to expose fence per cs submission.

Exactly, that's what this mail thread is all about.

As Daniel correctly noted you need something like a functionality to get a fence as the result of a command submission as well as pass in a list of fences to wait for before beginning a command submission.

At least it looks like we are all on the same general line here, its just nobody has a good idea how the details should look like.

Regards,
Christian.

Quoted 28 lines

Cheers,
Jérôme

Quoted 25 lines

Regards,
Christian.

Quoted 22 lines

Cheers,
Jérôme

Quoted 19 lines

Alex

Quoted 17 lines

Also one thing that the Android sync point does not have, AFAICT, is a way to schedule synchronization as part of a cs ioctl so cpu never have to be involve for cmd stream that deal only one gpu (assuming the driver and hw can do such trick).

Cheers,
Jérôme

Quoted 5 lines

-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#18 lore raw
In reply to Christian König
Quoted 7 lines · On Fri, 12 Sep 2014 18:08:23 +0200 Christian König <[email protected]>…
Quoted 2 lines

As Daniel said using fd is most likely the way we want to do it but this remains vague.

Separating the discussion if it should be an fd or not. Using an fd sounds fine to me in general, but I have some concerns as well.

For example what was the maximum number of opened FDs per process again? Could that become a problem? etc...

You can check out the i915 patches I posted if you want to see examples. Max fds may be an issue if userspace doesn't clean up its fences. The implementation is pretty easy with the stuff Maarten has done recently.

The changes I still need to make to mine:
- sit on top of Chris's request/seqno changes (driver internals really)
- switch over to execbuf as the main API on the render side (like you're doing)
- add support for display and other timelines

As far as compat goes, I don't think it should be too hard. Even with GPU scheduling, a given context's buffers should all be in-order with respect to one another, so we ought to be able to mix & match clients using explicit fencing and implicit fencing. Though in Mesa I still haven't looked at how to handle server vs client side arb_sync with the scheduler and explicit fencing in place; might need some extra work there...

Signature · 5 lines
Jesse Barnes, Intel Open Source Technology Center
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#14 lore raw
In reply to John Harrison
Quoted 1 line

Doing such combining and cleaning up fds as soon as they have been passed on should keep each application's fd usage fairly small.

Yeah, but this is exactly what we wanted to avoid internally because of the IOCTL overhead.

And thinking more about it for our driver internal use we will definitely hit some limitations with the number of FDs in use and the overhead for creating and closing them. With the execution model we target for the long term we will need something like 10k fences per second or more.

How about this: We use an identifier per client for the fence internally and when we need to somehow expose it to somebody else export it as sync point fd. Very similar to how we currently have GEM handles internally and when we need to expose them export a DMA_buf fd.

Regards,
Christian.

Am 12.09.2014 um 18:38 schrieb John Harrison:

Quoted 136 lines · Christian König
Quoted 1 line

pass in a list of fences to wait for before beginning a command

submission.

The Android implementation has a mechanism for combining multiple sync points into a brand new single sync pt. Thus APIs only ever need to take in a single fd not a list of them. If the user wants an operation to wait for multiple events to occur then it is up to them to request the combined version first. They can then happily close the individual fds that have been combined and only keep the one big one around. Indeed, even that fd can be closed once it has been passed on to some other API.

Doing such combining and cleaning up fds as soon as they have been passed on should keep each application's fd usage fairly small.

Quoted 126 lines · Christian König
Quoted 2 lines

As Daniel said using fd is most likely the way we want to do it but this remains vague.

Separating the discussion if it should be an fd or not. Using an fd sounds fine to me in general, but I have some concerns as well.

For example what was the maximum number of opened FDs per process again? Could that become a problem? etc...

Please comment,
Christian.

Am 12.09.2014 um 18:03 schrieb Jerome Glisse:

Quoted 115 lines · Christian König
Quoted 61 lines

Am 12.09.2014 um 17:48 schrieb Jerome Glisse:

Quoted 52 lines · Christian König
Quoted 43 lines

Am 12.09.2014 um 17:33 schrieb Jerome Glisse:

Quoted 31 lines · Alex Deucher
Quoted 28 lines · Jerome Glisse
Quoted 19 lines · Daniel Vetter
Quoted 18 lines · Daniel Vetter
Quoted 17 lines · Christian König
Quoted 11 lines

Hello everyone,

to allow concurrent buffer access by different engines beyond the multiple readers/single writer model that we currently use in radeon and other drivers we need some kind of synchonization object exposed to userspace.

My initial patch set for this used (or rather abused) zero sized GEM buffers as fence handles. This is obviously isn't the best way of doing this (to much overhead, rather ugly etc...), Jerome commented on this accordingly.

So what should a driver expose instead? Android sync points? Something else?

I think actually exposing the struct fence objects as a fd, using android syncpts (or at least something compatible to it) is the way to go. Problem is that it's super-hard to get the android guys out of hiding for this :(

Adding a bunch of people in the hopes that something sticks.

Quoted 8 lines
Quoted 1 line

More people.

Just to re-iterate, exposing such thing while still using command stream ioctl that use implicit synchronization is a waste and you can only get the lowest common denominator which is implicit synchronization. So i do not see the point of such api if you are not also adding a new cs ioctl with explicit contract that it does not do any kind of synchronization (it could be almost the exact same code modulo the do not wait for previous cmd to complete).

Quoted 2 lines

Our thinking was to allow explicit sync from a single process, but implicitly sync between processes.

Quoted 7 lines

This is a BIG NAK if you are using the same ioctl as it would mean you are changing userspace API, well at least userspace expectation. Adding a new cs flag might do the trick but it should not be about inter-process, or any thing special, it's just implicit sync or no synchronization. Converting userspace is not that much of a big deal either, it can be broken into several step. Like mesa use explicit synchronization all time but ddx use implicit.

The thinking here is that we need to be backward compatible for DRI2/3 and support all kind of different use cases like old DDX and new Mesa, or old Mesa and new DDX etc...

Quoted 8 lines

So for my prototype if the kernel sees any access of a BO from two different clients it falls back to the old behavior of implicit synchronization of access to the same buffer object. That might not be the fastest approach, but is as far as I can see conservative and so should work under all conditions.

Apart from that the planning so far was that we just hide this feature behind a couple of command submission flags and new chunks.

Quoted 8 lines

Just to reproduce IRC discussion, i think it's a lot simpler and not that complex. For explicit cs ioctl you do not wait for any previous fence of any of the buffer referenced in the cs ioctl, but you still associate a new fence with all the buffer object referenced in the cs ioctl. So if the next ioctl is an implicit sync ioctl it will wait properly and synchronize properly with previous explicit cs ioctl. Hence you can easily have a mix in userspace thing is you only get benefit once enough of your userspace is using explicit.

Quoted 6 lines

Yes, that's exactly what my patches currently implement.

The only difference is that by current planning I implemented it as a per BO flag for the command submission, but that was just for testing. Having a single flag to switch between implicit and explicit synchronization for whole CS IOCTL would do equally well.

Doing it per BO sounds bogus to me. But otherwise yes we are in agreement. As Daniel said using fd is most likely the way we want to do it but this remains vague.

Quoted 43 lines
Quoted 3 lines

Note that you still need a way to have explicit cs ioctl to wait on a previos "explicit" fence so you need some api to expose fence per cs submission.

Exactly, that's what this mail thread is all about.

As Daniel correctly noted you need something like a functionality to get a fence as the result of a command submission as well as pass in a list of fences to wait for before beginning a command submission.

At least it looks like we are all on the same general line here, its just nobody has a good idea how the details should look like.

Regards,
Christian.

Quoted 28 lines

Cheers,
Jérôme

Quoted 25 lines

Regards,
Christian.

Quoted 22 lines

Cheers,
Jérôme

Quoted 19 lines

Alex

Quoted 17 lines

Also one thing that the Android sync point does not have, AFAICT, is a way to schedule synchronization as part of a cs ioctl so cpu never have to be involve for cmd stream that deal only one gpu (assuming the driver and hw can do such trick).

Cheers,
Jérôme

Quoted 5 lines

-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#15 lore raw

BTW, we can recycle fences in userspace just like we recycle buffers. That should make the create/close overhead non-existent.

Marek

Quoted 236 lines · Christian König
Quoted 2 lines

Doing such combining and cleaning up fds as soon as they have been passed on should keep each application's fd usage fairly small.

Yeah, but this is exactly what we wanted to avoid internally because of the IOCTL overhead.

And thinking more about it for our driver internal use we will definitely hit some limitations with the number of FDs in use and the overhead for creating and closing them. With the execution model we target for the long term we will need something like 10k fences per second or more.

How about this: We use an identifier per client for the fence internally and when we need to somehow expose it to somebody else export it as sync point fd. Very similar to how we currently have GEM handles internally and when we need to expose them export a DMA_buf fd.

Regards,
Christian.

Am 12.09.2014 um 18:38 schrieb John Harrison:

Quoted 12 lines · Christian König
Quoted 2 lines

pass in a list of fences to wait for before beginning a command submission.

The Android implementation has a mechanism for combining multiple sync points into a brand new single sync pt. Thus APIs only ever need to take in a single fd not a list of them. If the user wants an operation to wait for multiple events to occur then it is up to them to request the combined version first. They can then happily close the individual fds that have been combined and only keep the one big one around. Indeed, even that fd can be closed once it has been passed on to some other API.

Quoted 202 lines

Doing such combining and cleaning up fds as soon as they have been passed on should keep each application's fd usage fairly small.

Quoted 197 lines · Christian König
Quoted 3 lines

As Daniel said using fd is most likely the way we want to do it but this remains vague.

Separating the discussion if it should be an fd or not. Using an fd sounds fine to me in general, but I have some concerns as well.

For example what was the maximum number of opened FDs per process again? Could that become a problem? etc...

Please comment,
Christian.

Am 12.09.2014 um 18:03 schrieb Jerome Glisse:

Quoted 181 lines · Christian König
Quoted 114 lines

Am 12.09.2014 um 17:48 schrieb Jerome Glisse:

Quoted 96 lines · Christian König
Quoted 90 lines

Am 12.09.2014 um 17:33 schrieb Jerome Glisse:

Quoted 59 lines · Alex Deucher
Quoted 54 lines
Quoted 38 lines · Jerome Glisse
Quoted 32 lines · Daniel Vetter
Quoted 29 lines · Daniel Vetter
Quoted 19 lines · Christian König

Hello everyone,

to allow concurrent buffer access by different engines beyond
the multiple
readers/single writer model that we currently use in radeon and
other
drivers we need some kind of synchonization object exposed to
userspace.

My initial patch set for this used (or rather abused) zero
sized GEM buffers
as fence handles. This is obviously isn't the best way of doing
this (to
much overhead, rather ugly etc...), Jerome commented on this
accordingly.

So what should a driver expose instead? Android sync points?
Something else?

I think actually exposing the struct fence objects as a fd, using android
syncpts (or at least something compatible to it) is the way to go. Problem
is that it's super-hard to get the android guys out of hiding for this :(

Quoted 3 lines
Quoted 1 line

Adding a bunch of people in the hopes that something sticks.

More people.

Quoted 12 lines

Just to re-iterate, exposing such thing while still using command stream
ioctl that use implicit synchronization is a waste and you can only get
the lowest common denominator which is implicit synchronization. So i do
not see the point of such api if you are not also adding a new cs ioctl
with explicit contract that it does not do any kind of synchronization
(it could be almost the exact same code modulo the do not wait for previous cmd to complete).

Quoted 2 lines

Our thinking was to allow explicit sync from a single process, but implicitly sync between processes.

Quoted 13 lines

This is a BIG NAK if you are using the same ioctl as it would mean you are
changing userspace API, well at least userspace expectation. Adding a new
cs flag might do the trick but it should not be about inter-process, or any
thing special, it's just implicit sync or no synchronization. Converting
userspace is not that much of a big deal either, it can be broken into
several step. Like mesa use explicit synchronization all time but ddx use
implicit.

The thinking here is that we need to be backward compatible for DRI2/3 and
support all kind of different use cases like old DDX and new Mesa, or old
Mesa and new DDX etc...

So for my prototype if the kernel sees any access of a BO from two different
clients it falls back to the old behavior of implicit synchronization of
access to the same buffer object. That might not be the fastest approach,
but is as far as I can see conservative and so should work under all conditions.

Quoted 3 lines

Apart from that the planning so far was that we just hide this feature
behind a couple of command submission flags and new chunks.

Quoted 15 lines

Just to reproduce IRC discussion, i think it's a lot simpler and not that
complex. For explicit cs ioctl you do not wait for any previous fence of
any of the buffer referenced in the cs ioctl, but you still associate a
new fence with all the buffer object referenced in the cs ioctl. So if the
next ioctl is an implicit sync ioctl it will wait properly and synchronize
properly with previous explicit cs ioctl. Hence you can easily have a mix
in userspace thing is you only get benefit once enough of your userspace
is using explicit.

Quoted 8 lines

Yes, that's exactly what my patches currently implement.

The only difference is that by current planning I implemented it as a per BO
flag for the command submission, but that was just for testing. Having a
single flag to switch between implicit and explicit synchronization for whole CS IOCTL would do equally well.

Doing it per BO sounds bogus to me. But otherwise yes we are in agreement.
As Daniel said using fd is most likely the way we want to do it but this remains vague.

Quoted 51 lines
Quoted 3 lines

Note that you still need a way to have explicit cs ioctl to wait on a previos "explicit" fence so you need some api to expose fence per cs submission.

Exactly, that's what this mail thread is all about.

As Daniel correctly noted you need something like a functionality to get a
fence as the result of a command submission as well as pass in a list of
fences to wait for before beginning a command submission.

At least it looks like we are all on the same general line here, its just
nobody has a good idea how the details should look like.

Regards,
Christian.

Quoted 32 lines

Cheers,
Jérôme

Quoted 29 lines

Regards,
Christian.

Quoted 26 lines

Cheers,
Jérôme

Quoted 23 lines

Alex

Quoted 21 lines

Also one thing that the Android sync point does not have, AFAICT, is a
way to schedule synchronization as part of a cs ioctl so cpu never have
to be involve for cmd stream that deal only one gpu (assuming the driver
and hw can do such trick).

Cheers,
Jérôme

Quoted 5 lines

-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#16 lore raw

Yeah, right. Providing the fd to reassign to a fence would indeed reduce the create/close overhead.

But it would still be more overhead than for example a simple on demand growing ring buffer which then uses 64bit sequence numbers in userspace to refer to a fence in the kernel.

Apart from that I'm pretty sure that when we do the syncing completely in userspace we need more fences open at the same time than fds are available by default.

As long as our internal handle or sequence based fence are easily convertible to a fence fd I actually don't really see a problem with that. Going to hack that approach into my prototype and then we can see how bad the code looks after all.

Christian.

Am 14.09.2014 um 02:32 schrieb Marek Olšák:

Quoted 220 lines

BTW, we can recycle fences in userspace just like we recycle buffers. That should make the create/close overhead non-existent.

Marek

Quoted 213 lines · Christian König
Quoted 2 lines

Doing such combining and cleaning up fds as soon as they have been passed on should keep each application's fd usage fairly small.

Yeah, but this is exactly what we wanted to avoid internally because of the IOCTL overhead.

And thinking more about it for our driver internal use we will definitely hit some limitations with the number of FDs in use and the overhead for creating and closing them. With the execution model we target for the long term we will need something like 10k fences per second or more.

How about this: We use an identifier per client for the fence internally and when we need to somehow expose it to somebody else export it as sync point fd. Very similar to how we currently have GEM handles internally and when we need to expose them export a DMA_buf fd.

Regards,
Christian.

Am 12.09.2014 um 18:38 schrieb John Harrison:

Quoted 11 lines · Christian König
Quoted 2 lines

pass in a list of fences to wait for before beginning a command submission.

The Android implementation has a mechanism for combining multiple sync points into a brand new single sync pt. Thus APIs only ever need to take in a single fd not a list of them. If the user wants an operation to wait for multiple events to occur then it is up to them to request the combined version first. They can then happily close the individual fds that have been combined and only keep the one big one around. Indeed, even that fd can be closed once it has been passed on to some other API.

Quoted 178 lines

Doing such combining and cleaning up fds as soon as they have been passed on should keep each application's fd usage fairly small.

Quoted 173 lines · Christian König
Quoted 2 lines

As Daniel said using fd is most likely the way we want to do it but this remains vague.

Separating the discussion if it should be an fd or not. Using an fd sounds fine to me in general, but I have some concerns as well.

For example what was the maximum number of opened FDs per process again? Could that become a problem? etc...

Please comment,
Christian.

Am 12.09.2014 um 18:03 schrieb Jerome Glisse:

Quoted 160 lines · Christian König
Quoted 97 lines

Am 12.09.2014 um 17:48 schrieb Jerome Glisse:

Quoted 81 lines · Christian König
Quoted 77 lines

Am 12.09.2014 um 17:33 schrieb Jerome Glisse:

Quoted 48 lines · Alex Deucher
Quoted 45 lines
Quoted 31 lines · Jerome Glisse
Quoted 28 lines · Daniel Vetter
Quoted 26 lines · Daniel Vetter

On Fri, Sep 12, 2014 at 03:23:22PM +0200, Christian König wrote:
Hello everyone,

to allow concurrent buffer access by different engines beyond
the multiple
readers/single writer model that we currently use in radeon and
other
drivers we need some kind of synchonization object exposed to
userspace.

My initial patch set for this used (or rather abused) zero
sized GEM buffers
as fence handles. This is obviously isn't the best way of doing
this (to
much overhead, rather ugly etc...), Jerome commented on this
accordingly.

So what should a driver expose instead? Android sync points?
Something else?
I think actually exposing the struct fence objects as a fd,
using android
syncpts (or at least something compatible to it) is the way to
go. Problem
is that it's super-hard to get the android guys out of hiding
for this :(

Quoted 2 lines
Quoted 1 line

Adding a bunch of people in the hopes that something sticks.

More people.

Quoted 12 lines

Just to re-iterate, exposing such thing while still using command stream
ioctl that use implicit synchronization is a waste and you can only get
the lowest common denominator which is implicit synchronization. So i do
not see the point of such api if you are not also adding a new cs ioctl
with explicit contract that it does not do any kind of synchronization
(it could be almost the exact same code modulo the do not wait for previous cmd to complete).

Quoted 2 lines

Our thinking was to allow explicit sync from a single process, but implicitly sync between processes.

Quoted 13 lines

This is a BIG NAK if you are using the same ioctl as it would mean you are
changing userspace API, well at least userspace expectation. Adding a new
cs flag might do the trick but it should not be about inter-process, or any
thing special, it's just implicit sync or no synchronization. Converting
userspace is not that much of a big deal either, it can be broken into
several step. Like mesa use explicit synchronization all time but ddx use
implicit.

The thinking here is that we need to be backward compatible for DRI2/3 and
support all kind of different use cases like old DDX and new Mesa, or old
Mesa and new DDX etc...

So for my prototype if the kernel sees any access of a BO from two different
clients it falls back to the old behavior of implicit synchronization of
access to the same buffer object. That might not be the fastest approach,
but is as far as I can see conservative and so should work under all conditions.

Quoted 3 lines

Apart from that the planning so far was that we just hide this feature
behind a couple of command submission flags and new chunks.

Quoted 15 lines

Just to reproduce IRC discussion, i think it's a lot simpler and not that
complex. For explicit cs ioctl you do not wait for any previous fence of
any of the buffer referenced in the cs ioctl, but you still associate a
new fence with all the buffer object referenced in the cs ioctl. So if the
next ioctl is an implicit sync ioctl it will wait properly and synchronize
properly with previous explicit cs ioctl. Hence you can easily have a mix
in userspace thing is you only get benefit once enough of your userspace
is using explicit.

Quoted 8 lines

Yes, that's exactly what my patches currently implement.

The only difference is that by current planning I implemented it as a per BO
flag for the command submission, but that was just for testing. Having a
single flag to switch between implicit and explicit synchronization for whole CS IOCTL would do equally well.

Doing it per BO sounds bogus to me. But otherwise yes we are in agreement.
As Daniel said using fd is most likely the way we want to do it but this remains vague.

Quoted 49 lines
Quoted 3 lines

Note that you still need a way to have explicit cs ioctl to wait on a previos "explicit" fence so you need some api to expose fence per cs submission.

Exactly, that's what this mail thread is all about.

As Daniel correctly noted you need something like a functionality to get a
fence as the result of a command submission as well as pass in a list of
fences to wait for before beginning a command submission.

At least it looks like we are all on the same general line here, its just
nobody has a good idea how the details should look like.

Regards,
Christian.

Quoted 31 lines

Cheers,
Jérôme

Quoted 28 lines

Regards,
Christian.

Quoted 25 lines

Cheers,
Jérôme

Quoted 22 lines

Alex

Quoted 20 lines

Also one thing that the Android sync point does not have, AFAICT, is a
way to schedule synchronization as part of a cs ioctl so cpu never have
to be involve for cmd stream that deal only one gpu (assuming the driver
and hw can do such trick).

Cheers,
Jérôme

Quoted 5 lines

-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#17 lore raw
Quoted 10 lines · Christian König

Yeah, right. Providing the fd to reassign to a fence would indeed reduce the create/close overhead.

But it would still be more overhead than for example a simple on demand growing ring buffer which then uses 64bit sequence numbers in userspace to refer to a fence in the kernel.

Apart from that I'm pretty sure that when we do the syncing completely in userspace we need more fences open at the same time than fds are available by default.

If you do the syncing completely in userspace you don't need kernel fences at all. Kernel fences are only required if you sync with a different process (where the pure userspace syncing might not work out) or with different devices.

tbh I don't see any use-case at all where you'd need 10k such fences. That means your driver gets to deal with 2 kinds of fences, but so be it. Since not using fds for cross-device or cross-process syncing imo just doesn't make sense, so that one pretty much will have to stick.

Quoted 4 lines

As long as our internal handle or sequence based fence are easily convertible to a fence fd I actually don't really see a problem with that. Going to hack that approach into my prototype and then we can see how bad the code looks after all.

My plan for i915 is to start out with fd fences only, and once we have some clarity on the exact requirements probably add some pure userspace-controlled fences for tightly coupled stuff. Those might be fully internal to the opencl userspace driver though and never get out of there, ever.
-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch