memcg: fix return value of mem_cgroup_hierarchy_write()
Subsystems (2)
PATCH 1/1 memcg: fix return value of mem_cgroup_hierarchy_write()
When there are sub-dirs, writing to memory.use_hierarchy returns -EBUSY, this doesn't seem to fit the meaning of EBUSY, and is inconsistent with memory.swappiness, which returns -EINVAL in this case.
--- mm/memcontrol.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)
mm/memcontrol.c +5 -5
@@ -1760,6 +1760,9 @@ static int mem_cgroup_hierarchy_write(struct cgroup *cont, struct cftype *cft,struct cgroup *parent = cont->parent;struct mem_cgroup *parent_mem =NULL ; +if (val !=0 && val !=1 ) +return -EINVAL ; +if (parent) parent_mem =mem_cgroup_from_cont (parent);
@@ -1773,12 +1776,9 @@ static int mem_cgroup_hierarchy_write(struct cgroup *cont, struct cftype *cft,* set if there are no children. */ if ((!parent_mem || !parent_mem->use_hierarchy) && - (val ==1 || val ==0 )) { -if (list_empty (&cont->children)) +list_empty (&cont->children)) mem->use_hierarchy = val; -else - retval = -EBUSY ; - }else +else retval = -EINVAL ;cgroup_unlock ();
Signature · 7 lines
1.5.4.rc3 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 4 lines · On Wed, 14 Jan 2009 16:10:52 +0800 Li Zefan <[email protected]> wrote:
When there are sub-dirs, writing to memory.use_hierarchy returns
-EBUSY, this doesn't seem to fit the meaning of EBUSY, and is inconsistent with memory.swappiness, which returns-EINVALin this case.
Hmm...I'm not sure what error code is the best.
In usual, -EINVAL means parameter to write() is bad. In this case, it isn't.
Considering that, -EBUSY seems ok at returning error because of children. How about change swappiness to return -EBUSY ?
Thanks,
-Kame
Quoted 37 lines
Signed-off-by Li Zefan <[email protected]>--- mm/memcontrol.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)mm/memcontrol.c +5
-5@@ -1760,6 +1760,9 @@ static int mem_cgroup_hierarchy_write(struct cgroup *cont, struct cftype *cft,struct cgroup *parent = cont->parent;struct mem_cgroup *parent_mem =NULL ; +if (val !=0 && val !=1 ) +return -EINVAL ; +if (parent) parent_mem =mem_cgroup_from_cont (parent);@@ -1773,12 +1776,9 @@ static int mem_cgroup_hierarchy_write(struct cgroup *cont, struct cftype *cft,* set if there are no children. */ if ((!parent_mem || !parent_mem->use_hierarchy) && - (val ==1 || val ==0 )) { -if (list_empty (&cont->children)) +list_empty (&cont->children)) mem->use_hierarchy = val; -else - retval = -EBUSY ; - }else +else retval = -EINVAL ;cgroup_unlock ();Signature · 1 line
1.5.4.rc3
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 4 lines · Li Zefan
When there are sub-dirs, writing to memory.use_hierarchy returns
-EBUSY, this doesn't seem to fit the meaning of EBUSY, and is inconsistent with memory.swappiness, which returns-EINVALin this case.
I also think -EBUSY is not so bad in this case.
Thanks,
Daisuke Nishimura.
Quoted 36 lines
Signed-off-by Li Zefan <[email protected]>--- mm/memcontrol.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)mm/memcontrol.c +5
-5@@ -1760,6 +1760,9 @@ static int mem_cgroup_hierarchy_write(struct cgroup *cont, struct cftype *cft,struct cgroup *parent = cont->parent;struct mem_cgroup *parent_mem =NULL ; +if (val !=0 && val !=1 ) +return -EINVAL ; +if (parent) parent_mem =mem_cgroup_from_cont (parent);@@ -1773,12 +1776,9 @@ static int mem_cgroup_hierarchy_write(struct cgroup *cont, struct cftype *cft,* set if there are no children. */ if ((!parent_mem || !parent_mem->use_hierarchy) && - (val ==1 || val ==0 )) { -if (list_empty (&cont->children)) +list_empty (&cont->children)) mem->use_hierarchy = val; -else - retval = -EBUSY ; - }else +else retval = -EINVAL ;cgroup_unlock ();Signature · 1 line
1.5.4.rc3
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 5 lines · Li Zefan
When there are sub-dirs, writing to memory.use_hierarchy returns
-EBUSY, this doesn't seem to fit the meaning of EBUSY, and is inconsistent with memory.swappiness, which returns-EINVALin this case.Signed-off-by Li Zefan <[email protected]>
The patch does much more than the changelog says. The reason for EBUSY is that the group is in use due to children or existing references and tasks. I think EBUSY is the correct error code to return.
Signature · 7 lines
Balbir -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 6 lines · Balbir Singh
Quoted 4 lines · Li Zefan
When there are sub-dirs, writing to memory.use_hierarchy returns
-EBUSY, this doesn't seem to fit the meaning of EBUSY, and is inconsistent with memory.swappiness, which returns-EINVALin this case.
Quoted 6 lines
Quoted 1 line
Signed-off-by Li Zefan <[email protected]>The patch does much more than the changelog says. The reason for EBUSY is that the group is in use due to children or existing references and tasks. I think EBUSY is the correct error code to return.
Sounds reasonable for me. Thanks.
Regards
Li Zefan
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>