Skip to content

Commit d44d363

Browse files
shligittorvalds
authored andcommitted
mm: don't assume anonymous pages have SwapBacked flag
There are a few places the code assumes anonymous pages should have SwapBacked flag set. MADV_FREE pages are anonymous pages but we are going to add them to LRU_INACTIVE_FILE list and clear SwapBacked flag for them. The assumption doesn't hold any more, so fix them. Link: http://lkml.kernel.org/r/3945232c0df3dd6c4ef001976f35a95f18dcb407.1487965799.git.shli@fb.com Signed-off-by: Shaohua Li <[email protected]> Acked-by: Johannes Weiner <[email protected]> Acked-by: Hillf Danton <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Minchan Kim <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: Rik van Riel <[email protected]> Cc: Mel Gorman <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent a128ca7 commit d44d363

File tree

4 files changed

+7
-8
lines changed

4 files changed

+7
-8
lines changed

mm/huge_memory.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2399,7 +2399,6 @@ int split_huge_page_to_list(struct page *page, struct list_head *list)
23992399

24002400
VM_BUG_ON_PAGE(is_huge_zero_page(page), page);
24012401
VM_BUG_ON_PAGE(!PageLocked(page), page);
2402-
VM_BUG_ON_PAGE(!PageSwapBacked(page), page);
24032402
VM_BUG_ON_PAGE(!PageCompound(page), page);
24042403

24052404
if (PageAnon(head)) {

mm/khugepaged.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -483,8 +483,7 @@ void __khugepaged_exit(struct mm_struct *mm)
483483

484484
static void release_pte_page(struct page *page)
485485
{
486-
/* 0 stands for page_is_file_cache(page) == false */
487-
dec_node_page_state(page, NR_ISOLATED_ANON + 0);
486+
dec_node_page_state(page, NR_ISOLATED_ANON + page_is_file_cache(page));
488487
unlock_page(page);
489488
putback_lru_page(page);
490489
}
@@ -532,7 +531,6 @@ static int __collapse_huge_page_isolate(struct vm_area_struct *vma,
532531

533532
VM_BUG_ON_PAGE(PageCompound(page), page);
534533
VM_BUG_ON_PAGE(!PageAnon(page), page);
535-
VM_BUG_ON_PAGE(!PageSwapBacked(page), page);
536534

537535
/*
538536
* We can do it before isolate_lru_page because the
@@ -579,8 +577,8 @@ static int __collapse_huge_page_isolate(struct vm_area_struct *vma,
579577
result = SCAN_DEL_PAGE_LRU;
580578
goto out;
581579
}
582-
/* 0 stands for page_is_file_cache(page) == false */
583-
inc_node_page_state(page, NR_ISOLATED_ANON + 0);
580+
inc_node_page_state(page,
581+
NR_ISOLATED_ANON + page_is_file_cache(page));
584582
VM_BUG_ON_PAGE(!PageLocked(page), page);
585583
VM_BUG_ON_PAGE(PageLRU(page), page);
586584

mm/migrate.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1944,7 +1944,8 @@ int migrate_misplaced_transhuge_page(struct mm_struct *mm,
19441944

19451945
/* Prepare a page as a migration target */
19461946
__SetPageLocked(new_page);
1947-
__SetPageSwapBacked(new_page);
1947+
if (PageSwapBacked(page))
1948+
__SetPageSwapBacked(new_page);
19481949

19491950
/* anon mapping, we can simply copy page->mapping to the new page: */
19501951
new_page->mapping = page->mapping;

mm/rmap.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1424,7 +1424,8 @@ static int try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
14241424
* Store the swap location in the pte.
14251425
* See handle_pte_fault() ...
14261426
*/
1427-
VM_BUG_ON_PAGE(!PageSwapCache(page), page);
1427+
VM_BUG_ON_PAGE(!PageSwapCache(page) && PageSwapBacked(page),
1428+
page);
14281429

14291430
if (!PageDirty(page)) {
14301431
/* It's a freeable page by MADV_FREE */

0 commit comments

Comments
 (0)