Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755041AbYKTLPa (ORCPT ); Thu, 20 Nov 2008 06:15:30 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754183AbYKTLPT (ORCPT ); Thu, 20 Nov 2008 06:15:19 -0500 Received: from cn.fujitsu.com ([222.73.24.84]:52196 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1754152AbYKTLPR (ORCPT ); Thu, 20 Nov 2008 06:15:17 -0500 Message-ID: <49254617.2090409@cn.fujitsu.com> Date: Thu, 20 Nov 2008 19:12:23 +0800 From: Gui Jianfeng User-Agent: Thunderbird 2.0.0.5 (Windows/20070716) MIME-Version: 1.0 To: Andrea Righi , Ryo Tsuruta , Hirokazu Takahashi CC: menage@google.com, containers@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Andrew Morton , KAMEZAWA Hiroyuki Subject: [PATCH 4/7] enables bio-cgroup in io-throttle, have to mount together References: <4925445C.10302@cn.fujitsu.com> In-Reply-To: <4925445C.10302@cn.fujitsu.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4762 Lines: 171 This patch enables bio-cgroup in io-throttle, but you have to mount them together. Signed-of-by: Gui Jianfeng --- block/blk-io-throttle.c | 7 +++++-- include/linux/biotrack.h | 2 ++ include/linux/memcontrol.h | 3 --- init/Kconfig | 2 +- mm/biotrack.c | 35 +++++++++++++++++++++++++++++++++++ mm/memcontrol.c | 30 ------------------------------ 6 files changed, 43 insertions(+), 36 deletions(-) diff --git a/block/blk-io-throttle.c b/block/blk-io-throttle.c index bb27587..e6a0a03 100644 --- a/block/blk-io-throttle.c +++ b/block/blk-io-throttle.c @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include #include @@ -649,7 +649,10 @@ static struct iothrottle *get_iothrottle_from_page(struct page *page) if (!cgrp) return NULL; iot = cgroup_to_iothrottle(cgrp); - css_get(&iot->css); + if (iot) + css_get(&iot->css); + else + return NULL; put_cgroup_from_page(page); return iot; diff --git a/include/linux/biotrack.h b/include/linux/biotrack.h index d352abd..371d263 100644 --- a/include/linux/biotrack.h +++ b/include/linux/biotrack.h @@ -21,6 +21,8 @@ static inline void __init_bio_page_cgroup(struct page_cgroup *pc) { pc->bio_cgroup_id = 0; } +extern struct cgroup *get_cgroup_from_page(struct page *page); +extern void put_cgroup_from_page(struct page *page); static inline int bio_cgroup_disabled(void) { diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 009e5e4..a7e3dc2 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -49,9 +49,6 @@ int task_in_mem_cgroup(struct task_struct *task, const struct mem_cgroup *mem); extern struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p); -extern struct cgroup *get_cgroup_from_page(struct page *page); -extern void put_cgroup_from_page(struct page *page); - #define mm_match_cgroup(mm, cgroup) \ ((cgroup) == mem_cgroup_from_task((mm)->owner)) diff --git a/init/Kconfig b/init/Kconfig index 06649c5..4082e8e 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -315,7 +315,7 @@ config CGROUP_DEVICE config CGROUP_IO_THROTTLE bool "Enable cgroup I/O throttling (EXPERIMENTAL)" - depends on CGROUPS && CGROUP_MEM_RES_CTLR && RESOURCE_COUNTERS && EXPERIMENTAL + depends on CGROUPS && CGROUP_BIO && RESOURCE_COUNTERS && EXPERIMENTAL help This allows to limit the maximum I/O bandwidth for specific cgroup(s). diff --git a/mm/biotrack.c b/mm/biotrack.c index 1af5910..ba6b45b 100644 --- a/mm/biotrack.c +++ b/mm/biotrack.c @@ -213,6 +213,41 @@ static struct bio_cgroup *find_bio_cgroup(int id) return biog; } +struct cgroup *get_cgroup_from_page(struct page *page) +{ + struct page_cgroup *pc; + struct bio_cgroup *biog; + struct cgroup *cgrp = NULL; + + pc = lookup_page_cgroup(page); + if (pc) { + lock_page_cgroup(pc); + biog = find_bio_cgroup(pc->bio_cgroup_id); + if (biog) { + css_get(&biog->css); + cgrp = biog->css.cgroup; + } + unlock_page_cgroup(pc); + } + + return cgrp; +} + +void put_cgroup_from_page(struct page *page) +{ + struct bio_cgroup *biog; + struct page_cgroup *pc; + + pc = lookup_page_cgroup(page); + if (pc) { + lock_page_cgroup(pc); + biog = find_bio_cgroup(pc->bio_cgroup_id); + if (biog) + css_put(&biog->css); + unlock_page_cgroup(pc); + } +} + /* Determine the bio-cgroup id of a given bio. */ int get_bio_cgroup_id(struct bio *bio) { diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 097278c..95048fe 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -241,36 +241,6 @@ struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p) struct mem_cgroup, css); } -struct cgroup *get_cgroup_from_page(struct page *page) -{ - struct page_cgroup *pc; - struct cgroup *cgrp = NULL; - - pc = lookup_page_cgroup(page); - if (pc) { - lock_page_cgroup(pc); - if(pc->mem_cgroup) { - css_get(&pc->mem_cgroup->css); - cgrp = pc->mem_cgroup->css.cgroup; - } - unlock_page_cgroup(pc); - } - - return cgrp; -} - -void put_cgroup_from_page(struct page *page) -{ - struct page_cgroup *pc; - - pc = lookup_page_cgroup(page); - if (pc) { - lock_page_cgroup(pc); - css_put(&pc->mem_cgroup->css); - unlock_page_cgroup(pc); - } -} - static void __mem_cgroup_remove_list(struct mem_cgroup_per_zone *mz, struct page_cgroup *pc) { -- 1.5.4.rc3 -- 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/