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

From: Tejun Heo
Date: Wed Dec 02 2020 - 13:38:17 EST


On Wed, Dec 02, 2020 at 10:58:36PM +0800, Fox Chen wrote:
> diff --git a/include/linux/kernfs.h b/include/linux/kernfs.h
> index 89f6a4214a70..545cdb39b34b 100644
> --- a/include/linux/kernfs.h
> +++ b/include/linux/kernfs.h
> @@ -156,6 +156,7 @@ struct kernfs_node {
> unsigned short flags;
> umode_t mode;
> struct kernfs_iattrs *iattr;
> + rwlock_t iattr_rwlock;
> };

Also, while this might not look like much, kernfs_node is very size
sensitive. There are systems with huge number of these nodes, so I don't
think putting a per-node lock like this is a good idea. Either we can use a
shared iattr protecting lock or play some cmpxchg games when allocating and
setting ->iattr and put the lock there.

Thanks.

--
tejun