From patchwork Wed Oct 10 10:36:48 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 1572871 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork1.kernel.org (Postfix) with ESMTP id 6FECF40135 for ; Wed, 10 Oct 2012 10:37:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6A024A0AEB for ; Wed, 10 Oct 2012 03:37:07 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTP id 22E4F9E74D for ; Wed, 10 Oct 2012 03:36:58 -0700 (PDT) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 10 Oct 2012 03:36:57 -0700 Message-Id: X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.80,564,1344236400"; d="scan'208";a="232135888" Received: from unknown (HELO cantiga.alporthouse.com) ([10.255.14.77]) by fmsmga001.fm.intel.com with SMTP; 10 Oct 2012 03:36:55 -0700 Received: by cantiga.alporthouse.com (sSMTP sendmail emulation); Wed, 10 Oct 2012 11:36:48 +0100 From: Chris Wilson To: Daniel Vetter In-Reply-To: <20121010092144.GC5533@phenom.ffwll.local> References: <84c8a8$624sk4@orsmga001.jf.intel.com> <1349815848-1824-1-git-send-email-daniel.vetter@ffwll.ch> <6c3329$6m595h@orsmga002.jf.intel.com> <453bf0$61a4mf@azsmga001.ch.intel.com> <20121010092144.GC5533@phenom.ffwll.local> Date: Wed, 10 Oct 2012 11:36:48 +0100 Cc: Daniel Vetter , Intel Graphics Development Subject: Re: [Intel-gfx] [PATCH] drm/i915: fixup i915_gem_object_get_page inline helper X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org On Wed, 10 Oct 2012 11:21:44 +0200, Daniel Vetter wrote: > On Wed, Oct 10, 2012 at 10:01:47AM +0100, Chris Wilson wrote: > > On Tue, 09 Oct 2012 23:16:02 +0100, Chris Wilson wrote: > > > On Tue, 9 Oct 2012 22:50:48 +0200, Daniel Vetter wrote: > > > > The obj->pages to obj->pages->sgl rework introduced this helper, but > > > > it doesn't actually work for n >= SG_MAX_SINGLE_ALLOC. > > > > > > > > For simplicity (and since right now I seem to be too stupid to see > > > > the bug), let's just grab the right page with a for_each_sg loop. > > > > > > > > This is exercised by the improved hangman tests and the gem_exec_big > > > > test in i-g-t. > > > > > > > > v2: Compared to v1, don't try to be clever since I seemingly only > > > > manage to prove that I'm not clever. > > > > > > Only I expect that loop to show up on profiles even higher than the > > > sg_next() from pwrite. :| > > > > > > I expect it to have a measureable impact upon relocation throughput, > > > so I should measure it... > > > -Chris > > > > > > -- > > > Chris Wilson, Intel Open Source Technology Centre > > > _______________________________________________ > > > Intel-gfx mailing list > > > Intel-gfx@lists.freedesktop.org > > > http://lists.freedesktop.org/mailman/listinfo/intel-gfx > > From: Chris Wilson > > Subject: Re: [PATCH] drm/i915: fixup i915_gem_object_get_page inline helper > > To: Daniel Vetter , Intel Graphics Development > > Cc: Daniel Vetter > > In-Reply-To: <1349815848-1824-1-git-send-email-daniel.vetter@ffwll.ch> > > References: <84c8a8$624sk4@orsmga001.jf.intel.com> <1349815848-1824-1-git-send-email-daniel.vetter@ffwll.ch> > > > > On Tue, 9 Oct 2012 22:50:48 +0200, Daniel Vetter wrote: > > > The obj->pages to obj->pages->sgl rework introduced this helper, but > > > it doesn't actually work for n >= SG_MAX_SINGLE_ALLOC. > > > > > > For simplicity (and since right now I seem to be too stupid to see > > > the bug), let's just grab the right page with a for_each_sg loop. > > > > > > This is exercised by the improved hangman tests and the gem_exec_big > > > test in i-g-t. > > > > > > v2: Compared to v1, don't try to be clever since I seemingly only > > > manage to prove that I'm not clever. > > > > > > Signed-off-by: Daniel Vetter > > > > Looks like my worries are baseless. It can always be attacked latter if > > need be. I'd still like to know what the mistake was... > > > > Reviewed-by: Chris Wilson > > Merged to -fixes, with the missing regression-sha1 citation added. > -Daniel > -- > Daniel Vetter > Software Engineer, Intel Corporation > +41 (0) 79 365 57 48 - http://blog.ffwll.ch From: Chris Wilson Subject: Re: [Intel-gfx] [PATCH] drm/i915: fixup i915_gem_object_get_page inline helper To: Daniel Vetter Cc: Daniel Vetter , Intel Graphics Development In-Reply-To: <20121010091538.GB5533@phenom.ffwll.local> References: <84c8a8$624sk4@orsmga001.jf.intel.com> <1349815848-1824-1-git-send-email-daniel.vetter@ffwll.ch> <6c3329$6m595h@orsmga002.jf.intel.com> <453bf0$61a4mf@azsmga001.ch.intel.com> <20121010091538.GB5533@phenom.ffwll.local> On Wed, 10 Oct 2012 11:15:38 +0200, Daniel Vetter wrote: > On Wed, Oct 10, 2012 at 10:01:47AM +0100, Chris Wilson wrote: > > On Tue, 09 Oct 2012 23:16:02 +0100, Chris Wilson wrote: > > > On Tue, 9 Oct 2012 22:50:48 +0200, Daniel Vetter wrote: > > > > The obj->pages to obj->pages->sgl rework introduced this helper, but > > > > it doesn't actually work for n >= SG_MAX_SINGLE_ALLOC. > > > > > > > > For simplicity (and since right now I seem to be too stupid to see > > > > the bug), let's just grab the right page with a for_each_sg loop. > > > > > > > > This is exercised by the improved hangman tests and the gem_exec_big > > > > test in i-g-t. > > > > > > > > v2: Compared to v1, don't try to be clever since I seemingly only > > > > manage to prove that I'm not clever. > > > > > > Only I expect that loop to show up on profiles even higher than the > > > sg_next() from pwrite. :| > > > > > > I expect it to have a measureable impact upon relocation throughput, > > > so I should measure it... > > > -Chris > > > > > > -- > > > Chris Wilson, Intel Open Source Technology Centre > > > _______________________________________________ > > > Intel-gfx mailing list > > > Intel-gfx@lists.freedesktop.org > > > http://lists.freedesktop.org/mailman/listinfo/intel-gfx > > From: Chris Wilson > > Subject: Re: [PATCH] drm/i915: fixup i915_gem_object_get_page inline helper > > To: Daniel Vetter , Intel Graphics Development > > Cc: Daniel Vetter > > In-Reply-To: <1349815848-1824-1-git-send-email-daniel.vetter@ffwll.ch> > > References: <84c8a8$624sk4@orsmga001.jf.intel.com> <1349815848-1824-1-git-send-email-daniel.vetter@ffwll.ch> > > > > On Tue, 9 Oct 2012 22:50:48 +0200, Daniel Vetter wrote: > > > The obj->pages to obj->pages->sgl rework introduced this helper, but > > > it doesn't actually work for n >= SG_MAX_SINGLE_ALLOC. > > > > > > For simplicity (and since right now I seem to be too stupid to see > > > the bug), let's just grab the right page with a for_each_sg loop. > > > > > > This is exercised by the improved hangman tests and the gem_exec_big > > > test in i-g-t. > > > > > > v2: Compared to v1, don't try to be clever since I seemingly only > > > manage to prove that I'm not clever. > > > > > > Signed-off-by: Daniel Vetter > > > > Looks like my worries are baseless. It can always be attacked latter if > > need be. I'd still like to know what the mistake was... > > I think it was two mistakes: > - One was the off-by-one fixed in v1. > - Second seemed to be the special case that if the table fits exactly, > sg_alloc doesn't set a chain ptr with another sg table with just one > entry. That oddity is the reason why the loop was structured so. The mistake is that just because we have n == MAX, does not mean that there are only n elements left in the sg! *hides* -Chris diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index d2dda78..e6707e7 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -1383,9 +1383,14 @@ int __must_check i915_gem_object_get_pages(struct drm_i91 static inline struct page *i915_gem_object_get_page(struct drm_i915_gem_object { struct scatterlist *sg = obj->pages->sgl; - while (n >= SG_MAX_SINGLE_ALLOC) { + int nents = obj->pages->orig; + while (nents > SG_MAX_SINGLE_ALLOC) { + if (n < SG_MAX_SINGLE_ALLOC - 1) + break; + sg = sg_chain_ptr(sg + SG_MAX_SINGLE_ALLOC - 1); n -= SG_MAX_SINGLE_ALLOC - 1; + nents -= SG_MAX_SINGLE_ALLOC - 1; } return sg_page(sg+n); }