On 21/02/2020 14:59, Roger Pau Monné wrote:
On Fri, Feb 21, 2020 at 02:56:20PM +0000, 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).

Why not? We don't touch the top 16bits in any way, the subtraction
only affects the low 16bits and is done in an atomic manner.

Hmmm, I did misread the code :(. Sorry for the that.


Thanks, Roger.


--
Julien Grall

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

Reply via email to