]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
when we use cgsnapshot with the given controller, the result always
authorWeng Meiling <wengmeiling.weng@huawei.com>
Tue, 23 Jul 2013 12:30:33 +0000 (14:30 +0200)
committerWeng Meiling <wengmeiling.weng@huawei.com>
Tue, 23 Jul 2013 12:30:33 +0000 (14:30 +0200)
displays
the last mounted controller which is not specified, so fix it.

Example:

# lssubsys  -m
cpuset /cgroup/cpuset
cpu /cgroup/cpu
# lscgroup
cpu:/
cpu:/test
cpuset:/
cpuset:/test

before the patch:

# cgsnapshot -s cpu
# Configuration file generated by cgsnapshot
mount {
cpuset = /cgroup/cpuset;
cpu = /cgroup/cpu;
}

group test {
cpu {
cpu.rt_period_us="1000000";
cpu.rt_runtime_us="0";
cpu.shares="1024";
}
}

group test {
cpuset {
cpuset.memory_spread_slab="0";
cpuset.memory_spread_page="0";
cpuset.memory_migrate="0";
cpuset.sched_relax_domain_level="-1";
cpuset.sched_load_balance="1";
cpuset.mem_hardwall="0";
cpuset.mem_exclusive="0";
cpuset.cpu_exclusive="0";
cpuset.mems="";
cpuset.cpus="";
}
}

after the patch:

# cgsnapshot -s cpu
# Configuration file generated by cgsnapshot
mount {
cpuset = /cgroup/cpuset;
cpu = /cgroup/cpu;
}

group test {
cpu {
cpu.rt_period_us="1000000";
cpu.rt_runtime_us="0";
cpu.shares="1024";
}
}

Signed-off-by: Weng Meiling <wengmeiling.weng@huawei.com>
src/tools/cgsnapshot.c

index 8217798f32060e6669e0c09204c35d3dabeb9270..046c70a12775ed0ece74aea7555e7174f5f7880e 100644 (file)
@@ -582,7 +582,9 @@ static int parse_controllers(cont_name_t cont_names[CG_CONTROLLER_MAX],
                ret = cgroup_get_controller_next(&handle, &controller);
        }
 
-       if (max != 0) {
+       if ((!(flags & FL_LIST) ||
+               (is_ctlr_on_list(controllers, cont_names)))
+               && (max != 0)) {
                (controllers[max])[0] = '\0';
                ret = display_controller_data(
                        controllers, program_name);