From: Weng Meiling <wengmeiling.w...@huawei.com>
Date: Mon, 15 Jul 2013 04:08:20 -0400
Subject: [PATCH] cgsnapshot: fix the display message of the given controllers

when we use cgsnapshot with the given controller, the result always 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.w...@huawei.com>
---
 src/tools/cgsnapshot.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/tools/cgsnapshot.c b/src/tools/cgsnapshot.c
index 324f93b..166611b 100644
--- a/src/tools/cgsnapshot.c
+++ b/src/tools/cgsnapshot.c
@@ -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);
-- 
1.8.2.2



------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Libcg-devel mailing list
Libcg-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libcg-devel

Reply via email to