mm: clean up page_remove_rmap()
page_remove_rmap() has multiple PageAnon() tests and it has deep nesting. Clean this up. Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Acked-by: Mel Gorman <mel@csn.ul.ie> Reviewed-by: Wu Fengguang <fengguang.wu@intel.com> Cc: Rik van Riel <riel@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
committed by
Linus Torvalds
parent
57dd28fb05
commit
b904dcfed6
17
mm/rmap.c
17
mm/rmap.c
@@ -739,7 +739,10 @@ void page_dup_rmap(struct page *page, struct vm_area_struct *vma, unsigned long
|
|||||||
*/
|
*/
|
||||||
void page_remove_rmap(struct page *page)
|
void page_remove_rmap(struct page *page)
|
||||||
{
|
{
|
||||||
if (atomic_add_negative(-1, &page->_mapcount)) {
|
/* page still mapped by someone else? */
|
||||||
|
if (!atomic_add_negative(-1, &page->_mapcount))
|
||||||
|
return;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Now that the last pte has gone, s390 must transfer dirty
|
* Now that the last pte has gone, s390 must transfer dirty
|
||||||
* flag from storage key to struct page. We can usually skip
|
* flag from storage key to struct page. We can usually skip
|
||||||
@@ -747,15 +750,16 @@ void page_remove_rmap(struct page *page)
|
|||||||
* not if it's in swapcache - there might be another pte slot
|
* not if it's in swapcache - there might be another pte slot
|
||||||
* containing the swap entry, but page not yet written to swap.
|
* containing the swap entry, but page not yet written to swap.
|
||||||
*/
|
*/
|
||||||
if ((!PageAnon(page) || PageSwapCache(page)) &&
|
if ((!PageAnon(page) || PageSwapCache(page)) && page_test_dirty(page)) {
|
||||||
page_test_dirty(page)) {
|
|
||||||
page_clear_dirty(page);
|
page_clear_dirty(page);
|
||||||
set_page_dirty(page);
|
set_page_dirty(page);
|
||||||
}
|
}
|
||||||
if (PageAnon(page))
|
if (PageAnon(page)) {
|
||||||
mem_cgroup_uncharge_page(page);
|
mem_cgroup_uncharge_page(page);
|
||||||
__dec_zone_page_state(page,
|
__dec_zone_page_state(page, NR_ANON_PAGES);
|
||||||
PageAnon(page) ? NR_ANON_PAGES : NR_FILE_MAPPED);
|
} else {
|
||||||
|
__dec_zone_page_state(page, NR_FILE_MAPPED);
|
||||||
|
}
|
||||||
mem_cgroup_update_mapped_file_stat(page, -1);
|
mem_cgroup_update_mapped_file_stat(page, -1);
|
||||||
/*
|
/*
|
||||||
* It would be tidy to reset the PageAnon mapping here,
|
* It would be tidy to reset the PageAnon mapping here,
|
||||||
@@ -767,7 +771,6 @@ void page_remove_rmap(struct page *page)
|
|||||||
* faster for those pages still in swapcache.
|
* faster for those pages still in swapcache.
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Subfunctions of try_to_unmap: try_to_unmap_one called
|
* Subfunctions of try_to_unmap: try_to_unmap_one called
|
||||||
|
Reference in New Issue
Block a user