Thread (5 messages) 5 messages, 3 authors, 2015-08-03

RE: [PATCH 08/15] drivers: net: Drop unlikely before IS_ERR(_OR_NULL)

From: David Laight <hidden>
Date: 2015-07-31 16:28:13
Also in: lkml

From: Murali Karicheri
Sent: 31 July 2015 16:04
On 07/31/2015 04:38 AM, Viresh Kumar wrote:
quoted
IS_ERR(_OR_NULL) already contain an 'unlikely' compiler flag and there
is no need to do that again from its callers. Drop it.
IS_ERR_OR_NULL() is defined as

static inline bool __must_check IS_ERR_OR_NULL(__force const void *ptr)
{
         return !ptr || IS_ERR_VALUE((unsigned long)ptr);
}

So the unlikely() applies only to second part. Wouldn't that be a
problem for optimization?
Ugg...

The unlikely() in IS_ERR_VALUE() is likely to stop the compiler
doing a single 'window' comparison for the range [-MAX_ERROR .. 0].
So you are likely to end up with 2 comparisons.
I suspect that:

	return IS_ERR_VALUE((unsigned long)ptr - 1);

would be a much better test.
(Ignoring the off-by-one for the highest error.)

	David
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help