diff options
author | Wu Fengguang <fengguang.wu@intel.com> | 2011-08-08 17:22:00 -0400 |
---|---|---|
committer | Wu Fengguang <fengguang.wu@intel.com> | 2011-12-18 01:20:23 -0500 |
commit | 2f800fbd777b792de54187088df19a7df0251254 (patch) | |
tree | 2dc813b41da42d647468dafcf49a0b9e673df8b5 | |
parent | d3bc1fef9389e409a772ea174a5e41a6f93d9b7b (diff) |
writeback: fix dirtied pages accounting on redirty
De-account the accumulative dirty counters on page redirty.
Page redirties (very common in ext4) will introduce mismatch between
counters (a) and (b)
a) NR_DIRTIED, BDI_DIRTIED, tsk->nr_dirtied
b) NR_WRITTEN, BDI_WRITTEN
This will introduce systematic errors in balanced_rate and result in
dirty page position errors (ie. the dirty pages are no longer balanced
around the global/bdi setpoints).
Acked-by: Jan Kara <jack@suse.cz>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
-rw-r--r-- | include/linux/writeback.h | 2 | ||||
-rw-r--r-- | mm/page-writeback.c | 19 |
2 files changed, 21 insertions, 0 deletions
diff --git a/include/linux/writeback.h b/include/linux/writeback.h index 05eaf5e3aad7..b30419cd425e 100644 --- a/include/linux/writeback.h +++ b/include/linux/writeback.h | |||
@@ -197,6 +197,8 @@ void writeback_set_ratelimit(void); | |||
197 | void tag_pages_for_writeback(struct address_space *mapping, | 197 | void tag_pages_for_writeback(struct address_space *mapping, |
198 | pgoff_t start, pgoff_t end); | 198 | pgoff_t start, pgoff_t end); |
199 | 199 | ||
200 | void account_page_redirty(struct page *page); | ||
201 | |||
200 | /* pdflush.c */ | 202 | /* pdflush.c */ |
201 | extern int nr_pdflush_threads; /* Global so it can be exported to sysctl | 203 | extern int nr_pdflush_threads; /* Global so it can be exported to sysctl |
202 | read-only. */ | 204 | read-only. */ |
diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 5d1ef5d8613a..96b3e7aa705c 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c | |||
@@ -1825,6 +1825,24 @@ int __set_page_dirty_nobuffers(struct page *page) | |||
1825 | EXPORT_SYMBOL(__set_page_dirty_nobuffers); | 1825 | EXPORT_SYMBOL(__set_page_dirty_nobuffers); |
1826 | 1826 | ||
1827 | /* | 1827 | /* |
1828 | * Call this whenever redirtying a page, to de-account the dirty counters | ||
1829 | * (NR_DIRTIED, BDI_DIRTIED, tsk->nr_dirtied), so that they match the written | ||
1830 | * counters (NR_WRITTEN, BDI_WRITTEN) in long term. The mismatches will lead to | ||
1831 | * systematic errors in balanced_dirty_ratelimit and the dirty pages position | ||
1832 | * control. | ||
1833 | */ | ||
1834 | void account_page_redirty(struct page *page) | ||
1835 | { | ||
1836 | struct address_space *mapping = page->mapping; | ||
1837 | if (mapping && mapping_cap_account_dirty(mapping)) { | ||
1838 | current->nr_dirtied--; | ||
1839 | dec_zone_page_state(page, NR_DIRTIED); | ||
1840 | dec_bdi_stat(mapping->backing_dev_info, BDI_DIRTIED); | ||
1841 | } | ||
1842 | } | ||
1843 | EXPORT_SYMBOL(account_page_redirty); | ||
1844 | |||
1845 | /* | ||
1828 | * When a writepage implementation decides that it doesn't want to write this | 1846 | * When a writepage implementation decides that it doesn't want to write this |
1829 | * page for some reason, it should redirty the locked page via | 1847 | * page for some reason, it should redirty the locked page via |
1830 | * redirty_page_for_writepage() and it should then unlock the page and return 0 | 1848 | * redirty_page_for_writepage() and it should then unlock the page and return 0 |
@@ -1832,6 +1850,7 @@ EXPORT_SYMBOL(__set_page_dirty_nobuffers); | |||
1832 | int redirty_page_for_writepage(struct writeback_control *wbc, struct page *page) | 1850 | int redirty_page_for_writepage(struct writeback_control *wbc, struct page *page) |
1833 | { | 1851 | { |
1834 | wbc->pages_skipped++; | 1852 | wbc->pages_skipped++; |
1853 | account_page_redirty(page); | ||
1835 | return __set_page_dirty_nobuffers(page); | 1854 | return __set_page_dirty_nobuffers(page); |
1836 | } | 1855 | } |
1837 | EXPORT_SYMBOL(redirty_page_for_writepage); | 1856 | EXPORT_SYMBOL(redirty_page_for_writepage); |