Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dma-buf: Relax the write-seqlock for reallocating the shared fence list

As the set of shared fences is not being changed during reallocation of
the reservation list, we can skip updating the write_seqlock.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Christian König <christian.koenig@amd.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20190712080314.21018-2-chris@chris-wilson.co.uk

+7 -7
+7 -7
drivers/dma-buf/reservation.c
··· 157 157 (ksize(new) - offsetof(typeof(*new), shared)) / 158 158 sizeof(*new->shared); 159 159 160 - preempt_disable(); 161 - write_seqcount_begin(&obj->seq); 162 160 /* 163 - * RCU_INIT_POINTER can be used here, 164 - * seqcount provides the necessary barriers 161 + * We are not changing the effective set of fences here so can 162 + * merely update the pointer to the new array; both existing 163 + * readers and new readers will see exactly the same set of 164 + * active (unsignaled) shared fences. Individual fences and the 165 + * old array are protected by RCU and so will not vanish under 166 + * the gaze of the rcu_read_lock() readers. 165 167 */ 166 - RCU_INIT_POINTER(obj->fence, new); 167 - write_seqcount_end(&obj->seq); 168 - preempt_enable(); 168 + rcu_assign_pointer(obj->fence, new); 169 169 170 170 if (!old) 171 171 return 0;