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 D107DC433E3 for ; Wed, 15 Jul 2020 08:31:44 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8943020657 for ; Wed, 15 Jul 2020 08:31:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=shutemov-name.20150623.gappssmtp.com header.i=@shutemov-name.20150623.gappssmtp.com header.b="d2Q3jVi1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8943020657 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=shutemov.name Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id AABBA6B0003; Wed, 15 Jul 2020 04:11:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A5CC56B0006; Wed, 15 Jul 2020 04:11:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 94B066B0007; Wed, 15 Jul 2020 04:11:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0128.hostedemail.com [216.40.44.128]) by kanga.kvack.org (Postfix) with ESMTP id 7D92C6B0003 for ; Wed, 15 Jul 2020 04:11:47 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 0694D180AD815 for ; Wed, 15 Jul 2020 08:11:47 +0000 (UTC) X-FDA: 77039591454.25.pig62_230286526ef8 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin25.hostedemail.com (Postfix) with ESMTP id CB78A1804E3A1 for ; Wed, 15 Jul 2020 08:11:46 +0000 (UTC) X-HE-Tag: pig62_230286526ef8 X-Filterd-Recvd-Size: 5668 Received: from mail-lf1-f67.google.com (mail-lf1-f67.google.com [209.85.167.67]) by imf13.hostedemail.com (Postfix) with ESMTP for ; Wed, 15 Jul 2020 08:11:46 +0000 (UTC) Received: by mail-lf1-f67.google.com with SMTP id u12so583614lff.2 for ; Wed, 15 Jul 2020 01:11:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=r58zgr+dFUtMHO8bMdDys5iOfYMIt5NXXpWBTmydEcE=; b=d2Q3jVi1joXvon+jSxrPSrpeL8n7zUBeVPObZ0usiT22dNLY7KRKXMYrMQTQaMsUqw ZML3ybd2ItswlymaGlTDLlpnYxEMup0Mv+XXSz1d44DByUHbI4svxA+64rv6rYq6N3Fw LZTI7q8p4mL4DpNvCzSzC5n3Sqy69xU+oIXEW66TyX6o5F0XSBzz5andR0PwL5RI8ijW wnJsJc14v3tagRrqqIxAADZxbQY0q2Rn9SC9mPTAKdZAqoVr/9m3Bk5IyezrHok+O3TD LZNp3Thb/18HnD9sYfuK0byDNBjmsEcSa5nU2ZFL26/aRwO7fit59T6lSILFFd1BlMVt UItw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=r58zgr+dFUtMHO8bMdDys5iOfYMIt5NXXpWBTmydEcE=; b=U2X/08/EobD/jay/sKHKx4dD3vwsdbaY31RqhvhGk0Ads5vvxfnGl69WBY57dEcbIq 2rmakEJNTgKFnkNNgbyirbjWibtrFrXFybjLb7l7WNs8DHM/DbBEHHBy9xf91JlDPrf3 9tTtL1S1bAeJ1b8vPjF5R7/EHGqxj4nHXXOkxjihkNAFo8hHs2/OGfWQNzmWEzn8zgQ2 kZfSwFAvs6fLGicqpADrrM4YCaDSXlNOZFsMdYS9VPDKFwRTGxxccWLNeFVlGBL4CR9E 1kKr+jqFIotl7TETUMggLOUbDU7oNpkLJZEmiIq4mzINekE1Dkhqot5J5S3H3KyAkSFS 3/ow== X-Gm-Message-State: AOAM533zzOPOmpTt/ACJMJaOdEEGXkN7DkngdejYmEAG8obEbMcg8CSk C+jSM0cjLmYUXQyRQJhFnPu7Lg== X-Google-Smtp-Source: ABdhPJygnAIMcjY9IH7L7lww2iefyofOwl+m8Oz8PP+g5xfoCJJUzKGYICWaioD43IU4WV7dO+fw6Q== X-Received: by 2002:a19:e61a:: with SMTP id d26mr4180514lfh.96.1594800704746; Wed, 15 Jul 2020 01:11:44 -0700 (PDT) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id y69sm330239lfa.86.2020.07.15.01.11.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jul 2020 01:11:43 -0700 (PDT) Received: by box.localdomain (Postfix, from userid 1000) id 43B8510209F; Wed, 15 Jul 2020 11:11:48 +0300 (+03) Date: Wed, 15 Jul 2020 11:11:48 +0300 From: "Kirill A. Shutemov" To: Robbie Ko Cc: Vlastimil Babka , linux-mm@kvack.org, LKML , linux-btrfs@vger.kernel.org, Roman Gushchin , David Sterba , "Kirill A. Shutemov" Subject: Re: [PATCH] mm : fix pte _PAGE_DIRTY bit when fallback migrate page Message-ID: <20200715081148.ufmy6rlrdqn52c4v@box> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: CB78A1804E3A1 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.000813, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Jul 15, 2020 at 10:45:39AM +0800, Robbie Ko wrote: >=20 > 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 > > > > > >=20 > > > > > > 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. > > > > > >=20 > > > > > > In the writeout, we will clear the dirty bit of the page and = use > > > > > > page_mkclean to clear the dirty bit along with the correspond= ing pte, > > > > > > but page_mkclean does not support migration entry. > > I don't follow the scenario. > >=20 > > When we establish migration entries with try_to_unmap(), it transfers > > dirty bit from PTE to the page. >=20 > Sorry, I mean is _PAGE_RW with pte_write >=20 > When we establish migration entries with try_to_unmap(), > we create a migration entry, and if pte_write we set it to SWP_MIGRATIO= N_WRITE, > which will replace the migration entry with the original pte. >=20 > When migratepage, we go to fallback_migrate_page to execute a writeout > if the migratepage is not supported. >=20 > In the writeout, we call clear_page_dirty_for_io to clear the dirty bi= t of the page > and use page_mkclean to clear pte _PAGE_RW with pte_wrprotect in page_m= kclean_one. >=20 > However, page_mkclean_one does not support migration entries, so the > migration entry is still SWP_MIGRATION_WRITE. >=20 > In writeout, then we call remove_migration_ptes to remove the migration= entry, > because it is still SWP_MIGRATION_WRITE so set _PAGE_RW to pte via pte_= mkwrite. >=20 > Therefore, subsequent mmap wirte will not trigger page_mkwrite to cause= data loss. Hm, okay. Folks, is there any good reason why try_to_unmap(TTU_MIGRATION) should no= t clear PTE (make the PTE none) for file page? --=20 Kirill A. Shutemov