Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mm: hugetlb: initialize PG_reserved for tail pages of gigantic compou…
…nd pages Commit 11feeb4 ("kvm: optimize away THP checks in kvm_is_mmio_pfn()") introduced a memory leak when KVM is run on gigantic compound pages. That commit depends on the assumption that PG_reserved is identical for all head and tail pages of a compound page. So that if get_user_pages returns a tail page, we don't need to check the head page in order to know if we deal with a reserved page that requires different refcounting. The assumption that PG_reserved is the same for head and tail pages is certainly correct for THP and regular hugepages, but gigantic hugepages allocated through bootmem don't clear the PG_reserved on the tail pages (the clearing of PG_reserved is done later only if the gigantic hugepage is freed). This patch corrects the gigantic compound page initialization so that we can retain the optimization in 11feeb4. The cacheline was already modified in order to set PG_tail so this won't affect the boot time of large memory systems. [[email protected]: tweak comment layout and grammar] Signed-off-by: Andrea Arcangeli <[email protected]> Reported-by: andy123 <[email protected]> Acked-by: Rik van Riel <[email protected]> Cc: Gleb Natapov <[email protected]> Cc: Mel Gorman <[email protected]> Cc: Hugh Dickins <[email protected]> Acked-by: Rafael Aquini <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
- Loading branch information