Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp633632ybt; Fri, 10 Jul 2020 08:32:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwOZggLHPCZELhiNfQzpqV+qDUKzMIjShLJ/WLN9tDo0c9082C7uQ+PH9qGbd72PdBP9ANB X-Received: by 2002:a17:906:7017:: with SMTP id n23mr44749397ejj.262.1594395177862; Fri, 10 Jul 2020 08:32:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594395177; cv=none; d=google.com; s=arc-20160816; b=QHt/9GhpsiQ//Zuj1Fqkay4cUjN+CoCIsoqZkSuLCiwws/JBv45DSJztMkgIHEZKKG O9ihKH47VqpKQEnDWVpVri7w+O8SaxgVsaVsHkolxA5frWn9XwU7Mc3STIyOffWyk7gI fkm3P3nacPLOHqmcL/XodiwxVJWtsRT0DAKA/+icfLdJj5tIyd21CvnqUrSC5619GTct P1TnGK2969JsDZ0xpz1UKUsxGXsmqaisocqfhodYiLAKMaTAUU9amJrh4e7CDf6yOHfb rlYlWPfRHwq39mlF4LJq8nVPiSbbOX0PyQqbaenFZxuzfxwZghopbu6XHNwsFODv8xeD HDDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=VS+1ln0yIr5T2PSB/0/JmrDnZBodUc6yz/eHP1P0UWU=; b=wORMEUmiVtBPDTX8SLtihmvMIRsKF0njbHpFZTSMSAIe6uCLMVZ0uUaJZ5hqcIS/dg yqIiso5P/UNbSoL0gEN2aDLAL8XfeIWz8lWZwavjC+EhI6cvQ1Dl00nSjXct4boBXLbq 8suC+/KUy3NDJ87OhhKmxWk4ZDvCPE7wYgNfLZfOYWrtks2zQkJGm569n/SzNwMtZGev GGHtf5NwtvFGasskQOfgI03/QhEOmpSLaThk8hAWd1FYkXMITpf2IYXWlO+4NvAcDH+l OlnkQOIACEjmamFjSoThxTPSXVaL9lcRv8oIl5Mw4gd7o01L9C4kMwBQkEaIH9OvaGXw lmWA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cw25si4515986edb.203.2020.07.10.08.32.34; Fri, 10 Jul 2020 08:32:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727978AbgGJPbQ (ORCPT + 99 others); Fri, 10 Jul 2020 11:31:16 -0400 Received: from mx2.suse.de ([195.135.220.15]:57984 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726950AbgGJPbQ (ORCPT ); Fri, 10 Jul 2020 11:31:16 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id AF9E4AC53; Fri, 10 Jul 2020 15:31:15 +0000 (UTC) Subject: Re: [PATCH] mm : fix pte _PAGE_DIRTY bit when fallback migrate page To: robbieko , linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org References: <20200709024808.18466-1-robbieko@synology.com> From: Vlastimil Babka Message-ID: <859c810e-376e-5e8b-e8a5-0da3f83315d1@suse.cz> Date: Fri, 10 Jul 2020 17:31:14 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <20200709024808.18466-1-robbieko@synology.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/9/20 4:48 AM, robbieko wrote: > From: Robbie Ko > > When a migrate page occurs, we first create a migration entry > to replace the original pte, and then go to fallback_migrate_page > to execute a writeout if the migratepage is not supported. > > In the writeout, we will clear the dirty bit of the page and use > page_mkclean to clear the dirty bit along with the corresponding pte, > but page_mkclean does not support migration entry. > > The page ditry bit is cleared, but the dirty bit of the pte still exists, > so if mmap continues to write, it will result in data loss. Curious, did you observe this data loss? What filesystem? If yes, it seems serious enough to CC stable and determine a Fixes: tag? > We fix the by first remove the migration entry and then clearing > the dirty bits of the page, which also clears the pte's dirty bits. > > Signed-off-by: Robbie Ko > --- > mm/migrate.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/mm/migrate.c b/mm/migrate.c > index f37729673558..5c407434b9ba 100644 > --- a/mm/migrate.c > +++ b/mm/migrate.c > @@ -875,10 +875,6 @@ static int writeout(struct address_space *mapping, struct page *page) > /* No write method for the address space */ > return -EINVAL; > > - if (!clear_page_dirty_for_io(page)) > - /* Someone else already triggered a write */ > - return -EAGAIN; > - > /* > * A dirty page may imply that the underlying filesystem has > * the page on some queue. So the page must be clean for > @@ -889,6 +885,10 @@ static int writeout(struct address_space *mapping, struct page *page) > */ > remove_migration_ptes(page, page, false); > > + if (!clear_page_dirty_for_io(page)) > + /* Someone else already triggered a write */ > + return -EAGAIN; > + > rc = mapping->a_ops->writepage(page, &wbc); > > if (rc != AOP_WRITEPAGE_ACTIVATE) >