From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from bombadil.infradead.org ([198.137.202.133]:54734 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727179AbeJ0CVx (ORCPT ); Fri, 26 Oct 2018 22:21:53 -0400 Date: Fri, 26 Oct 2018 10:43:52 -0700 From: Matthew Wilcox To: Bart Van Assche Cc: Alexander Viro , linux-fsdevel@vger.kernel.org, Johannes Berg , Peter Zijlstra , Ingo Molnar , Theodore Ts'o Subject: Re: [PATCH RFC] kernel/locking, fs/direct-io: Introduce and use down_write_nolockdep() Message-ID: <20181026174352.GT25444@bombadil.infradead.org> References: <20181026164905.214474-1-bvanassche@acm.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181026164905.214474-1-bvanassche@acm.org> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Fri, Oct 26, 2018 at 09:49:05AM -0700, Bart Van Assche wrote: > +++ b/include/linux/rwsem.h > @@ -41,6 +41,10 @@ struct rw_semaphore { > #endif > #ifdef CONFIG_DEBUG_LOCK_ALLOC > struct lockdep_map dep_map; > + /* > + * Number of up_write() calls that must skip rwsem_release(). > + */ > + unsigned nolockdep; This reads a bit weird. By definition, only one writer is allowed at a time. And you can't call up_write() before down_write(). So functionally, this is a bool, and the comment should at least ackowledge that, even if it remains implemented as an unsigned int. I'd suggest the implementation uses '= 1' and '= 0' rather than ++ and --. > diff --git a/mm/rmap.c b/mm/rmap.c > index 1e79fac3186b..2a953d3b7431 100644 > --- a/mm/rmap.c > +++ b/mm/rmap.c > @@ -81,6 +81,7 @@ static inline struct anon_vma *anon_vma_alloc(void) > > anon_vma = kmem_cache_alloc(anon_vma_cachep, GFP_KERNEL); > if (anon_vma) { > + init_rwsem(&anon_vma->rwsem); > atomic_set(&anon_vma->refcount, 1); > anon_vma->degree = 1; /* Reference for first vma */ > anon_vma->parent = anon_vma; Why is this needed? The anon_vma_ctor() already calls init_rwsem(). (I suspect this is one of those ctors that isn't actually useful and should be inlined into anon_vma_alloc())