Skip to content

Commit e84e691

Browse files
Claudio Imbrendagregkh
authored andcommitted
mm/ksm.c: fix inconsistent accounting of zero pages
commit a38c015 upstream. 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]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 577b4eb commit e84e691

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
@@ -1133,6 +1133,13 @@ static int replace_page(struct vm_area_struct *vma, struct page *page,
11331133
} else {
11341134
newpte = pte_mkspecial(pfn_pte(page_to_pfn(kpage),
11351135
vma->vm_page_prot));
1136+
/*
1137+
* We're replacing an anonymous page with a zero page, which is
1138+
* not anonymous. We need to do proper accounting otherwise we
1139+
* will get wrong values in /proc, and a BUG message in dmesg
1140+
* when tearing down the mm.
1141+
*/
1142+
dec_mm_counter(mm, MM_ANONPAGES);
11361143
}
11371144

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

0 commit comments

Comments
 (0)