Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753224AbbGaQ2N (ORCPT ); Fri, 31 Jul 2015 12:28:13 -0400 Received: from smtp-out4.electric.net ([192.162.216.182]:64760 "EHLO smtp-out4.electric.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751687AbbGaQ2M convert rfc822-to-8bit (ORCPT ); Fri, 31 Jul 2015 12:28:12 -0400 From: David Laight To: "'Murali Karicheri'" , Viresh Kumar , "akpm@linux-foundation.org" CC: "linaro-kernel@lists.linaro.org" , "linux-kernel@vger.kernel.org" , "TI NETCP ETHERNET DRIVER" , Wingman Kwok Subject: RE: [PATCH 08/15] drivers: net: Drop unlikely before IS_ERR(_OR_NULL) Thread-Topic: [PATCH 08/15] drivers: net: Drop unlikely before IS_ERR(_OR_NULL) Thread-Index: AQHQy6IGXqinzt+ZWUC8nGLxOsGQ3p31tTZg Date: Fri, 31 Jul 2015 15:39:56 +0000 Message-ID: <063D6719AE5E284EB5DD2968C1650D6D1CB71042@AcuExch.aculab.com> References: <55BB8E7B.7050307@ti.com> In-Reply-To: <55BB8E7B.7050307@ti.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.202.99.200] Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-Outbound-IP: 213.249.233.130 X-Env-From: David.Laight@ACULAB.COM X-PolicySMART: 3396946, 3397078 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1099 Lines: 36 From: Murali Karicheri > Sent: 31 July 2015 16:04 > On 07/31/2015 04:38 AM, Viresh Kumar wrote: > > 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/