Skip to content

Commit

Permalink
page migration: fix NR_FILE_PAGES accounting
Browse files Browse the repository at this point in the history
NR_FILE_PAGES must be accounted for depending on the zone that the page
belongs to.  If we replace the page in the radix tree then we may have to
shift the count to another zone.

Suggested-by: Ethan Solomita <[email protected]>
Eventually-typed-in-by: Christoph Lameter <[email protected]>
Cc: Martin Bligh <[email protected]>
Cc: <[email protected]>
Signed-off-by: Christoph Lameter <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Christoph Lameter authored and Linus Torvalds committed Apr 24, 2007
1 parent 10ccaf4 commit 0e8c7d0
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion mm/migrate.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ static int migrate_page_move_mapping(struct address_space *mapping,
void **pslot;

if (!mapping) {
/* Anonymous page */
/* Anonymous page without mapping */
if (page_count(page) != 1)
return -EAGAIN;
return 0;
Expand Down Expand Up @@ -333,6 +333,19 @@ static int migrate_page_move_mapping(struct address_space *mapping,
*/
__put_page(page);

/*
* If moved to a different zone then also account
* the page for that zone. Other VM counters will be
* taken care of when we establish references to the
* new page and drop references to the old page.
*
* Note that anonymous pages are accounted for
* via NR_FILE_PAGES and NR_ANON_PAGES if they
* are mapped to swap space.
*/
__dec_zone_page_state(page, NR_FILE_PAGES);
__inc_zone_page_state(newpage, NR_FILE_PAGES);

write_unlock_irq(&mapping->tree_lock);

return 0;
Expand Down

0 comments on commit 0e8c7d0

Please sign in to comment.