Skip to content

Commit a38c015

Browse files
Claudio Imbrendatorvalds
authored andcommitted
mm/ksm.c: fix inconsistent accounting of zero pages
When using KSM with use_zero_pages, we replace anonymous pages containing only zeroes with actual zero pages, which are not anonymous. We need to do proper accounting of the mm counters, otherwise we will get wrong values in /proc and a BUG message in dmesg when tearing down the mm. Link: http://lkml.kernel.org/r/[email protected] Fixes: e86c59b ("mm/ksm: improve deduplication of zero pages with colouring") Signed-off-by: Claudio Imbrenda <[email protected]> Reviewed-by: Andrew Morton <[email protected]> Cc: Andrea Arcangeli <[email protected]> Cc: Minchan Kim <[email protected]> Cc: Kirill A. Shutemov <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: Christian Borntraeger <[email protected]> Cc: Gerald Schaefer <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 8a97ea5 commit a38c015

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

mm/ksm.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,6 +1131,13 @@ static int replace_page(struct vm_area_struct *vma, struct page *page,
11311131
} else {
11321132
newpte = pte_mkspecial(pfn_pte(page_to_pfn(kpage),
11331133
vma->vm_page_prot));
1134+
/*
1135+
* We're replacing an anonymous page with a zero page, which is
1136+
* not anonymous. We need to do proper accounting otherwise we
1137+
* will get wrong values in /proc, and a BUG message in dmesg
1138+
* when tearing down the mm.
1139+
*/
1140+
dec_mm_counter(mm, MM_ANONPAGES);
11341141
}
11351142

11361143
flush_cache_page(vma, addr, pte_pfn(*ptep));

0 commit comments

Comments
 (0)