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

Re: [Xen-devel] [PATCH v2] xen/x86: lock cacheline for add_sized()

On 07.08.19 11:10, Jan Beulich wrote:
On 07.08.2019 09:32, Juergen Gross wrote:
add_sized() should use an atomic update of the memory word, as it is
used by spin_unlock().

Ticket locks are using a read-modify-write operation on parts of the
lockword for unlocking, while trying to lock is done by an atomic
update of the complete lockword. This requires the unlock operation to
be atomic, too, as otherwise the unlock might not write back the
correct data.

I have to take back my reply to v1, and hence I'm afraid that
if the change is really needed the description is still
insufficient. Let's look at both sides: Acquire is a LOCKed
read-modify-write of the full word, with the additional
property that the value written back to the low half is
unchanged from the value read. Release is

     read low half
     increment low half
     write low half

Since the low half doesn't change during any acquire (including
attempts, i.e. try-lock), it doesn't matter if it races with
the above sequence. It can freely happen between any two of the
three steps.

Hmm, sounds sensible.

Therefore what I'm really after is (a) clarification whether
the issue you mean to fix was observed in practice and (b) a
concrete scenario where things would go wrong.

I have seen a crash due to nmi watchdog with my core scheduling series.
It really looked like no one was holding the lock, but two cpus were
waiting for it. I couldn't find another explanation for that behavior,
but there might be another reason for it.

The problem occurred a short time after onlining a cpu when all cpus
tried to gather for time calibration and two of the cpus were not
joining, as they were waiting for the lock with IRQs disabled.

I have seen this scenario only once, but there are other strange hangs
in the same situation, so it might be that the bug I'm still looking for
is the reason for the problem I'm trying to solve with this patch.


Xen-devel mailing list



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