From patchwork Mon Jun 24 02:23:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 11012031 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 40A5976 for ; Mon, 24 Jun 2019 02:25:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 321B328A53 for ; Mon, 24 Jun 2019 02:25:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 261C828AF8; Mon, 24 Jun 2019 02:25:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A3CB628A53 for ; Mon, 24 Jun 2019 02:25:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4EA846B0003; Sun, 23 Jun 2019 22:25:22 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 473DE8E0002; Sun, 23 Jun 2019 22:25:22 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 314628E0001; Sun, 23 Jun 2019 22:25:22 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by kanga.kvack.org (Postfix) with ESMTP id E9B0C6B0003 for ; Sun, 23 Jun 2019 22:25:21 -0400 (EDT) Received: by mail-pl1-f197.google.com with SMTP id t2so6455510plo.10 for ; Sun, 23 Jun 2019 19:25:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:mime-version:content-transfer-encoding; bh=i62MDUco+L88u+gho4OXVi2QGt71UcWNN0qob8xe0Ws=; b=Jh98xvDLyf/i2loVX/DPK/d5nE0Sv4fq8gKosYE/eioON6PjbSN4q8t0s6BJBVCIK+ HBa1pN8HjmTxNd0dm/OmutaLYRkrA1D8f+9gYsG+ab6nRDbigRhkyJw9Rp4d9VrCBCau hXn1P9/YQMuvd393Uf9CnMS8Ty0BL9uonAhhg5lqZqjsd7CyHHFtZEfy9NnHXjfgo9Kv XBQGw5N+7/fcV5EeIm5hugie/sWFh98h8nBM2re+ciXS4W6HZkhvSDC9hxfrzBedlYNP 2oyGaGd214DFVdpD7nfBboOdu1xACl2om5hudkGLmqudso7vkXmVP2/eSyklma5ciOUb CHUw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ying.huang@intel.com designates 192.55.52.93 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: APjAAAV15mkwz/YoBeUBJxqG9xAVr57YBD6rM0uMKuc+7HsatPJxzUPf SmzPpaZk4YhVg/IzKrk9+/tqRsQxyDVPdstLxFkOVCXw5d8HJOoDKY/XgMXBuXa6euD5g9aaHoU 5jWBTSICIX4m32VHdwwXCM0USWZjgHlFdcp3TW6fZp5u9Y2Lb2wzgy/W19Y2/oEMkTA== X-Received: by 2002:a17:902:846:: with SMTP id 64mr20317941plk.265.1561343121539; Sun, 23 Jun 2019 19:25:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqznpADUUtuy9kL1OUuPcKifiXaKNzEFAx6osMQoqiYhNTH3x0rX9yuAFIcNU+TzScgaoYu4 X-Received: by 2002:a17:902:846:: with SMTP id 64mr20317900plk.265.1561343120714; Sun, 23 Jun 2019 19:25:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561343120; cv=none; d=google.com; s=arc-20160816; b=uczNxjDFngCbRlm6SNg90+ejw/hbUUEcPVhmHGoVeZb/LZzEcKtbceuNmIdxLyTrxH z07bAGprEg8bc35zmyMGT8z60W3yn3b6KLH5/TYay+FFCK+1ATsY2ALRvZKiZBzuMGIT TnBmUAzoU/4K1WGNeXWvGmlBU+JIFNcL7jQx/XeH9y3GrElPy8XNwhkbT5Hte1k/b009 l778lRrGpwgLgtynLn3gkimA+eYJADYSBWmr95Eh/RqBC7z1ER5VDEhSJCuiybJ8Be23 MGsdxSh1/a/rFSH8zEyzOl9ESoSdpBQ13q/e7dStlS4uNWcOXM/nawtAkny/S4MVjEqT IOJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from; bh=i62MDUco+L88u+gho4OXVi2QGt71UcWNN0qob8xe0Ws=; b=LkCA8sPFf5d9Dcl2UBZPnt1VC6QrXrWCo5/53mgGGW89QAYOJXEN4XTV+gobXqraIU nEWrmVkWdmIBgpRzxeanIeobp2+oPKng3JmC9oQbXNxlCCYU1SPqdz8dSj6hAFSZqJWF HiF7gw1qx8tHFwBynRSvTvjzjevKx/xSg9WOIzj7skuDHoHroiCnc76S1T20ekSKroPg PDgaXDI+kCgAlx/yHlvZjVKqbuCtQI7or19qGg5zVsY6ASJPrAdpXfz0SPGpYc60KbZh M9xu8ki0mtxgcbJIJAzU75u66sC5ey45usN5xcciF/735p3YsOGuhbBhj0Trq66iUpeT EQdA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ying.huang@intel.com designates 192.55.52.93 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga11.intel.com (mga11.intel.com. [192.55.52.93]) by mx.google.com with ESMTPS id t1si8989531pgv.169.2019.06.23.19.25.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 23 Jun 2019 19:25:20 -0700 (PDT) Received-SPF: pass (google.com: domain of ying.huang@intel.com designates 192.55.52.93 as permitted sender) client-ip=192.55.52.93; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ying.huang@intel.com designates 192.55.52.93 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Jun 2019 19:25:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,410,1557212400"; d="scan'208";a="171832130" Received: from yhuang-dev.sh.intel.com ([10.239.159.29]) by orsmga002.jf.intel.com with ESMTP; 23 Jun 2019 19:25:17 -0700 From: "Huang, Ying" To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Huang Ying , Ming Lei , Michal Hocko , Johannes Weiner , Hugh Dickins , Minchan Kim , Rik van Riel , Daniel Jordan Subject: [PATCH -mm] mm, swap: Fix THP swap out Date: Mon, 24 Jun 2019 10:23:36 +0800 Message-Id: <20190624022336.12465-1-ying.huang@intel.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Huang Ying 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. Fixes: 6861428921b5 ("block: always define BIO_MAX_PAGES as 256") Signed-off-by: "Huang, Ying" Cc: Ming Lei Cc: Michal Hocko Cc: Johannes Weiner Cc: Hugh Dickins Cc: Minchan Kim Cc: Rik van Riel Cc: Daniel Jordan --- mm/page_io.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/mm/page_io.c b/mm/page_io.c index 2e8019d0e048..4ab997f84061 100644 --- 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 gfp_flags, 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; }