* [PATCH] memcg: fix return value of mem_cgroup_hierarchy_write()
@ 2009-01-14 8:10 Li Zefan
2009-01-14 8:21 ` KAMEZAWA Hiroyuki
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Li Zefan @ 2009-01-14 8:10 UTC (permalink / raw)
To: Andrew Morton
Cc: KAMEZAWA Hiroyuki, Balbir Singh, Paul Menage, Daisuke Nishimura,
LKML, linux-mm@kvack.org
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.
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
mm/memcontrol.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index bc8f101..2497f7d 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -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();
--
1.5.4.rc3
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] memcg: fix return value of mem_cgroup_hierarchy_write()
2009-01-14 8:10 [PATCH] memcg: fix return value of mem_cgroup_hierarchy_write() Li Zefan
@ 2009-01-14 8:21 ` KAMEZAWA Hiroyuki
2009-01-14 8:29 ` Daisuke Nishimura
2009-01-14 8:38 ` Balbir Singh
2 siblings, 0 replies; 5+ messages in thread
From: KAMEZAWA Hiroyuki @ 2009-01-14 8:21 UTC (permalink / raw)
To: Li Zefan
Cc: Andrew Morton, Balbir Singh, Paul Menage, Daisuke Nishimura, LKML,
linux-mm@kvack.org
On Wed, 14 Jan 2009 16:10:52 +0800
Li Zefan <lizf@cn.fujitsu.com> 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 -EINVAL in 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
> Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
> ---
> mm/memcontrol.c | 10 +++++-----
> 1 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index bc8f101..2497f7d 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -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();
>
> --
> 1.5.4.rc3
>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] memcg: fix return value of mem_cgroup_hierarchy_write()
2009-01-14 8:10 [PATCH] memcg: fix return value of mem_cgroup_hierarchy_write() Li Zefan
2009-01-14 8:21 ` KAMEZAWA Hiroyuki
@ 2009-01-14 8:29 ` Daisuke Nishimura
2009-01-14 8:38 ` Balbir Singh
2 siblings, 0 replies; 5+ messages in thread
From: Daisuke Nishimura @ 2009-01-14 8:29 UTC (permalink / raw)
To: Li Zefan
Cc: nishimura, Andrew Morton, KAMEZAWA Hiroyuki, Balbir Singh,
Paul Menage, LKML, linux-mm@kvack.org
On Wed, 14 Jan 2009 16:10:52 +0800, Li Zefan <lizf@cn.fujitsu.com> 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 -EINVAL in this case.
>
I also think -EBUSY is not so bad in this case.
Thanks,
Daisuke Nishimura.
> Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
> ---
> mm/memcontrol.c | 10 +++++-----
> 1 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index bc8f101..2497f7d 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -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();
>
> --
> 1.5.4.rc3
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] memcg: fix return value of mem_cgroup_hierarchy_write()
2009-01-14 8:10 [PATCH] memcg: fix return value of mem_cgroup_hierarchy_write() Li Zefan
2009-01-14 8:21 ` KAMEZAWA Hiroyuki
2009-01-14 8:29 ` Daisuke Nishimura
@ 2009-01-14 8:38 ` Balbir Singh
2009-01-14 8:45 ` Li Zefan
2 siblings, 1 reply; 5+ messages in thread
From: Balbir Singh @ 2009-01-14 8:38 UTC (permalink / raw)
To: Li Zefan
Cc: Andrew Morton, KAMEZAWA Hiroyuki, Paul Menage, Daisuke Nishimura,
LKML, linux-mm@kvack.org
* Li Zefan <lizf@cn.fujitsu.com> [2009-01-14 16:10:52]:
> 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.
>
> Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
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.
--
Balbir
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] memcg: fix return value of mem_cgroup_hierarchy_write()
2009-01-14 8:38 ` Balbir Singh
@ 2009-01-14 8:45 ` Li Zefan
0 siblings, 0 replies; 5+ messages in thread
From: Li Zefan @ 2009-01-14 8:45 UTC (permalink / raw)
To: balbir
Cc: Andrew Morton, KAMEZAWA Hiroyuki, Paul Menage, Daisuke Nishimura,
LKML, linux-mm@kvack.org
Balbir Singh wrote:
> * Li Zefan <lizf@cn.fujitsu.com> [2009-01-14 16:10:52]:
>
>> 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.
>>
>> Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
>
> 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 majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-01-14 8:46 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-14 8:10 [PATCH] memcg: fix return value of mem_cgroup_hierarchy_write() Li Zefan
2009-01-14 8:21 ` KAMEZAWA Hiroyuki
2009-01-14 8:29 ` Daisuke Nishimura
2009-01-14 8:38 ` Balbir Singh
2009-01-14 8:45 ` Li Zefan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).