Skip to contentSkip to conversation

mlock: only hold mmap_sem in shared mode when

PATCH George Spelvin 1 participant 1 message Dec 10, 2010

lore
Share & tools
lore
#0 lore raw

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.