mm: task dirty accounting fix

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.

Cc: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: Nick Piggin <npiggin@suse.de>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Nick Piggin 2009-02-18 14:48:18 -08:00 committed by Linus Torvalds
parent 610d18f412
commit 1cf6e7d83b
3 changed files with 5 additions and 10 deletions

View file

@ -777,6 +777,7 @@ static int __set_page_dirty(struct page *page,
__inc_zone_page_state(page, NR_FILE_DIRTY); __inc_zone_page_state(page, NR_FILE_DIRTY);
__inc_bdi_stat(mapping->backing_dev_info, __inc_bdi_stat(mapping->backing_dev_info,
BDI_RECLAIMABLE); BDI_RECLAIMABLE);
task_dirty_inc(current);
task_io_account_write(PAGE_CACHE_SIZE); task_io_account_write(PAGE_CACHE_SIZE);
} }
radix_tree_tag_set(&mapping->page_tree, radix_tree_tag_set(&mapping->page_tree,

View file

@ -1159,6 +1159,7 @@ extern int filemap_fault(struct vm_area_struct *, struct vm_fault *);
/* mm/page-writeback.c */ /* mm/page-writeback.c */
int write_one_page(struct page *page, int wait); int write_one_page(struct page *page, int wait);
void task_dirty_inc(struct task_struct *tsk);
/* readahead.c */ /* readahead.c */
#define VM_MAX_READAHEAD 128 /* kbytes */ #define VM_MAX_READAHEAD 128 /* kbytes */

View file

@ -240,7 +240,7 @@ void bdi_writeout_inc(struct backing_dev_info *bdi)
} }
EXPORT_SYMBOL_GPL(bdi_writeout_inc); 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); prop_inc_single(&vm_dirties, &tsk->dirties);
} }
@ -1230,6 +1230,7 @@ int __set_page_dirty_nobuffers(struct page *page)
__inc_zone_page_state(page, NR_FILE_DIRTY); __inc_zone_page_state(page, NR_FILE_DIRTY);
__inc_bdi_stat(mapping->backing_dev_info, __inc_bdi_stat(mapping->backing_dev_info,
BDI_RECLAIMABLE); BDI_RECLAIMABLE);
task_dirty_inc(current);
task_io_account_write(PAGE_CACHE_SIZE); task_io_account_write(PAGE_CACHE_SIZE);
} }
radix_tree_tag_set(&mapping->page_tree, radix_tree_tag_set(&mapping->page_tree,
@ -1262,7 +1263,7 @@ EXPORT_SYMBOL(redirty_page_for_writepage);
* If the mapping doesn't provide a set_page_dirty a_op, then * If the mapping doesn't provide a set_page_dirty a_op, then
* just fall through and assume that it wants buffer_heads. * 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); struct address_space *mapping = page_mapping(page);
@ -1280,14 +1281,6 @@ static int __set_page_dirty(struct page *page)
} }
return 0; 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); EXPORT_SYMBOL(set_page_dirty);
/* /*