From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A3C3C433DF for ; Fri, 10 Jul 2020 15:31:22 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C78A9207BB for ; Fri, 10 Jul 2020 15:31:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C78A9207BB Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 417588D0005; Fri, 10 Jul 2020 11:31:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3C6D48D0001; Fri, 10 Jul 2020 11:31:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2DC7F8D0005; Fri, 10 Jul 2020 11:31:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0069.hostedemail.com [216.40.44.69]) by kanga.kvack.org (Postfix) with ESMTP id 19B278D0001 for ; Fri, 10 Jul 2020 11:31:21 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 8EC1C4DB3 for ; Fri, 10 Jul 2020 15:31:20 +0000 (UTC) X-FDA: 77022555120.19.cork28_560ca0626ecf Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin19.hostedemail.com (Postfix) with ESMTP id ADACD1ACC22 for ; Fri, 10 Jul 2020 15:31:17 +0000 (UTC) X-HE-Tag: cork28_560ca0626ecf X-Filterd-Recvd-Size: 2993 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf43.hostedemail.com (Postfix) with ESMTP for ; Fri, 10 Jul 2020 15:31:17 +0000 (UTC) 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 X-Rspamd-Queue-Id: ADACD1ACC22 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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) >