From patchwork Wed Jan 9 02:02:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Arcangeli X-Patchwork-Id: 10753369 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 4081913BF for ; Wed, 9 Jan 2019 02:02:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 30D9A28942 for ; Wed, 9 Jan 2019 02:02:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 24A8028DF8; Wed, 9 Jan 2019 02:02:14 +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 C4A9228994 for ; Wed, 9 Jan 2019 02:02:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D54EE8E009D; Tue, 8 Jan 2019 21:02:10 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id CB5448E0038; Tue, 8 Jan 2019 21:02:10 -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 BB24D8E009F; Tue, 8 Jan 2019 21:02:10 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by kanga.kvack.org (Postfix) with ESMTP id 7C6598E009D for ; Tue, 8 Jan 2019 21:02:10 -0500 (EST) Received: by mail-qt1-f198.google.com with SMTP id j5so5221110qtk.11 for ; Tue, 08 Jan 2019 18:02:10 -0800 (PST) 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:in-reply-to:references:mime-version :content-transfer-encoding; bh=B+5MlzNnmygbePmOLKrtcFiRa3eh83v9fD3vP7jZHjo=; b=FKnQpo8NGeR1FEl/CnU92LL5uBn2N32p2U/FrAd6Mpz2v9aqa4JSmH51ypdp8h7fzs o8I1hpoZVZ+VqFJt2a/VNqKhrw7ogwCGfQQnTRQOyG9gT9NR1klAb8rpigbEYQsYJE6F rQt/7WDISpKSkT+3CWf2cVpzeQ0J/2wjZyr9qXfUtdxABxS/OXhkxWLCSXw61/CMlEKL WlHSHVWhDu1NDq6FVKdJPLHWMUu31PPzviqzwS60OiSgy7not72suULnkBXEJYDe1+Vq o/KQkVBumVj8UOEToRs3zyV3pSflOmcMLTyslW/tt0U6rUBcuVPeVbw8LkYMQjPAQ1Ay I/EQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of aarcange@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=aarcange@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AJcUukc2TNaDr8g2dAo4gCqPXNVlna8YllsmI6lLsrm8ZCePSPyoUdNH LsDUdbKUwubMdwYKYK9FnIDWPxjBsH4tBQEU/MEex6MuEbYWKf86+jmlJtd7nQLpVsCJeGs2V6v 8BMBPtozTpmd1aLHk7tcAggnvteHgNzp7t1iidXBjY3EMQ+5pFpaCdfNO9UXk44LMWQ== X-Received: by 2002:a0c:8286:: with SMTP id i6mr3948762qva.65.1546999330238; Tue, 08 Jan 2019 18:02:10 -0800 (PST) X-Google-Smtp-Source: ALg8bN42DUOM7B7iczophhw/VfLGDSEsTZpLBw3aa2IbTGj/FMDKFzIJjWi3P1ZydwSEErXyK8+6 X-Received: by 2002:a0c:8286:: with SMTP id i6mr3948743qva.65.1546999329758; Tue, 08 Jan 2019 18:02:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546999329; cv=none; d=google.com; s=arc-20160816; b=NdfUHgdKSGuvvtHuZUooCO7tm/NakQdPJA7Ra5RZMG1eO2/xDeFTsKu/lKJPEiB3t8 flTxPTaa+noKuTrB7keJPJ5w8TygRcKc9di7QCqHhAmF/rm4xa+/Lz50+UApAcVcLSf+ SiDjsVtuRqsrPhtO7+8dKMPeS10+BkOdV2cJHh7+dyPeLPxpI5HAUGPs4MfD8NZH4g16 uEuh2qOadEv7vSJDvXAxOysy9x5YwFzFPerqzslURoLzdyTXCrDYSRumjTiDNeIILCB7 mncAYrX8OWw3owWxojg0z7VWsmpLRJq7kfHkNZ+g3I9qj31yF8RZZi57g12HxUvQXl+s 91Dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=B+5MlzNnmygbePmOLKrtcFiRa3eh83v9fD3vP7jZHjo=; b=M4v6ZXar7/ROuuPm2V9ohgCxl3FMGbgT/d/WEuSwF3rbr/yT3Up8E2s8tIxYeaXJhG 3ROvw+rpnl7I6kArCJVKr3V0aMQi76QoIBPMcVlQnw7POeXMyPwoRoWBauoPRdMu9UBF /e3OOFOQODvDU+7xRbx4ycsd2uMW3j2CjCdLwElxEmFCLOtYQOicFB9aBBcxMdxQAWp1 w4hyMvVl/QixY4puILtHVcx9WkojML/qQ2/8u4doWxE5GCEAhpCGZsY7Ebs+t8wwPCcG zsEthoH+GPVQOloXgPAUh9NYYVVNPPbMb8Ng8IeXFnb3FUeu/9Ze5eIvRtUD+pdtKpjd Artw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of aarcange@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=aarcange@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id j14si753700qvm.164.2019.01.08.18.02.09 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Jan 2019 18:02:09 -0800 (PST) Received-SPF: pass (google.com: domain of aarcange@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of aarcange@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=aarcange@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E0F8488319; Wed, 9 Jan 2019 02:02:08 +0000 (UTC) Received: from sky.random (ovpn-120-73.rdu2.redhat.com [10.10.120.73]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BA69B101963E; Wed, 9 Jan 2019 02:02:05 +0000 (UTC) From: Andrea Arcangeli To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Mike Rapoport , Mike Kravetz , Peter Xu , "Dr. David Alan Gilbert" Subject: [PATCH 1/1] mm/hugetlb.c: teach follow_hugetlb_page() to handle FOLL_NOWAIT Date: Tue, 8 Jan 2019 21:02:03 -0500 Message-Id: <20190109020203.26669-2-aarcange@redhat.com> In-Reply-To: <20190109020203.26669-1-aarcange@redhat.com> References: <20190109020203.26669-1-aarcange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 09 Jan 2019 02:02:09 +0000 (UTC) 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 hugetlb needs the same fix as faultin_nopage (which was applied in 96312e61282ae3f6537a562625706498cbc75594) or KVM hangs because it thinks the mmap_sem was already released by hugetlb_fault() if it returned VM_FAULT_RETRY, but it wasn't in the FOLL_NOWAIT case. Fixes: ce53053ce378 ("kvm: switch get_user_page_nowait() to get_user_pages_unlocked()") Signed-off-by: Andrea Arcangeli Tested-by: "Dr. David Alan Gilbert" Reported-by: "Dr. David Alan Gilbert" Reviewed-by: Mike Kravetz Reviewed-by: Peter Xu --- mm/hugetlb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index e37efd5d8318..b3622d7888c8 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -4301,7 +4301,8 @@ long follow_hugetlb_page(struct mm_struct *mm, struct vm_area_struct *vma, break; } if (ret & VM_FAULT_RETRY) { - if (nonblocking) + if (nonblocking && + !(fault_flags & FAULT_FLAG_RETRY_NOWAIT)) *nonblocking = 0; *nr_pages = 0; /*