Commit 91018134 authored by Tejun Heo's avatar Tejun Heo Committed by Jens Axboe

writeback: attribute stats to the matching per-cgroup bdi_writeback

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: default avatarTejun Heo <tj@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Jan Kara <jack@suse.cz>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent ce7acfea
...@@ -2130,7 +2130,7 @@ void account_page_cleaned(struct page *page, struct address_space *mapping, ...@@ -2130,7 +2130,7 @@ void account_page_cleaned(struct page *page, struct address_space *mapping,
if (mapping_cap_account_dirty(mapping)) { if (mapping_cap_account_dirty(mapping)) {
mem_cgroup_dec_page_stat(memcg, MEM_CGROUP_STAT_DIRTY); mem_cgroup_dec_page_stat(memcg, MEM_CGROUP_STAT_DIRTY);
dec_zone_page_state(page, NR_FILE_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);
task_io_account_cancelled_write(PAGE_CACHE_SIZE); task_io_account_cancelled_write(PAGE_CACHE_SIZE);
} }
} }
...@@ -2191,10 +2191,13 @@ EXPORT_SYMBOL(__set_page_dirty_nobuffers); ...@@ -2191,10 +2191,13 @@ EXPORT_SYMBOL(__set_page_dirty_nobuffers);
void account_page_redirty(struct page *page) void account_page_redirty(struct page *page)
{ {
struct address_space *mapping = page->mapping; struct address_space *mapping = page->mapping;
if (mapping && mapping_cap_account_dirty(mapping)) { if (mapping && mapping_cap_account_dirty(mapping)) {
struct bdi_writeback *wb = inode_to_wb(mapping->host);
current->nr_dirtied--; current->nr_dirtied--;
dec_zone_page_state(page, 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); EXPORT_SYMBOL(account_page_redirty);
...@@ -2373,8 +2376,7 @@ int clear_page_dirty_for_io(struct page *page) ...@@ -2373,8 +2376,7 @@ int clear_page_dirty_for_io(struct page *page)
if (TestClearPageDirty(page)) { if (TestClearPageDirty(page)) {
mem_cgroup_dec_page_stat(memcg, MEM_CGROUP_STAT_DIRTY); mem_cgroup_dec_page_stat(memcg, MEM_CGROUP_STAT_DIRTY);
dec_zone_page_state(page, NR_FILE_DIRTY); dec_zone_page_state(page, NR_FILE_DIRTY);
dec_wb_stat(&inode_to_bdi(mapping->host)->wb, dec_wb_stat(inode_to_wb(mapping->host), WB_RECLAIMABLE);
WB_RECLAIMABLE);
ret = 1; ret = 1;
} }
mem_cgroup_end_page_stat(memcg); mem_cgroup_end_page_stat(memcg);
...@@ -2392,7 +2394,8 @@ int test_clear_page_writeback(struct page *page) ...@@ -2392,7 +2394,8 @@ int test_clear_page_writeback(struct page *page)
memcg = mem_cgroup_begin_page_stat(page); memcg = mem_cgroup_begin_page_stat(page);
if (mapping) { 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; unsigned long flags;
spin_lock_irqsave(&mapping->tree_lock, flags); spin_lock_irqsave(&mapping->tree_lock, flags);
...@@ -2402,8 +2405,10 @@ int test_clear_page_writeback(struct page *page) ...@@ -2402,8 +2405,10 @@ int test_clear_page_writeback(struct page *page)
page_index(page), page_index(page),
PAGECACHE_TAG_WRITEBACK); PAGECACHE_TAG_WRITEBACK);
if (bdi_cap_account_writeback(bdi)) { if (bdi_cap_account_writeback(bdi)) {
__dec_wb_stat(&bdi->wb, WB_WRITEBACK); struct bdi_writeback *wb = inode_to_wb(inode);
__wb_writeout_inc(&bdi->wb);
__dec_wb_stat(wb, WB_WRITEBACK);
__wb_writeout_inc(wb);
} }
} }
spin_unlock_irqrestore(&mapping->tree_lock, flags); spin_unlock_irqrestore(&mapping->tree_lock, flags);
...@@ -2427,7 +2432,8 @@ int __test_set_page_writeback(struct page *page, bool keep_write) ...@@ -2427,7 +2432,8 @@ int __test_set_page_writeback(struct page *page, bool keep_write)
memcg = mem_cgroup_begin_page_stat(page); memcg = mem_cgroup_begin_page_stat(page);
if (mapping) { 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; unsigned long flags;
spin_lock_irqsave(&mapping->tree_lock, flags); spin_lock_irqsave(&mapping->tree_lock, flags);
...@@ -2437,7 +2443,7 @@ int __test_set_page_writeback(struct page *page, bool keep_write) ...@@ -2437,7 +2443,7 @@ int __test_set_page_writeback(struct page *page, bool keep_write)
page_index(page), page_index(page),
PAGECACHE_TAG_WRITEBACK); PAGECACHE_TAG_WRITEBACK);
if (bdi_cap_account_writeback(bdi)) 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)) if (!PageDirty(page))
radix_tree_tag_clear(&mapping->page_tree, radix_tree_tag_clear(&mapping->page_tree,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment