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,URIBL_BLOCKED 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 39B05C433E6 for ; Thu, 16 Jul 2020 10:16:00 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D31EF2074B for ; Thu, 16 Jul 2020 10:15:59 +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="aQmOvhVS" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D31EF2074B 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 52C886B0029; Thu, 16 Jul 2020 06:15:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4DD366B002A; Thu, 16 Jul 2020 06:15:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3F5196B002B; Thu, 16 Jul 2020 06:15:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0189.hostedemail.com [216.40.44.189]) by kanga.kvack.org (Postfix) with ESMTP id 2F5986B0029 for ; Thu, 16 Jul 2020 06:15:59 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 95770181AC9CC for ; Thu, 16 Jul 2020 10:15:58 +0000 (UTC) X-FDA: 77043533196.19.event70_080dbbe26f01 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin19.hostedemail.com (Postfix) with ESMTP id 681441AD31E for ; Thu, 16 Jul 2020 10:15:58 +0000 (UTC) X-HE-Tag: event70_080dbbe26f01 X-Filterd-Recvd-Size: 4159 Received: from synology.com (mail.synology.com [211.23.38.101]) by imf45.hostedemail.com (Postfix) with ESMTP for ; Thu, 16 Jul 2020 10:15:57 +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=1594894528; bh=lHblaYpK9Py+0RsvfRbjoNjLu34cxZmUSNhY6JGGRCA=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=aQmOvhVSgyFHZKHFp7QpZYdpMkgD7JKW+ZP3FahWEhFgdPmuYLldzvGyM2f7VgMMV H7cHhyEY2PwewkGo6/tuAj7iH+SSGPy0FigTwSR8/ROYdcMqPx1eW+ie5mSR9aZicG 3mrx6HfyWrUrpTThcQyPJCI6Bev1As58+qcAs8xM= To: "Kirill A. Shutemov" Cc: Vlastimil Babka , 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> <20200715081148.ufmy6rlrdqn52c4v@box> From: Robbie Ko Message-ID: <68879817-1507-f42e-7f48-8565145754de@synology.com> Date: Thu, 16 Jul 2020 18:15:23 +0800 MIME-Version: 1.0 In-Reply-To: <20200715081148.ufmy6rlrdqn52c4v@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: 681441AD31E X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.089740, 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/15 =E4=B8=8B=E5=8D=884:11 =E5=AF=AB=E9= =81=93: > On Wed, Jul 15, 2020 at 10:45:39AM +0800, Robbie Ko wrote: >> 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 = pte, >>>>>>> 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_MIGRATI= ON_WRITE, >> which will replace the migration entry with the original pte. >> >> When migratepage, we go to fallback_migrate_page to execute a writeou= t >> if the migratepage is not supported. >> >> In the writeout, we call clear_page_dirty_for_io to clear the dirty b= it of the page >> and use page_mkclean to clear pte _PAGE_RW with pte_wrprotect in page_= mkclean_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 migratio= n entry, >> because it is still SWP_MIGRATION_WRITE so set _PAGE_RW to pte via pte= _mkwrite. >> >> Therefore, subsequent mmap wirte will not trigger page_mkwrite to caus= e data loss. > Hm, okay. > > Folks, is there any good reason why try_to_unmap(TTU_MIGRATION) should = not > clear PTE (make the PTE none) for file page? > This, I'm not sure. But I think that for the fs that support migratepage, when migratepage=20 is finished, the page should still be dirty, and the pte should still have _PAGE_RW, when the next mmap write occurs, we don't need to trigger the=20 page_mkwrite again.