Re: bio_iov_iter_get_pages() + page_alloc.shuffle=1 migrating failures

From: Qian Cai
Date: Thu Apr 25 2019 - 09:02:45 EST


On Thu, 2019-04-25 at 16:15 +0800, Ming Lei wrote:
> On Thu, Apr 25, 2019 at 4:13 PM Qian Cai <cai@xxxxxx> wrote:
> >
> > Memory offline [1] starts to fail on linux-next on ppc64le with
> > page_alloc.shuffle=1 where the "echo offline" command hangs with lots of
> > migrating failures below. It seems in migrate_page_move_mapping()
> >
> > ÂÂÂÂÂÂÂÂif (!mapping) {
> > ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ/* Anonymous page without mapping */
> > ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂif (page_count(page) != expected_count)
> > ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂreturn -EAGAIN;
> >
> > It expected count=1 but actual count=2.
> >
> > There are two ways to make the problem go away. One is to remove this line
> > in
> > __shuffle_free_memory(),
> >
> > ÂÂÂÂÂÂÂÂshuffle_zone(z);
> >
> > The other is reverting some bio commits. Bisecting so far indicates the
> > culprit
> > is in one of those (the 3rd commit looks more suspicious than the others).
> >
> > block: only allow contiguous page structs in a bio_vec
> > block: don't allow multiple bio_iov_iter_get_pages calls per bio
> > block: change how we get page references in bio_iov_iter_get_pages
> >
> > [ÂÂ446.578064] migrating pfn 2003d5eaa failed ret:22
> > [ÂÂ446.578066] page:c00a00800f57aa80 count:2 mapcount:0
> > mapping:c000001db4c827e9
> > index:0x13c08a
> > [ÂÂ446.578220] anon
> > [ÂÂ446.578222] flags:
> > 0x83fffc00008002e(referenced|uptodate|dirty|active|swapbacked)
> > [ÂÂ446.578347] raw: 083fffc00008002e c00a00800f57f808 c00a00800f579f88
> > c000001db4c827e9
> > [ÂÂ446.944807] raw: 000000000013c08a 0000000000000000 00000002ffffffff
> > c00020141a738008
> > [ÂÂ446.944883] page dumped because: migration failure
> > [ÂÂ446.944948] page->mem_cgroup:c00020141a738008
> > [ÂÂ446.945024] page allocated via order 0, migratetype Movable, gfp_mask
> > 0x100cca(GFP_HIGHUSER_MOVABLE)
> > [ÂÂ446.945148]ÂÂprep_new_page+0x390/0x3a0
> > [ÂÂ446.945228]ÂÂget_page_from_freelist+0xd9c/0x1bf0
> > [ÂÂ446.945292]ÂÂ__alloc_pages_nodemask+0x1cc/0x1780
> > [ÂÂ446.945335]ÂÂalloc_pages_vma+0xc0/0x360
> > [ÂÂ446.945401]ÂÂdo_anonymous_page+0x244/0xb20
> > [ÂÂ446.945472]ÂÂ__handle_mm_fault+0xcf8/0xfb0
> > [ÂÂ446.945532]ÂÂhandle_mm_fault+0x1c0/0x2b0
> > [ÂÂ446.945615]ÂÂ__get_user_pages+0x3ec/0x690
> > [ÂÂ446.945652]ÂÂget_user_pages_unlocked+0x104/0x2f0
> > [ÂÂ446.945693]ÂÂget_user_pages_fast+0xb0/0x200
> > [ÂÂ446.945762]ÂÂiov_iter_get_pages+0xf4/0x6a0
> > [ÂÂ446.945802]ÂÂbio_iov_iter_get_pages+0xc0/0x450
> > [ÂÂ446.945876]ÂÂblkdev_direct_IO+0x2e0/0x630
> > [ÂÂ446.945941]ÂÂgeneric_file_read_iter+0xbc/0x230
> > [ÂÂ446.945990]ÂÂblkdev_read_iter+0x50/0x80
> > [ÂÂ446.946031]ÂÂaio_read+0x128/0x1d0
> > [ÂÂ446.946082] migrating pfn 2003d5fe0 failed ret:22
> > [ÂÂ446.946084] page:c00a00800f57f800 count:2 mapcount:0
> > mapping:c000001db4c827e9
> > index:0x13c19e
> > [ÂÂ446.946239] anon
> > [ÂÂ446.946241] flags:
> > 0x83fffc00008002e(referenced|uptodate|dirty|active|swapbacked)
> > [ÂÂ446.946384] raw: 083fffc00008002e c000200deb3dfa28 c00a00800f57aa88
> > c000001db4c827e9
> > [ÂÂ446.946497] raw: 000000000013c19e 0000000000000000 00000002ffffffff
> > c00020141a738008
> > [ÂÂ446.946605] page dumped because: migration failure
> > [ÂÂ446.946662] page->mem_cgroup:c00020141a738008
> > [ÂÂ446.946724] page allocated via order 0, migratetype Movable, gfp_mask
> > 0x100cca(GFP_HIGHUSER_MOVABLE)
> > [ÂÂ446.946846]ÂÂprep_new_page+0x390/0x3a0
> > [ÂÂ446.946899]ÂÂget_page_from_freelist+0xd9c/0x1bf0
> > [ÂÂ446.946959]ÂÂ__alloc_pages_nodemask+0x1cc/0x1780
> > [ÂÂ446.947047]ÂÂalloc_pages_vma+0xc0/0x360
> > [ÂÂ446.947101]ÂÂdo_anonymous_page+0x244/0xb20
> > [ÂÂ446.947143]ÂÂ__handle_mm_fault+0xcf8/0xfb0
> > [ÂÂ446.947200]ÂÂhandle_mm_fault+0x1c0/0x2b0
> > [ÂÂ446.947256]ÂÂ__get_user_pages+0x3ec/0x690
> > [ÂÂ446.947306]ÂÂget_user_pages_unlocked+0x104/0x2f0
> > [ÂÂ446.947366]ÂÂget_user_pages_fast+0xb0/0x200
> > [ÂÂ446.947458]ÂÂiov_iter_get_pages+0xf4/0x6a0
> > [ÂÂ446.947515]ÂÂbio_iov_iter_get_pages+0xc0/0x450
> > [ÂÂ446.947588]ÂÂblkdev_direct_IO+0x2e0/0x630
> > [ÂÂ446.947636]ÂÂgeneric_file_read_iter+0xbc/0x230
> > [ÂÂ446.947703]ÂÂblkdev_read_iter+0x50/0x80
> > [ÂÂ446.947758]ÂÂaio_read+0x128/0x1d0
> >
> > [1]
> > i=0
> > found=0
> > for mem in $(ls -d /sys/devices/system/memory/memory*); do
> > ÂÂÂÂÂÂÂÂi=$((i + 1))
> > ÂÂÂÂÂÂÂÂecho "iteration: $i"
> > ÂÂÂÂÂÂÂÂecho offline > $mem/state
> > ÂÂÂÂÂÂÂÂif [ $? -eq 0 ] && [ $found -eq 0 ]; then
> > ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂfound=1
> > ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂcontinue
> > ÂÂÂÂÂÂÂÂfi
> > ÂÂÂÂÂÂÂÂecho online > $mem/state
> > done
>
> Please try the following patch:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git/commit/?
> h=for-5.2/block&id=0257c0ed5ea3de3e32cb322852c4c40bc09d1b97

It works great so far!