From patchwork Tue Apr 28 12:44:57 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryo Tsuruta X-Patchwork-Id: 20416 Received: from hormel.redhat.com (hormel1.redhat.com [209.132.177.33]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n3SCjNNB008062 for ; Tue, 28 Apr 2009 12:45:23 GMT Received: from listman.util.phx.redhat.com (listman.util.phx.redhat.com [10.8.4.110]) by hormel.redhat.com (Postfix) with ESMTP id 4739C61A1F7; Tue, 28 Apr 2009 08:45:22 -0400 (EDT) Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by listman.util.phx.redhat.com (8.13.1/8.13.1) with ESMTP id n3SCjI60017681 for ; Tue, 28 Apr 2009 08:45:21 -0400 Received: from mx3.redhat.com (mx3.redhat.com [172.16.48.32]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n3SCjGfn016454 for ; Tue, 28 Apr 2009 08:45:16 -0400 Received: from mail.valinux.co.jp (fms-01.valinux.co.jp [210.128.90.1]) by mx3.redhat.com (8.13.8/8.13.8) with ESMTP id n3SCiwou002056 for ; Tue, 28 Apr 2009 08:44:58 -0400 Received: from localhost (kappa.local.valinux.co.jp [172.16.2.46]) by mail.valinux.co.jp (Postfix) with ESMTP id ABEF72DC791; Tue, 28 Apr 2009 21:44:57 +0900 (JST) Date: Tue, 28 Apr 2009 21:44:57 +0900 (JST) Message-Id: <20090428.214457.226801820.ryov@valinux.co.jp> To: linux-kernel@vger.kernel.org, dm-devel@redhat.com, containers@lists.linux-foundation.org, virtualization@lists.linux-foundation.org, xen-devel@lists.xensource.com From: Ryo Tsuruta In-Reply-To: <20090428.214423.193684619.ryov@valinux.co.jp> References: <20090428.214423.193684619.ryov@valinux.co.jp> Mime-Version: 1.0 X-RedHat-Spam-Score: -0.188 X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 X-Scanned-By: MIMEDefang 2.63 on 172.16.48.32 X-loop: dm-devel@redhat.com Cc: Subject: [dm-devel] [PATCH 2/7] blkio-cgroup: The new page_cgroup framework X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.5 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com This patch makes the page_cgroup framework be able to be used even if the compile option of the cgroup memory controller is off. So blkio-cgroup can use this framework without the memory controller. Based on 2.6.30-rc3-git3 Signed-off-by: Hirokazu Takahashi Signed-off-by: Ryo Tsuruta --- include/linux/memcontrol.h | 6 ++++++ include/linux/mmzone.h | 4 ++-- include/linux/page_cgroup.h | 8 +++++--- init/Kconfig | 4 ++++ mm/Makefile | 3 ++- mm/memcontrol.c | 6 ++++++ mm/page_cgroup.c | 3 +-- 7 files changed, 26 insertions(+), 8 deletions(-) -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel Index: linux-2.6.30-rc3-git3/include/linux/memcontrol.h =================================================================== --- linux-2.6.30-rc3-git3.orig/include/linux/memcontrol.h +++ linux-2.6.30-rc3-git3/include/linux/memcontrol.h @@ -37,6 +37,8 @@ struct mm_struct; * (Of course, if memcg does memory allocation in future, GFP_KERNEL is sane.) */ +extern void __init_mem_page_cgroup(struct page_cgroup *pc); + extern int mem_cgroup_newpage_charge(struct page *page, struct mm_struct *mm, gfp_t gfp_mask); /* for swap handling */ @@ -120,6 +122,10 @@ extern bool mem_cgroup_oom_called(struct #else /* CONFIG_CGROUP_MEM_RES_CTLR */ struct mem_cgroup; +static inline void __init_mem_page_cgroup(struct page_cgroup *pc) +{ +} + static inline int mem_cgroup_newpage_charge(struct page *page, struct mm_struct *mm, gfp_t gfp_mask) { Index: linux-2.6.30-rc3-git3/include/linux/mmzone.h =================================================================== --- linux-2.6.30-rc3-git3.orig/include/linux/mmzone.h +++ linux-2.6.30-rc3-git3/include/linux/mmzone.h @@ -607,7 +607,7 @@ typedef struct pglist_data { int nr_zones; #ifdef CONFIG_FLAT_NODE_MEM_MAP /* means !SPARSEMEM */ struct page *node_mem_map; -#ifdef CONFIG_CGROUP_MEM_RES_CTLR +#ifdef CONFIG_CGROUP_PAGE struct page_cgroup *node_page_cgroup; #endif #endif @@ -958,7 +958,7 @@ struct mem_section { /* See declaration of similar field in struct zone */ unsigned long *pageblock_flags; -#ifdef CONFIG_CGROUP_MEM_RES_CTLR +#ifdef CONFIG_CGROUP_PAGE /* * If !SPARSEMEM, pgdat doesn't have page_cgroup pointer. We use * section. (see memcontrol.h/page_cgroup.h about this.) Index: linux-2.6.30-rc3-git3/include/linux/page_cgroup.h =================================================================== --- linux-2.6.30-rc3-git3.orig/include/linux/page_cgroup.h +++ linux-2.6.30-rc3-git3/include/linux/page_cgroup.h @@ -1,7 +1,7 @@ #ifndef __LINUX_PAGE_CGROUP_H #define __LINUX_PAGE_CGROUP_H -#ifdef CONFIG_CGROUP_MEM_RES_CTLR +#ifdef CONFIG_CGROUP_PAGE #include /* * Page Cgroup can be considered as an extended mem_map. @@ -12,9 +12,11 @@ */ struct page_cgroup { unsigned long flags; - struct mem_cgroup *mem_cgroup; struct page *page; +#ifdef CONFIG_CGROUP_MEM_RES_CTLR + struct mem_cgroup *mem_cgroup; struct list_head lru; /* per cgroup LRU list */ +#endif }; void __meminit pgdat_page_cgroup_init(struct pglist_data *pgdat); @@ -71,7 +73,7 @@ static inline void unlock_page_cgroup(st bit_spin_unlock(PCG_LOCK, &pc->flags); } -#else /* CONFIG_CGROUP_MEM_RES_CTLR */ +#else /* CONFIG_CGROUP_PAGE */ struct page_cgroup; static inline void __meminit pgdat_page_cgroup_init(struct pglist_data *pgdat) Index: linux-2.6.30-rc3-git3/init/Kconfig =================================================================== --- linux-2.6.30-rc3-git3.orig/init/Kconfig +++ linux-2.6.30-rc3-git3/init/Kconfig @@ -608,6 +608,10 @@ config CGROUP_MEM_RES_CTLR_SWAP endif # CGROUPS +config CGROUP_PAGE + def_bool y + depends on CGROUP_MEM_RES_CTLR + config MM_OWNER bool Index: linux-2.6.30-rc3-git3/mm/Makefile =================================================================== --- linux-2.6.30-rc3-git3.orig/mm/Makefile +++ linux-2.6.30-rc3-git3/mm/Makefile @@ -37,4 +37,5 @@ else obj-$(CONFIG_SMP) += allocpercpu.o endif obj-$(CONFIG_QUICKLIST) += quicklist.o -obj-$(CONFIG_CGROUP_MEM_RES_CTLR) += memcontrol.o page_cgroup.o +obj-$(CONFIG_CGROUP_MEM_RES_CTLR) += memcontrol.o +obj-$(CONFIG_CGROUP_PAGE) += page_cgroup.o Index: linux-2.6.30-rc3-git3/mm/memcontrol.c =================================================================== --- linux-2.6.30-rc3-git3.orig/mm/memcontrol.c +++ linux-2.6.30-rc3-git3/mm/memcontrol.c @@ -128,6 +128,12 @@ struct mem_cgroup_lru_info { struct mem_cgroup_per_node *nodeinfo[MAX_NUMNODES]; }; +void __meminit __init_mem_page_cgroup(struct page_cgroup *pc) +{ + pc->mem_cgroup = NULL; + INIT_LIST_HEAD(&pc->lru); +} + /* * The memory controller data structure. The memory controller controls both * page cache and RSS per cgroup. We would eventually like to provide Index: linux-2.6.30-rc3-git3/mm/page_cgroup.c =================================================================== --- linux-2.6.30-rc3-git3.orig/mm/page_cgroup.c +++ linux-2.6.30-rc3-git3/mm/page_cgroup.c @@ -14,9 +14,8 @@ static void __meminit __init_page_cgroup(struct page_cgroup *pc, unsigned long pfn) { pc->flags = 0; - pc->mem_cgroup = NULL; pc->page = pfn_to_page(pfn); - INIT_LIST_HEAD(&pc->lru); + __init_mem_page_cgroup(pc); } static unsigned long total_usage;