public inbox for cgroups@vger.kernel.org
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Michal Koutný" <mkoutny@suse.com>,
	"Paul E. McKenney" <paulmck@kernel.org>,
	"Boqun Feng" <boqun.feng@gmail.com>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Hillf Danton" <hdanton@sina.com>,
	"Johannes Weiner" <hannes@cmpxchg.org>,
	"Marco Elver" <elver@google.com>,
	"Zefan Li" <lizefan.x@bytedance.com>,
	tglx@linutronix.de
Subject: Re: [PATCH v2 1/2] kernfs: Make it possible to use RCU for kernfs_node::name lookup.
Date: Tue, 12 Nov 2024 08:52:11 -1000	[thread overview]
Message-ID: <ZzOj2z4g7nzWnCBb@slm.duckdns.org> (raw)
In-Reply-To: <20241112155713.269214-2-bigeasy@linutronix.de>

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

  reply	other threads:[~2024-11-12 18:52 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-12 15:52 [PATCH v2 0/2] Let cgroup use RCU for kernfs_node::name lookup Sebastian Andrzej Siewior
2024-11-12 15:52 ` [PATCH v2 1/2] kernfs: Make it possible to " Sebastian Andrzej Siewior
2024-11-12 18:52   ` Tejun Heo [this message]
2024-11-13  7:42     ` Sebastian Andrzej Siewior
2024-11-14 13:48   ` Michal Koutný
2024-11-15 17:32     ` Sebastian Andrzej Siewior
2024-11-12 15:52 ` [PATCH v2 2/2] cgroup, kernfs: Move cgroup to the RCU interface for name lookups Sebastian Andrzej Siewior
2024-11-12 18:59   ` Tejun Heo
2024-11-13  7:43     ` Sebastian Andrzej Siewior
2024-11-13 12:07       ` Sebastian Andrzej Siewior
2024-11-13 13:23         ` Sebastian Andrzej Siewior
2024-11-13 18:28           ` Tejun Heo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZzOj2z4g7nzWnCBb@slm.duckdns.org \
    --to=tj@kernel.org \
    --cc=bigeasy@linutronix.de \
    --cc=boqun.feng@gmail.com \
    --cc=cgroups@vger.kernel.org \
    --cc=elver@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hannes@cmpxchg.org \
    --cc=hdanton@sina.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizefan.x@bytedance.com \
    --cc=mkoutny@suse.com \
    --cc=paulmck@kernel.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox