From: Thomas Hellstrom <thellstrom@vmware.com>
To: "dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
Linux-graphics-maintainer <Linux-graphics-maintainer@vmware.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: "Thomas Hellstrom" <thellstrom@vmware.com>,
"Michal Hocko" <mhocko@suse.com>,
"Rik van Riel" <riel@surriel.com>,
"Peter Zijlstra" <peterz@infradead.org>,
"Will Deacon" <will.deacon@arm.com>,
"Matthew Wilcox" <willy@infradead.org>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
"Minchan Kim" <minchan@kernel.org>,
"Jérôme Glisse" <jglisse@redhat.com>,
"Souptick Joarder" <jrdr.linux@gmail.com>,
"Huang Ying" <ying.huang@intel.com>,
"Andrew Morton" <akpm@linux-foundation.org>
Subject: [PATCH 1/9] mm: Allow the [page|pfn]_mkwrite callbacks to drop the mmap_sem
Date: Fri, 12 Apr 2019 16:04:15 +0000 [thread overview]
Message-ID: <20190412160338.64994-2-thellstrom@vmware.com> (raw)
In-Reply-To: <20190412160338.64994-1-thellstrom@vmware.com>
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 <akpm@linux-foundation.org>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rik van Riel <riel@surriel.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Huang Ying <ying.huang@intel.com>
Cc: Souptick Joarder <jrdr.linux@gmail.com>
Cc: "Jérôme Glisse" <jglisse@redhat.com>
Cc: linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
---
mm/memory.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
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 = 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_RETRY | VM_FAULT_NOPAGE)))
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 *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_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 *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_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 = 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;
}
--
2.20.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
WARNING: multiple messages have this Message-ID (diff)
From: Thomas Hellstrom <thellstrom@vmware.com>
To: "dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
Linux-graphics-maintainer <Linux-graphics-maintainer@vmware.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: "Thomas Hellstrom" <thellstrom@vmware.com>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Matthew Wilcox" <willy@infradead.org>,
"Will Deacon" <will.deacon@arm.com>,
"Peter Zijlstra" <peterz@infradead.org>,
"Rik van Riel" <riel@surriel.com>,
"Minchan Kim" <minchan@kernel.org>,
"Michal Hocko" <mhocko@suse.com>,
"Huang Ying" <ying.huang@intel.com>,
"Souptick Joarder" <jrdr.linux@gmail.com>,
"Jérôme Glisse" <jglisse@redhat.com>,
"linux-mm@kvack.org" <linux-mm@kvack.org>
Subject: [PATCH 1/9] mm: Allow the [page|pfn]_mkwrite callbacks to drop the mmap_sem
Date: Fri, 12 Apr 2019 16:04:15 +0000 [thread overview]
Message-ID: <20190412160338.64994-2-thellstrom@vmware.com> (raw)
In-Reply-To: <20190412160338.64994-1-thellstrom@vmware.com>
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 <akpm@linux-foundation.org>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rik van Riel <riel@surriel.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Huang Ying <ying.huang@intel.com>
Cc: Souptick Joarder <jrdr.linux@gmail.com>
Cc: "Jérôme Glisse" <jglisse@redhat.com>
Cc: linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
---
mm/memory.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
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 = 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_RETRY | VM_FAULT_NOPAGE)))
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 *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_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 *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_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 = 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;
}
--
2.20.1
next prev parent reply other threads:[~2019-04-12 16:04 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-12 16:04 [PATCH 0/9] Emulated coherent graphics memory Thomas Hellstrom
2019-04-12 16:04 ` Thomas Hellstrom
2019-04-12 16:04 ` Thomas Hellstrom [this message]
2019-04-12 16:04 ` [PATCH 1/9] mm: Allow the [page|pfn]_mkwrite callbacks to drop the mmap_sem Thomas Hellstrom
2019-04-12 18:52 ` Ralph Campbell
2019-04-13 15:11 ` Souptick Joarder
2019-04-17 10:58 ` Thomas Hellstrom
2019-04-17 10:58 ` Thomas Hellstrom
2019-04-17 13:00 ` Souptick Joarder
2019-04-12 16:04 ` [PATCH 2/9] mm: Add an apply_to_pfn_range interface Thomas Hellstrom
2019-04-12 18:52 ` Ralph Campbell
2019-04-12 21:07 ` Jerome Glisse
2019-04-12 21:07 ` Jerome Glisse
2019-04-13 8:34 ` Thomas Hellstrom
2019-04-13 8:34 ` Thomas Hellstrom
2019-04-16 14:46 ` Jerome Glisse
2019-04-17 9:15 ` Thomas Hellstrom
2019-04-17 14:28 ` Jerome Glisse
2019-04-12 16:04 ` [PATCH 3/9] mm: Add write-protect and clean utilities for address space ranges Thomas Hellstrom
2019-04-12 16:04 ` Thomas Hellstrom
2019-04-12 18:52 ` Ralph Campbell
2019-04-13 8:40 ` Thomas Hellstrom
2019-04-12 16:04 ` [PATCH 4/9] drm/ttm: Allow the driver to provide the ttm struct vm_operations_struct Thomas Hellstrom
2019-04-13 18:39 ` Koenig, Christian
2019-04-13 18:39 ` Koenig, Christian
2019-04-12 16:04 ` [PATCH 5/9] drm/ttm: TTM fault handler helpers Thomas Hellstrom
2019-04-12 16:04 ` Thomas Hellstrom
2019-04-15 6:34 ` Christian König
2019-04-17 10:53 ` Thomas Hellstrom
2019-04-17 10:53 ` Thomas Hellstrom
2019-04-12 16:04 ` [PATCH 6/9] drm/vmwgfx: Implement an infrastructure for write-coherent resources Thomas Hellstrom
2019-04-12 16:04 ` Thomas Hellstrom
2019-04-22 18:54 ` Deepak Singh Rawat
2019-04-22 18:54 ` Deepak Singh Rawat
2019-04-24 9:10 ` Thomas Hellstrom
2019-04-24 9:10 ` Thomas Hellstrom
2019-04-12 16:04 ` [PATCH 7/9] drm/vmwgfx: Use an RBtree instead of linked list for MOB resources Thomas Hellstrom
2019-04-12 16:04 ` Thomas Hellstrom
2019-04-22 19:15 ` Deepak Singh Rawat
2019-04-22 19:15 ` Deepak Singh Rawat
2019-04-12 16:04 ` [PATCH 8/9] drm/vmwgfx: Implement an infrastructure for read-coherent resources Thomas Hellstrom
2019-04-12 16:04 ` Thomas Hellstrom
2019-04-22 20:12 ` Deepak Singh Rawat
2019-04-22 20:12 ` Deepak Singh Rawat
2019-04-24 9:26 ` Thomas Hellstrom
2019-04-12 16:04 ` [PATCH 9/9] drm/vmwgfx: Add surface dirty-tracking callbacks Thomas Hellstrom
2019-04-12 16:04 ` Thomas Hellstrom
2019-04-23 2:51 ` Deepak Singh Rawat
2019-04-23 2:51 ` Deepak Singh Rawat
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190412160338.64994-2-thellstrom@vmware.com \
--to=thellstrom@vmware.com \
--cc=Linux-graphics-maintainer@vmware.com \
--cc=akpm@linux-foundation.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=jglisse@redhat.com \
--cc=jrdr.linux@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=minchan@kernel.org \
--cc=peterz@infradead.org \
--cc=riel@surriel.com \
--cc=will.deacon@arm.com \
--cc=willy@infradead.org \
--cc=ying.huang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.