Re: [PATCH] mm: thp: clear PageDoubleMap flag when the last PMD map gone

From: Kirill A. Shutemov
Date: Fri Oct 25 2019 - 11:36:23 EST

On Fri, Oct 25, 2019 at 01:27:46AM +0800, Yang Shi wrote:
> File THP sets PageDoubleMap flag when the first it gets PTE mapped, but
> the flag is never cleared until the THP is freed. This result in
> unbalanced state although it is not a big deal.
> Clear the flag when the last compound_mapcount is gone. It should be
> cleared when all the PTE maps are gone (become PMD mapped only) as well,
> but this needs check all subpage's _mapcount every time any subpage's
> rmap is removed, the overhead may be not worth. The anonymous THP also
> just clears PageDoubleMap flag when the last PMD map is gone.

NAK, sorry.

The key difference with anon THP that file THP can be mapped again with
PMD after all PMD (or all) mappings are gone.

Your patch breaks the case when you map the page with PMD again while the
page is still mapped with PTEs. Who would set PageDoubleMap() in this

Kirill A. Shutemov