[Intel-gfx] [PATCH] drm/i915: Don't prefault the entire obj if the vma is smaller

Chris Wilson chris at chris-wilson.co.uk
Wed Jun 18 23:25:33 CEST 2014


On Tue, Jun 17, 2014 at 11:35:40PM +0200, Daniel Vetter wrote:
> On Tue, Jun 17, 2014 at 10:11:45PM +0100, Chris Wilson wrote:
> > On Tue, Jun 17, 2014 at 09:03:00PM +0300, ville.syrjala at linux.intel.com wrote:
> > > From: Ville Syrjälä <ville.syrjala at linux.intel.com>
> > > 
> > > 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 <chris at chris-wilson.co.uk>
> > >  Date:   Tue Jun 10 12:14:40 2014 +0100
> > > 
> > >     drm/i915: Prefault the entire object on first page fault
> > > 
> > > Cc: Chris Wilson <chris at chris-wilson.co.uk>
> > > Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
> > > ---
> > >  drivers/gpu/drm/i915/i915_gem.c | 5 ++++-
> > >  1 file changed, 4 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> > > index 6f8c206..4ef80d1 100644
> > > --- a/drivers/gpu/drm/i915/i915_gem.c
> > > +++ b/drivers/gpu/drm/i915/i915_gem.c
> > > @@ -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.
> 
> 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

-- 
Chris Wilson, Intel Open Source Technology Centre



More information about the Intel-gfx mailing list