drm/i915: Don't prefault the entire obj if the vma is smaller
Subsystems (2)
PATCH 1/1 drm/i915: Don't prefault the entire obj if the vma is smaller
From: Ville Syrjälä <[email protected]>
Take the minimum of the object size and the vma size and prefault only that much. Avoids a SIGBUS when mmapping only a portion of the object.
Prefaulting was introduced here:
commit b90b91d87038f6b257b40a02b42ed4f9705e06f0
Author: Chris Wilson <[email protected]>
Date: Tue Jun 10 12:14:40 2014 +0100
drm/i915: Prefault the entire object on first page fault
--- drivers/gpu/drm/i915/i915_gem.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem.c +4 -1
@@ -1578,9 +1578,12 @@ int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf) pfn >>=PAGE_SHIFT ;if (!obj->fault_mappable) { + unsigned long size = min_t(unsigned long, + vma->vm_end - vma->vm_start, + obj->base.size);int i; -for (i =0 ; i < obj->base.size >>PAGE_SHIFT ; i++) { +for (i =0 ; i < size >>PAGE_SHIFT ; i++) { ret =vm_insert_pfn (vma, (unsigned long )vma->vm_start + i *PAGE_SIZE , pfn + i);
Signature · 6 lines
1.8.5.5 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 11 lines · On Tue, Jun 17, 2014 at 8:03 PM, <[email protected]> wrote:
From: Ville Syrjälä <[email protected]>
Take the minimum of the object size and the vma size and prefault only that much. Avoids a SIGBUS when mmapping only a portion of the object.
Prefaulting was introduced here:
commitb90b91d87038f6b257b40a02b42ed4f9705e06f0
Author: Chris Wilson <[email protected]>
Date: Tue Jun 10 12:14:40 2014 +0100
Quoted 4 lines
drm/i915: Prefault the entire object on first page fault
Cc Chris Wilson <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>
Do we have an igt for this?
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 12 lines · Daniel Vetter
Quoted 11 lines · On Tue, Jun 17, 2014 at 8:03 PM, <[email protected]> wrote:
From: Ville Syrjälä <[email protected]>
Take the minimum of the object size and the vma size and prefault only that much. Avoids a SIGBUS when mmapping only a portion of the object.
Prefaulting was introduced here:
commitb90b91d87038f6b257b40a02b42ed4f9705e06f0
Author: Chris Wilson <[email protected]>
Date: Tue Jun 10 12:14:40 2014 +0100
Quoted 6 lines
Quoted 4 lines
drm/i915: Prefault the entire object on first page fault
Cc Chris Wilson <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>Do we have an igt for this?
Well, written one since trivial to do and merged the patch. Thanks. -Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Quoted 24 lines · On Tue, Jun 17, 2014 at 09:03:00PM +0300, [email protected] wrote:
From: Ville Syrjälä <[email protected]>
Take the minimum of the object size and the vma size and prefault only that much. Avoids a SIGBUS when mmapping only a portion of the object.
Prefaulting was introduced here:
commitb90b91d87038f6b257b40a02b42ed4f9705e06f0
Author: Chris Wilson <[email protected]>
Date: Tue Jun 10 12:14:40 2014 +0100drm/i915: Prefault the entire object on first page fault
Cc Chris Wilson <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/i915/i915_gem.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/i915_gem.c +0
-0
drivers/gpu/drm/i915/i915_gem.c int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf) · line 1583
Quoted 6 lines
drivers/gpu/drm/i915/i915_gem.c +3
-0@@ -1578,9 +1578,12 @@ int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf) pfn >>=PAGE_SHIFT ;if (!obj->fault_mappable) { + unsigned long size = min_t(unsigned long, + vma->vm_end - vma->vm_start, + obj->base.size);
The vma should be the same size as the obj... Unless it gets coalesced... I wonder if that is even legal for our objects because I was under the impression that we depended upon it in other places. -Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Quoted 27 lines · Chris Wilson
Quoted 26 lines · On Tue, Jun 17, 2014 at 09:03:00PM +0300, [email protected] wrote:
From: Ville Syrjälä <[email protected]>
Take the minimum of the object size and the vma size and prefault only that much. Avoids a SIGBUS when mmapping only a portion of the object.
Prefaulting was introduced here:
commitb90b91d87038f6b257b40a02b42ed4f9705e06f0
Author: Chris Wilson <[email protected]>
Date: Tue Jun 10 12:14:40 2014 +0100drm/i915: Prefault the entire object on first page fault
Cc Chris Wilson <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/i915/i915_gem.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/i915_gem.c +0
-0@@ -1578,9 +1578,12 @@ int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf) pfn >>=PAGE_SHIFT ;
Quoted 8 lines
drivers/gpu/drm/i915/i915_gem.c int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf) · line 1583
Quoted 4 lines
drivers/gpu/drm/i915/i915_gem.c +3
-0if (!obj->fault_mappable) { + unsigned long size = min_t(unsigned long, + vma->vm_end - vma->vm_start, + obj->base.size);The vma should be the same size as the obj... Unless it gets coalesced... I wonder if that is even legal for our objects because I was under the impression that we depended upon it in other places.
You have to map from the first page otherwise the lookup won't find it. But apparently we have at least igts that hit this (Rodrigo's psr test as an example). And it's easy to test and easy to fix, so figured ok to merge.
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Quoted 37 lines · Daniel Vetter
Quoted 27 lines · Chris Wilson
Quoted 26 lines · On Tue, Jun 17, 2014 at 09:03:00PM +0300, [email protected] wrote:
From: Ville Syrjälä <[email protected]>
Take the minimum of the object size and the vma size and prefault only that much. Avoids a SIGBUS when mmapping only a portion of the object.
Prefaulting was introduced here:
commitb90b91d87038f6b257b40a02b42ed4f9705e06f0
Author: Chris Wilson <[email protected]>
Date: Tue Jun 10 12:14:40 2014 +0100drm/i915: Prefault the entire object on first page fault
Cc Chris Wilson <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/i915/i915_gem.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/i915_gem.c +0
-0@@ -1578,9 +1578,12 @@ int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf) pfn >>=PAGE_SHIFT ;Quoted 8 lines
drivers/gpu/drm/i915/i915_gem.c int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf) · line 1583
Quoted 4 lines
drivers/gpu/drm/i915/i915_gem.c +3
-0if (!obj->fault_mappable) { + unsigned long size = min_t(unsigned long, + vma->vm_end - vma->vm_start, + obj->base.size);The vma should be the same size as the obj... Unless it gets coalesced... I wonder if that is even legal for our objects because I was under the impression that we depended upon it in other places.
Quoted 4 lines
You have to map from the first page otherwise the lookup won't find it. But apparently we have at least igts that hit this (Rodrigo's psr test as an example). And it's easy to test and easy to fix, so figured ok to merge.
Oh, userspace is mapping less than the obj. Yes, I now see that drm_gem_obj_mmap() allows that. I ruled out that we merged our vma together, as the core doesn't merge vma with vma->vm_ops->close (which we do). And for what it is worth, these switched to using vma->vm_end - vma->vm_start in the next, postponed, patch.
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre