Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2955599ybi; Mon, 17 Jun 2019 13:27:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqywojn82icsOGYEKIUTXTvYw0/CA2Sp63QQ5uM6i47lxtQmq6KJLJrnzNWzzV7JqpX1/OzA X-Received: by 2002:a17:90a:206a:: with SMTP id n97mr881767pjc.10.1560803255276; Mon, 17 Jun 2019 13:27:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560803255; cv=none; d=google.com; s=arc-20160816; b=OW8Cvpu+7xlbPAO4eT4/WKwFpRh7njZGeYGNy2P46qVnoWh7m1EWcPC14EiFtWd3ak 5LcTOb/YlWl/aS1IAIG7DvLumqTjKTH2DjIWXCzjd/eXIzutfvxnAvYQ/8qAQJKvGXFF XkXSqPZT87pMl/HkC2RKLJG9L23G2IIYMZ6fq8uSYPe2WSuThArFsu6YHH2u3wsLEhvV +TXEiD2hsEGVfHba4nu2Uwq3faYnuHq0O8LfmYInoMh6FFhA0LfDMzB/+n7s3a4Aidj+ v3NZl8HvDCh7IXiBi62aSqAjAH3K6q9LvVRdg7jSNPBHab4ujo6RFIUEU197ECDBwQRC /IUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=nXeAn+b9rzfB9xUtBdzEuMbNYPo06z76iQWWf55VKQQ=; b=UqTJZ5M33P95fU/lvPXcHNtl4l7CixIQSUxpVDCAxi3qCpK0c9bKhbnao0763Fcfjd Ter+VRSBAQn685+1Itlm2F7wMWVKXQ1b8gzG/AsP8gWZOadRqFI4H1uE8NkhCGOlfCjg /LxJnFilO1GVNOTWSoqu6dflwMKsNBiPj5QMbH7so9VxmqD0jaDT+mTr92bHmI9VbSJ7 AtOnxfVDF9ofCwnLc6+RHlZq4jKhsnZH1y1MMS7pzBDNRAZuD2rcjqTekEhluVpb+zim tf7P2n/Mu1WxTsXAHsJjGrT5AAxwlkXBsw50BFZ7TWvQHDoCyO0lL87PrHQGqKVFkD7D hU5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@shipmail.org header.s=mail header.b=DgKGvIHD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f15si11732429pgi.56.2019.06.17.13.27.19; Mon, 17 Jun 2019 13:27:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@shipmail.org header.s=mail header.b=DgKGvIHD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727795AbfFQU1K (ORCPT + 99 others); Mon, 17 Jun 2019 16:27:10 -0400 Received: from pio-pvt-msa3.bahnhof.se ([79.136.2.42]:60376 "EHLO pio-pvt-msa3.bahnhof.se" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726023AbfFQU1J (ORCPT ); Mon, 17 Jun 2019 16:27:09 -0400 Received: from localhost (localhost [127.0.0.1]) by pio-pvt-msa3.bahnhof.se (Postfix) with ESMTP id 8CF103F96D; Mon, 17 Jun 2019 22:18:19 +0200 (CEST) Authentication-Results: pio-pvt-msa3.bahnhof.se; dkim=pass (1024-bit key; unprotected) header.d=shipmail.org header.i=@shipmail.org header.b=DgKGvIHD; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at bahnhof.se X-Spam-Flag: NO X-Spam-Score: -3.099 X-Spam-Level: X-Spam-Status: No, score=-3.099 tagged_above=-999 required=6.31 tests=[ALL_TRUSTED=-1, BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no Received: from pio-pvt-msa3.bahnhof.se ([127.0.0.1]) by localhost (pio-pvt-msa3.bahnhof.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wJgy2N-cuyPz; Mon, 17 Jun 2019 22:18:05 +0200 (CEST) Received: from mail1.shipmail.org (h-205-35.A357.priv.bahnhof.se [155.4.205.35]) (Authenticated sender: mb878879) by pio-pvt-msa3.bahnhof.se (Postfix) with ESMTPA id 460C43F9AD; Mon, 17 Jun 2019 22:18:05 +0200 (CEST) Received: from localhost.localdomain.localdomain (h-205-35.A357.priv.bahnhof.se [155.4.205.35]) by mail1.shipmail.org (Postfix) with ESMTPSA id DABBF36196F; Mon, 17 Jun 2019 22:18:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=shipmail.org; s=mail; t=1560802684; bh=Yjmtl92sLAlEoB99F5XOnCklObajAbb4hpy0froOh7I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DgKGvIHD+BQzCinbcZ00LwMWVT8XN0GXc9j1aYJM7nBZYRwIDReixcJ3mCGKHZ/Hi g18grOyedUJBk5IQVHCEkGOA9L462r1skv8BFNOgXYe45woAv57pFF2NjMJIuzv/1f Myo6q5Sz8915On8lU5DVdop7iP+FLs1b1WS0t+9I= From: =?UTF-8?q?Thomas=20Hellstr=C3=B6m=20=28VMware=29?= To: dri-devel@lists.freedesktop.org Cc: linux-graphics-maintainer@vmware.com, pv-drivers@vmware.com, linux-kernel@vger.kernel.org Subject: [PATCH v7 1/9] mm: Allow the [page|pfn]_mkwrite callbacks to drop the mmap_sem Date: Mon, 17 Jun 2019 22:17:48 +0200 Message-Id: <20190617201756.12587-2-thomas@shipmail.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190617201756.12587-1-thomas@shipmail.org> References: <20190617201756.12587-1-thomas@shipmail.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thomas Hellstrom Driver fault callbacks are allowed to drop the mmap_sem when expecting long hardware waits to avoid blocking other mm users. Allow the mkwrite callbacks to do the same by returning early on VM_FAULT_RETRY. In particular we want to be able to drop the mmap_sem when waiting for a reservation object lock on a GPU buffer object. These locks may be held while waiting for the GPU. Cc: Andrew Morton Cc: Matthew Wilcox Cc: Will Deacon Cc: Peter Zijlstra Cc: Rik van Riel Cc: Minchan Kim Cc: Michal Hocko Cc: Huang Ying Cc: Souptick Joarder Cc: "Jérôme Glisse" Cc: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Thomas Hellstrom Reviewed-by: Ralph Campbell --- mm/memory.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index ddf20bd0c317..168f546af1ad 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -2238,7 +2238,7 @@ static vm_fault_t do_page_mkwrite(struct vm_fault *vmf) ret = vmf->vma->vm_ops->page_mkwrite(vmf); /* Restore original flags so that caller is not surprised */ vmf->flags = old_flags; - if (unlikely(ret & (VM_FAULT_ERROR | VM_FAULT_NOPAGE))) + if (unlikely(ret & (VM_FAULT_ERROR | VM_FAULT_NOPAGE | VM_FAULT_RETRY))) return ret; if (unlikely(!(ret & VM_FAULT_LOCKED))) { lock_page(page); @@ -2515,7 +2515,7 @@ static vm_fault_t wp_pfn_shared(struct vm_fault *vmf) pte_unmap_unlock(vmf->pte, vmf->ptl); vmf->flags |= FAULT_FLAG_MKWRITE; ret = vma->vm_ops->pfn_mkwrite(vmf); - if (ret & (VM_FAULT_ERROR | VM_FAULT_NOPAGE)) + if (ret & (VM_FAULT_ERROR | VM_FAULT_NOPAGE | VM_FAULT_RETRY)) return ret; return finish_mkwrite_fault(vmf); } @@ -2536,7 +2536,8 @@ static vm_fault_t wp_page_shared(struct vm_fault *vmf) pte_unmap_unlock(vmf->pte, vmf->ptl); tmp = do_page_mkwrite(vmf); if (unlikely(!tmp || (tmp & - (VM_FAULT_ERROR | VM_FAULT_NOPAGE)))) { + (VM_FAULT_ERROR | VM_FAULT_NOPAGE | + VM_FAULT_RETRY)))) { put_page(vmf->page); return tmp; } @@ -3601,7 +3602,8 @@ static vm_fault_t do_shared_fault(struct vm_fault *vmf) unlock_page(vmf->page); tmp = do_page_mkwrite(vmf); if (unlikely(!tmp || - (tmp & (VM_FAULT_ERROR | VM_FAULT_NOPAGE)))) { + (tmp & (VM_FAULT_ERROR | VM_FAULT_NOPAGE | + VM_FAULT_RETRY)))) { put_page(vmf->page); return tmp; } -- 2.20.1