[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v2] rwlock: allow recursive read locking when already locked in write mode



On 21.02.2020 15:56, Julien Grall wrote:
> On 21/02/2020 14:49, Roger Pau Monné wrote:
>> On Fri, Feb 21, 2020 at 03:41:59PM +0100, Jan Beulich wrote:
>>> Because you need to invoke smp_processor_id() to calculate the value
>>> to use in the subtraction. I'm not meaning to say I'm entirely
>>> opposed (seeing how much of a discussion we're having), but the
>>> "simple write of zero" approach is certainly appealing.
>>
>> Well, we could avoid the smp_processor_id() call and instead use:
>>
>> atomic_sub(atomic_read(&lock->cnts) & 0xffff, &lock->cnts);
> 
> AFAICT, this would not be safe because the top 16-bit may change behind 
> your back (via a read_lock).

But them changing between the atomic_read() and the atomic_sub()
is fine. The sub then will still only affect the low bits, leaving
the high ones as they were (potentially as updated after the read).

Jan

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.