Hello,
before I read the patch I do some tests and there is a problem:

# lscgroup memory:/
cpu,memory:///
cpu,memory:///test1
cpu,memory:///test
# ./cgdelete -g memory:test1 -g cpu:test
# lscgroup memory:/
cpu,memory:///
cpu,memory:///test

Ivana


----- Original Message -----
> From: "Weng Meiling" <wengmeiling.w...@huawei.com>
> To: "Ivana Varekova" <varek...@redhat.com>
> Cc: "Libcg Development list" <libcg-devel@lists.sourceforge.net>, "libo chen" 
> <libo.c...@huawei.com>, "Huang Qiang"
> <h.huangqi...@huawei.com>
> Sent: Saturday, October 12, 2013 3:02:57 AM
> Subject: Re: [PATCH v2] cgdelete:fix the display problem
> 
> Hi Ivana,
> 
>        what do you think about the second version patch about cgdelete
>        problem?
> 
> On 2013/10/8 14:31, Weng Meiling wrote:
> > 
> > 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++;
> >             }
> > 
> 
> 
> 

------------------------------------------------------------------------------
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=60135031&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