Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3058167ybi; Tue, 2 Jul 2019 01:18:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqy11VG7s2g8w5wTV7UlN4g/9Hb0w7UUbeW0gYZvOHPKknMGh0EPGTOhMsrundYu4HrRB6QB X-Received: by 2002:a17:90a:2488:: with SMTP id i8mr4042662pje.123.1562055534859; Tue, 02 Jul 2019 01:18:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562055534; cv=none; d=google.com; s=arc-20160816; b=NT3vxMIdyTnIffY4YwKb3FravUh2hefyLCYYDoWonVbMEvpTvyI5NEil5TSZ5bjVuz va4eknWyhkrhyHJSv7YspqaEiRFKxS+OaUDF3fGutTP9medHxSDFUwhoIS4eO4PMogXc mHJfkJpsjchHVETObW9/rXCSL9r9lvTeWNW8zC7t+2uESybjBWBDZQcKCQdxA6Jhm56J +sNS9IBAM+C+pu6uw5sa8Ni4G/srNRU3yrQ0dssDAujSD97MSPjGhsptVmoqz/Ff7Ric xoJu4Jz5nZ1nHl5ZkDpRSGJ814WPZX1gsF2K/zfsgjKphBvo43KwImH/01JZnS2Ro0GF bddw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=s71PpdqMXd1zi6eJjK7Grdorh0BsnrmopcWKSp+/juY=; b=BXOgW883NBuxDtCuzGJ/SVyzdiT47tLB1O3WhTkKvSQSRlBFYiCgPd59ZfWuo/5hJj fRqhDSygiCq7qWScDaTe1Iz+PbnPNIhr9c9DrsSFSHekVtabHSG9LNSbFZNRysKaITL1 DJUwcQV3Y0/9r9vL6jV4044PpQjT6QOluAwJFacRxH+OF5e4h5p9loNtbk4qk3aY0mp1 /gqRuR3hTkFV3Xjl7dQSbgg1j1P8gbwyduV2i/pujA0MUtrzc9eSnga57m+U7xvcANAV 5uZliSTHHncQNDCZXILdfhJwBNfz422bjKS6qPmnbPQbpJJFqRL202En6yNZ1fua/sI2 u2Zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kRG3rsI1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e1si1685118pjr.28.2019.07.02.01.18.40; Tue, 02 Jul 2019 01:18:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kRG3rsI1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727229AbfGBIC4 (ORCPT + 99 others); Tue, 2 Jul 2019 04:02:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:47578 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727202AbfGBICy (ORCPT ); Tue, 2 Jul 2019 04:02:54 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 74A9121479; Tue, 2 Jul 2019 08:02:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562054573; bh=RaKKqX569LuBgmaHBLPgIetwk+japE1Civy0m2rrXQY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kRG3rsI1i5DHovFfmjjqp6lNOKAoSrt7Tz8wDfZ/+h3d/TlJMHbDmie33cgQj5Fob XS1r10H1rwUwegk09Z91GtvzeZ1qBGoD00BQlv3fpkpJ7r/nPqyFJ/vjbY2/YqkhAp O2RAes+ibepIzQSK1Pf44zVz/sKEZm3FHHuPHz4c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Huang, Ying" , Ming Lei , Michal Hocko , Johannes Weiner , Hugh Dickins , Minchan Kim , Rik van Riel , Daniel Jordan , Jens Axboe , Andrew Morton , Linus Torvalds Subject: [PATCH 5.1 16/55] mm, swap: fix THP swap out Date: Tue, 2 Jul 2019 10:01:24 +0200 Message-Id: <20190702080124.884746006@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190702080124.103022729@linuxfoundation.org> References: <20190702080124.103022729@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Huang Ying commit 1a5f439c7c02837d943e528d46501564d4226757 upstream. 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" Reviewed-by: Ming Lei Cc: Michal Hocko Cc: Johannes Weiner Cc: Hugh Dickins Cc: Minchan Kim Cc: Rik van Riel Cc: Daniel Jordan Cc: Jens Axboe Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- mm/page_io.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) --- a/mm/page_io.c +++ b/mm/page_io.c @@ -29,10 +29,9 @@ static struct bio *get_swap_bio(gfp_t gfp_flags, struct page *page, bio_end_io_t end_io) { - int i, nr = hpage_nr_pages(page); struct bio *bio; - bio = bio_alloc(gfp_flags, nr); + bio = bio_alloc(gfp_flags, 1); if (bio) { struct block_device *bdev; @@ -41,9 +40,7 @@ static struct bio *get_swap_bio(gfp_t gf bio->bi_iter.bi_sector <<= PAGE_SHIFT - 9; bio->bi_end_io = end_io; - for (i = 0; i < nr; i++) - bio_add_page(bio, page + i, PAGE_SIZE, 0); - VM_BUG_ON(bio->bi_iter.bi_size != PAGE_SIZE * nr); + bio_add_page(bio, page, PAGE_SIZE * hpage_nr_pages(page), 0); } return bio; }