All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH v2] drm/i915/breadcrumbs: Drop request reference for the signaler thread
Date: Mon, 5 Feb 2018 13:45:16 +0000	[thread overview]
Message-ID: <e497e551-5905-5557-4a41-79cc88415012@linux.intel.com> (raw)
In-Reply-To: <151783779666.15322.2777983453531447737@mail.alporthouse.com>


On 05/02/2018 13:36, Chris Wilson wrote:
> Quoting Tvrtko Ursulin (2018-02-05 13:23:54)
>>
>> On 03/02/2018 10:19, Chris Wilson wrote:
>>> @@ -656,41 +705,21 @@ static int intel_breadcrumbs_signaler(void *arg)
>>>                 * a new client.
>>>                 */
>>>                rcu_read_lock();
>>> -             request = rcu_dereference(b->first_signal);
>>> -             if (request)
>>> -                     request = i915_gem_request_get_rcu(request);
>>> +             request = get_first_signal_rcu(b);
>>>                rcu_read_unlock();
>>>                if (signal_complete(request)) {
>>> -                     local_bh_disable();
>>> -                     dma_fence_signal(&request->fence);
>>> -                     local_bh_enable(); /* kick start the tasklets */
>>> -
>>> -                     spin_lock_irq(&b->rb_lock);
>>> -
>>> -                     /* Wake up all other completed waiters and select the
>>> -                      * next bottom-half for the next user interrupt.
>>> -                      */
>>> -                     __intel_engine_remove_wait(engine,
>>> -                                                &request->signaling.wait);
>>> -
>>> -                     /* Find the next oldest signal. Note that as we have
>>> -                      * not been holding the lock, another client may
>>> -                      * have installed an even older signal than the one
>>> -                      * we just completed - so double check we are still
>>> -                      * the oldest before picking the next one.
>>> -                      */
>>> -                     if (request == rcu_access_pointer(b->first_signal)) {
>>> -                             struct rb_node *rb =
>>> -                                     rb_next(&request->signaling.node);
>>> -                             rcu_assign_pointer(b->first_signal,
>>> -                                                rb ? to_signaler(rb) : NULL);
>>> +                     if (!test_bit(DMA_FENCE_FLAG_SIGNALED_BIT,
>>> +                                   &request->fence.flags)) {
>>> +                             local_bh_disable();
>>> +                             dma_fence_signal(&request->fence);
>>> +                             local_bh_enable(); /* kick start the tasklets */
>>>                        }
>>> -                     rb_erase(&request->signaling.node, &b->signals);
>>> -                     RB_CLEAR_NODE(&request->signaling.node);
>>> -
>>> -                     spin_unlock_irq(&b->rb_lock);
>>>    
>>> -                     i915_gem_request_put(request);
>>> +                     if (READ_ONCE(request->signaling.wait.seqno)) {
>>> +                             spin_lock_irq(&b->rb_lock);
>>> +                             __intel_engine_remove_signal(engine, request);
>>> +                             spin_unlock_irq(&b->rb_lock);
>>> +                     }
>>
>> How would you view taking the request->lock over this block in the
>> signaler and then being able to call simply
>> intel_engine_cancel_signaling - ending up with very similar code as in
>> i915_gem_request_retire?
> 
> I am not keen on the conflation here (maybe it's just a hatred of bool
> parameters). But at first glance it's just the commonality of
> remove_signal, which is already a common routine?
> 
>> Only difference would be the tasklet kicking, but maybe still it would
>> be possible to consolidate the two in one helper.
>>
>> __i915_gem_request_retire_signaling(req, bool kick_tasklets)
>> {
>>          if (!DMA_FENCE_FLAG_SIGNALED_BIT) {
>>                  dma_fence_signal_locked(...);
>>                  if (kick_tasklets) {
>>                          local_bh_disable();
>>                          local_bh_enable();
>>                  }
> 
> We can't kick the tasklet inside a spinlock. Especially not a lockclass
> as nested as request.lock :(

Yep bool is ugly. So maybe make the helper return status, so the caller 
can kick if fence was signaled? Or you would worry about losing a little 
bit of latency? That also is not ideal I agree.

Too bad, I would kind of like to consolidate if nothing to be 
symmetrical wrt req->lock usage.

Otherwise patch looks safe to me. At least I failed to find any problems.

Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Regards,

Tvrtko
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2018-02-05 13:45 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-22 15:41 [PATCH] drm/i915/breadcrumbs: Drop request reference for the signaler thread Chris Wilson
2018-01-22 16:07 ` ✗ Fi.CI.BAT: warning for " Patchwork
2018-01-22 19:01 ` ✓ Fi.CI.BAT: success " Patchwork
2018-01-23  0:03 ` ✗ Fi.CI.IGT: failure " Patchwork
2018-01-24 13:09 ` [PATCH] " Tvrtko Ursulin
2018-01-24 14:44   ` Chris Wilson
2018-01-26  9:42     ` Chris Wilson
2018-01-31 10:02 ` Chris Wilson
2018-01-31 17:18 ` Tvrtko Ursulin
2018-01-31 17:30   ` Chris Wilson
2018-01-31 20:40     ` Chris Wilson
2018-01-31 20:43       ` Chris Wilson
2018-02-03 10:19   ` [PATCH v2] " Chris Wilson
2018-02-05 13:23     ` Tvrtko Ursulin
2018-02-05 13:36       ` Chris Wilson
2018-02-05 13:39         ` Chris Wilson
2018-02-05 13:45         ` Tvrtko Ursulin [this message]
2018-02-05 16:11           ` Chris Wilson
2018-02-03 10:40 ` ✓ Fi.CI.BAT: success for drm/i915/breadcrumbs: Drop request reference for the signaler thread (rev2) Patchwork
2018-02-03 11:32 ` ✗ Fi.CI.IGT: failure " Patchwork
2018-02-05 16:09   ` Chris Wilson

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=e497e551-5905-5557-4a41-79cc88415012@linux.intel.com \
    --to=tvrtko.ursulin@linux.intel.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.