[PATCH v4 0/4] locking, drm: Fix ww mutex naming / algorithm inconsistency
Thomas Hellstrom
thellstrom at vmware.com
Tue Jun 19 08:24:42 UTC 2018
This is a small fallout from a work to allow batching WW mutex locks and
unlocks.
Our Wound-Wait mutexes actually don't use the Wound-Wait algorithm but
the Wait-Die algorithm. One could perhaps rename those mutexes tree-wide to
"Wait-Die mutexes" or "Deadlock Avoidance mutexes". Another approach suggested
here is to implement also the "Wound-Wait" algorithm as a per-WW-class
choice, as it has advantages in some cases. See for example
http://www.mathcs.emory.edu/~cheung/Courses/554/Syllabus/8-recv+serial/deadlock-compare.html
Now Wound-Wait is a preemptive algorithm, and the preemption is implemented
using a lazy scheme: If a wounded transaction is about to go to sleep on
a contended WW mutex, we return -EDEADLK. That is sufficient for deadlock
prevention. Since with WW mutexes we also require the aborted transaction to
sleep waiting to lock the WW mutex it was aborted on, this choice also provides
a suitable WW mutex to sleep on. If we were to return -EDEADLK on the first
WW mutex lock after the transaction was wounded whether the WW mutex was
contended or not, the transaction might frequently be restarted without a wait,
which is far from optimal. Note also that with the lazy preemption scheme,
contrary to Wait-Die there will be no rollbacks on lock contention of locks
held by a transaction that has completed its locking sequence.
The modeset locks are then changed from Wait-Die to Wound-Wait since the
typical locking pattern of those locks very well matches the criterion for
a substantial reduction in the number of rollbacks. For reservation objects,
the benefit is more unclear at this point and they remain using Wait-Die.
Cc: Ingo Molnar <mingo at redhat.com>
Cc: Jonathan Corbet <corbet at lwn.net>
Cc: Gustavo Padovan <gustavo at padovan.org>
Cc: Maarten Lankhorst <maarten.lankhorst at linux.intel.com>
Cc: Sean Paul <seanpaul at chromium.org>
Cc: David Airlie <airlied at linux.ie>
Cc: Davidlohr Bueso <dave at stgolabs.net>
Cc: "Paul E. McKenney" <paulmck at linux.vnet.ibm.com>
Cc: Josh Triplett <josh at joshtriplett.org>
Cc: Thomas Gleixner <tglx at linutronix.de>
Cc: Kate Stewart <kstewart at linuxfoundation.org>
Cc: Philippe Ombredanne <pombredanne at nexb.com>
Cc: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
Cc: linux-doc at vger.kernel.org
Cc: linux-media at vger.kernel.org
Cc: linaro-mm-sig at lists.linaro.org
v2:
Updated DEFINE_WW_CLASS() API, minor code- and comment fixes as
detailed in each patch.
v3:
Included cleanup patch from Peter Zijlstra. Documentation fixes and
a small correctness fix.
v4:
Reworked the correctness fix.
More information about the dri-devel
mailing list