From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755357Ab0LJLNQ (ORCPT ); Fri, 10 Dec 2010 06:13:16 -0500 Received: from canuck.infradead.org ([134.117.69.58]:59247 "EHLO canuck.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753672Ab0LJLNP convert rfc822-to-8bit (ORCPT ); Fri, 10 Dec 2010 06:13:15 -0500 Subject: Re: [PATCH 1/6] mlock: only hold mmap_sem in shared mode when faulting in pages From: Peter Zijlstra To: Michel Lespinasse Cc: Linus Torvalds , Andrew Morton , "linux-mm@kvack.org" , Hugh Dickins , Rik van Riel , Nick Piggin , KOSAKI Motohiro , "linux-kernel@vger.kernel.org" In-Reply-To: References: <1291335412-16231-1-git-send-email-walken@google.com> <1291335412-16231-2-git-send-email-walken@google.com> <20101208152740.ac449c3d.akpm@linux-foundation.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT Date: Fri, 10 Dec 2010 12:12:49 +0100 Message-ID: <1291979569.6803.114.camel@twins> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2010-12-09 at 22:39 -0800, Michel Lespinasse wrote: > I think rwsem_is_contended() actually sounds better than fiddling with > constants, but OTOH maybe the mlock use case is not significant enough > to justify introducing that new API. Right, so I don't see the problem with _is_contended() either. In fact, I introduce mutex_is_contended() in the mmu_preempt series to convert existing (spin) lock break tests. If you want to do lock-breaks like cond_resched_lock() all you really have is *_is_contended(), sleeping locks will schedule unconditional. int cond_break_mutex(struct mutex *mutex) { int ret = 0; if (mutex_is_contended(mutex)) { mutex_unlock(mutex); ret = 1; mutex_lock(mutex); } return 1; } Or more exotic lock breaks, like the mmu-gather stuff, which falls out of its nested page-table loops and restarts the whole affair.