[11/11] drm/i915: Use __ffs() in for_each_priolist for more compact code
diff mbox series

Message ID 20190226102404.29153-11-chris@chris-wilson.co.uk
State New
Headers show
Series
  • [01/11] drm/i915: Skip scanning for signalers if we are already inflight
Related show

Commit Message

Chris Wilson Feb. 26, 2019, 10:24 a.m. UTC
Gcc has a slight preference if we use __ffs() to subtract one from the
index once rather than each use:

__execlists_submission_tasklet              2867    2847     -20

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_scheduler.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Tvrtko Ursulin Feb. 28, 2019, 7:42 a.m. UTC | #1
On 26/02/2019 10:24, Chris Wilson wrote:
> Gcc has a slight preference if we use __ffs() to subtract one from the
> index once rather than each use:
> 
> __execlists_submission_tasklet              2867    2847     -20
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---
>   drivers/gpu/drm/i915/i915_scheduler.h | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_scheduler.h b/drivers/gpu/drm/i915/i915_scheduler.h
> index 24c2c027fd2c..068a6750540f 100644
> --- a/drivers/gpu/drm/i915/i915_scheduler.h
> +++ b/drivers/gpu/drm/i915/i915_scheduler.h
> @@ -100,9 +100,11 @@ struct i915_priolist {
>   		list_for_each_entry(it, &(plist)->requests[idx], sched.link)
>   
>   #define priolist_for_each_request_consume(it, n, plist, idx) \
> -	for (; (idx = ffs((plist)->used)); (plist)->used &= ~BIT(idx - 1)) \
> +	for (; \
> +	     (plist)->used ? (idx = __ffs((plist)->used)), 1 : 0; \
> +	     (plist)->used &= ~BIT(idx)) \
>   		list_for_each_entry_safe(it, n, \
> -					 &(plist)->requests[idx - 1], \
> +					 &(plist)->requests[idx], \
>   					 sched.link)
>   
>   void i915_sched_node_init(struct i915_sched_node *node);
> 

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

Regards,

Tvrtko

Patch
diff mbox series

diff --git a/drivers/gpu/drm/i915/i915_scheduler.h b/drivers/gpu/drm/i915/i915_scheduler.h
index 24c2c027fd2c..068a6750540f 100644
--- a/drivers/gpu/drm/i915/i915_scheduler.h
+++ b/drivers/gpu/drm/i915/i915_scheduler.h
@@ -100,9 +100,11 @@  struct i915_priolist {
 		list_for_each_entry(it, &(plist)->requests[idx], sched.link)
 
 #define priolist_for_each_request_consume(it, n, plist, idx) \
-	for (; (idx = ffs((plist)->used)); (plist)->used &= ~BIT(idx - 1)) \
+	for (; \
+	     (plist)->used ? (idx = __ffs((plist)->used)), 1 : 0; \
+	     (plist)->used &= ~BIT(idx)) \
 		list_for_each_entry_safe(it, n, \
-					 &(plist)->requests[idx - 1], \
+					 &(plist)->requests[idx], \
 					 sched.link)
 
 void i915_sched_node_init(struct i915_sched_node *node);