Re: [PATCH 3/3] mm: migrate: Stabilise page count when migrating transparent hugepages

From: Kirill A. Shutemov
Date: Thu Jun 08 2017 - 06:47:26 EST


On Tue, Jun 06, 2017 at 06:58:36PM +0100, Will Deacon wrote:
> When migrating a transparent hugepage, migrate_misplaced_transhuge_page
> guards itself against a concurrent fastgup of the page by checking that
> the page count is equal to 2 before and after installing the new pmd.
>
> If the page count changes, then the pmd is reverted back to the original
> entry, however there is a small window where the new (possibly writable)
> pmd is installed and the underlying page could be written by userspace.
> Restoring the old pmd could therefore result in loss of data.
>
> This patch fixes the problem by freezing the page count whilst updating
> the page tables, which protects against a concurrent fastgup without the
> need to restore the old pmd in the failure case (since the page count can
> no longer change under our feet).
>
> Cc: Mel Gorman <mgorman@xxxxxxx>
> Signed-off-by: Will Deacon <will.deacon@xxxxxxx>

Looks correct to me.

Acked-by: Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx>

--
Kirill A. Shutemov