Skip to content

Commit

Permalink
move page writeback acounting out of macros
Browse files Browse the repository at this point in the history
page-writeback accounting is presently performed in the page-flags macros.
This is inconsistent and a bit ugly and makes it awkward to implement
per-backing_dev under-writeback page accounting.

So move this accounting down to the callsite(s).

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>
  • Loading branch information
Andrew Morton authored and Linus Torvalds committed Jul 19, 2007
1 parent 6819457 commit d688abf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 30 deletions.
38 changes: 8 additions & 30 deletions include/linux/page-flags.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,37 +189,15 @@ static inline void SetPageUptodate(struct page *page)
#define __SetPagePrivate(page) __set_bit(PG_private, &(page)->flags)
#define __ClearPagePrivate(page) __clear_bit(PG_private, &(page)->flags)

/*
* Only test-and-set exist for PG_writeback. The unconditional operators are
* risky: they bypass page accounting.
*/
#define PageWriteback(page) test_bit(PG_writeback, &(page)->flags)
#define SetPageWriteback(page) \
do { \
if (!test_and_set_bit(PG_writeback, \
&(page)->flags)) \
inc_zone_page_state(page, NR_WRITEBACK); \
} while (0)
#define TestSetPageWriteback(page) \
({ \
int ret; \
ret = test_and_set_bit(PG_writeback, \
&(page)->flags); \
if (!ret) \
inc_zone_page_state(page, NR_WRITEBACK); \
ret; \
})
#define ClearPageWriteback(page) \
do { \
if (test_and_clear_bit(PG_writeback, \
&(page)->flags)) \
dec_zone_page_state(page, NR_WRITEBACK); \
} while (0)
#define TestClearPageWriteback(page) \
({ \
int ret; \
ret = test_and_clear_bit(PG_writeback, \
&(page)->flags); \
if (ret) \
dec_zone_page_state(page, NR_WRITEBACK); \
ret; \
})
#define TestSetPageWriteback(page) test_and_set_bit(PG_writeback, \
&(page)->flags)
#define TestClearPageWriteback(page) test_and_clear_bit(PG_writeback, \
&(page)->flags)

#define PageBuddy(page) test_bit(PG_buddy, &(page)->flags)
#define __SetPageBuddy(page) __set_bit(PG_buddy, &(page)->flags)
Expand Down
4 changes: 4 additions & 0 deletions mm/page-writeback.c
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,8 @@ int test_clear_page_writeback(struct page *page)
} else {
ret = TestClearPageWriteback(page);
}
if (ret)
dec_zone_page_state(page, NR_WRITEBACK);
return ret;
}

Expand All @@ -1012,6 +1014,8 @@ int test_set_page_writeback(struct page *page)
} else {
ret = TestSetPageWriteback(page);
}
if (!ret)
inc_zone_page_state(page, NR_WRITEBACK);
return ret;

}
Expand Down

0 comments on commit d688abf

Please sign in to comment.