Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp700199yba; Fri, 12 Apr 2019 11:53:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqwN6Ai34eZCAXHxRtHFQCsgyMsUx0NeQpXGQ6hF5ggrChPigKh3Fk3RDGtCZxcFEvfRf5RD X-Received: by 2002:a17:902:be09:: with SMTP id r9mr56935460pls.215.1555095196074; Fri, 12 Apr 2019 11:53:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555095196; cv=none; d=google.com; s=arc-20160816; b=VaF6WlhtwKdoSDHQ9AaRMAz+Npxr4zUFcPmrQhP79vogPHl6sFmW5dz5ONNQS+dls7 cXVel4/BQZxIMxOL7Yk9diSbHkCRcy/+Y4KR+Bzim7RNjXR77/a7aRKTaQ9zc0miREcE saHSK8QHJ1Ss5QEb3nTcwXxagD8sDy0SQE2+qcW2qcjsFwqOGO0yFnaUmuHfMxLg7GKb //9I5tgxQdWfodNYtp+fcXyDo7cxEbvXgVZhe6gmb7H5nEyCWYKKfPwhRizRHAgtAtKF WCdjUeMdEExex+m53iYE/TSWs6jLAk/QBg37ufMQ9A6SUiOPr9i9d2fmy3TuTP8iEqPc mRyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=o7pYXYebwcZB9VG+SfqHk39wa19WyWkdp0pR+i/f4wo=; b=uGi+LqWG3I54aYjYV3hvxm034lLqh/ckd4jwrpmwZjgfT+tBsFgCdOFotcb9hk3PeC aBpbchUFhiYj7nQzDkBY/nrl+RMamkr+BPPwYOmApsqa52Sd43GsRkhqiB35ndTNkeTw q+jk6X3tOunrfNMjnnJtMbEDKjBaj0bNRTxk2Zb06F4CvkpBZ8gJuHLTGaxe9pvyMm7V sFXeY62bADuqPvftrzeEOIHT53Qwmm0vyx359JYVf12m7aoWodJeFI52ZophazSOE/xg 4nw6wWjK6r97bDNUavdAiE61xZbPtBjGF8tmYyCG9LL3ATel0TRvvoqtNBur2GgFw6zZ AkIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=IcH1Vq4J; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q4si37995409pfh.157.2019.04.12.11.53.00; Fri, 12 Apr 2019 11:53:16 -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=pass header.i=@nvidia.com header.s=n1 header.b=IcH1Vq4J; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727024AbfDLSwV (ORCPT + 99 others); Fri, 12 Apr 2019 14:52:21 -0400 Received: from hqemgate16.nvidia.com ([216.228.121.65]:2885 "EHLO hqemgate16.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726711AbfDLSwU (ORCPT ); Fri, 12 Apr 2019 14:52:20 -0400 Received: from hqpgpgate102.nvidia.com (Not Verified[216.228.121.13]) by hqemgate16.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Fri, 12 Apr 2019 11:52:16 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate102.nvidia.com (PGP Universal service); Fri, 12 Apr 2019 11:52:19 -0700 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Fri, 12 Apr 2019 11:52:19 -0700 Received: from rcampbell-dev.nvidia.com (172.20.13.39) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 12 Apr 2019 18:52:18 +0000 Subject: Re: [PATCH 1/9] mm: Allow the [page|pfn]_mkwrite callbacks to drop the mmap_sem To: Thomas Hellstrom , "dri-devel@lists.freedesktop.org" , Linux-graphics-maintainer , "linux-kernel@vger.kernel.org" CC: Andrew Morton , Matthew Wilcox , Will Deacon , Peter Zijlstra , Rik van Riel , Minchan Kim , Michal Hocko , Huang Ying , Souptick Joarder , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , "linux-mm@kvack.org" References: <20190412160338.64994-1-thellstrom@vmware.com> <20190412160338.64994-2-thellstrom@vmware.com> From: Ralph Campbell Message-ID: Date: Fri, 12 Apr 2019 11:52:18 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.0 MIME-Version: 1.0 In-Reply-To: <20190412160338.64994-2-thellstrom@vmware.com> X-Originating-IP: [172.20.13.39] X-ClientProxiedBy: HQMAIL103.nvidia.com (172.20.187.11) To HQMAIL101.nvidia.com (172.20.187.10) Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1555095136; bh=o7pYXYebwcZB9VG+SfqHk39wa19WyWkdp0pR+i/f4wo=; h=X-PGP-Universal:Subject:To:CC:References:From:Message-ID:Date: User-Agent:MIME-Version:In-Reply-To:X-Originating-IP: X-ClientProxiedBy:Content-Type:Content-Language: Content-Transfer-Encoding; b=IcH1Vq4J4rSeqgJQnoLEJb9hwun7XOw2WYaxyxKQCbrYuDvOmT3ZgXFheM2V416Rh WP7IdahP6zQOcF8JdvhBxSGWZarcrCtB7aaD2wGupWDCn/X0E2w+wleEJqI/H5e/fQ KO9gQ8wsvS/LxO8nIYgGV6SCU2oVfApi6rX20zQ1LvM4+h32eoA4D080vrE3YldHHA sVbXiYHGuzjA9VzRFIveZQ2RbpRqVOl0qtqoezcP+6qCvCeNctnNNJKNzw7nq0Sxok 28HP4HmU45/XGzLeg5wSrw9fl4PCItC/vDgrHuXyEGek48BFv418PbWAbFTCicny+7 9/EtLR0lLHaSQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/12/19 9:04 AM, Thomas Hellstrom wrote: > 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. >=20 > 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. >=20 > 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=C3=A9r=C3=B4me Glisse" > Cc: linux-mm@kvack.org > Cc: linux-kernel@vger.kernel.org >=20 > Signed-off-by: Thomas Hellstrom Reviewed-by: Ralph Campbell > --- > mm/memory.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) >=20 > diff --git a/mm/memory.c b/mm/memory.c > index e11ca9dd823f..a95b4a3b1ae2 100644 > --- a/mm/memory.c > +++ b/mm/memory.c > @@ -2144,7 +2144,7 @@ static vm_fault_t do_page_mkwrite(struct vm_fault *= vmf) > ret =3D vmf->vma->vm_ops->page_mkwrite(vmf); > /* Restore original flags so that caller is not surprised */ > vmf->flags =3D old_flags; > - if (unlikely(ret & (VM_FAULT_ERROR | VM_FAULT_NOPAGE))) > + if (unlikely(ret & (VM_FAULT_ERROR | VM_FAULT_RETRY | VM_FAULT_NOPAGE))= ) A very minor nit, for consistency elsewhere in mm/memory.c, could you make this be: (VM_FAULT_ERROR | VM_FAULT_NOPAGE | VM_FAULT_RETRY) > return ret; > if (unlikely(!(ret & VM_FAULT_LOCKED))) { > lock_page(page); > @@ -2419,7 +2419,7 @@ static vm_fault_t wp_pfn_shared(struct vm_fault *vm= f) > pte_unmap_unlock(vmf->pte, vmf->ptl); > vmf->flags |=3D FAULT_FLAG_MKWRITE; > ret =3D vma->vm_ops->pfn_mkwrite(vmf); > - if (ret & (VM_FAULT_ERROR | VM_FAULT_NOPAGE)) > + if (ret & (VM_FAULT_ERROR | VM_FAULT_RETRY | VM_FAULT_NOPAGE)) > return ret; > return finish_mkwrite_fault(vmf); > } > @@ -2440,7 +2440,8 @@ static vm_fault_t wp_page_shared(struct vm_fault *v= mf) > pte_unmap_unlock(vmf->pte, vmf->ptl); > tmp =3D do_page_mkwrite(vmf); > if (unlikely(!tmp || (tmp & > - (VM_FAULT_ERROR | VM_FAULT_NOPAGE)))) { > + (VM_FAULT_ERROR | VM_FAULT_RETRY | > + VM_FAULT_NOPAGE)))) { > put_page(vmf->page); > return tmp; > } > @@ -3494,7 +3495,8 @@ static vm_fault_t do_shared_fault(struct vm_fault *= vmf) > unlock_page(vmf->page); > tmp =3D do_page_mkwrite(vmf); > if (unlikely(!tmp || > - (tmp & (VM_FAULT_ERROR | VM_FAULT_NOPAGE)))) { > + (tmp & (VM_FAULT_ERROR | VM_FAULT_RETRY | > + VM_FAULT_NOPAGE)))) { > put_page(vmf->page); > return tmp; > } >=20