mlock: only hold mmap_sem in shared mode when
How about (bugfixed):
bool cond_break_mutex(struct mutex *mutex)
{
if (!mutex_is_contended(mutex))
return false;
mutex_unlock(mutex);
mutex_lock(mutex);
return true;
}It would be possible to share work between the unlock and lock slowpaths (particularly the wait_lock acquisition), but that's probably more maintenance effort than it's worth.