From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from sd0208e0.au.ibm.com (d23rh904.au.ibm.com [202.81.18.202]) by ausmtp05.au.ibm.com (8.13.8/8.13.6) with ESMTP id kAAMUOsX8003612 for ; Fri, 10 Nov 2006 21:30:29 -0100 Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.250.237]) by sd0208e0.au.ibm.com (8.13.6/8.13.6/NCO v8.1.1) with ESMTP id kAAAVZiC219436 for ; Fri, 10 Nov 2006 21:31:40 +1100 Received: from d23av04.au.ibm.com (loopback [127.0.0.1]) by d23av04.au.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id kAAAS8nL026372 for ; Fri, 10 Nov 2006 21:28:09 +1100 Message-ID: <45545429.7080903@in.ibm.com> Date: Fri, 10 Nov 2006 15:57:53 +0530 From: Balbir Singh Reply-To: balbir@in.ibm.com MIME-Version: 1.0 Subject: Re: [ckrm-tech] [RFC][PATCH 6/8] RSS controller shares allocation References: <20061109193523.21437.86224.sendpatchset@balbir.in.ibm.com> <20061109193619.21437.84173.sendpatchset@balbir.in.ibm.com> <45544240.80609@openvz.org> In-Reply-To: <45544240.80609@openvz.org> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org Return-Path: To: Pavel Emelianov Cc: dev@openvz.org, ckrm-tech@lists.sourceforge.net, haveblue@us.ibm.com, Linux Kernel Mailing List , Linux MM , rohitseth@google.com List-ID: Pavel Emelianov wrote: > Balbir Singh wrote: >> Support shares assignment and propagation. >> >> Signed-off-by: Balbir Singh >> --- >> >> kernel/res_group/memctlr.c | 59 ++++++++++++++++++++++++++++++++++++++++++++- >> 1 file changed, 58 insertions(+), 1 deletion(-) > > [snip] > >> +static void recalc_and_propagate(struct memctlr *res, struct memctlr *parres) >> +{ >> + struct resource_group *child = NULL; >> + int child_divisor; >> + u64 numerator; >> + struct memctlr *child_res; >> + >> + if (parres) { >> + if (res->shares.max_shares == SHARE_DONT_CARE || >> + parres->shares.max_shares == SHARE_DONT_CARE) >> + return; >> + >> + child_divisor = parres->shares.child_shares_divisor; >> + if (child_divisor == 0) >> + return; >> + >> + numerator = (u64)(parres->shares.unused_min_shares * >> + res->shares.max_shares); >> + do_div(numerator, child_divisor); >> + numerator = (u64)(parres->nr_pages * numerator); >> + do_div(numerator, SHARE_DEFAULT_DIVISOR); >> + res->nr_pages = numerator; >> + } >> + >> + for_each_child(child, res->rgroup) { >> + child_res = get_memctlr(child); >> + BUG_ON(!child_res); >> + recalc_and_propagate(child_res, res); > > Recursion? Won't it eat all the stack in case of a deep tree? The depth of the hierarchy can be controlled. Recursion is needed to do a DFS walk > >> + } >> + >> +} >> + >> +static void memctlr_shares_changed(struct res_shares *shares) >> +{ >> + struct memctlr *res, *parres; >> + >> + res = get_memctlr_from_shares(shares); >> + if (!res) >> + return; >> + >> + if (is_res_group_root(res->rgroup)) >> + parres = NULL; >> + else >> + parres = get_memctlr((struct container *)res->rgroup->parent); >> + >> + recalc_and_propagate(res, parres); >> +} >> + >> struct res_controller memctlr_rg = { >> .name = res_ctlr_name, >> .ctlr_id = NO_RES_ID, >> .alloc_shares_struct = memctlr_alloc_instance, >> .free_shares_struct = memctlr_free_instance, >> .move_task = memctlr_move_task, >> - .shares_changed = NULL, >> + .shares_changed = memctlr_shares_changed, > > I didn't find where in this patches this callback is called. It's a part of the resource groups infrastructure. It's been ported on top of Paul Menage's containers patches. The code can be easily adapted to work directly with containers instead of resource groups if required. -- Balbir Singh, Linux Technology Center, IBM Software Labs -- 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: email@kvack.org