From patchwork Mon Nov 26 23:26:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 10699339 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 35F2D17D5 for ; Mon, 26 Nov 2018 23:26:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 231F22A5B2 for ; Mon, 26 Nov 2018 23:26:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 114AB2A63A; Mon, 26 Nov 2018 23:26:40 +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=-10.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, USER_IN_DEF_DKIM_WL 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 99D0D2A5B2 for ; Mon, 26 Nov 2018 23:26:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CBDD06B4464; Mon, 26 Nov 2018 18:26:38 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C6C746B4465; Mon, 26 Nov 2018 18:26:38 -0500 (EST) 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 B5EDA6B4466; Mon, 26 Nov 2018 18:26:38 -0500 (EST) 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 76D426B4464 for ; Mon, 26 Nov 2018 18:26:38 -0500 (EST) Received: by mail-pl1-f197.google.com with SMTP id h10so22534067plk.12 for ; Mon, 26 Nov 2018 15:26:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:date:from:to:cc:subject :in-reply-to:message-id:references:user-agent:mime-version; bh=ES/MPQaKtrXNGEigMK4kdNgyIwCP/oFzqKMlT72/m1g=; b=ttZ3MnW3iJjL60K8B7d4QNl7+RLrq8NkVcUxHbCFIrBNZwqAky9Nfp/IS1mtzPf00e QnVNuVk1nXzGErNeCHCDIO/xRT3lQ9CoG76SX8ZkkKZH0aV9+3K3Ik0gBeYXLk81rGrB BMb7NnB/UDF27o+o7Hs+L52dajOYmMV/GMcQBOS4G+u1u6HB2DBVQQHSA5tpMXncn3Ut TaqO10kE47TkgmKZMMjqmXQeWLnZuuFychIVupcjvVbclFsLmw2KhBeYEfNjqu1Qhflo Ab9NAj91LixNSuvnZFZ0OedYqPFH3O4L9IOjxAHnXDhTKEHYaHDbaluyEL7Na1c+EL0U vbpw== X-Gm-Message-State: AA+aEWYvdsQAI2lJ1cSGWgiNdXv/b86eDjh4VnpkZ4WPQMQKkhaLXjAk KGbco3h9d4y4QH9nC+0FYPJJjAgvmQKK1V/7xMZvhlsCifjDziB6q4omTC5zGmeCukK0vxBP8PE tSVpUGvwyM+4XiK7X3Szo/8tgyL5M7KEXHBKwecK/Q2EF9Wz9IB0tPFesYjCEVaE/VLKmZOqXrN GT4S6nFjgYOqUzQSEiX4FC3oxNoZyuXrLOhJ3bdiOXnAA1TqCE6pIdMRSbKpIB00ICvYkHEOjL3 bOD8K1eLdP3GhhsdQLa+zYUXFNCxc/z5XUvevUY60yLGggQmVFzpo239taYl8JtM+n6T+qUp4sZ SYn3YvsgAm6pLbCRHx9zl2OqzeuBYv2GgWEdgZ48Ft0tFWgoxLrqZzOQ1PejTmrcEV9fAQFp/tm U X-Received: by 2002:a63:e915:: with SMTP id i21mr26422565pgh.409.1543274798123; Mon, 26 Nov 2018 15:26:38 -0800 (PST) X-Received: by 2002:a63:e915:: with SMTP id i21mr26422521pgh.409.1543274797402; Mon, 26 Nov 2018 15:26:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543274797; cv=none; d=google.com; s=arc-20160816; b=aJ4QeXraFzoNjac30tBou3zQq8nfP13WgVXgO21qRO5JiPL0IZi6GyAZuDXUoo5N0k i0/JkQhWnkI2Cj6ouS+9+0AivSeKEmyHr/fR4VMWHht5+d49BJF9kKalujQqJBKS8WRP egh1Lv4IPN2pqln+Odc1BMwGU9REvm0XRwSyXHO9JhnNLtqKmB73MVi5dpLGpDhMmqLX j34zJp3oCeaSJfW2w/ZfyIM1gFouwH2M13iOVNZ533zBdicCnw3I/Tt6NhkVD1qhWkUX JZrAbMsWqEqzD9W/HbJYEe2LCGAaCbZgG8CwJHJ8pcJDposQwpOMnJjZZ1YHqq0cqexG uQGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:references:message-id:in-reply-to:subject :cc:to:from:date:dkim-signature; bh=ES/MPQaKtrXNGEigMK4kdNgyIwCP/oFzqKMlT72/m1g=; b=loxiR/MtXD+Dm3xh3N7Z+Ul/h/PydrgQ1GEnW7Kp9ov9Ic6YtflPF8X05zpWBNXxgJ 6lpJtaXoRHW1ck/+zlXQmzy7er3uQHMZBKmCazFeBtnioHBJdGwCINFw93rodZA/mORR jA3jRigZvfUTFZwwgWnmk+rXsBEQeqXGhqPPjZiUtDC9RVaBTvTVe+ND/YgQ2ql8NKmo Dblw4CzzNUDUq/jKHRIIJOP4w5bdg3PF0BNEeyHH9ULBFFU9neAzh910BOmLbq8aK2Bi o+/SvMOEhTYZXIA7JTn9M0a0YVCAiqzGtY1snLvkKgIH27jHjqQQjRtjXGAw03i1/YXh acPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=JeEAmBlZ; spf=pass (google.com: domain of hughd@google.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id gn15sor2447092plb.64.2018.11.26.15.26.37 for (Google Transport Security); Mon, 26 Nov 2018 15:26:37 -0800 (PST) Received-SPF: pass (google.com: domain of hughd@google.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=JeEAmBlZ; spf=pass (google.com: domain of hughd@google.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=ES/MPQaKtrXNGEigMK4kdNgyIwCP/oFzqKMlT72/m1g=; b=JeEAmBlZsaBdId52Bq97/6asHJtPkltKiD3thGhn0bTdkiyOW9INJqZyTQIAdBakqT VZxwJCTi9xyko7l+XikzW6vo8EHNrskKo+P2RlQocdLAElHahwvkWk54BS0SOVA7DQzy BpYFWIvTuqTaC4YHgNymvZEm7T+MQ8N+Zhk5sEO0oFC5p+eL7rlc3XAufX8969Rua2Ni 0flKTX6+3C1k7KBQRsyhlMpFeogvO//l3A136G9od8GXvIYez8JIIEdIXazCwc4WKu8j tw0HZeeOw5DQaWDE1TCgMzOCFZ4hPi+3tuNv706rAcqyyZi31wZUDC19dhIdoXUs7cA9 QRQQ== X-Google-Smtp-Source: AFSGD/WY+t/6WquRIc621kcDoOJCimgJQyjg9NZnd0TWWFlJRVdupL8oL/cPgaiJXMArvFZ68coTYg== X-Received: by 2002:a17:902:7587:: with SMTP id j7mr30114848pll.191.1543274796640; Mon, 26 Nov 2018 15:26:36 -0800 (PST) Received: from [100.112.89.103] ([104.133.8.103]) by smtp.gmail.com with ESMTPSA id f13sm1981535pfa.132.2018.11.26.15.26.35 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Nov 2018 15:26:36 -0800 (PST) Date: Mon, 26 Nov 2018 15:26:34 -0800 (PST) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Andrew Morton cc: "Kirill A. Shutemov" , "Kirill A. Shutemov" , Matthew Wilcox , linux-mm@kvack.org Subject: [PATCH 06/10] mm/khugepaged: collapse_shmem() remember to clear holes In-Reply-To: Message-ID: References: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) 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 Huge tmpfs testing reminds us that there is no __GFP_ZERO in the gfp flags khugepaged uses to allocate a huge page - in all common cases it would just be a waste of effort - so collapse_shmem() must remember to clear out any holes that it instantiates. The obvious place to do so, where they are put into the page cache tree, is not a good choice: because interrupts are disabled there. Leave it until further down, once success is assured, where the other pages are copied (before setting PageUptodate). Fixes: f3f0e1d2150b2 ("khugepaged: add support of collapse for tmpfs/shmem pages") Signed-off-by: Hugh Dickins Cc: Kirill A. Shutemov Cc: stable@vger.kernel.org # 4.8+ Acked-by: Kirill A. Shutemov --- mm/khugepaged.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 65e82f665c7c..1c402d33547e 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -1467,7 +1467,12 @@ static void collapse_shmem(struct mm_struct *mm, * Replacing old pages with new one has succeeded, now we * need to copy the content and free the old pages. */ + index = start; list_for_each_entry_safe(page, tmp, &pagelist, lru) { + while (index < page->index) { + clear_highpage(new_page + (index % HPAGE_PMD_NR)); + index++; + } copy_highpage(new_page + (page->index % HPAGE_PMD_NR), page); list_del(&page->lru); @@ -1477,6 +1482,11 @@ static void collapse_shmem(struct mm_struct *mm, ClearPageActive(page); ClearPageUnevictable(page); put_page(page); + index++; + } + while (index < end) { + clear_highpage(new_page + (index % HPAGE_PMD_NR)); + index++; } local_irq_disable();