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