[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Zy6ROmfQhUvYK9YK@slm.duckdns.org>
Date: Fri, 8 Nov 2024 12:31:22 -1000
From: Tejun Heo <tj@...nel.org>
To: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
Cc: Boqun Feng <boqun.feng@...il.com>, Hillf Danton <hdanton@...a.com>,
"Paul E. McKenney" <paulmck@...nel.org>,
Marco Elver <elver@...gle.com>, linux-kernel@...r.kernel.org,
gregkh@...uxfoundation.org, tglx@...utronix.de,
syzbot <syzbot+6ea37e2e6ffccf41a7e6@...kaller.appspotmail.com>
Subject: Re: [PATCH] kernfs: Use RCU for kernfs_node::name lookup.
Hello, Sebastian.
On Fri, Nov 08, 2024 at 11:24:06PM +0100, Sebastian Andrzej Siewior wrote:
> Instead of using kernfs_rename_lock for lookups of ::name use RCU for
> lookup. Rely on kn's kernfs_root::kernfs_rwsem for update
> synchronisation.
>
> The .*_locked() have been moved into the callers.
> The lock in kernfs_get_parent() has been dropped, the parent node should
> node vanish underneath us. The RCU read-lock and atomic_inc_not_zero()
> is a safety net in case it does.
> kernfs_fop_readdir() no longer drops kernfs_root::kernfs_rwsem to ensure
> the name pointer does not vanish while the page fault is handled.
> kernfs_notify_workfn() gained the lock for the same reason.
I owe an apology. I was just thinking about cgroups. Sysfs, I think, does
allow moving node a different parent, which IIRC is used by netdevs. How
about something like this:
- Add a KERNFS_ROOT flag indicating that parent-changing moves aren't
allowed.
- Update kernfs_rename_ns() to trigger warning and fail if the above flag is
set and new_parent is different from the old one.
- Create a separate interface which uses RCU instead of rename lock for name
/ path lookups. The RCU ones should trigger warning if used when the above
KERNFS_ROOT flag is not set.
Thanks.
--
tejun
Powered by blists - more mailing lists