From ddb6e4f0b0ae76ecbbc867c5a2050e0d22098f22 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Thu, 3 May 2012 15:43:38 +1000 Subject: [PATCH] memcg-add-hugetlb-extension-fix-fix optimise CONFIG_HUGETLB_PAGE=y, CONFIG_MEM_RES_CTLR_HUGETLB=n Cc: Andrea Arcangeli Cc: Aneesh Kumar K.V Cc: David Rientjes Cc: Hillf Danton Cc: Johannes Weiner Cc: KAMEZAWA Hiroyuki Cc: Michal Hocko Signed-off-by: Andrew Morton --- mm/memcontrol.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index d1b774c0e3fd..d10288836e5a 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -57,6 +57,16 @@ #include +/* + * If CONFIG_MEM_RES_CTLR_HUGETLB=n, CONFIG_HUGETLB_PAGE=y we can avoid + * generating any code or storage for the resource counters + */ +#ifdef CONFIG_MEM_RES_CTLR_HUGETLB +#define NR_HUGEPAGE_RES_COUNTERS HUGE_MAX_HSTATE +#else +#define NR_HUGEPAGE_RES_COUNTERS 0 +#endif + struct cgroup_subsys mem_cgroup_subsys __read_mostly; #define MEM_CGROUP_RECLAIM_RETRIES 5 struct mem_cgroup *root_mem_cgroup __read_mostly; @@ -254,7 +264,7 @@ struct mem_cgroup { /* * the counter to account for hugepages from hugetlb. */ - struct res_counter hugepage[HUGE_MAX_HSTATE]; + struct res_counter hugepage[NR_HUGEPAGE_RES_COUNTERS]; /* * Per cgroup active and inactive list, similar to the * per zone LRU lists. @@ -5112,9 +5122,9 @@ mem_cgroup_create(struct cgroup *cont) mem_cgroup_get(parent); /* * We could get called before hugetlb init is called. - * Use HUGE_MAX_HSTATE as the max index. + * Use NR_HUGEPAGE_RES_COUNTERS as the max index. */ - for (idx = 0; idx < HUGE_MAX_HSTATE; idx++) + for (idx = 0; idx < NR_HUGEPAGE_RES_COUNTERS; idx++) res_counter_init(&memcg->hugepage[idx], &parent->hugepage[idx]); } else { @@ -5122,9 +5132,9 @@ mem_cgroup_create(struct cgroup *cont) res_counter_init(&memcg->memsw, NULL); /* * We could get called before hugetlb init is called. - * Use HUGE_MAX_HSTATE as the max index. + * Use NR_HUGEPAGE_RES_COUNTERS as the max index. */ - for (idx = 0; idx < HUGE_MAX_HSTATE; idx++) + for (idx = 0; idx < NR_HUGEPAGE_RES_COUNTERS; idx++) res_counter_init(&memcg->hugepage[idx], NULL); } memcg->last_scanned_node = MAX_NUMNODES; -- 2.39.5