----- Original Message -----
> From: "Jan Safranek" <[email protected]>
> To: [email protected]
> Sent: Monday, September 2, 2013 10:03:25 AM
> Subject: Re: [Libcg-devel] [PATCH] cgsnapshot: don't display mountpoints
> which are not wanted
>
> On 08/27/2013 10:39 AM, Ivana Hutarova Varekova wrote:
> > the first version of this patch was created by Libo Chen
> > <clbchenlibo.chen@...>
> > see
> > http://sourceforge.net/p/libcg/mailman/libcg-devel/thread/51FB6459.9000307%40huawei.com/#msg31243958
> >
> > before patch:
> > #lscgroup
> > cpu:/
> > cpuset:/
> >
> > #cgsnapshot -s cpu
> >
> > mount {
> > cpuset = /cgroup/cpuacct;
> > cpu = /cgroup/cpu;
> > }
> >
> > We just wanted to save cpu controller, so cpuset was unexpected
> >
> > Changelog:
> > * parse controller list only if the list is set, if there is no
> > restriction display all hierarchies
> > * parse named list as well, thus they are not output if they are not
> > wanted
> > * remove TODO comment
> >
> > Signed-off-by: Ivana Hutarova Varekova <[email protected]>
> > Reported-by: Libo Chen <clbchenlibo.chen@...>
>
> Acked-By: Jan Safranek <[email protected]>
merged
>
> > ---
> >
> > src/tools/cgsnapshot.c | 61
> > +++++++++++++++++++++++++++++++++++-------------
> > 1 files changed, 44 insertions(+), 17 deletions(-)
> >
> > diff --git a/src/tools/cgsnapshot.c b/src/tools/cgsnapshot.c
> > index 046c70a..dd49c9c 100644
> > --- a/src/tools/cgsnapshot.c
> > +++ b/src/tools/cgsnapshot.c
> > @@ -624,8 +624,46 @@ static int show_mountpoints(const char *controller)
> > return 0;
> > }
> >
> > +/* parse whether data about given controller "name" should be displayed.
> > + * If yes then the data are printed. "cont_names" is list of controllers
> > + * which should be shown.
> > + */
> > +static void parse_mountpoint(cont_name_t cont_names[CG_CONTROLLER_MAX],
> > + char *name)
> > +{
> > + int i;
> > +
> > + /* if there is no controller list show all mounted controllers */
> > + if (!(flags & FL_LIST)) {
> > + if (show_mountpoints(name)) {
> > + /* the controller is not mounted */
> > + if ((flags & FL_SILENT) == 0)
> > + fprintf(stderr, "ERROR: %s hierarchy "\
> > + "not mounted\n", name);
> > + }
> > + return;
> > + }
> > +
> > + /* there is controller list - show wanted mounted controllers only */
> > + for (i = 0; i <= CG_CONTROLLER_MAX-1; i++) {
> > + if (!strncmp(cont_names[i], name, strlen(name)+1)) {
> > + /* controller is on the list */
> > + if (show_mountpoints(name)) {
> > + /* the controller is not mounted */
> > + if ((flags & FL_SILENT) == 0) {
> > + fprintf(stderr, "ERROR: %s hierarchy "\
> > + "not mounted\n", name);
> > + }
> > + break;
> > + }
> > + break;
> > + }
> > + }
> > +
> > + return;
> > +}
> > +
> > /* print data about input mount points */
> > -/* TODO only wanted ones */
> > static int parse_mountpoints(cont_name_t cont_names[CG_CONTROLLER_MAX],
> > const char *program_name)
> > {
> > @@ -642,16 +680,8 @@ static int parse_mountpoints(cont_name_t
> > cont_names[CG_CONTROLLER_MAX],
> > while (ret == 0) {
> >
> > /* the controller attached to some hierarchy */
> > - if (info.hierarchy != 0) {
> > - ret = show_mountpoints(info.name);
> > - if (ret != 0) {
> > - /* the controller is not mounted */
> > - if ((flags & FL_SILENT) == 0) {
> > - fprintf(stderr, "ERROR: %s hierarchy "\
> > - "not mounted\n", info.name);
> > - }
> > - }
> > - }
> > + if (info.hierarchy != 0)
> > + parse_mountpoint(cont_names, info.name);
> >
> > /* next controller */
> > ret = cgroup_get_all_controller_next(&handle, &info);
> > @@ -664,19 +694,16 @@ static int parse_mountpoints(cont_name_t
> > cont_names[CG_CONTROLLER_MAX],
> > }
> > final_ret = ret;
> > }
> > -
> > cgroup_get_all_controller_end(&handle);
> >
> > /* process also named hierarchies */
> > ret = cgroup_get_controller_begin(&handle, &mount);
> > while (ret == 0) {
> > - if (strncmp(mount.name, "name=", 5) == 0) {
> > - ret = show_mountpoints(mount.name);
> > - if (ret != 0)
> > - break;
> > - }
> > + if (strncmp(mount.name, "name=", 5) == 0)
> > + parse_mountpoint(cont_names, mount.name);
> > ret = cgroup_get_controller_next(&handle, &mount);
> > }
> > +
> > if (ret != ECGEOF) {
> > if ((flags & FL_SILENT) != 0) {
> > fprintf(stderr,
> >
> >
> > ------------------------------------------------------------------------------
> > Introducing Performance Central, a new site from SourceForge and
> > AppDynamics. Performance Central is your source for news, insights,
> > analysis and resources for efficient Application Performance Management.
> > Visit us today!
> > http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
> > _______________________________________________
> > Libcg-devel mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/libcg-devel
> >
>
>
> ------------------------------------------------------------------------------
> Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
> Discover the easy way to master current and previous Microsoft technologies
> and advance your career. Get an incredible 1,500+ hours of step-by-step
> tutorial videos with LearnDevNow. Subscribe today and save!
> http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk
> _______________________________________________
> Libcg-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/libcg-devel
>
------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk
_______________________________________________
Libcg-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libcg-devel