mm: task dirty accounting fix
Subsystems (4)
PATCH 1/1 mm: task dirty accounting fix
Hi,
This is based from an earlier patch from YAMAMOTO-san which I have somewhat simplified. What do you think?
Thanks,
Nick
--
YAMAMOTO-san noticed that task_dirty_inc doesn't seem to be called properly for cases where set_page_dirty is not used to dirty a page (eg. mark_buffer_dirty).
Additionally, there is some inconsistency about when task_dirty_inc is called. It is used for dirty balancing, however it even gets called for __set_page_dirty_no_writeback.
So rather than increment it in a set_page_dirty wrapper, move it down to exactly where the dirty page accounting stats are incremented.
--- fs/buffer.c | 1 + include/linux/mm.h | 1 + mm/page-writeback.c | 13 +++---------- 3 files changed, 5 insertions(+), 10 deletions(-)
include/linux/mm.h +1 -0
@@ -1162,6 +1162,7 @@ extern int filemap_fault(struct vm_area_/* mm/page-writeback.c */ int write_one_page (struct page *page,int wait); +void task_dirty_inc (struct task_struct *tsk);/* readahead.c */ #define VM_MAX_READAHEAD 128/* kbytes */
mm/page-writeback.c +3 -10
@@ -241,7 +241,7 @@ void bdi_writeout_inc(struct backing_dev }EXPORT_SYMBOL_GPL (bdi_writeout_inc); -static inline void task_dirty_inc (struct task_struct *tsk) +void task_dirty_inc (struct task_struct *tsk) {prop_inc_single (&vm_dirties, &tsk->dirties); }
@@ -1228,6 +1228,7 @@ int __set_page_dirty_nobuffers(struct pa__inc_zone_page_state (page,NR_FILE_DIRTY );__inc_bdi_stat (mapping->backing_dev_info,BDI_RECLAIMABLE ); +task_dirty_inc (current);task_io_account_write (PAGE_CACHE_SIZE ); } radix_tree_tag_set(&mapping->page_tree,
@@ -1263,7 +1264,7 @@ EXPORT_SYMBOL(redirty_page_for_writepage* If the mapping doesn't provide a set_page_dirty a_op, then * just fall through and assume that it wants buffer_heads. */ -static int __set_page_dirty (struct page *page) +int set_page_dirty (struct page *page) {struct address_space *mapping =page_mapping (page);
@@ -1281,14 +1282,6 @@ static int __set_page_dirty(struct page }return 0 ; } - -int set_page_dirty (struct page *page) -{ -int ret =__set_page_dirty (page); -if (ret) -task_dirty_inc (current); -return ret; -}EXPORT_SYMBOL (set_page_dirty);/*
fs/buffer.c +1 -0
@@ -628,6 +628,7 @@ static int __set_page_dirty(struct page__inc_zone_page_state (page,NR_FILE_DIRTY );__inc_bdi_stat (mapping->backing_dev_info,BDI_RECLAIMABLE ); +task_dirty_inc (current);task_io_account_write (PAGE_CACHE_SIZE ); } radix_tree_tag_set(&mapping->page_tree,
Quoted 4 lines · Nick Piggin
Hi,
This is based from an earlier patch from YAMAMOTO-san which I have somewhat simplified. What do you think?
Looks nice. Was a bit surprised we never actually merged the previous one though..
Quoted 11 lines
Thanks,
Nick--
YAMAMOTO-san noticed thattask_dirty_incdoesn't seem to be called properly for cases whereset_page_dirtyis not used to dirty a page (eg.mark_buffer_dirty).Additionally, there is some inconsistency about when
task_dirty_incis called. It is used for dirty balancing, however it even gets called for__set_page_dirty_no_writeback.
Quoted 5 lines
So rather than increment it in a
set_page_dirtywrapper, move it down to exactly where the dirty page accounting stats are incremented.Cc YAMAMOTO Takashi <[email protected]>Signed-off-by Nick Piggin <[email protected]>
Quoted 75 lines
--- fs/buffer.c | 1 + include/linux/mm.h | 1 + mm/page-writeback.c | 13 +++---------- 3 files changed, 5 insertions(+), 10 deletions(-)Index:
linux-2.6/include/linux/mm.h
===================================================================include/linux/mm.h +1
-0@@ -1162,6 +1162,7 @@ extern int filemap_fault(struct vm_area_/* mm/page-writeback.c */ int write_one_page (struct page *page,int wait); +void task_dirty_inc (struct task_struct *tsk);/* readahead.c */ #define VM_MAX_READAHEAD 128/* kbytes */ Index:
linux-2.6/mm/page-writeback.c
===================================================================mm/page-writeback.c +3
-10@@ -241,7 +241,7 @@ void bdi_writeout_inc(struct backing_dev }EXPORT_SYMBOL_GPL (bdi_writeout_inc); -static inline void task_dirty_inc (struct task_struct *tsk) +void task_dirty_inc (struct task_struct *tsk) {prop_inc_single (&vm_dirties, &tsk->dirties); }@@ -1228,6 +1228,7 @@ int __set_page_dirty_nobuffers(struct pa__inc_zone_page_state (page,NR_FILE_DIRTY );__inc_bdi_stat (mapping->backing_dev_info,BDI_RECLAIMABLE ); +task_dirty_inc (current);task_io_account_write (PAGE_CACHE_SIZE ); } radix_tree_tag_set(&mapping->page_tree,@@ -1263,7 +1264,7 @@ EXPORT_SYMBOL(redirty_page_for_writepage* If the mapping doesn't provide a set_page_dirty a_op, then * just fall through and assume that it wants buffer_heads. */ -static int __set_page_dirty (struct page *page) +int set_page_dirty (struct page *page) {struct address_space *mapping =page_mapping (page);@@ -1281,14 +1282,6 @@ static int __set_page_dirty(struct page }return 0 ; } - -int set_page_dirty (struct page *page) -{ -int ret =__set_page_dirty (page); -if (ret) -task_dirty_inc (current); -return ret; -}EXPORT_SYMBOL (set_page_dirty);/* Index:
linux-2.6/fs/buffer.c
===================================================================fs/buffer.c +1
-0@@ -628,6 +628,7 @@ static int __set_page_dirty(struct page__inc_zone_page_state (page,NR_FILE_DIRTY );__inc_bdi_stat (mapping->backing_dev_info,BDI_RECLAIMABLE ); +task_dirty_inc (current);task_io_account_write (PAGE_CACHE_SIZE ); } radix_tree_tag_set(&mapping->page_tree,
Quoted 8 lines · Peter Zijlstra
Quoted 4 lines · Nick Piggin
Hi,
This is based from an earlier patch from YAMAMOTO-san which I have somewhat simplified. What do you think?
Looks nice. Was a bit surprised we never actually merged the previous one though..
So was I, it was always in the back of my mind because I didn't want to lose a good fix. I was going to just resend it, but I decided it should actually be more consistent to do this accounting with the other ones, and the patch ended up being much smaller as a result too.
But credit to YAMAMOTO san for the core fix.
Quoted 95 lines
Quoted 12 lines
Thanks,
Nick--
YAMAMOTO-san noticed thattask_dirty_incdoesn't seem to be called properly for cases whereset_page_dirtyis not used to dirty a page (eg.mark_buffer_dirty).Additionally, there is some inconsistency about when
task_dirty_incis called. It is used for dirty balancing, however it even gets called for__set_page_dirty_no_writeback.Quoted 5 lines
So rather than increment it in a
set_page_dirtywrapper, move it down to exactly where the dirty page accounting stats are incremented.Cc YAMAMOTO Takashi <[email protected]>Signed-off-by Nick Piggin <[email protected]>Acked-by Peter Zijlstra <[email protected]>Quoted 75 lines
--- fs/buffer.c | 1 + include/linux/mm.h | 1 + mm/page-writeback.c | 13 +++---------- 3 files changed, 5 insertions(+), 10 deletions(-)Index:
linux-2.6/include/linux/mm.h
===================================================================include/linux/mm.h +1
-0@@ -1162,6 +1162,7 @@ extern int filemap_fault(struct vm_area_/* mm/page-writeback.c */ int write_one_page (struct page *page,int wait); +void task_dirty_inc (struct task_struct *tsk);/* readahead.c */ #define VM_MAX_READAHEAD 128/* kbytes */ Index:
linux-2.6/mm/page-writeback.c
===================================================================mm/page-writeback.c +3
-10@@ -241,7 +241,7 @@ void bdi_writeout_inc(struct backing_dev }EXPORT_SYMBOL_GPL (bdi_writeout_inc); -static inline void task_dirty_inc (struct task_struct *tsk) +void task_dirty_inc (struct task_struct *tsk) {prop_inc_single (&vm_dirties, &tsk->dirties); }@@ -1228,6 +1228,7 @@ int __set_page_dirty_nobuffers(struct pa__inc_zone_page_state (page,NR_FILE_DIRTY );__inc_bdi_stat (mapping->backing_dev_info,BDI_RECLAIMABLE ); +task_dirty_inc (current);task_io_account_write (PAGE_CACHE_SIZE ); } radix_tree_tag_set(&mapping->page_tree,@@ -1263,7 +1264,7 @@ EXPORT_SYMBOL(redirty_page_for_writepage* If the mapping doesn't provide a set_page_dirty a_op, then * just fall through and assume that it wants buffer_heads. */ -static int __set_page_dirty (struct page *page) +int set_page_dirty (struct page *page) {struct address_space *mapping =page_mapping (page);@@ -1281,14 +1282,6 @@ static int __set_page_dirty(struct page }return 0 ; } - -int set_page_dirty (struct page *page) -{ -int ret =__set_page_dirty (page); -if (ret) -task_dirty_inc (current); -return ret; -}EXPORT_SYMBOL (set_page_dirty);/* Index:
linux-2.6/fs/buffer.c
===================================================================fs/buffer.c +1
-0@@ -628,6 +628,7 @@ static int __set_page_dirty(struct page__inc_zone_page_state (page,NR_FILE_DIRTY );__inc_bdi_stat (mapping->backing_dev_info,BDI_RECLAIMABLE ); +task_dirty_inc (current);task_io_account_write (PAGE_CACHE_SIZE ); } radix_tree_tag_set(&mapping->page_tree,