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=-14.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS 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 B988AC433E1 for ; Mon, 13 Jul 2020 01:57:28 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6236D206D9 for ; Mon, 13 Jul 2020 01:57:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=synology.com header.i=@synology.com header.b="PlIuW+Kc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6236D206D9 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=synology.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id CD8108D0006; Sun, 12 Jul 2020 21:57:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C883E8D0005; Sun, 12 Jul 2020 21:57:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B9FA98D0006; Sun, 12 Jul 2020 21:57:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0022.hostedemail.com [216.40.44.22]) by kanga.kvack.org (Postfix) with ESMTP id A65EF8D0005 for ; Sun, 12 Jul 2020 21:57:27 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 56652180AD81A for ; Mon, 13 Jul 2020 01:57:27 +0000 (UTC) X-FDA: 77031390534.03.pies77_02148d926ee4 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin03.hostedemail.com (Postfix) with ESMTP id 2CC0E28A4EA for ; Mon, 13 Jul 2020 01:57:27 +0000 (UTC) X-HE-Tag: pies77_02148d926ee4 X-Filterd-Recvd-Size: 3705 Received: from synology.com (mail.synology.com [211.23.38.101]) by imf30.hostedemail.com (Postfix) with ESMTP for ; Mon, 13 Jul 2020 01:57:26 +0000 (UTC) Subject: Re: [PATCH] mm : fix pte _PAGE_DIRTY bit when fallback migrate page DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synology.com; s=123; t=1594605443; bh=dMt+4j48OGNWxlYU555z1xu2wQ1GhECOEHBMhx3gXYc=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=PlIuW+KcQCXbqf+KNuT0az7wI1UjNfW25kD3FT1JxChhMBgqDffloSHQ8PGVw/iKS nF8wf6FNSEVt/U6Mq8eNHkttyvN9i/ySllUUdH8WXHrOS+S/QedOAfybYCdXZ9hhLV ZbpTyC4D0r6dYOqwjOYhtYtkESYfK/CcsDlzzDBM= To: Vlastimil Babka , linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org References: <20200709024808.18466-1-robbieko@synology.com> <859c810e-376e-5e8b-e8a5-0da3f83315d1@suse.cz> From: Robbie Ko Message-ID: <80b55fcf-def1-8a83-8f53-a22f2be56244@synology.com> Date: Mon, 13 Jul 2020 09:57:23 +0800 MIME-Version: 1.0 In-Reply-To: <859c810e-376e-5e8b-e8a5-0da3f83315d1@suse.cz> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US X-Synology-MCP-Status: no X-Synology-Spam-Flag: no X-Synology-Spam-Status: score=0, required 6, WHITELIST_FROM_ADDRESS 0 X-Synology-Virus-Status: no X-Rspamd-Queue-Id: 2CC0E28A4EA X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 Content-Transfer-Encoding: quoted-printable 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: Vlastimil Babka =E6=96=BC 2020/7/10 =E4=B8=8B=E5=8D=8811:31 =E5=AF=AB=E9=81= =93: > 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 exis= ts, >> so if mmap continues to write, it will result in data loss. > Curious, did you observe this data loss? What filesystem? If yes, it se= ems > serious enough to > CC stable and determine a Fixes: tag? Yes, there is data loss. I'm using a btrfs environment, but not the following patch btrfs: implement migratepage callback for data pages https://git.kernel.org/pub/scm/linux/kernel=20 /git/torvalds/linux.git/commit/?h=3Dv5.8-rc5&=20 id=3Df8e6608180a31cc72a23b74969da428da236dbd1 >> 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; >> =20 >> - 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); >> =20 >> + if (!clear_page_dirty_for_io(page)) >> + /* Someone else already triggered a write */ >> + return -EAGAIN; >> + >> rc =3D mapping->a_ops->writepage(page, &wbc); >> =20 >> if (rc !=3D AOP_WRITEPAGE_ACTIVATE) >> >