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=-3.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no 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 C60C0C433E2 for ; Wed, 15 Jul 2020 02:45:44 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5C19520663 for ; Wed, 15 Jul 2020 02:45:44 +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="Nfgl23aW" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5C19520663 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 DE4976B0002; Tue, 14 Jul 2020 22:45:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DBB2D6B0003; Tue, 14 Jul 2020 22:45:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CD2B16B0005; Tue, 14 Jul 2020 22:45:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0243.hostedemail.com [216.40.44.243]) by kanga.kvack.org (Postfix) with ESMTP id B8F176B0002 for ; Tue, 14 Jul 2020 22:45:43 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 7E6711EE6 for ; Wed, 15 Jul 2020 02:45:43 +0000 (UTC) X-FDA: 77038769766.07.class34_06177cf26ef6 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin07.hostedemail.com (Postfix) with ESMTP id 542AD1803F9A7 for ; Wed, 15 Jul 2020 02:45:43 +0000 (UTC) X-HE-Tag: class34_06177cf26ef6 X-Filterd-Recvd-Size: 3457 Received: from synology.com (mail.synology.com [211.23.38.101]) by imf41.hostedemail.com (Postfix) with ESMTP for ; Wed, 15 Jul 2020 02:45:42 +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=1594781139; bh=5fo2vbPQ7m0yDE7a+ouN9kyFBdQ4CHGkaiwDsK86hQk=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=Nfgl23aWE5cPGhbzZyBHoHpDRntBMrczkLPs8jSdjooB7SYTCWFOjF8xRl90nIgsP BTF44JCfl8U7+nDG/G3rY0jQawU3ZVk/MNbC363MoOJt3uW+Rmy/hCSDvvLbPDq7bu 9UnavLI1Faun19PsxcBq241LLszwx83kkXJaQuus= To: "Kirill A. Shutemov" , Vlastimil Babka Cc: linux-mm@kvack.org, LKML , linux-btrfs@vger.kernel.org, Roman Gushchin , David Sterba , "Kirill A. Shutemov" References: <20200709024808.18466-1-robbieko@synology.com> <859c810e-376e-5e8b-e8a5-0da3f83315d1@suse.cz> <80b55fcf-def1-8a83-8f53-a22f2be56244@synology.com> <433e26b0-5201-129a-4afe-4881e42781fa@suse.cz> <20200714101951.6osakxdgbhrnfrbd@box> From: Robbie Ko Message-ID: Date: Wed, 15 Jul 2020 10:45:39 +0800 MIME-Version: 1.0 In-Reply-To: <20200714101951.6osakxdgbhrnfrbd@box> 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: 542AD1803F9A7 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.061457, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Kirill A. Shutemov =E6=96=BC 2020/7/14 =E4=B8=8B=E5=8D=886:19 =E5=AF=AB=E9= =81=93: > On Tue, Jul 14, 2020 at 11:46:12AM +0200, Vlastimil Babka wrote: >> On 7/13/20 3:57 AM, Robbie Ko wrote: >>> 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 pt= e, >>>>> but page_mkclean does not support migration entry. > I don't follow the scenario. > > When we establish migration entries with try_to_unmap(), it transfers > dirty bit from PTE to the page. Sorry, I mean is _PAGE_RW with pte_write When we establish migration entries with try_to_unmap(), we create a migration entry, and if pte_write we set it to SWP_MIGRATION_= WRITE, which will replace the migration entry with the original pte. When migratepage, we go to fallback_migrate_page to execute a writeout if the migratepage is not supported. In the writeout, we call clear_page_dirty_for_io to clear the dirty bit = of the page and use page_mkclean to clear pte _PAGE_RW with pte_wrprotect in page_mkc= lean_one. However, page_mkclean_one does not support migration entries, so the migration entry is still SWP_MIGRATION_WRITE. In writeout, then we call remove_migration_ptes to remove the migration e= ntry, because it is still SWP_MIGRATION_WRITE so set _PAGE_RW to pte via pte_mk= write. Therefore, subsequent mmap wirte will not trigger page_mkwrite to cause d= ata loss.