All of lore.kernel.org
 help / color / mirror / Atom feed
From: Li Zefan <lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
To: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
Subject: Re: [PATCH cgroup/for-3.10] cgroup: make cgroup_path() not print double slashes
Date: Mon, 15 Apr 2013 11:10:33 +0800	[thread overview]
Message-ID: <516B6FA9.9030301@huawei.com> (raw)
In-Reply-To: <20130414173704.GB3050-Gd/HAXX7CRxy/B6EtB590w@public.gmane.org>

On 2013/4/15 1:37, Tejun Heo wrote:
>>From 277f3d4be79aefe2071d9053a9c7c89c4e5dad30 Mon Sep 17 00:00:00 2001
> From: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
> Date: Sun, 14 Apr 2013 10:32:19 -0700
> 
> While reimplementing cgroup_path(), 65dff759d2 ("cgroup: fix
> cgroup_path() vs rename() race") introduced a bug where the path of a
> non-root cgroup would have two slahses at the beginning, which is
> caused by adding '/' before the name of the root cgroup which is an
> empty string.
> 

I guess I booted a wrong kernel when testing that patch...

>  $ grep systemd /proc/self/cgroup
>  1:name=systemd://user/root/1
> 
> Fix it by special casing root cgroup.
> 

I made a patch to fix it before the weekend, but didn't post it. It doesn't
treat root-only cgroup specially.

You can apply whichever you like better.

> Signed-off-by: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
> Cc: Li Zefan <lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
> ---
> Applying to cgroup/for-3.10.
> 
> Thanks.
> 
>  kernel/cgroup.c | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
> 

[PATCH] cgroup: make cgroup_path() not print double slashes

While reimplementing cgroup_path(), 65dff759d2 ("cgroup: fix
cgroup_path() vs rename() race") introduced a bug where the path of a
non-root cgroup would have two slahses at the beginning, which is
caused by treating the root cgroup which has the name '/' like
non-root cgroups.

Fix it by not adding '/' if it's the root cgroup.

 $ grep systemd /proc/self/cgroup
 1:name=systemd://user/root/1

Signed-off-by: Li Zefan <lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
---
 kernel/cgroup.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 06aeb42..2a28425 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1809,14 +1809,15 @@ int cgroup_path(const struct cgroup *cgrp, char *buf, int buflen)
 			goto out;
 		memcpy(start, name, len);
 
-		if (!cgrp->parent)
+		cgrp = cgrp->parent;
+		if (!cgrp)
 			break;
+		if (!cgrp->parent)
+			continue;
 
 		if (--start < buf)
 			goto out;
 		*start = '/';
-
-		cgrp = cgrp->parent;
 	}
 	ret = 0;
 	memmove(buf, start, buf + buflen - start);
-- 
1.8.0.2

  parent reply	other threads:[~2013-04-15  3:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-14 17:37 [PATCH cgroup/for-3.10] cgroup: make cgroup_path() not print double slashes Tejun Heo
     [not found] ` <20130414173704.GB3050-Gd/HAXX7CRxy/B6EtB590w@public.gmane.org>
2013-04-14 17:48   ` [PATCH UPDATED " Tejun Heo
2013-04-15  3:10   ` Li Zefan [this message]
     [not found]     ` <516B6FA9.9030301-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2013-04-15  3:18       ` [PATCH " Tejun Heo
2013-04-15  3:18       ` Tejun Heo
  -- strict thread matches above, loose matches on Subject: below --
2013-04-14 17:37 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=516B6FA9.9030301@huawei.com \
    --to=lizefan-hv44wf8li93qt0dzr+alfa@public.gmane.org \
    --cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.