From: Chris Wilson Date: Tue, 26 Feb 2019 10:24:04 +0000 (+0000) Subject: drm/i915: Use __ffs() in for_each_priolist for more compact code X-Git-Tag: v5.2-rc1~48^2~40^2~152 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=bd5d6781a0f1b9be8c26da78c0e3110e7481b45b;p=uclinux-h8%2Flinux.git drm/i915: Use __ffs() in for_each_priolist for more compact code 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 Reviewed-by: Tvrtko Ursulin Link: https://patchwork.freedesktop.org/patch/msgid/20190226102404.29153-11-chris@chris-wilson.co.uk --- diff --git a/drivers/gpu/drm/i915/i915_scheduler.h b/drivers/gpu/drm/i915/i915_scheduler.h index 4153c6a607b0..bb3d496d4c49 100644 --- a/drivers/gpu/drm/i915/i915_scheduler.h +++ b/drivers/gpu/drm/i915/i915_scheduler.h @@ -95,9 +95,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);