Re: [PATCH] kernfs: switch global kernfs_rwsem lock to per-fs lock

From: Greg Kroah-Hartman
Date: Tue Nov 23 2021 - 01:44:58 EST


On Mon, Nov 22, 2021 at 09:39:28AM -0800, Minchan Kim wrote:
> On Thu, Nov 18, 2021 at 01:03:32PM -1000, Tejun Heo wrote:
> > On Thu, Nov 18, 2021 at 03:00:08PM -0800, Minchan Kim wrote:
> > > The kernfs implementation has big lock granularity(kernfs_rwsem) so
> > > every kernfs-based(e.g., sysfs, cgroup) fs are able to compete the
> > > lock. It makes trouble for some cases to wait the global lock
> > > for a long time even though they are totally independent contexts
> > > each other.
> > >
> > > A general example is process A goes under direct reclaim with holding
> > > the lock when it accessed the file in sysfs and process B is waiting
> > > the lock with exclusive mode and then process C is waiting the lock
> > > until process B could finish the job after it gets the lock from
> > > process A.
> > >
> > > This patch switches the global kernfs_rwsem to per-fs lock, which
> > > put the rwsem into kernfs_root.
> > >
> > > Suggested-by: Tejun Heo <tj@xxxxxxxxxx>
> > > Signed-off-by: Minchan Kim <minchan@xxxxxxxxxx>
> >
> > Acked-by: Tejun Heo <tj@xxxxxxxxxx>
> >
> > Greg, I think this is the right thing to do even if there is no concrete
> > performance argument (not saying there isn't). It's just weird to entangle
> > these completely unrelated users in a single rwsem.
> >
> > Thanks.
>
> Greg, Do you mind picking this patch?

$ mdfrm -c ~/mail/todo/
1872 messages in /home/gregkh/mail/todo/

Give me a chance to catch up...

thanks,

greg k-h