Skip to content

Commit

Permalink
mm: migrate: one less atomic operation
Browse files Browse the repository at this point in the history
migrate_page_move_mapping() drops a reference from the old page after
unfreezing its counter.  Both operations can be merged into a single
atomic operation by directly unfreezing to one less reference.

The same applies to migrate_huge_page_move_mapping().

Signed-off-by: Jacobo Giralt <jacobo.giralt@gmail.com>
Cc: Mel Gorman <mel@csn.ul.ie>
Cc: Minchan Kim <minchan.kim@gmail.com>
Cc: Johannes Weiner <jweiner@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Jacobo Giralt authored and Linus Torvalds committed Jan 11, 2012
1 parent 90a5d5a commit 937a94c
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions mm/migrate.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,12 +269,12 @@ static int migrate_page_move_mapping(struct address_space *mapping,

radix_tree_replace_slot(pslot, newpage);

page_unfreeze_refs(page, expected_count);
/*
* Drop cache reference from old page.
* Drop cache reference from old page by unfreezing
* to one less reference.
* We know this isn't the last reference.
*/
__put_page(page);
page_unfreeze_refs(page, expected_count - 1);

/*
* If moved to a different zone then also account
Expand Down Expand Up @@ -334,9 +334,7 @@ int migrate_huge_page_move_mapping(struct address_space *mapping,

radix_tree_replace_slot(pslot, newpage);

page_unfreeze_refs(page, expected_count);

__put_page(page);
page_unfreeze_refs(page, expected_count - 1);

spin_unlock_irq(&mapping->tree_lock);
return 0;
Expand Down

0 comments on commit 937a94c

Please sign in to comment.