Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1359687

Re: [PATCH] UBIFS: Implement ->migratepage()

From Vlastimil Babka <vbabka@suse.cz>
Newsgroups linux.kernel
Subject Re: [PATCH] UBIFS: Implement ->migratepage()
Date 2016-03-17 11:00 +0100
Message-ID <rdCSL-5Ht-41@gated-at.bofh.it> (permalink)
References <rdqye-5Es-7@gated-at.bofh.it> <rdsA1-78W-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


+CC Hugh, Mel

On 03/16/2016 11:55 PM, Richard Weinberger wrote:
> From: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
>
> When using CMA during page migrations UBIFS might get confused

It shouldn't be CMA specific, the same code runs from compaction, 
autonuma balancing...

> and the following assert triggers:
> UBIFS assert failed in ubifs_set_page_dirty at 1451 (pid 436)
>
> UBIFS is using PagePrivate() which can have different meanings across
> filesystems. Therefore the generic page migration code cannot handle this
> case correctly.
> We have to implement our own migration function which basically does a
> plain copy but also duplicates the page private flag.

Lack of PagePrivate() migration is surely a bug, but at a glance of how 
UBIFS uses the flag, it's more about accounting, it shouldn't prevent a 
page from being marked PageDirty()?
I suspect your initial bug (which is IIUC the fact that there's a dirty 
pte, but PageDirty(page) is false) comes from the generic 
fallback_migrate_page() which does:

         if (PageDirty(page)) {
                 /* Only writeback pages in full synchronous migration */
                 if (mode != MIGRATE_SYNC)
                         return -EBUSY;
                 return writeout(mapping, page);
         }

And writeout() seems to Clear PageDirty() through 
clear_page_dirty_for_io() but I'm not so sure about the pte (or pte's in 
all rmaps). But this comment in the latter function:

                  * Yes, Virginia, this is indeed insane.

scared me enough to not investigate further. Hopefully the people I CC'd 
understand more about page migration than me. I'm just an user :)

In any case, this patch would solve both lack of PageDirty() transfer, 
and avoid the path leading from fallback_migrate_page() to writeout(). 
But I'm not confident enough here to ack it.

> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> [rw: Massaged changelog]
> Signed-off-by: Richard Weinberger <richard@nod.at>
> ---
>   fs/ubifs/file.c | 20 ++++++++++++++++++++
>   1 file changed, 20 insertions(+)
>
> diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
> index 0edc128..48b2944 100644
> --- a/fs/ubifs/file.c
> +++ b/fs/ubifs/file.c
> @@ -52,6 +52,7 @@
>   #include "ubifs.h"
>   #include <linux/mount.h>
>   #include <linux/slab.h>
> +#include <linux/migrate.h>
>
>   static int read_block(struct inode *inode, void *addr, unsigned int block,
>   		      struct ubifs_data_node *dn)
> @@ -1452,6 +1453,24 @@ static int ubifs_set_page_dirty(struct page *page)
>   	return ret;
>   }
>
> +static int ubifs_migrate_page(struct address_space *mapping,
> +		struct page *newpage, struct page *page, enum migrate_mode mode)
> +{
> +	int rc;
> +
> +	rc = migrate_page_move_mapping(mapping, newpage, page, NULL, mode, 0);
> +	if (rc != MIGRATEPAGE_SUCCESS)
> +		return rc;
> +
> +	if (PagePrivate(page)) {
> +		ClearPagePrivate(page);
> +		SetPagePrivate(newpage);
> +	}
> +
> +	migrate_page_copy(newpage, page);
> +	return MIGRATEPAGE_SUCCESS;
> +}
> +
>   static int ubifs_releasepage(struct page *page, gfp_t unused_gfp_flags)
>   {
>   	/*
> @@ -1591,6 +1610,7 @@ const struct address_space_operations ubifs_file_address_operations = {
>   	.write_end      = ubifs_write_end,
>   	.invalidatepage = ubifs_invalidatepage,
>   	.set_page_dirty = ubifs_set_page_dirty,
> +	.migratepage	= ubifs_migrate_page,
>   	.releasepage    = ubifs_releasepage,
>   };
>
>

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Page migration issue with UBIFS Richard Weinberger <richard@nod.at> - 2016-03-15 15:20 +0100
  Re: Page migration issue with UBIFS "Kirill A. Shutemov" <kirill@shutemov.name> - 2016-03-15 16:20 +0100
    Re: Page migration issue with UBIFS Richard Weinberger <richard@nod.at> - 2016-03-15 16:30 +0100
      Re: Page migration issue with UBIFS Christoph Hellwig <hch@infradead.org> - 2016-03-15 16:40 +0100
      Re: Page migration issue with UBIFS "Kirill A. Shutemov" <kirill@shutemov.name> - 2016-03-15 16:50 +0100
    Re: Page migration issue with UBIFS Richard Weinberger <richard@nod.at> - 2016-03-15 16:40 +0100
      Re: Page migration issue with UBIFS Christoph Hellwig <hch@infradead.org> - 2016-03-15 16:40 +0100
        Re: Page migration issue with UBIFS Richard Weinberger <richard@nod.at> - 2016-03-15 17:10 +0100
        Re: Page migration issue with UBIFS Richard Weinberger <richard@nod.at> - 2016-03-16 00:20 +0100
          Re: Page migration issue with UBIFS "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2016-03-16 15:30 +0100
            Re: Page migration issue with UBIFS Richard Weinberger <richard@nod.at> - 2016-03-16 21:50 +0100
              [PATCH] UBIFS: Implement ->migratepage() Richard Weinberger <richard@nod.at> - 2016-03-17 00:00 +0100
                Re: [PATCH] UBIFS: Implement ->migratepage() Vlastimil Babka <vbabka@suse.cz> - 2016-03-17 11:00 +0100
                Re: [PATCH] UBIFS: Implement ->migratepage() Richard Weinberger <richard@nod.at> - 2016-03-26 00:00 +0100
              Re: Page migration issue with UBIFS Joonsoo Kim <iamjoonsoo.kim@lge.com> - 2016-03-17 08:20 +0100
                Re: Page migration issue with UBIFS Richard Weinberger <richard@nod.at> - 2016-03-17 09:20 +0100
                Re: Page migration issue with UBIFS Joonsoo Kim <js1304@gmail.com> - 2016-03-17 16:20 +0100
              Re: Page migration issue with UBIFS Andrew Morton <akpm@linux-foundation.org> - 2016-03-22 00:10 +0100
                Re: Page migration issue with UBIFS Richard Weinberger <richard@nod.at> - 2016-03-22 00:10 +0100
          Re: Page migration issue with UBIFS "Kirill A. Shutemov" <kirill@shutemov.name> - 2016-03-16 15:30 +0100
            Re: Page migration issue with UBIFS Christoph Hellwig <hch@infradead.org> - 2016-03-21 16:30 +0100
  Re: Page migration issue with UBIFS Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-03-17 16:30 +0100

csiph-web