public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] res_counter: fix off-by-one bug in setting limit
@ 2008-09-01  5:08 Li Zefan
  2008-09-01  5:30 ` KAMEZAWA Hiroyuki
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Li Zefan @ 2008-09-01  5:08 UTC (permalink / raw)
  To: Andrew Morton; +Cc: KAMEZAWA Hiroyuki, Balbir Singh, Pavel Emelianov, LKML

I found we can no longer set limit to 0 with 2.6.27-rcX:
 # mount -t cgroup -omemory xxx /mnt
 # mkdir /mnt/0
 # echo 0 > /mnt/0/memory.limit_in_bytes
 bash: echo: write error: Device or resource busy

It turned out 'limit' can't be set to 'usage', which is wrong IMO.

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
 include/linux/res_counter.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/include/linux/res_counter.h b/include/linux/res_counter.h
index fdeadd9..271c1c2 100644
--- a/include/linux/res_counter.h
+++ b/include/linux/res_counter.h
@@ -166,7 +166,7 @@ static inline int res_counter_set_limit(struct res_counter *cnt,
 	int ret = -EBUSY;
 
 	spin_lock_irqsave(&cnt->lock, flags);
-	if (cnt->usage < limit) {
+	if (cnt->usage <= limit) {
 		cnt->limit = limit;
 		ret = 0;
 	}
-- 1.5.4.rc3 

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] res_counter: fix off-by-one bug in setting limit
  2008-09-01  5:08 [PATCH] res_counter: fix off-by-one bug in setting limit Li Zefan
@ 2008-09-01  5:30 ` KAMEZAWA Hiroyuki
  2008-09-01  5:43   ` Li Zefan
  2008-09-01  6:28 ` Balbir Singh
  2008-09-01  8:55 ` Pavel Emelyanov
  2 siblings, 1 reply; 6+ messages in thread
From: KAMEZAWA Hiroyuki @ 2008-09-01  5:30 UTC (permalink / raw)
  To: Li Zefan; +Cc: Andrew Morton, Balbir Singh, Pavel Emelianov, LKML

On Mon, 01 Sep 2008 13:08:55 +0800
Li Zefan <lizf@cn.fujitsu.com> wrote:

> I found we can no longer set limit to 0 with 2.6.27-rcX:
>  # mount -t cgroup -omemory xxx /mnt
>  # mkdir /mnt/0
>  # echo 0 > /mnt/0/memory.limit_in_bytes
>  bash: echo: write error: Device or resource busy
> 
> It turned out 'limit' can't be set to 'usage', which is wrong IMO.
> 
> Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>

But setting limit to 0(usage) in memcg is buggy operation unless you want to see OOM..
Hmm..

Thanks,
-Kame


> ---
>  include/linux/res_counter.h |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/include/linux/res_counter.h b/include/linux/res_counter.h
> index fdeadd9..271c1c2 100644
> --- a/include/linux/res_counter.h
> +++ b/include/linux/res_counter.h
> @@ -166,7 +166,7 @@ static inline int res_counter_set_limit(struct res_counter *cnt,
>  	int ret = -EBUSY;
>  
>  	spin_lock_irqsave(&cnt->lock, flags);
> -	if (cnt->usage < limit) {
> +	if (cnt->usage <= limit) {
>  		cnt->limit = limit;
>  		ret = 0;
>  	}
> -- 1.5.4.rc3 
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] res_counter: fix off-by-one bug in setting limit
  2008-09-01  5:30 ` KAMEZAWA Hiroyuki
@ 2008-09-01  5:43   ` Li Zefan
  2008-09-01  6:04     ` KAMEZAWA Hiroyuki
  0 siblings, 1 reply; 6+ messages in thread
From: Li Zefan @ 2008-09-01  5:43 UTC (permalink / raw)
  To: KAMEZAWA Hiroyuki; +Cc: Andrew Morton, Balbir Singh, Pavel Emelianov, LKML

KAMEZAWA Hiroyuki wrote:
> On Mon, 01 Sep 2008 13:08:55 +0800
> Li Zefan <lizf@cn.fujitsu.com> wrote:
> 
>> I found we can no longer set limit to 0 with 2.6.27-rcX:
>>  # mount -t cgroup -omemory xxx /mnt
>>  # mkdir /mnt/0
>>  # echo 0 > /mnt/0/memory.limit_in_bytes
>>  bash: echo: write error: Device or resource busy
>>
>> It turned out 'limit' can't be set to 'usage', which is wrong IMO.
>>
>> Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
> 
> But setting limit to 0(usage) in memcg is buggy operation unless you want to see OOM..
> Hmm..
> 

