From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DE4E6C11D0C for ; Thu, 20 Feb 2020 14:54:44 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8F36324656 for ; Thu, 20 Feb 2020 14:54:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="NWmKDJh/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8F36324656 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3256B6B0006; Thu, 20 Feb 2020 09:54:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2B0DF6B0007; Thu, 20 Feb 2020 09:54:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 129F76B0008; Thu, 20 Feb 2020 09:54:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0232.hostedemail.com [216.40.44.232]) by kanga.kvack.org (Postfix) with ESMTP id E3F126B0006 for ; Thu, 20 Feb 2020 09:54:43 -0500 (EST) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 92734180AD80F for ; Thu, 20 Feb 2020 14:54:43 +0000 (UTC) X-FDA: 76510802046.11.train81_4651a3cef2c3b X-HE-Tag: train81_4651a3cef2c3b X-Filterd-Recvd-Size: 5171 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by imf37.hostedemail.com (Postfix) with ESMTP for ; Thu, 20 Feb 2020 14:54:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582210482; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pC83s6/oCw9UYO0HRmtCBYiP7WO47JpUOZG4bdgeobM=; b=NWmKDJh/NBAjhxqhMIJsIHjFCh3yAcFoBALQsgeJ80y5Qzn+5kgdcUNkYUlnai0RnKATEd 3DRzNSREdW50EJai3CADQSqC86uIAq0ty4lkjRjXZbx3dzCVwY5z6qWBB54OA+ykwfbhDj 5j/Wbx59it9k5+rlHBrA2FFNv5dlsdk= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-62-q3BP6l04PqC6jgTCZD27LQ-1; Thu, 20 Feb 2020 09:54:41 -0500 X-MC-Unique: q3BP6l04PqC6jgTCZD27LQ-1 Received: by mail-qk1-f200.google.com with SMTP id k133so2866075qke.13 for ; Thu, 20 Feb 2020 06:54: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:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GuXFXQMyc7fgJvuGyXbyHcTTw4JLf36BXSP5cKDpRYA=; b=cSg8tAXMHifhsG3PxQBBLcHcY1cdKg7k08y2lW8Y1vS4Z1aQA23WDiBm5ifAsggIF4 mv8jNWcFF4/PZZSWKGei6v9+434zoNajyQsoB2SkoSghwloYlFWIGsKKdl4PGth7hl2v Fflnf0/anTkEhIr+jSlp5RSaBgUrW7OkpsDdbq9rvyJaBhS4Og/mHMW4Dq3idqv2nDCF jdDLc7ZJy6hP5h8zLRyLbgFGEVCSCZJcLwkE6eB7BWlRxX4RaQ0Kx2eUuxJrxglf/dwM dgC63U2DkgAY/h7DoMuLhNz6UHfKPIcWH1zeZqNbAK8MiAm1vGPRvO+V+rzM5nf2wXxi CKeQ== X-Gm-Message-State: APjAAAVl3tzU5xuOXuV+w1YRbDeYmJcoKjGg/fy8btlz5JISOhhTNoyQ XM0O+RZLhhzuDmdoX+p9xbOeB1tItlf0fvAaMDKyUQFaAN9PVq4WZEzJRt2ywZLwZc2r5NrenzQ ieQyBA9nQrL8= X-Received: by 2002:aed:2344:: with SMTP id i4mr27122886qtc.136.1582210479967; Thu, 20 Feb 2020 06:54:39 -0800 (PST) X-Google-Smtp-Source: APXvYqxwOVehITbq/u1z2q7iTC6ia0QK/vAUkzyQy3GbFT+OSQxJLwuoeMqLraCRelgvzUEVbAWpxQ== X-Received: by 2002:aed:2344:: with SMTP id i4mr27122858qtc.136.1582210479693; Thu, 20 Feb 2020 06:54:39 -0800 (PST) Received: from xz-x1.redhat.com ([104.156.64.75]) by smtp.gmail.com with ESMTPSA id v82sm1725109qka.51.2020.02.20.06.54.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Feb 2020 06:54:38 -0800 (PST) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Martin Cracauer , Mike Rapoport , Hugh Dickins , Jerome Glisse , peterx@redhat.com, "Kirill A . Shutemov" , Matthew Wilcox , Pavel Emelyanov , Brian Geffon , Maya Gokhale , Denis Plotnikov , Andrea Arcangeli , Johannes Weiner , "Dr . David Alan Gilbert" , Linus Torvalds , Mike Kravetz , Marty McFadden , David Hildenbrand , Bobby Powers , Mel Gorman Subject: [PATCH v6 02/16] mm/gup: Fix __get_user_pages() on fault retry of hugetlb Date: Thu, 20 Feb 2020 09:54:18 -0500 Message-Id: <20200220145432.4561-3-peterx@redhat.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200220145432.4561-1-peterx@redhat.com> References: <20200220145432.4561-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable 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: When follow_hugetlb_page() returns with *locked=3D=3D0, it means we've got a VM_FAULT_RETRY within the fauling process and we've released the mmap_sem. When that happens, we should stop and bail out. Signed-off-by: Peter Xu --- mm/gup.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mm/gup.c b/mm/gup.c index 1b4411bd0042..76cb420c0fb7 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -849,6 +849,16 @@ static long __get_user_pages(struct task_struct *tsk, = struct mm_struct *mm, =09=09=09=09i =3D follow_hugetlb_page(mm, vma, pages, vmas, =09=09=09=09=09=09&start, &nr_pages, i, =09=09=09=09=09=09gup_flags, locked); +=09=09=09=09if (locked && *locked =3D=3D 0) { +=09=09=09=09=09/* +=09=09=09=09=09 * We've got a VM_FAULT_RETRY +=09=09=09=09=09 * and we've lost mmap_sem. +=09=09=09=09=09 * We must stop here. +=09=09=09=09=09 */ +=09=09=09=09=09BUG_ON(gup_flags & FOLL_NOWAIT); +=09=09=09=09=09BUG_ON(ret !=3D 0); +=09=09=09=09=09goto out; +=09=09=09=09} =09=09=09=09continue; =09=09=09} =09=09} --=20 2.24.1