diff mbox

[1/2] drm/i915: Introduce execlist_port_* accessors

Message ID 87h8ucephj.fsf@gaia.fi.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Mika Kuoppala Nov. 2, 2017, 2:15 p.m. UTC
Mika Kuoppala <mika.kuoppala@linux.intel.com> writes:

> Chris Wilson <chris@chris-wilson.co.uk> writes:
>
>> Quoting Mika Kuoppala (2017-11-02 10:38:30)
>>> Chris Wilson <chris@chris-wilson.co.uk> writes:
>>> 
>>> > Quoting Mika Kuoppala (2017-10-31 15:27:33)
>>> >> +static inline struct execlist_port *
>>> >> +execlists_port_next(struct intel_engine_execlists * const execlists,
>>> >> +                   const struct execlist_port * const port)
>>> >> +{
>>> >> +       const unsigned int n = __port_add(port_index(port, execlists),
>>> >> +                                         1,
>>> >> +                                         execlists->port_mask);
>>> >
>>> > How does this compare to
>>> >
>>> >       if (port++ == execlists->port + execlists->port_mask)
>>> >               port = execlists->port;
>>> >
>>> >       return port;
>>> > ?
>>> 
>>> add/remove: 0/0 grow/shrink: 1/1 up/down: 29/-29 (0)
>>> function                                     old     new   delta
>>> i915_guc_irq_handler                        2584    2613     +29
>>> intel_lrc_irq_handler                       2963    2934     -29
>>> Total: Before=1123627, After=1123627, chg +0.00%
>>
>> Hmm, your functions saw little difference and are twice as big as
>> mine... Weird.
>>
>> I used gcc version 6.3.0 20170516 (Debian 6.3.0-18) with defconfig.
>> Yourself?
>
> I had debugs on, sigh...
>
> Now with the defconfig and gcc (Ubuntu 6.3.0-12ubuntu2) 6.3.0 20170406:
>
> add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-139 (-139)
> function                                     old     new   delta
> i915_guc_irq_handler                        1620    1617      -3
> intel_lrc_irq_handler                       1926    1790    -136
>
> So we have a clear winner.
>

And to be precise on what diff lead to above:


> -Mika
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.h b/drivers/gpu/drm/i915/intel_ringbuffer.h
index 387667fe50d3..9131d66fb628 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.h
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.h
@@ -599,12 +599,12 @@  execlists_port_tail(struct intel_engine_execlists * const execlists)
 
 static inline struct execlist_port *
 execlists_port_next(struct intel_engine_execlists * const execlists,
-                   const struct execlist_port * const port)
+                   struct execlist_port *port)
 {
-       const unsigned int n = __port_add(port_index(port, execlists),
-                                         1,
-                                         execlists->port_mask);
-       return &execlists->port[n];
+       if (port++ == execlists->port + execlists->port_mask)
+               port = execlists->port;
+
+       return port;
 }