[systemd-devel] [PATCH v2] cgroup-util: fix is_valid check to pass for unified cgroup hierchy.

Lennart Poettering lennart at poettering.net
Thu May 28 10:08:48 PDT 2015


On Thu, 28.05.15 16:42, Dimitri John Ledkov (dimitri.j.ledkov at intel.com) wrote:

> It appears in /proc/self/cgroup as `0::/'

What precisely does this fix?

I mean, we need to do some major rework of things before the unified
hierarchy is really supported in systemd, and this one thing won't
really get us too much in this regard, does it?

> ---
> 
>  v2 change: Test for unified cgroup should pass irrespective of
>  whether allow_named is set.
> 
>  src/shared/cgroup-util.c    | 4 ++++
>  src/test/test-cgroup-util.c | 3 ++-
>  2 files changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/src/shared/cgroup-util.c b/src/shared/cgroup-util.c
> index c0b0ca4..eda7523 100644
> --- a/src/shared/cgroup-util.c
> +++ b/src/shared/cgroup-util.c
> @@ -1616,6 +1616,10 @@ bool cg_controller_is_valid(const char *p, bool allow_named) {
>          if (!p)
>                  return false;
>  
> +        /* Unified cgroup */
> +        if (*p == 0)
> +                return true;
> +
>          if (allow_named) {
>                  s = startswith(p, "name=");
>                  if (s)
> diff --git a/src/test/test-cgroup-util.c b/src/test/test-cgroup-util.c
> index 4a89f64..015d3d7 100644
> --- a/src/test/test-cgroup-util.c
> +++ b/src/test/test-cgroup-util.c
> @@ -247,7 +247,8 @@ static void test_controller_is_valid(void) {
>          assert_se(cg_controller_is_valid("foobar", false));
>          assert_se(cg_controller_is_valid("foo_bar", false));
>          assert_se(cg_controller_is_valid("name=foo", true));
> -        assert_se(!cg_controller_is_valid("", false));
> +        assert_se(cg_controller_is_valid("", true));
> +        assert_se(cg_controller_is_valid("", false));
>          assert_se(!cg_controller_is_valid("name=", true));
>          assert_se(!cg_controller_is_valid("=", false));
>          assert_se(!cg_controller_is_valid("cpu,cpuacct", false));
> -- 
> 2.1.4
> 
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list