From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail137.messagelabs.com (mail137.messagelabs.com [216.82.249.19]) by kanga.kvack.org (Postfix) with ESMTP id 661885F0048 for ; Wed, 20 Oct 2010 00:08:33 -0400 (EDT) From: Greg Thelen Subject: Re: [PATCH v3 07/11] memcg: add dirty limits to mem_cgroup References: <1287448784-25684-1-git-send-email-gthelen@google.com> <1287448784-25684-8-git-send-email-gthelen@google.com> <20101020095056.48098b34.nishimura@mxp.nes.nec.co.jp> Date: Tue, 19 Oct 2010 21:08:20 -0700 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-linux-mm@kvack.org To: Daisuke Nishimura Cc: Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, containers@lists.osdl.org, Andrea Righi , Balbir Singh , KAMEZAWA Hiroyuki , Minchan Kim , Ciju Rajan K , David Rientjes List-ID: Daisuke Nishimura writes: >> +static unsigned long long >> +memcg_hierarchical_free_pages(struct mem_cgroup *mem) >> +{ >> + struct cgroup *cgroup; >> + unsigned long long min_free, free; >> + >> + min_free = res_counter_read_u64(&mem->res, RES_LIMIT) - >> + res_counter_read_u64(&mem->res, RES_USAGE); >> + cgroup = mem->css.cgroup; >> + if (!mem->use_hierarchy) >> + goto out; >> + >> + while (cgroup->parent) { >> + cgroup = cgroup->parent; >> + mem = mem_cgroup_from_cont(cgroup); >> + if (!mem->use_hierarchy) >> + break; >> + free = res_counter_read_u64(&mem->res, RES_LIMIT) - >> + res_counter_read_u64(&mem->res, RES_USAGE); >> + min_free = min(min_free, free); >> + } >> +out: >> + /* Translate free memory in pages */ >> + return min_free >> PAGE_SHIFT; >> +} >> + > I think you can simplify this function using parent_mem_cgroup(). > > unsigned long free, min_free = ULLONG_MAX; > > while (mem) { > free = res_counter_read_u64(&mem->res, RES_LIMIT) - > res_counter_read_u64(&mem->res, RES_USAGE); > min_free = min(min_free, free); > mem = parent_mem_cgroup(); > } > > /* Translate free memory in pages */ > return min_free >> PAGE_SHIFT; > > And, IMHO, we should return min(global_page_state(NR_FREE_PAGES), min_free >> PAGE_SHIFT). > Because we are allowed to set no-limit(or a very big limit) in memcg, > so min_free can be very big if we don't set a limit against all the memcg's in hierarchy. > > > Thanks, > Dasiuke Nishimura. Thank you. This is a good suggestion. I will update the page to include this. -- Greg -- 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