From patchwork Mon Mar 23 04:54:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 6069711 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 704A0BF90F for ; Mon, 23 Mar 2015 05:07:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7E23D20108 for ; Mon, 23 Mar 2015 05:07:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7B11D20107 for ; Mon, 23 Mar 2015 05:07:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752331AbbCWEzw (ORCPT ); Mon, 23 Mar 2015 00:55:52 -0400 Received: from mail-qg0-f42.google.com ([209.85.192.42]:34925 "EHLO mail-qg0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752307AbbCWEzt (ORCPT ); Mon, 23 Mar 2015 00:55:49 -0400 Received: by qgf74 with SMTP id 74so11436062qgf.2; Sun, 22 Mar 2015 21:55:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=ujQzTQqDuebeu8TOdQEQvdOy11NP6uoAUI9fYXH33hA=; b=PVMgEeYQn2XH97LjQd9KvnExQ4Bwlp/+onHUAhvZjIP1MV3leI7ol7GsqSlAsbnnaW azYfpMLclo133NfI5n6ikUWxvoncGIAMb7zrM8MFEk9DxzJ4hCxwiG5Dzyint8K50dRo IqG8psGU2BHtzl3+Fkn/2RmD7Zhx418vY7IJmOqYk2LQGONYLH56N+2NWW7gF1r+Y4lF a7XDUOrZj1OBFrVpYH1Bg85qsFztMv/91H94MVq26oOda/RP6ZyZNd/bJKNxBKPCLLfK Y2WUf/S2FbkIljoVruM6OD9+DSGs0QviSmUN98nWw7lV3dCgr4ebqMvQ3vEnOvtWRmfs 1GVQ== X-Received: by 10.140.48.201 with SMTP id o67mr6006867qga.8.1427086548004; Sun, 22 Mar 2015 21:55:48 -0700 (PDT) Received: from htj.duckdns.org.lan (207-38-238-8.c3-0.wsd-ubr1.qens-wsd.ny.cable.rcn.com. [207.38.238.8]) by mx.google.com with ESMTPSA id n20sm8504159qgd.48.2015.03.22.21.55.46 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 22 Mar 2015 21:55:47 -0700 (PDT) From: Tejun Heo To: axboe@kernel.dk Cc: linux-kernel@vger.kernel.org, jack@suse.cz, hch@infradead.org, hannes@cmpxchg.org, linux-fsdevel@vger.kernel.org, vgoyal@redhat.com, lizefan@huawei.com, cgroups@vger.kernel.org, linux-mm@kvack.org, mhocko@suse.cz, clm@fb.com, fengguang.wu@intel.com, david@fromorbit.com, gthelen@google.com, Tejun Heo Subject: [PATCH 23/48] writeback: attribute stats to the matching per-cgroup bdi_writeback Date: Mon, 23 Mar 2015 00:54:34 -0400 Message-Id: <1427086499-15657-24-git-send-email-tj@kernel.org> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1427086499-15657-1-git-send-email-tj@kernel.org> References: <1427086499-15657-1-git-send-email-tj@kernel.org> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Until now, all WB_* stats were accounted against the root wb (bdi_writeback), now that multiple wb (bdi_writeback) support is in place, let's attributes the stats to the respective per-cgroup wb's. As no filesystem has FS_CGROUP_WRITEBACK yet, this doesn't lead to visible behavior differences. v2: Updated for per-inode wb association. Signed-off-by: Tejun Heo Cc: Jens Axboe Cc: Jan Kara --- mm/filemap.c | 2 +- mm/page-writeback.c | 22 ++++++++++++++-------- mm/truncate.c | 6 ++++-- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index a2b098b..64698fa 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -215,7 +215,7 @@ void __delete_from_page_cache(struct page *page, void *shadow, if (PageDirty(page) && mapping_cap_account_dirty(mapping)) { mem_cgroup_dec_page_stat(memcg, MEM_CGROUP_STAT_DIRTY); dec_zone_page_state(page, NR_FILE_DIRTY); - dec_wb_stat(&inode_to_bdi(mapping->host)->wb, WB_RECLAIMABLE); + dec_wb_stat(inode_to_wb(mapping->host), WB_RECLAIMABLE); } } diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 10624e3..d5635cf 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2175,10 +2175,13 @@ EXPORT_SYMBOL(__set_page_dirty_nobuffers); void account_page_redirty(struct page *page) { struct address_space *mapping = page->mapping; + if (mapping && mapping_cap_account_dirty(mapping)) { + struct bdi_writeback *wb = inode_to_wb(mapping->host); + current->nr_dirtied--; dec_zone_page_state(page, NR_DIRTIED); - dec_wb_stat(&inode_to_bdi(mapping->host)->wb, WB_DIRTIED); + dec_wb_stat(wb, WB_DIRTIED); } } EXPORT_SYMBOL(account_page_redirty); @@ -2324,8 +2327,7 @@ int clear_page_dirty_for_io(struct page *page) if (TestClearPageDirty(page)) { mem_cgroup_dec_page_stat(memcg, MEM_CGROUP_STAT_DIRTY); dec_zone_page_state(page, NR_FILE_DIRTY); - dec_wb_stat(&inode_to_bdi(mapping->host)->wb, - WB_RECLAIMABLE); + dec_wb_stat(inode_to_wb(mapping->host), WB_RECLAIMABLE); ret = 1; } mem_cgroup_end_page_stat(memcg); @@ -2343,7 +2345,8 @@ int test_clear_page_writeback(struct page *page) memcg = mem_cgroup_begin_page_stat(page); if (mapping) { - struct backing_dev_info *bdi = inode_to_bdi(mapping->host); + struct inode *inode = mapping->host; + struct backing_dev_info *bdi = inode_to_bdi(inode); unsigned long flags; spin_lock_irqsave(&mapping->tree_lock, flags); @@ -2353,8 +2356,10 @@ int test_clear_page_writeback(struct page *page) page_index(page), PAGECACHE_TAG_WRITEBACK); if (bdi_cap_account_writeback(bdi)) { - __dec_wb_stat(&bdi->wb, WB_WRITEBACK); - __wb_writeout_inc(&bdi->wb); + struct bdi_writeback *wb = inode_to_wb(inode); + + __dec_wb_stat(wb, WB_WRITEBACK); + __wb_writeout_inc(wb); } } spin_unlock_irqrestore(&mapping->tree_lock, flags); @@ -2378,7 +2383,8 @@ int __test_set_page_writeback(struct page *page, bool keep_write) memcg = mem_cgroup_begin_page_stat(page); if (mapping) { - struct backing_dev_info *bdi = inode_to_bdi(mapping->host); + struct inode *inode = mapping->host; + struct backing_dev_info *bdi = inode_to_bdi(inode); unsigned long flags; spin_lock_irqsave(&mapping->tree_lock, flags); @@ -2388,7 +2394,7 @@ int __test_set_page_writeback(struct page *page, bool keep_write) page_index(page), PAGECACHE_TAG_WRITEBACK); if (bdi_cap_account_writeback(bdi)) - __inc_wb_stat(&bdi->wb, WB_WRITEBACK); + __inc_wb_stat(inode_to_wb(inode), WB_WRITEBACK); } if (!PageDirty(page)) radix_tree_tag_clear(&mapping->page_tree, diff --git a/mm/truncate.c b/mm/truncate.c index df16f8c..fe2d769 100644 --- a/mm/truncate.c +++ b/mm/truncate.c @@ -113,11 +113,13 @@ void cancel_dirty_page(struct page *page, unsigned int account_size) memcg = mem_cgroup_begin_page_stat(page); if (TestClearPageDirty(page)) { struct address_space *mapping = page->mapping; + if (mapping && mapping_cap_account_dirty(mapping)) { + struct bdi_writeback *wb = inode_to_wb(mapping->host); + mem_cgroup_dec_page_stat(memcg, MEM_CGROUP_STAT_DIRTY); dec_zone_page_state(page, NR_FILE_DIRTY); - dec_wb_stat(&inode_to_bdi(mapping->host)->wb, - WB_RECLAIMABLE); + dec_wb_stat(wb, WB_RECLAIMABLE); if (account_size) task_io_account_cancelled_write(account_size); }