Re: [PATCH] locking/mutex: fix the MUTEX_FLAG_HANDOFF bit is cleared unexpected

From: Xu, Yanfei
Date: Wed Jun 30 2021 - 06:06:35 EST




On 6/30/21 2:20 PM, Xu, Yanfei wrote:
Oh, you are right. The current code doesn't actually prevent lock
stealer from actually stealing the lock in the special case that the
lock is in the unlock state when the HANDOFF bit is set. In this case,

How about setting the HANDOFF bit before the top-waiter first give up
cpu and fall asleep. Then It must can get the lock after being woken up,
and there is no chance happen stealing lock.  And I sent a v2 with this.

Please ignore this, It is incorrect. Lock stealing is a performance
optimization.

Yanfei


it is free for all and whoever gets the lock will also clear the the
HANDOFF bit. The comment in __mutex_trylock_or_owner() about "We set the
HANDOFF bit" isn't quite right.