[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZzOj2z4g7nzWnCBb@slm.duckdns.org>
Date: Tue, 12 Nov 2024 08:52:11 -1000
From: Tejun Heo <tj@...nel.org>
To: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
Cc: cgroups@...r.kernel.org, linux-kernel@...r.kernel.org,
Michal Koutný <mkoutny@...e.com>,
"Paul E. McKenney" <paulmck@...nel.org>,
Boqun Feng <boqun.feng@...il.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Hillf Danton <hdanton@...a.com>,
Johannes Weiner <hannes@...xchg.org>,
Marco Elver <elver@...gle.com>, Zefan Li <lizefan.x@...edance.com>,
tglx@...utronix.de
Subject: Re: [PATCH v2 1/2] kernfs: Make it possible to use RCU for
kernfs_node::name lookup.
Hello,
On Tue, Nov 12, 2024 at 04:52:38PM +0100, Sebastian Andrzej Siewior wrote:
...
> KERNFS_ROOT_SAME_PARENT is added to signal that the parent never
Maybe KERNFS_ROOT_INVARIANT_PARENT captures it better?
...
> @@ -195,13 +191,47 @@ static int kernfs_path_from_node_locked(struct kernfs_node *kn_to,
> */
> int kernfs_name(struct kernfs_node *kn, char *buf, size_t buflen)
> {
> + struct kernfs_root *root;
>
> + guard(read_lock_irqsave)(&kernfs_rename_lock);
> + if (kn) {
> + root = kernfs_root(kn);
> + if (WARN_ON_ONCE(root->flags & KERNFS_ROOT_SAME_PARENT))
> + kn = NULL;
Hmm... does kn need to be set to NULL here?
> + }
> +
> + if (!kn)
> + return strscpy(buf, "(null)", buflen);
> +
> + return strscpy(buf, kn->parent ? kn->name : "/", buflen);
...
> +int kernfs_name_rcu(struct kernfs_node *kn, char *buf, size_t buflen)
> +{
> + struct kernfs_root *root;
> +
> + if (kn) {
> + root = kernfs_root(kn);
> + if (WARN_ON_ONCE(!(root->flags & KERNFS_ROOT_SAME_PARENT)))
> + kn = NULL;
Ah, I suppose it's to keep things symmetric. That's fine.
> + }
> + if (!kn)
> + return strscpy(buf, "(null)", buflen);
> +
> + guard(rcu)();
Also, why are guards in different locations? Even when !SAME_PARENT, kn's
can't jump across roots, so guard there can also be in the same location as
this one?
...
> @@ -200,7 +205,10 @@ struct kernfs_node {
> * parent directly.
> */
> struct kernfs_node *parent;
> - const char *name;
> + union {
> + const char __rcu *name_rcu;
> + const char *name;
> + };
Wouldn't it be simpler if ->name is always __rcu and !SAME_PARENT just
requires further protection on the read side?
Thanks.
--
tejun
Powered by blists - more mailing lists