From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757302AbdDFKYi (ORCPT ); Thu, 6 Apr 2017 06:24:38 -0400 Received: from bombadil.infradead.org ([65.50.211.133]:36145 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757279AbdDFKYX (ORCPT ); Thu, 6 Apr 2017 06:24:23 -0400 Date: Thu, 6 Apr 2017 12:24:13 +0200 From: Peter Zijlstra To: Davidlohr Bueso Cc: mingo@kernel.org, akpm@linux-foundation.org, jack@suse.cz, kirill.shutemov@linux.intel.com, ldufour@linux.vnet.ibm.com, mhocko@suse.com, mgorman@techsingularity.net, linux-kernel@vger.kernel.org, Davidlohr Bueso Subject: Re: [PATCH 2/6] locking: Introduce range reader/writer lock Message-ID: <20170406102413.ilg4qojezn3fbsbh@hirez.programming.kicks-ass.net> References: <20170406084620.22700-1-dave@stgolabs.net> <20170406084620.22700-3-dave@stgolabs.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170406084620.22700-3-dave@stgolabs.net> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 06, 2017 at 01:46:16AM -0700, Davidlohr Bueso wrote: > +/* > + * Range/interval rw-locking > + * ------------------------- > + * > + * An interval tree of locked and to-be-locked ranges is kept. When a new range > + * lock is requested, we add its interval to the tree and store number of > + * intervals intersecting it to 'blocking_ranges'. You're again confusing semantics with implementation here. > For the reader case, > + * 'blocking_ranges' is only accounted for if the intersecting range is > + * marked as a writer. To achieve mutual exclusion of arbitrary ranges, we > + * guarantee that task is blocked until there are no overlapping ranges in the > + * tree. > + * > + * When a range is unlocked, we again walk intervals that overlap with the > + * unlocked one and decrement their 'blocking_ranges'. Naturally, we wake up > + * owner of any range lock whose 'blocking_ranges' drops to 0. Wakeup order > + * therefore relies on the order of the interval tree -- as opposed to a > + * more traditional fifo mechanism. Which order is that? (I could of course go read the interval tree code, but it shouldn't be too much effort to mention it here). > There is no lock stealing either, which > + * prevents starvation and guarantees fairness. So no lock stealing has always been very bad for performance. So are you sure people will not frob this back in? > +#ifndef _LINUX_RANGE_RWLOCK_H Still don't like the name... rwlock_t is a spinlock.