Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp268946ybh; Wed, 15 Jul 2020 01:13:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyCg1espM3cfhXnyaPezHyWcKHe6K1+sX+jju9lcOA5kfbo+KqJ3Vkt15bMR7ct7+nrYPNX X-Received: by 2002:a05:6402:1a54:: with SMTP id bf20mr8444294edb.69.1594800789844; Wed, 15 Jul 2020 01:13:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594800789; cv=none; d=google.com; s=arc-20160816; b=tO4ktKc2GtLeMK6/FiCzniw2QWBn5NqPxqlvt++Kie1xeiflpSmVMnJNTknzC0kNSS N/grCswNBt0+pYAKKraHXgzdmPjIYgxcuTaidbElh3pi83eID4lVNCdDZ1ZqaxkJ5rKh 56Bq/HIlJld6ms0gesT+lW/MiPJbG7OAicNBGG6xVvIeAY5Ve3XioDMWmZb3AsTJTaC2 MLLyLHTVRML1zZquWXzMJACqs2Sb3VN8dTeHTsDV3mZomJgRVULBmHOx/T2beOuvoZ1R dzK8cHaWfJ6cv9DWXXswuealacXdFAyevGy1uqiQfuh4gj0cMTbc7lbsMNTw7GrM42Ey Rq0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=r58zgr+dFUtMHO8bMdDys5iOfYMIt5NXXpWBTmydEcE=; b=Y3/2oisSIV0GNeRRwNkUsnuykeiqM3VZ6P6gqZpbTJ59srVwqFSd8ArtPEofTp8UXT HpVaaQuiZJ6m3z+rAGQDHs+7TAC27w9wXE5DjhgSO4Z9ymdEzcc6T3mT0tlvokzjQnNd EG+hU8WuKEfKTEppRgNhwmZUEs+fTp5QliNqpqtkjbjtQWT9XWts/m4simSOxQuwAaxi 7Br/7zjutqUIzjjDxrmvONs9Q+I6mxWb8t6RTYRjwuec7P7wLWycrEt+5ZJ77XsJW5lC pWfwBpnHXdLzWCjTDKfYVkAhbqSwjeunNkIfKVkEN6rB4JRfIh6y+8B0NDdUhSPNYOZJ yD9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=d2Q3jVi1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cw22si762080ejb.61.2020.07.15.01.12.45; Wed, 15 Jul 2020 01:13:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=d2Q3jVi1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729665AbgGOILr (ORCPT + 99 others); Wed, 15 Jul 2020 04:11:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729609AbgGOILq (ORCPT ); Wed, 15 Jul 2020 04:11:46 -0400 Received: from mail-lf1-x141.google.com (mail-lf1-x141.google.com [IPv6:2a00:1450:4864:20::141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53FFEC08C5C1 for ; Wed, 15 Jul 2020 01:11:46 -0700 (PDT) Received: by mail-lf1-x141.google.com with SMTP id g2so588771lfb.0 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=bNDIlrhCm69XEn7Mm/nxzDmAfaFQpZR3LPRresKPi8KY/C3Gzcl2LDMGLuFMv/GVop pXYtdTNGF3UYDYbWo8yWetM9ea4mzuq5yhHAAhI+o5mbFz60A/ft+ORX46bIll6mHhmX OsFxmQNfm2/+cBXEnKaXPBGYZBVuFYUCXvlj87amrON9epvZElmBAcsxWB0AxAO5D+06 1NaFaXaI57DA6jaCecizxizO4cxz5nDe8KqaSvJsxE6rfHdp9O9V5Xx/JOLMc+Ifi6m0 z76xbSjoRb/6FGKLr7kf0CbRSUxWXZLynNHsAXdkVQbFjZ8J4B60zkd8TSzMwxD+R4dq Pz/A== X-Gm-Message-State: AOAM530f8ikTGAFOc9ET1LE5S5Ww5uPuOoisXYkXllVuqA1XOA2WtlEK RyMx4Mj5YPhAdEVl/M+HMiF5MQ== 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 Content-Transfer-Encoding: 8bit In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 15, 2020 at 10:45:39AM +0800, Robbie Ko wrote: > > Kirill A. Shutemov 於 2020/7/14 下午6:19 寫道: > > 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 於 2020/7/10 下午11:31 寫道: > > > > > 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_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_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 migration 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 cause 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? -- Kirill A. Shutemov