Re: [PATCH 1/2] kernfs: replace the mutex in kernfs_iop_permission with a rwlock

From: Tejun Heo
Date: Wed Dec 02 2020 - 13:35:22 EST


Hello,

On Wed, Dec 02, 2020 at 10:58:36PM +0800, Fox Chen wrote:
> @@ -121,7 +121,7 @@ int kernfs_iop_setattr(struct dentry *dentry, struct iattr *iattr)
> if (!kn)
> return -EINVAL;
>
> - mutex_lock(&kernfs_mutex);
> + write_lock(&kn->iattr_rwlock);
> error = setattr_prepare(dentry, iattr);
> if (error)
> goto out;
> @@ -134,7 +134,7 @@ int kernfs_iop_setattr(struct dentry *dentry, struct iattr *iattr)
> setattr_copy(inode, iattr);
>
> out:
> - mutex_unlock(&kernfs_mutex);
> + write_unlock(&kn->iattr_rwlock);
> return error;
> }

This is putting GFP_KERNEL allocation inside a rwlock. Can you please test
with debug options including LOCKDEP and DEBUG_ATOMIC_SLEEP turned on?

Thanks.

--
tejun