[Intel-gfx] [PATCH 02/31] drm/i915: Prefer list_first_entry_or_null

Chris Wilson chris at chris-wilson.co.uk
Mon Jul 25 08:03:35 UTC 2016


On Mon, Jul 25, 2016 at 10:55:24AM +0300, Joonas Lahtinen wrote:
> On ma, 2016-07-25 at 08:44 +0100, Chris Wilson wrote:
> > list_first_entry_or_null() can generate better code than using
> > if (!list_empty()) {ptr = list_first_entry()) ..., so put it to use.
> > 
> > Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> 
> It looks cleaner, not so sure of the code impact.

After the patch I sent to linux-kernel@ to improve code gneration for
list_first_entry_or_null() is applied we save a few bytes on each
invocation.

There are a few other places where I could have used
list_first_entry_or_null() but I have already sent patches transforming
the code so I didn't bother with the intermediate minor improvement.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


More information about the Intel-gfx mailing list