On 2013/10/23 10:58, Dhaval Giani wrote: > Hi, > > Sorry for the delay in getting back. > > On Wed, Oct 16, 2013 at 5:35 AM, Weng Meiling > <wengmeiling.w...@huawei.com> wrote: >> >> From: Weng Meiling <wengmeiling.w...@huawei.com> >> >> After setting memory.limit_in_bytes and memory.memsw.limit_in_bytes, >> use cgsnapshot -f to save the current cgroup configure, then use >> cgconfigparser to resume it according the configure file, but it failed. >> >> The steps: >> >> $ cgsnapshot -s memory -f config >> $ cat config >> mount { >> memory = /cgroup/memory; >> } >> >> group test { >> memory { >> memory.memsw.failcnt="0"; >> memory.memsw.limit_in_bytes="2097152"; >> memory.memsw.max_usage_in_bytes="0"; >> memory.oom_control="oom_kill_disable 0 >> under_oom 0"; >> memory.move_charge_at_immigrate="0"; >> memory.swappiness="60"; >> memory.use_hierarchy="0"; >> memory.force_empty=""; >> memory.failcnt="0"; >> memory.soft_limit_in_bytes="18446744073709551615"; >> memory.limit_in_bytes="1048576"; >> memory.max_usage_in_bytes="0"; >> } >> } >> >> $ cgclear >> $ cgconfigparser -l config >> /usr/sbin/cgconfigparser; error loading config: Failed to remove a non-empty >> group >> >> cgconfigparser failed because the memory.memsw.limit_in_bytes is setted >> before >> memory.limit_in_bytes, when setting memory.memsw.limit_in_bytes, >> memory.limit_in_bytes >> is still the default value 18446744073709551615, so it failed. This patch >> fixes the >> problem. It makes cgconfigparser command set memory.limit_in_bytes before >> memory.memsw.limit_in_bytes. >> >> v2 --> v3 >> have the ordering hardcoded into the code. >> > > But you haven't done what I was expecting :-). Having said that, I was > also not very clear on what I was expecting. I do apologize for that. > I will send a patch out with the changes I was thinking about in a day > or so. (that might be easier, and you won't waste time trying to get > this issue resolved)
It's nice :-) Thanks! Weng Meiling > > Thanks! > Dhaval > >> Signed-off-by: Weng Meiling <wengmeiling.w...@huawei.com> >> --- >> src/config.c | 41 ++++++++++++++++++++++++++++++++++++++++- >> 1 file changed, 40 insertions(+), 1 deletion(-) >> >> diff --git a/src/config.c b/src/config.c >> index ac844a7..ffaea33 100644 >> --- a/src/config.c >> +++ b/src/config.c >> @@ -726,10 +726,49 @@ out_err: >> static int cgroup_config_create_groups(void) >> { >> int error = 0; >> - int i; >> + int i, j, k; >> >> for (i = 0; i < cgroup_table_index; i++) { >> struct cgroup *cgroup = &config_cgroup_table[i]; >> + /* >> + * ensure memory.memsw.limit_in_bytes will be set before >> + * memory.limit_in_bytes to avoid cgconfigparser fail. >> + */ >> + for (j = 0; j < cgroup->index; j++) { >> + if (!strcmp(cgroup->controller[j]->name, "memory")) { >> + int mem_idx = 0; >> + int memsw_idx = 0; >> + char name[FILENAME_MAX], value[CG_VALUE_MAX]; >> + >> + for (k = 0; k < >> cgroup->controller[j]->index; k++) >> + if >> (!strcmp(cgroup->controller[j]->values[k]->name, >> + "memory.limit_in_bytes")) >> + mem_idx = k; >> + else if >> (!strcmp(cgroup->controller[j]->values[k]->name, >> + >> "memory.memsw.limit_in_bytes")) >> + memsw_idx = k; >> + if (memsw_idx && (mem_idx > memsw_idx)) { >> + memset(name, 0, FILENAME_MAX); >> + memset(value, 0, CG_VALUE_MAX); >> + strncpy(name, >> + >> cgroup->controller[j]->values[mem_idx]->name, >> + FILENAME_MAX); >> + strncpy(value, >> + >> cgroup->controller[j]->values[mem_idx]->value, >> + CG_VALUE_MAX); >> + >> strncpy(cgroup->controller[j]->values[mem_idx]->name, >> + >> cgroup->controller[j]->values[memsw_idx]->name, >> + FILENAME_MAX); >> + >> strncpy(cgroup->controller[j]->values[mem_idx]->value, >> + >> cgroup->controller[j]->values[memsw_idx]->value, >> + CG_VALUE_MAX); >> + >> strncpy(cgroup->controller[j]->values[memsw_idx]->name, >> + name, FILENAME_MAX); >> + >> strncpy(cgroup->controller[j]->values[memsw_idx]->value, >> + value, CG_VALUE_MAX); >> + } >> + } >> + } >> error = cgroup_create_cgroup(cgroup, 0); >> cgroup_dbg("creating group %s, error %d\n", cgroup->name, >> error); >> -- 1.8.3 >> >> > > . > ------------------------------------------------------------------------------ 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=60135991&iu=/4140/ostg.clktrk _______________________________________________ Libcg-devel mailing list Libcg-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libcg-devel