From patchwork Thu Apr 16 12:31:05 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryo Tsuruta X-Patchwork-Id: 18512 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 n3GCVM87019690 for ; Thu, 16 Apr 2009 12:31:22 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 0C23D6199B8; Thu, 16 Apr 2009 08:31: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 n3GCVKUQ029212 for ; Thu, 16 Apr 2009 08:31:20 -0400 Received: from mx1.redhat.com (mx1.redhat.com [172.16.48.31]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n3GCVJnq002929 for ; Thu, 16 Apr 2009 08:31:19 -0400 Received: from mail.valinux.co.jp (fms-01.valinux.co.jp [210.128.90.1]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n3GCV5op032399 for ; Thu, 16 Apr 2009 08:31:06 -0400 Received: from localhost (kappa.local.valinux.co.jp [172.16.2.46]) by mail.valinux.co.jp (Postfix) with ESMTP id 403602DC813; Thu, 16 Apr 2009 21:31:05 +0900 (JST) Date: Thu, 16 Apr 2009 21:31:05 +0900 (JST) Message-Id: <20090416.213105.189713999.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: <20090416.213019.104045053.ryov@valinux.co.jp> References: <20090416.212836.226792104.ryov@valinux.co.jp> <20090416.212931.71100972.ryov@valinux.co.jp> <20090416.213019.104045053.ryov@valinux.co.jp> Mime-Version: 1.0 X-RedHat-Spam-Score: -0.322 X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 X-Scanned-By: MIMEDefang 2.63 on 172.16.48.31 X-loop: dm-devel@redhat.com Cc: Subject: [dm-devel] [PATCH 4/5] bio-cgroup: Page tracking hooks 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 contains several hooks that let the bio-cgroup framework to know which bio-group is the owner of a page before starting I/O against the page. Based on 2.6.30-rc1 Signed-off-by: Hirokazu Takahashi Signed-off-by: Ryo Tsuruta --- fs/buffer.c | 2 ++ fs/direct-io.c | 2 ++ mm/Makefile | 1 + mm/bounce.c | 2 ++ mm/filemap.c | 2 ++ mm/memory.c | 5 +++++ mm/page-writeback.c | 2 ++ mm/swap_state.c | 2 ++ 8 files changed, 18 insertions(+) -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel Index: linux-2.6.30-rc1/fs/buffer.c =================================================================== --- linux-2.6.30-rc1.orig/fs/buffer.c +++ linux-2.6.30-rc1/fs/buffer.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -655,6 +656,7 @@ static void __set_page_dirty(struct page if (page->mapping) { /* Race with truncate? */ WARN_ON_ONCE(warn && !PageUptodate(page)); account_page_dirtied(page, mapping); + bio_cgroup_reset_owner_pagedirty(page, current->mm); radix_tree_tag_set(&mapping->page_tree, page_index(page), PAGECACHE_TAG_DIRTY); } Index: linux-2.6.30-rc1/fs/direct-io.c =================================================================== --- linux-2.6.30-rc1.orig/fs/direct-io.c +++ linux-2.6.30-rc1/fs/direct-io.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -799,6 +800,7 @@ static int do_direct_IO(struct dio *dio) ret = PTR_ERR(page); goto out; } + bio_cgroup_reset_owner(page, current->mm); while (block_in_page < blocks_per_page) { unsigned offset_in_page = block_in_page << blkbits; Index: linux-2.6.30-rc1/mm/bounce.c =================================================================== --- linux-2.6.30-rc1.orig/mm/bounce.c +++ linux-2.6.30-rc1/mm/bounce.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -212,6 +213,7 @@ static void __blk_queue_bounce(struct re to->bv_len = from->bv_len; to->bv_offset = from->bv_offset; inc_zone_page_state(to->bv_page, NR_BOUNCE); + bio_cgroup_copy_owner(to->bv_page, page); if (rw == WRITE) { char *vto, *vfrom; Index: linux-2.6.30-rc1/mm/filemap.c =================================================================== --- linux-2.6.30-rc1.orig/mm/filemap.c +++ linux-2.6.30-rc1/mm/filemap.c @@ -33,6 +33,7 @@ #include #include /* for BUG_ON(!in_atomic()) only */ #include +#include #include /* for page_is_file_cache() */ #include "internal.h" @@ -463,6 +464,7 @@ int add_to_page_cache_locked(struct page gfp_mask & GFP_RECLAIM_MASK); if (error) goto out; + bio_cgroup_set_owner(page, current->mm); error = radix_tree_preload(gfp_mask & ~__GFP_HIGHMEM); if (error == 0) { Index: linux-2.6.30-rc1/mm/Makefile =================================================================== --- linux-2.6.30-rc1.orig/mm/Makefile +++ linux-2.6.30-rc1/mm/Makefile @@ -39,3 +39,4 @@ endif obj-$(CONFIG_QUICKLIST) += quicklist.o obj-$(CONFIG_CGROUP_MEM_RES_CTLR) += memcontrol.o obj-$(CONFIG_CGROUP_PAGE) += page_cgroup.o +obj-$(CONFIG_CGROUP_BIO) += biotrack.o Index: linux-2.6.30-rc1/mm/memory.c =================================================================== --- linux-2.6.30-rc1.orig/mm/memory.c +++ linux-2.6.30-rc1/mm/memory.c @@ -51,6 +51,7 @@ #include #include #include +#include #include #include #include @@ -2053,6 +2054,7 @@ gotten: */ ptep_clear_flush_notify(vma, address, page_table); page_add_new_anon_rmap(new_page, vma, address); + bio_cgroup_set_owner(new_page, mm); set_pte_at(mm, address, page_table, entry); update_mmu_cache(vma, address, entry); if (old_page) { @@ -2497,6 +2499,7 @@ static int do_swap_page(struct mm_struct flush_icache_page(vma, page); set_pte_at(mm, address, page_table, pte); page_add_anon_rmap(page, vma, address); + bio_cgroup_reset_owner(page, mm); /* It's better to call commit-charge after rmap is established */ mem_cgroup_commit_charge_swapin(page, ptr); @@ -2560,6 +2563,7 @@ static int do_anonymous_page(struct mm_s goto release; inc_mm_counter(mm, anon_rss); page_add_new_anon_rmap(page, vma, address); + bio_cgroup_set_owner(page, mm); set_pte_at(mm, address, page_table, entry); /* No need to invalidate - it was non-present before */ @@ -2712,6 +2716,7 @@ static int __do_fault(struct mm_struct * if (anon) { inc_mm_counter(mm, anon_rss); page_add_new_anon_rmap(page, vma, address); + bio_cgroup_set_owner(page, mm); } else { inc_mm_counter(mm, file_rss); page_add_file_rmap(page); Index: linux-2.6.30-rc1/mm/page-writeback.c =================================================================== --- linux-2.6.30-rc1.orig/mm/page-writeback.c +++ linux-2.6.30-rc1/mm/page-writeback.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -1243,6 +1244,7 @@ int __set_page_dirty_nobuffers(struct pa BUG_ON(mapping2 != mapping); WARN_ON_ONCE(!PagePrivate(page) && !PageUptodate(page)); account_page_dirtied(page, mapping); + bio_cgroup_reset_owner_pagedirty(page, current->mm); radix_tree_tag_set(&mapping->page_tree, page_index(page), PAGECACHE_TAG_DIRTY); } Index: linux-2.6.30-rc1/mm/swap_state.c =================================================================== --- linux-2.6.30-rc1.orig/mm/swap_state.c +++ linux-2.6.30-rc1/mm/swap_state.c @@ -18,6 +18,7 @@ #include #include #include +#include #include @@ -308,6 +309,7 @@ struct page *read_swap_cache_async(swp_e */ __set_page_locked(new_page); SetPageSwapBacked(new_page); + bio_cgroup_set_owner(new_page, current->mm); err = add_to_swap_cache(new_page, entry, gfp_mask & GFP_KERNEL); if (likely(!err)) { /*