Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755000AbdC2JLZ (ORCPT ); Wed, 29 Mar 2017 05:11:25 -0400 Received: from bombadil.infradead.org ([65.50.211.133]:44993 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752459AbdC2JLY (ORCPT ); Wed, 29 Mar 2017 05:11:24 -0400 Date: Wed, 29 Mar 2017 11:11:14 +0200 From: Peter Zijlstra To: Davidlohr Bueso Cc: mingo@kernel.org, akpm@linux-foundation.org, jack@suse.cz, kirill.shutemov@linux.intel.com, mhocko@suse.com, mgorman@techsingularity.net, linux-kernel@vger.kernel.org, Davidlohr Bueso Subject: Re: [PATCH 1/5] locking: Introduce range reader/writer lock Message-ID: <20170329091114.4fgotmjhh7u2v7ga@hirez.programming.kicks-ass.net> References: <1488863010-13028-1-git-send-email-dave@stgolabs.net> <1488863010-13028-2-git-send-email-dave@stgolabs.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1488863010-13028-2-git-send-email-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 Content-Length: 1145 Lines: 25 On Mon, Mar 06, 2017 at 09:03:26PM -0800, Davidlohr Bueso wrote: > +/* > + * Implementation of read/write range locks. > + * > + * We keep interval tree of locked and to-be-locked ranges. When new range lock > + * is requested, we add its interval to the tree and store number of intervals > + * intersecting it to 'blocking_ranges'. > + * > + * When a range is unlocked, we again walk intervals that intersect with the > + * unlocked one and decrement their 'blocking_ranges'. We wake up owner of any > + * range lock whose 'blocking_ranges' drops to 0. For the shared case, the > + * 'blocking_ranges' is only incremented if the intersecting range is not marked > + * as a reader. Not a word about fairness and starvation... Such important topics for lock primitives. In order to mitigate some of the tree walk overhead for > + * non-intersecting ranges, the tree's min/max values are maintained and consulted > + * in O(1) in the fastpath. > + */ Maybe that ought not be here, doesn't seem like a fundamental design point and would thus be better suited for a comment near where this implementation detail is located ?