From: Weng Meiling <wengmeiling.w...@huawei.com> When multi subsystems mounted on one place like this:
$ lssubsys -m cpu,cpuacct /cgroup/cpu $ lscgroup cpu,cpuacct:/ cpu,cpuacct:/test if we delete the cgroup with the cgdelete -g, and specifying multi controllers like this: $ cgdelete -g cpu,cpuacct:test or $ cgdelete -g cpu:test -g cpuacct:test it will report error: cgdelete: cannot remove group 'test': No such file or directory this patch fix the problem. v1 -> v2 - make cgdelete -g cpu:/test -g cpu:test failed. Signed-off-by: Weng Meiling <wengmeiling.w...@huawei.com> --- src/tools/cgdelete.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src/tools/cgdelete.c b/src/tools/cgdelete.c index e84cd2d..3fb3139 100644 --- a/src/tools/cgdelete.c +++ b/src/tools/cgdelete.c @@ -60,6 +60,9 @@ int main(int argc, char *argv[]) int c; int flags = 0; int final_ret = 0; + int counter = 0, c_number = 0; + int h_list[CG_CONTROLLER_MAX]; + char cont_name[CG_CONTROLLER_MAX][FILENAME_MAX]; struct cgroup_group_spec **cgroup_list = NULL; struct cgroup *cgroup; @@ -139,6 +142,49 @@ int main(int argc, char *argv[]) /* add controllers to the cgroup */ j = 0; while (cgroup_list[i]->controllers[j]) { + int k; + struct controller_data info; + void *handle; + + for (k = 0; k < c_number; k++) + if (!strcmp(cont_name[k], + cgroup_list[i]->controllers[j])) + goto add_controller; + + /* if controller is different, record the controller's + * name, determine and skip the controllers mounted on + * one hierarchy. + */ + strncpy(cont_name[c_number], + cgroup_list[i]->controllers[j], FILENAME_MAX); + cont_name[c_number][FILENAME_MAX-1] = '\0'; + c_number++; + + ret = cgroup_get_all_controller_begin(&handle, &info); + while (ret == 0) { + if (!strcmp(info.name, + cgroup_list[i]->controllers[j])) { + for (k = 0; k < counter; k++) + if (h_list[k] == info.hierarchy) { + cgroup_get_all_controller_end(&handle); + goto skip_add; + } + h_list[counter] = info.hierarchy; + counter++; + break; + } + ret = cgroup_get_all_controller_next(&handle, &info); + } + cgroup_get_all_controller_end(&handle); + if (ret == ECGEOF) + ret = 0; + if (ret) { + fprintf(stderr, + "cgroup_get_controller_begin/next failed(%s)\n", + cgroup_strerror(ret)); + goto err; + } +add_controller: cgc = cgroup_add_controller(cgroup, cgroup_list[i]->controllers[j]); if (!cgc) { @@ -150,6 +196,7 @@ int main(int argc, char *argv[]) cgroup_free(&cgroup); goto err; } +skip_add: j++; } -- 1.8.2.2 ------------------------------------------------------------------------------ October Webinars: Code for Performance Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register > http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk _______________________________________________ Libcg-devel mailing list Libcg-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libcg-devel