linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Vlastimil Babka <vbabka@suse.cz>
To: robbieko <robbieko@synology.com>, linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm : fix pte _PAGE_DIRTY bit when fallback migrate page
Date: Fri, 10 Jul 2020 17:31:14 +0200	[thread overview]
Message-ID: <859c810e-376e-5e8b-e8a5-0da3f83315d1@suse.cz> (raw)
In-Reply-To: <20200709024808.18466-1-robbieko@synology.com>

On 7/9/20 4:48 AM, robbieko wrote:
> From: Robbie Ko <robbieko@synology.com>
> 
> 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 exists,
> so if mmap continues to write, it will result in data loss.

Curious, did you observe this data loss? What filesystem? If yes, it seems
serious enough to
CC stable and determine a Fixes: tag?

> 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 <robbieko@synology.com>
> ---
>  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;
>  
> -	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);
>  
> +	if (!clear_page_dirty_for_io(page))
> +		/* Someone else already triggered a write */
> +		return -EAGAIN;
> +
>  	rc = mapping->a_ops->writepage(page, &wbc);
>  
>  	if (rc != AOP_WRITEPAGE_ACTIVATE)
> 



  reply	other threads:[~2020-07-10 15:31 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-09  2:48 robbieko
2020-07-10 15:31 ` Vlastimil Babka [this message]
2020-07-13  1:57   ` Robbie Ko
2020-07-14  9:46     ` Vlastimil Babka
2020-07-14 10:19       ` Kirill A. Shutemov
2020-07-15  2:45         ` Robbie Ko
2020-07-15  8:11           ` Kirill A. Shutemov
2020-07-16 10:15             ` Robbie Ko
2020-07-17 17:41               ` Chris Mason
2020-07-15  2:05       ` Robbie Ko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=859c810e-376e-5e8b-e8a5-0da3f83315d1@suse.cz \
    --to=vbabka@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=robbieko@synology.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox