From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Vetter Subject: Re: [PATCH] drm/i915: Record the tail at each request and use it to estimate the head Date: Wed, 8 Feb 2012 19:28:28 +0100 Message-ID: <20120208182828.GG5030@phenom.ffwll.local> References: <20120208145149.GC5030@phenom.ffwll.local> <1328724390-28037-1-git-send-email-chris@chris-wilson.co.uk> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail-ww0-f43.google.com (mail-ww0-f43.google.com [74.125.82.43]) by gabe.freedesktop.org (Postfix) with ESMTP id A33C79E730 for ; Wed, 8 Feb 2012 10:28:18 -0800 (PST) Received: by wgbdr13 with SMTP id dr13so690687wgb.12 for ; Wed, 08 Feb 2012 10:28:17 -0800 (PST) Content-Disposition: inline In-Reply-To: <1328724390-28037-1-git-send-email-chris@chris-wilson.co.uk> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org To: Chris Wilson Cc: intel-gfx@lists.freedesktop.org List-Id: intel-gfx@lists.freedesktop.org On Wed, Feb 08, 2012 at 06:06:30PM +0000, Chris Wilson wrote: > By recording the location of every request in the ringbuffer, we know > that in order to retire the request the GPU must have finished reading > it and so the GPU head is now beyond the tail of the request. We can > therefore provide a conservative estimate of where the GPU is reading > from in order to avoid having to read back the ring buffer registers > when polling for space upon starting a new write into the ringbuffer. > > A secondary effect is that this allows us to convert > intel_ring_buffer_wait() to use i915_wait_request() and so consolidate > upon the single function to handle the complicated task of waiting upon > the GPU. A necessary precaution is that we need to make that wait > uninterruptible to match the existing conditions as all the callers of > intel_ring_begin() have not been audited to handle ERESTARTSYS > correctly. > > By using a conservative estimate for the head, and always processing all > outstanding requests first, we prevent a race condition between using > the estimate and direct reads of I915_RING_HEAD which could result in > the value of the head going backwards, and the tail overflowing once > again. We are also careful to mark any request that we skip over in > order to free space in ring as consumed which provides a > self-consistency check. > > Given sufficient abuse, such as a set of unthrottled GPU bound > cairo-traces, avoiding the use of I915_RING_HEAD gives a 10-20% boost on > Sandy Bridge (i5-2520m): > firefox-paintball 18927ms -> 15646ms: 1.21x speedup > firefox-fishtank 12563ms -> 11278ms: 1.11x speedup > which is a mild consolation for the performance those traces achieved from > exploiting the buggy autoreported head. > > v2: Add a few more comments and make request->tail a conservative > estimate as suggested by Daniel Vetter. > > Signed-off-by: Chris Wilson Reviewed-by: Daniel Vetter -- Daniel Vetter Mail: daniel@ffwll.ch Mobile: +41 (0)79 365 57 48