From: Li Zefan <lizefan@huawei.com>
To: Tejun Heo <tj@kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>, Cgroups <cgroups@vger.kernel.org>
Subject: [PATCH 3/3] cgroup: deal with dummp_top in cgroup_name() and cgroup_path()
Date: Fri, 14 Feb 2014 16:56:04 +0800 [thread overview]
Message-ID: <52FDDA24.6080204@huawei.com> (raw)
In-Reply-To: <52FDD9C4.1070001@huawei.com>
My kernel fails to boot, because blkcg calls cgroup_path() while
cgroupfs is not mounted.
Fix both cgroup_name() and cgroup_path().
Signed-off-by: Li Zefan <lizefan@huawei.com>
---
include/linux/cgroup.h | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index ef0b3af..8c283a9 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -487,13 +487,21 @@ struct cgroup_subsys_state *seq_css(struct seq_file *seq);
static inline int cgroup_name(struct cgroup *cgrp, char *buf, size_t buflen)
{
- return kernfs_name(cgrp->kn, buf, buflen);
+ /* dummy_top doesn't have a kn associated */
+ if (cgrp->kn)
+ return kernfs_name(cgrp->kn, buf, buflen);
+ else
+ return strlcpy(buf, "/", buflen);
}
static inline char * __must_check cgroup_path(struct cgroup *cgrp, char *buf,
size_t buflen)
{
- return kernfs_path(cgrp->kn, buf, buflen);
+ /* dummy_top doesn't have a kn associated */
+ if (cgrp->kn)
+ return kernfs_path(cgrp->kn, buf, buflen);
+ strlcpy(buf, "/", buflen);
+ return (buflen <= 2) ? NULL : buf;
}
static inline void pr_cont_cgroup_name(struct cgroup *cgrp)
--
1.8.0.2
next prev parent reply other threads:[~2014-02-14 8:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-14 8:54 [PATCH 1/3] cgroup: fix locking in cgroupstats_build() Li Zefan
2014-02-14 8:55 ` [PATCH 2/3] cgroup: fix memory leak in cgroup_mount() Li Zefan
2014-02-14 8:56 ` Li Zefan [this message]
[not found] ` <52FDD9C4.1070001-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2014-02-14 15:57 ` [PATCH 1/3] cgroup: fix locking in cgroupstats_build() Tejun Heo
2014-02-14 15:57 ` 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=52FDDA24.6080204@huawei.com \
--to=lizefan@huawei.com \
--cc=cgroups@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tj@kernel.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.