Hi!
Ugh. This became more complicated than I thought, but I'm OK with moving TTM over to fence while we sort out how / if we're going to use this.
While reviewing, it struck me that this is kind of error-prone, and hard to follow since we're operating on a structure that may be continually updated under us, needing a lot of RCU-specific macros and barriers.
Also the rcu wait appears to not complete until there are no busy fences left (new ones can be added while we wait) rather than waiting on a snapshot of busy fences.
I wonder if these issues can be addressed by having a function that provides a snapshot of all busy fences: This can be accomplished either by including the exclusive fence in the fence_list structure and allocate a new such structure each time it is updated. The RCU reader could then just make a copy of the current fence_list structure pointed to by &obj->fence, but I'm not sure we want to reallocate *each* time we update the fence pointer.
The other approach uses a seqlock to obtain a consistent snapshot, and I've attached an incomplete outline, and I'm not 100% whether it's OK to combine RCU and seqlocks in this way...
Both these approaches have the benefit of hiding the RCU snapshotting in a single function, that can then be used by any waiting or polling function.
/Thomas
On 04/09/2014 04:49 PM, Maarten Lankhorst wrote:
This adds 3 more functions to deal with rcu.
reservation_object_wait_timeout_rcu() will wait on all fences of the reservation_object, without obtaining the ww_mutex.
reservation_object_test_signaled_rcu() will test if all fences of the reservation_object are signaled without using the ww_mutex.
reservation_object_get_excl() is added because touching the fence_excl member directly will trigger a sparse warning.
Signed-off-by: Maarten Lankhorst maarten.lankhorst@canonical.com
drivers/base/dma-buf.c | 46 +++++++++++-- drivers/base/reservation.c | 147 +++++++++++++++++++++++++++++++++++++++++-- include/linux/fence.h | 22 ++++++ include/linux/reservation.h | 40 ++++++++---- 4 files changed, 224 insertions(+), 31 deletions(-)