Re: [PATCH RFC] kernel/locking, fs/direct-io: Introduce and use down_write_nolockdep()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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())



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux