From: John Harrison <John.C.Harrison@Intel.com>
To: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>,
Intel-GFX@Lists.FreeDesktop.Org
Subject: Re: [PATCH 13/13] drm/i915: Cache last IRQ seqno to reduce IRQ overhead
Date: Mon, 14 Dec 2015 11:58:19 +0000 [thread overview]
Message-ID: <566EAEDB.4080403@Intel.com> (raw)
In-Reply-To: <566ADD70.4030201@linux.intel.com>
On 11/12/2015 14:28, Tvrtko Ursulin wrote:
> On 11/12/15 13:12, John.C.Harrison@Intel.com wrote:
>> From: John Harrison <John.C.Harrison@Intel.com>
>>
>> The notify function can be called many times without the seqno
>> changing. A large number of duplicates are to prevent races due to the
>> requirement of not enabling interrupts until requested. However, when
>> interrupts are enabled the IRQ handle can be called multiple times
>> without the ring's seqno value changing. This patch reduces the
>> overhead of these extra calls by caching the last processed seqno
>> value and early exiting if it has not changed.
>>
>> v3: New patch for series.
>>
>> For: VIZ-5190
>> Signed-off-by: John Harrison <John.C.Harrison@Intel.com>
>> ---
>> drivers/gpu/drm/i915/i915_gem.c | 14 +++++++++++---
>> drivers/gpu/drm/i915/intel_ringbuffer.h | 1 +
>> 2 files changed, 12 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/i915/i915_gem.c
>> b/drivers/gpu/drm/i915/i915_gem.c
>> index 279d79f..3c88678 100644
>> --- a/drivers/gpu/drm/i915/i915_gem.c
>> +++ b/drivers/gpu/drm/i915/i915_gem.c
>> @@ -2457,6 +2457,8 @@ i915_gem_init_seqno(struct drm_device *dev, u32
>> seqno)
>>
>> for (j = 0; j < ARRAY_SIZE(ring->semaphore.sync_seqno); j++)
>> ring->semaphore.sync_seqno[j] = 0;
>> +
>> + ring->last_irq_seqno = 0;
>> }
>>
>> return 0;
>> @@ -2788,11 +2790,14 @@ void i915_gem_request_notify(struct
>> intel_engine_cs *ring, bool fence_locked)
>> return;
>> }
>>
>> - if (!fence_locked)
>> - spin_lock_irqsave(&ring->fence_lock, flags);
>> -
>> seqno = ring->get_seqno(ring, false);
>> trace_i915_gem_request_notify(ring, seqno);
>> + if (seqno == ring->last_irq_seqno)
>> + return;
>> + ring->last_irq_seqno = seqno;
>
> Hmmm.. do you want to make the check "seqno <= ring->last_irq_seqno" ?
>
> Is there a possibility for some weird timing or caching issue where
> two callers get in and last_irq_seqno goes backwards? Not sure that it
> would cause a problem, but pattern is unusual and hard to understand
> for me.
The check is simply to prevent repeat processing of identical seqno
values. The 'last_' value is never used for anything more complicated.
If there is a very rare race condition where the repeat processing can
still happen, it doesn't really matter too much.
> Also check and the assignment would need to be under the spinlock I
> think.
The whole point is to not grab the spinlock if there is no work to do.
Hence the seqno read and test must be done first. The assignment could
potentially be done after the lock but if two different threads have
made it that far concurrently then it doesn't really matter who does the
write first. Most likely they are both processing the same seqno and in
the really rare case of two concurrent threads actually reading two
different (and both new) seqno values then there is no guarantee about
which will take the lock first. So you are into the above situation of
it doesn't really matter if there is then a third time around later that
finds an 'incorrect' last value and goes through the processing sequence
but with no work to do.
>> +
>> + if (!fence_locked)
>> + spin_lock_irqsave(&ring->fence_lock, flags);
>>
>> list_for_each_entry_safe(req, req_next,
>> &ring->fence_signal_list, signal_link) {
>> if (!req->cancelled) {
>> @@ -3163,7 +3168,10 @@ static void i915_gem_reset_ring_cleanup(struct
>> drm_i915_private *dev_priv,
>> * Tidy up anything left over. This includes a call to
>> * i915_gem_request_notify() which will make sure that any
>> requests
>> * that were on the signal pending list get also cleaned up.
>> + * NB: The seqno cache must be cleared otherwise the notify call
>> will
>> + * simply return immediately.
>> */
>> + ring->last_irq_seqno = 0;
>> i915_gem_retire_requests_ring(ring);
>>
>> /* Having flushed all requests from all queues, we know that all
>> diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.h
>> b/drivers/gpu/drm/i915/intel_ringbuffer.h
>> index 9d09edb..1987abd 100644
>> --- a/drivers/gpu/drm/i915/intel_ringbuffer.h
>> +++ b/drivers/gpu/drm/i915/intel_ringbuffer.h
>> @@ -356,6 +356,7 @@ struct intel_engine_cs {
>> spinlock_t fence_lock;
>> struct list_head fence_signal_list;
>> struct list_head fence_unsignal_list;
>> + uint32_t last_irq_seqno;
>> };
>>
>> bool intel_ring_initialized(struct intel_engine_cs *ring);
>>
>
> Regards,
>
> Tvrtko
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2015-12-14 11:58 UTC|newest]
Thread overview: 74+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-11 13:11 [PATCH 00/13] Convert requests to use struct fence John.C.Harrison
2015-12-11 13:11 ` [PATCH 01/13] staging/android/sync: Support sync points created from dma-fences John.C.Harrison
2015-12-17 17:32 ` [Intel-gfx] " Jesse Barnes
2015-12-11 13:11 ` [PATCH 02/13] staging/android/sync: add sync_fence_create_dma John.C.Harrison
2015-12-17 17:29 ` Jesse Barnes
2015-12-11 13:11 ` [PATCH 03/13] staging/android/sync: Move sync framework out of staging John.C.Harrison
2015-12-17 17:35 ` Jesse Barnes
2015-12-21 10:03 ` Daniel Vetter
2015-12-21 14:20 ` John Harrison
2015-12-21 15:46 ` Daniel Vetter
2015-12-22 12:14 ` John Harrison
2015-12-11 13:11 ` [PATCH 04/13] android/sync: Improved debug dump to dmesg John.C.Harrison
2015-12-17 17:36 ` Jesse Barnes
2015-12-11 13:11 ` [PATCH 05/13] drm/i915: Convert requests to use struct fence John.C.Harrison
2015-12-17 17:43 ` Jesse Barnes
2016-01-04 17:20 ` Jesse Barnes
2016-01-04 20:57 ` Chris Wilson
2016-01-04 21:16 ` Jesse Barnes
2016-01-08 21:47 ` Chris Wilson
2016-01-08 21:55 ` Jesse Barnes
2015-12-11 13:11 ` [PATCH 06/13] drm/i915: Removed now redudant parameter to i915_gem_request_completed() John.C.Harrison
2015-12-11 13:11 ` [PATCH 07/13] drm/i915: Add per context timelines to fence object John.C.Harrison
2015-12-17 17:49 ` Jesse Barnes
2015-12-21 10:16 ` Chris Wilson
2015-12-11 13:11 ` [PATCH 08/13] drm/i915: Delay the freeing of requests until retire time John.C.Harrison
2015-12-11 13:11 ` [PATCH 09/13] drm/i915: Interrupt driven fences John.C.Harrison
2015-12-11 15:30 ` John Harrison
2015-12-11 16:07 ` Tvrtko Ursulin
2015-12-11 13:11 ` [PATCH 10/13] drm/i915: Updated request structure tracing John.C.Harrison
2015-12-11 13:11 ` [PATCH 11/13] android/sync: Fix reversed sense of signaled fence John.C.Harrison
2015-12-11 15:57 ` Tvrtko Ursulin
2015-12-14 11:22 ` John Harrison
2015-12-14 12:37 ` Tvrtko Ursulin
2015-12-11 13:12 ` [PATCH 12/13] drm/i915: Add sync framework support to execbuff IOCTL John.C.Harrison
2015-12-11 15:29 ` Tvrtko Ursulin
2015-12-14 11:46 ` John Harrison
2015-12-14 12:23 ` Chris Wilson
2015-12-11 13:12 ` [PATCH 13/13] drm/i915: Cache last IRQ seqno to reduce IRQ overhead John.C.Harrison
2015-12-11 14:28 ` Tvrtko Ursulin
2015-12-14 11:58 ` John Harrison [this message]
2015-12-14 12:52 ` Tvrtko Ursulin
2015-12-11 14:55 ` Chris Wilson
2015-12-11 15:35 ` John Harrison
2015-12-11 16:07 ` Chris Wilson
2016-01-08 18:47 ` [PATCH 0/7] Convert requests to use struct fence John.C.Harrison
2016-01-08 18:47 ` [PATCH 1/7] drm/i915: " John.C.Harrison
2016-01-08 21:59 ` Chris Wilson
2016-01-11 19:03 ` John Harrison
2016-01-11 22:41 ` Jesse Barnes
2016-01-08 18:47 ` [PATCH 2/7] drm/i915: Removed now redudant parameter to i915_gem_request_completed() John.C.Harrison
2016-01-11 22:43 ` Jesse Barnes
2016-01-08 18:47 ` [PATCH 3/7] drm/i915: Add per context timelines to fence object John.C.Harrison
2016-01-08 22:05 ` Chris Wilson
2016-01-11 19:03 ` John Harrison
2016-01-11 22:47 ` Jesse Barnes
2016-01-11 22:58 ` Chris Wilson
2016-01-12 11:03 ` John Harrison
2016-01-12 11:26 ` Chris Wilson
2016-01-08 18:47 ` [PATCH 4/7] drm/i915: Delay the freeing of requests until retire time John.C.Harrison
2016-01-08 22:08 ` Chris Wilson
2016-01-11 19:06 ` John Harrison
2016-01-25 11:52 ` Maarten Lankhorst
2016-01-25 12:11 ` Chris Wilson
2016-01-08 18:47 ` [PATCH 5/7] drm/i915: Interrupt driven fences John.C.Harrison
2016-01-08 22:14 ` Chris Wilson
2016-01-09 0:30 ` Chris Wilson
2016-01-08 22:46 ` Chris Wilson
2016-01-11 19:10 ` John Harrison
2016-01-11 23:01 ` Jesse Barnes
2016-01-08 18:47 ` [PATCH 6/7] drm/i915: Updated request structure tracing John.C.Harrison
2016-01-08 22:16 ` Chris Wilson
2016-01-08 18:47 ` [PATCH 7/7] drm/i915: Cache last IRQ seqno to reduce IRQ overhead John.C.Harrison
2016-01-08 22:47 ` [PATCH 0/7] Convert requests to use struct fence Chris Wilson
2016-01-11 19:15 ` John Harrison
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=566EAEDB.4080403@Intel.com \
--to=john.c.harrison@intel.com \
--cc=Intel-GFX@Lists.FreeDesktop.Org \
--cc=tvrtko.ursulin@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).