From: Daniel Vetter Subject: Re: [PATCH] drm/i915: Don't prefault the entire obj if the vma is smaller Date: Tue, 17 Jun 2014 23:35:40 +0200 Message-ID: <20140617213540.GV5821@phenom.ffwll.local> References: <1403028180-4005-1-git-send-email-ville.syrjala@linux.intel.com> <20140617211145.GA25464@nuc-i3427.alporthouse.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Received: from mail-wi0-f173.google.com (mail-wi0-f173.google.com [209.85.212.173]) by gabe.freedesktop.org (Postfix) with ESMTP id 8C5596E73F for ; Tue, 17 Jun 2014 14:35:47 -0700 (PDT) Received: by mail-wi0-f173.google.com with SMTP id cc10so6614561wib.0 for ; Tue, 17 Jun 2014 14:35:46 -0700 (PDT) Content-Disposition: inline In-Reply-To: <20140617211145.GA25464@nuc-i3427.alporthouse.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" To: Chris Wilson , ville.syrjala@linux.intel.com, intel-gfx@lists.freedesktop.org List-Id: intel-gfx@lists.freedesktop.org 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@linux.intel.com w= rote: > > From: Ville Syrj=E4l=E4 > > = > > 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 > > Date: Tue Jun 10 12:14:40 2014 +0100 > > = > > drm/i915: Prefault the entire object on first page fault > > = > > Cc: Chris Wilson > > Signed-off-by: Ville Syrj=E4l=E4 > > --- > > 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/i91= 5_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, s= truct vm_fault *vmf) > > pfn >>=3D PAGE_SHIFT; > > = > > if (!obj->fault_mappable) { > > + unsigned long size =3D 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 -- = Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch