From mboxrd@z Thu Jan 1 00:00:00 1970 From: Pavel Emelyanov Subject: Re: [RFC][PATCH 1/4] res_counter set_limit and -EBUSY. Date: Mon, 21 Jul 2008 21:32:10 +0400 Message-ID: <4884C81A.8090006@openvz.org> References: <20080718193123.cf74b574.kamezawa.hiroyu@jp.fujitsu.com> <20080718193437.ae79478a.kamezawa.hiroyu@jp.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20080718193437.ae79478a.kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: containers-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Errors-To: containers-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org To: KAMEZAWA Hiroyuki Cc: "yamamoto-jCdQPDEk3idL9jVzuh4AOg@public.gmane.org" , "nishimura-YQH0OdQVrdy45+QrQBaojngSJqDPrsil@public.gmane.org" , "kosaki.motohiro-+CUm20s59erQFUHtdCDX3A@public.gmane.org" , "containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org" , "menage-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org" , "balbir-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org" List-Id: containers.vger.kernel.org KAMEZAWA Hiroyuki wrote: > Add an interface to set limit. This is necessary to memory resource controller > because it shrinks usage at set limit. > > (*) Other controller may not need this interface to shrink usage because > shrinking is not necessary or impossible. > > This is an enhancement. > named as res_counter-limit-change-ebusy.patch > > Changelog v1->v2 > - fixed white space bug. > > Signed-off-by: KAMEZAWA Hiroyuki Acked-by: Pavel Emelyanov > > include/linux/res_counter.h | 15 +++++++++++++++ > 1 file changed, 15 insertions(+) > > Index: linux-2.6.26-rc8-mm1/include/linux/res_counter.h > =================================================================== > --- linux-2.6.26-rc8-mm1.orig/include/linux/res_counter.h > +++ linux-2.6.26-rc8-mm1/include/linux/res_counter.h > @@ -176,4 +176,19 @@ static inline bool res_counter_can_add(s > return ret; > } > > +static inline int res_counter_set_limit(struct res_counter *cnt, > + unsigned long long limit) > +{ > + unsigned long flags; > + int ret = -EBUSY; > + > + spin_lock_irqsave(&cnt->lock, flags); > + if (cnt->usage < limit) { > + cnt->limit = limit; > + ret = 0; > + } > + spin_unlock_irqrestore(&cnt->lock, flags); > + return ret; > +} > + > #endif > >