From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751454AbdFHKrY (ORCPT ); Thu, 8 Jun 2017 06:47:24 -0400 Received: from mga01.intel.com ([192.55.52.88]:45131 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751410AbdFHKrW (ORCPT ); Thu, 8 Jun 2017 06:47:22 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,314,1493708400"; d="scan'208";a="865839885" Date: Thu, 8 Jun 2017 13:47:03 +0300 From: "Kirill A. Shutemov" To: Will Deacon Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, mark.rutland@arm.com, akpm@linux-foundation.org, Punit.Agrawal@arm.com, mgorman@suse.de, steve.capper@arm.com Subject: Re: [PATCH 3/3] mm: migrate: Stabilise page count when migrating transparent hugepages Message-ID: <20170608104702.rqrczxh2wcyfril7@black.fi.intel.com> References: <1496771916-28203-1-git-send-email-will.deacon@arm.com> <1496771916-28203-4-git-send-email-will.deacon@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1496771916-28203-4-git-send-email-will.deacon@arm.com> User-Agent: NeoMutt/20161126 (1.7.0) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > Signed-off-by: Will Deacon Looks correct to me. Acked-by: Kirill A. Shutemov -- Kirill A. Shutemov