----- Original Message -----
> From: "Weng Meiling" <wengmeiling.w...@huawei.com>
> To: libcg-devel@lists.sourceforge.net
> Cc: "libo chen" <libo.c...@huawei.com>
> Sent: Friday, August 2, 2013 10:27:00 AM
> Subject: [Libcg-devel] [PATCH]add the value check before set the control      
> file value
> 
> 
> From: Weng Meiling <wengmeiling.w...@huawei.com>
> 
> When we use memory subsystem, the memory.oom_control value we get like
> this:
> 
> oom_kill_disable 0
> under_oom 0
> 
> but we set the value just by writing a value(0 or 1) like this:
> 
> #echo 1 > memory.oom_control
> 
> so setting the value memory.oom_control by cgset --copy-from or
> the config from cgsnapshot will fail, so before setting the control
> file value, checking the value and resetting the value.
> 
> Signed-off-by: Weng Meiling <wengmeiling.w...@huawei.com>
The solution is not optimal, but it fix the problem which you describes for 
now. Thus I ack the solution.
If there will be no negative reply I will merge it on Tuesday.
Acked-by: Ivana Hutarova Varekova <varek...@redhat.com>
> ---
>  src/api.c |   23 +++++++++++++++++++++++
>  1 files changed, 23 insertions(+), 0 deletions(-)
> 
> diff --git a/src/api.c b/src/api.c
> index e5e1959..72a285b 100644
> --- a/src/api.c
> +++ b/src/api.c
> @@ -1351,6 +1351,25 @@ static int cg_create_control_group(const char *path)
>  }
> 
>  /*
> + *
> + *cg_set_control_value_before()
> + *This is the function for deal with some sepcial control file value.
> + */
> +static void cg_set_control_value_before(char *name, char *val)
> +{
> +     if (!strcmp("memory.oom_control", name) && strstr(val, 
> "oom_kill_disable"))
> {
> +             /* get the control setting */
> +             char *seps = " ,\n";
> +             char *temp = NULL;
> +             temp = strtok(val, seps);
> +             temp = strtok(NULL, seps);
> +             strcpy(val, temp);
> +             return ;
> +     }
> +}
> +
> +
> +/*
>   * set_control_value()
>   * This is the low level function for putting in a value in a control file.
>   * This function takes in the complete path and sets the value in val in
>   that
> @@ -1463,6 +1482,8 @@ int cgroup_modify_cgroup(struct cgroup *cgroup)
>                               error = ECGOTHER;
>                               goto err;
>                       }
> +                     
> cg_set_control_value_before(cgroup->controller[i]->values[j]->name,
> +                             cgroup->controller[i]->values[j]->value);
>                       error = cg_set_control_value(path,
>                               cgroup->controller[i]->values[j]->value);
>                       free(path);
> @@ -1644,6 +1665,8 @@ int cgroup_create_cgroup(struct cgroup *cgroup, int
> ignore_ownership)
>                               error = ECGOTHER;
>                               goto err;
>                       }
> +                     
> cg_set_control_value_before(cgroup->controller[k]->values[j]->name,
> +                             cgroup->controller[k]->values[j]->value);
>                       error = cg_set_control_value(path,
>                               cgroup->controller[k]->values[j]->value);
>                       /*
> -- 1.7.1
> 
> 
> 
> ------------------------------------------------------------------------------
> Get your SQL database under version control now!
> Version control is standard for application code, but databases havent
> caught up. So what steps can you take to put your SQL databases under
> version control? Why should you start doing it? Read more to find out.
> http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk
> _______________________________________________
> Libcg-devel mailing list
> Libcg-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/libcg-devel
> 

------------------------------------------------------------------------------
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
Libcg-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libcg-devel

Reply via email to