I used to set 0 limit to test OOM in memcg. I don't think 0 limit is buggy, there's no
much difference with 0 limit and a very low limit.

And the real issue is, now we can set limit to > usage, but not >= usage. It's odd that
usage can reach to limit but limit can't be shrinked to usage.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] res_counter: fix off-by-one bug in setting limit
  2008-09-01  5:43   ` Li Zefan
@ 2008-09-01  6:04     ` KAMEZAWA Hiroyuki
  0 siblings, 0 replies; 6+ messages in thread
From: KAMEZAWA Hiroyuki @ 2008-09-01  6:04 UTC (permalink / raw)
  To: Li Zefan; +Cc: Andrew Morton, Balbir Singh, Pavel Emelianov, LKML

On Mon, 01 Sep 2008 13:43:57 +0800
Li Zefan <lizf@cn.fujitsu.com> wrote:

> KAMEZAWA Hiroyuki wrote:
> > On Mon, 01 Sep 2008 13:08:55 +0800
> > Li Zefan <lizf@cn.fujitsu.com> wrote:
> > 
> >> I found we can no longer set limit to 0 with 2.6.27-rcX:
> >>  # mount -t cgroup -omemory xxx /mnt
> >>  # mkdir /mnt/0
> >>  # echo 0 > /mnt/0/memory.limit_in_bytes
> >>  bash: echo: write error: Device or resource busy
> >>
> >> It turned out 'limit' can't be set to 'usage', which is wrong IMO.
> >>
> >> Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
> > 
> > But setting limit to 0(usage) in memcg is buggy operation unless you want to see OOM..
> > Hmm..
> > 
> 
> I used to set 0 limit to test OOM in memcg. I don't think 0 limit is buggy, there's no
> much difference with 0 limit and a very low limit.
> 
> And the real issue is, now we can set limit to > usage, but not >= usage. It's odd that
> usage can reach to limit but limit can't be shrinked to usage.
> 
ok.

Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] res_counter: fix off-by-one bug in setting limit
  2008-09-01  5:08 [PATCH] res_counter: fix off-by-one bug in setting limit Li Zefan
  2008-09-01  5:30 ` KAMEZAWA Hiroyuki
@ 2008-09-01  6:28 ` Balbir Singh
  2008-09-01  8:55 ` Pavel Emelyanov
  2 siblings, 0 replies; 6+ messages in thread
From: Balbir Singh @ 2008-09-01  6:28 UTC (permalink / raw)
  To: Li Zefan; +Cc: Andrew Morton, KAMEZAWA Hiroyuki, Pavel Emelianov, LKML

Li Zefan wrote:
> I found we can no longer set limit to 0 with 2.6.27-rcX:
>  # mount -t cgroup -omemory xxx /mnt
>  # mkdir /mnt/0
>  # echo 0 > /mnt/0/memory.limit_in_bytes
>  bash: echo: write error: Device or resource busy
> 
> It turned out 'limit' can't be set to 'usage', which is wrong IMO.
> 
> Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>

OK, based on Kamezawa's feedback and looking at the patch

Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com>

-- 
	Balbir

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] res_counter: fix off-by-one bug in setting limit
  2008-09-01  5:08 [PATCH] res_counter: fix off-by-one bug in setting limit Li Zefan
  2008-09-01  5:30 ` KAMEZAWA Hiroyuki
  2008-09-01  6:28 ` Balbir Singh
@ 2008-09-01  8:55 ` Pavel Emelyanov
  2 siblings, 0 replies; 6+ messages in thread
From: Pavel Emelyanov @ 2008-09-01  8:55 UTC (permalink / raw)
  To: Li Zefan; +Cc: Andrew Morton, KAMEZAWA Hiroyuki, Balbir Singh, LKML

Li Zefan wrote:
> I found we can no longer set limit to 0 with 2.6.27-rcX:
>  # mount -t cgroup -omemory xxx /mnt
>  # mkdir /mnt/0
>  # echo 0 > /mnt/0/memory.limit_in_bytes
>  bash: echo: write error: Device or resource busy
> 
> It turned out 'limit' can't be set to 'usage', which is wrong IMO.
> 
> Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>

Acked-by: Pavel Emelyanov <xemul@openvz.org>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-09-01  9:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-01  5:08 [PATCH] res_counter: fix off-by-one bug in setting limit Li Zefan
2008-09-01  5:30 ` KAMEZAWA Hiroyuki
2008-09-01  5:43   ` Li Zefan
2008-09-01  6:04     ` KAMEZAWA Hiroyuki
2008-09-01  6:28 ` Balbir Singh
2008-09-01  8:55 ` Pavel Emelyanov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox