Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751345AbWH3TPa (ORCPT ); Wed, 30 Aug 2006 15:15:30 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751341AbWH3TPa (ORCPT ); Wed, 30 Aug 2006 15:15:30 -0400 Received: from e35.co.us.ibm.com ([32.97.110.153]:13239 "EHLO e35.co.us.ibm.com") by vger.kernel.org with ESMTP id S1751345AbWH3TP3 (ORCPT ); Wed, 30 Aug 2006 15:15:29 -0400 Subject: Re: [ckrm-tech] [PATCH 5/7] BC: user interface (syscalls) From: Chandra Seetharaman Reply-To: sekharan@us.ibm.com To: Kirill Korotaev Cc: Andrew Morton , Rik van Riel , CKRM-Tech , Linux Kernel Mailing List , Andi Kleen , Christoph Hellwig , Andrey Savochkin , Alan Cox , Matt Helsley , Alexey Dobriyan , Oleg Nesterov , devel@openvz.org, Pavel Emelianov In-Reply-To: <44F45568.6000204@sw.ru> References: <44F45045.70402@sw.ru> <44F45568.6000204@sw.ru> Content-Type: text/plain Organization: IBM Date: Wed, 30 Aug 2006 12:15:23 -0700 Message-Id: <1156965323.12403.44.camel@linuxchandra> Mime-Version: 1.0 X-Mailer: Evolution 2.0.4 (2.0.4-7) Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2051 Lines: 70 On Tue, 2006-08-29 at 18:55 +0400, Kirill Korotaev wrote: > Add the following system calls for BC management: > 1. sys_get_bcid - get current BC id > 2. sys_set_bcid - change exec_ and fork_ BCs on current > 3. sys_set_bclimit - set limits for resources consumtions > 4. sys_get_bcstat - return br_resource_parm on resource > > Signed-off-by: Pavel Emelianov > Signed-off-by: Kirill Korotaev > > --- > + > +asmlinkage long sys_set_bclimit(bcid_t id, unsigned long resource, > + unsigned long __user *limits) > +{ > + int error; > + unsigned long flags; > + struct beancounter *bc; > + unsigned long new_limits[2]; > + > + error = -EPERM; > + if(!capable(CAP_SYS_RESOURCE)) > + goto out; > + > + error = -EINVAL; > + if (resource >= BC_RESOURCES) > + goto out; > + > + error = -EFAULT; > + if (copy_from_user(&new_limits, limits, sizeof(new_limits))) > + goto out; > + > + error = -EINVAL; > + if (new_limits[0] > BC_MAXVALUE || new_limits[1] > BC_MAXVALUE || > + new_limits[0] > new_limits[1]) > + goto out; > + > + error = -ENOENT; > + bc = beancounter_findcreate(id, BC_LOOKUP); > + if (bc == NULL) > + goto out; Moving this to be before copy_from_user() would be efficient. > + > + spin_lock_irqsave(&bc->bc_lock, flags); > + bc->bc_parms[resource].barrier = new_limits[0]; > + bc->bc_parms[resource].limit = new_limits[1]; > + spin_unlock_irqrestore(&bc->bc_lock, flags); > + > + put_beancounter(bc); > + error = 0; > +out: > + return error; > +} -- ---------------------------------------------------------------------- Chandra Seetharaman | Be careful what you choose.... - sekharan@us.ibm.com | .......you may get it. ---------------------------------------------------------------------- - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/