diff options
author | Huang Ying <ying.huang@intel.com> | 2019-06-28 15:07:18 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-06-29 04:43:45 -0400 |
commit | 1a5f439c7c02837d943e528d46501564d4226757 (patch) | |
tree | 050e4d16ffe8dfb351de624fbd5267aeff1e87a0 | |
parent | 1bf4580e00a248a2c86269125390eb3648e1877c (diff) |
mm, swap: fix THP swap out
0-Day test system reported some OOM regressions for several THP
(Transparent Huge Page) swap test cases. These regressions are bisected
to 6861428921b5 ("block: always define BIO_MAX_PAGES as 256"). In the
commit, BIO_MAX_PAGES is set to 256 even when THP swap is enabled. So the
bio_alloc(gfp_flags, 512) in get_swap_bio() may fail when swapping out
THP. That causes the OOM.
As in the patch description of 6861428921b5 ("block: always define
BIO_MAX_PAGES as 256"), THP swap should use multi-page bvec to write THP
to swap space. So the issue is fixed via doing that in get_swap_bio().
BTW: I remember I have checked the THP swap code when 6861428921b5
("block: always define BIO_MAX_PAGES as 256") was merged, and thought the
THP swap code needn't to be changed. But apparently, I was wrong. I
should have done this at that time.
Link: http://lkml.kernel.org/r/20190624075515.31040-1-ying.huang@intel.com
Fixes: 6861428921b5 ("block: always define BIO_MAX_PAGES as 256")
Signed-off-by: "Huang, Ying" <ying.huang@intel.com>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Hugh Dickins <hughd@google.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Daniel Jordan <daniel.m.jordan@oracle.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | mm/page_io.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/mm/page_io.c b/mm/page_io.c index 2e8019d0e048..189415852077 100644 --- a/mm/page_io.c +++ b/mm/page_io.c | |||
@@ -29,10 +29,9 @@ | |||
29 | static struct bio *get_swap_bio(gfp_t gfp_flags, | 29 | static struct bio *get_swap_bio(gfp_t gfp_flags, |
30 | struct page *page, bio_end_io_t end_io) | 30 | struct page *page, bio_end_io_t end_io) |
31 | { | 31 | { |
32 | int i, nr = hpage_nr_pages(page); | ||
33 | struct bio *bio; | 32 | struct bio *bio; |
34 | 33 | ||
35 | bio = bio_alloc(gfp_flags, nr); | 34 | bio = bio_alloc(gfp_flags, 1); |
36 | if (bio) { | 35 | if (bio) { |
37 | struct block_device *bdev; | 36 | struct block_device *bdev; |
38 | 37 | ||
@@ -41,9 +40,7 @@ static struct bio *get_swap_bio(gfp_t gfp_flags, | |||
41 | bio->bi_iter.bi_sector <<= PAGE_SHIFT - 9; | 40 | bio->bi_iter.bi_sector <<= PAGE_SHIFT - 9; |
42 | bio->bi_end_io = end_io; | 41 | bio->bi_end_io = end_io; |
43 | 42 | ||
44 | for (i = 0; i < nr; i++) | 43 | bio_add_page(bio, page, PAGE_SIZE * hpage_nr_pages(page), 0); |
45 | bio_add_page(bio, page + i, PAGE_SIZE, 0); | ||
46 | VM_BUG_ON(bio->bi_iter.bi_size != PAGE_SIZE * nr); | ||
47 | } | 44 | } |
48 | return bio; | 45 | return bio; |
49 | } | 46 | } |