From patchwork Mon Nov 26 23:23:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 10699335 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 EC60713AD for ; Mon, 26 Nov 2018 23:23:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D914528574 for ; Mon, 26 Nov 2018 23:23:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C748A28536; Mon, 26 Nov 2018 23:23:42 +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 9728228536 for ; Mon, 26 Nov 2018 23:23:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C71EA6B445D; Mon, 26 Nov 2018 18:23:40 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C20B26B445E; Mon, 26 Nov 2018 18:23:40 -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 B37146B445F; Mon, 26 Nov 2018 18:23:40 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by kanga.kvack.org (Postfix) with ESMTP id 730786B445D for ; Mon, 26 Nov 2018 18:23:40 -0500 (EST) Received: by mail-pg1-f200.google.com with SMTP id s27so8827838pgm.4 for ; Mon, 26 Nov 2018 15:23:40 -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=9cldGFQbC7ugVQhpvHUWhG/FaC/+yZV4xhPFMtVf1Ag=; b=KyxoKbp4ElVr5muLusauXeiRviGeYTnBUl79CNPrURfHhFfcvlN1dZmXRd0JeqFTHW AypHby+luKaK/5ds47fsbyaYSiSbg6UnNqGeZJRq4FxqYeKZrvlL2K2azONmElhnrkic 6i0EBfL+U/mGtmn3/Ihjx9deMuda+/9XmsyHRotO7aDNLXvzeGLUN4wbuozSHrUWgcm9 jZr/3+a50x6sNhyNe0S7YBWU2c84pRMT3/M+0ujg9n/IchtHiokh0otphEqIffm2aBoY T8yJpK/mH7k8XUwhMMhccDJ+6E9OI7G18JvQjgoVDHGEWnr+y/yh0Xv/O234JKE96axC xTjA== X-Gm-Message-State: AA+aEWZpxdZJ77lRZjMIr9dYuEeDFCPkAIa96tAEEbJyGhl0c7fjv+xv wnKKDsz1bNjp1sHx2RrBQJdu4BgNRdbXw8GvtDtqDWk0suuwTEmdCnL9za75Csg8tRlw6KwubM6 0m7hHuP6CRYepgNEL8qOjR+o4+SFelCQQr/up9Ai3pfIlvTKTJ4rwEIEw1Sk7fYSCzcYYurOX/0 0YMQEJcFQ1CLIGnzQZIZX6u+aF2NekgW03e9bcuRml56k+RZFj4w65e1mWMm9LXo+hLfTcMHsn8 8gPgjMjmHuGdHSYZq/jfhG/eMXU8Rnsr/wagArJx938wiKzDmxVtLb8x3MNM1VYIsC9hBDoYwN4 OyXi5CBEZGLbavwxhQezX1J2d8erJJSrdMtaVEz8cFf4/OojkPC4q7P0aL3mOEbnOUorfDerhmB y X-Received: by 2002:a17:902:b595:: with SMTP id a21mr17330042pls.120.1543274620144; Mon, 26 Nov 2018 15:23:40 -0800 (PST) X-Received: by 2002:a17:902:b595:: with SMTP id a21mr17330014pls.120.1543274619483; Mon, 26 Nov 2018 15:23:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543274619; cv=none; d=google.com; s=arc-20160816; b=0nvqvAfMMHTAEE5tkdp3uzr39JTrSZN4OzPJWtoiBmgQHcCXI4lVHJPf7DDOB77m1A rdIjsBjcBRi4BuPh6/2Ez+2QZmBqXtTjiY90JC4Vgft/vFs9G0ysczLZMpA150EO8zCd MlPgM5BY6RpkmMIWWDUenHF3x/MSuhQWLuUD/AKxjZiPQ4WVWNHVIoSMyLLKjBGg+Cmw GQAemNg7Vb+LSsiCkynLVUZYbcX9/xDIgYdoUJNByYE0fPVQ9dRwvIUwd68vHefUJ2G6 iLxL79yUFsDsK760FWE7lK2gBORGeHbBjkUNKEgSXkr6Z1dLHjJf3tGEgwUGsg9+U7oN 6vgA== 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=9cldGFQbC7ugVQhpvHUWhG/FaC/+yZV4xhPFMtVf1Ag=; b=VhkRLFMmu0ygTgAZrBpM9DG3+eYjMIr0Mw+C3oYvK10Qj4zej83Rchs1huJWT2oyNW HnL5lVzsXxdv3IQnvQDOAhQChHDZ8bLWsS9D0sx6emWeP5uaUbJ0YIj6se6uqY6QXSBF v5SL4B2qCDG5ndRXE/hOM3VOqGAI3Kbdxhyw1/v94v7aS2X67IO+aE6f1zwSr2Z0GO0i 8IynoKquB5T8BfJ1SjVxJqK8Y0uXz6Osr/yfWWWjz+3qKjhTTfgqtKLe+/EJDaF2WyAO UJY7JCmKmg27EUZDIdRSA0Ul7Au+1uAQxxV46piGrFs1w2roAV/VxxH5xeeiichygx7z zXLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=PoORlVPT; 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 r12sor2512417plo.58.2018.11.26.15.23.39 for (Google Transport Security); Mon, 26 Nov 2018 15:23:39 -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=PoORlVPT; 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=9cldGFQbC7ugVQhpvHUWhG/FaC/+yZV4xhPFMtVf1Ag=; b=PoORlVPTllS4vjsb7s92Iy1DBeDXNsgWTOPmFyqlf3qFTjneNHG3pRALYXmn89V7gW +lXRpg2mSpvFRe0U3BYsqpeNnHSxvMjxU4Fx0XX3m3cFPVQt5f/wkFVhqLiVrrT2OV5a QeYFum0dTEUT0UJbMCSjuYtzks5Qx2xXNuihRRfooHyuYoB2MvHzX4eTi88Cx8MLJvRP 3d6WxZFvdzc1zoHHXyCg7HqhPJNylo/H4N25Mhjy9YY/poA4HFqcbby38/EG+s9XO2Gi vJQvo79hnBL9gGr7g6VYq7Igd/jfdPofUVIbbVkLzTRGLHow5LwK6TLV6I9kZQoy8C5d sK+A== X-Google-Smtp-Source: AFSGD/Xoopmx/Dzvh24KYesC4RcW1ax4aSv4v6Hw/eD8IpqltZMmC3GYySoE75EvRmM8LbY46/uJaw== X-Received: by 2002:a17:902:6bc3:: with SMTP id m3-v6mr10621997plt.106.1543274618778; Mon, 26 Nov 2018 15:23:38 -0800 (PST) Received: from [100.112.89.103] ([104.133.8.103]) by smtp.gmail.com with ESMTPSA id t12sm1949179pfi.45.2018.11.26.15.23.37 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Nov 2018 15:23:38 -0800 (PST) Date: Mon, 26 Nov 2018 15:23:37 -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 04/10] mm/khugepaged: collapse_shmem() stop if punched or truncated 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 showed that although collapse_shmem() recognizes a concurrently truncated or hole-punched page correctly, its handling of holes was liable to refill an emptied extent. Add check to stop that. 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+ Reviewed-by: Matthew Wilcox --- mm/khugepaged.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index c13625c1ad5e..2070c316f06e 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -1359,6 +1359,17 @@ static void collapse_shmem(struct mm_struct *mm, VM_BUG_ON(index != xas.xa_index); if (!page) { + /* + * Stop if extent has been truncated or hole-punched, + * and is now completely empty. + */ + if (index == start) { + if (!xas_next_entry(&xas, end - 1)) { + result = SCAN_TRUNCATED; + break; + } + xas_set(&xas, index); + } if (!shmem_charge(mapping->host, 1)) { result = SCAN_FAIL; break;