[PATCH v4 2/2] vkd3d: Don't allow concurrent writes to descriptors.

Derek Lesho dlesho at codeweavers.com
Mon Sep 16 09:07:01 CDT 2019


On 9/15/19 10:22 PM, Conor McCarthy wrote:

> On Sat, Sep 14, 2019 at 12:20 AM Derek Lesho <dlesho at codeweavers.com 
> <mailto:dlesho at codeweavers.com>> wrote:
>
>     +    pthread_spin_lock(descriptor->lock);
>
>
> I think this isn't thread safe. If a thread tries to lock 
> descriptor->lock when another thread has memset the descriptor to 0, 
> it will crash if pthread_spin_lock() doesn't check for null.
>
> For performance reasons I think we need to test the possibility that 
> any thread which meets a locked descriptor can skip the operation 
> entirely. This would save spinning on the lock and an extra descriptor 
> write. If two threads are writing the same descriptor simultaneously, 
> this implies it's essentially random which thread sets what data, so 
> maybe it will work if only the first thread writes the descriptor. 
> Skipping can be done with pthread_spin_trylock(), but 
> InterlockedCompareExchange() would be simpler.
You're right, I did overlook that (descriptor->lock being NULL). I'll 
try your idea to discard writes when one is already in progress with 
SOTTR, that solution should be faster.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20190916/def8bccf/attachment-0001.htm>


More information about the wine-devel mailing list