From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752877AbcD1Q1v (ORCPT ); Thu, 28 Apr 2016 12:27:51 -0400 Received: from mail-bn1bn0107.outbound.protection.outlook.com ([157.56.110.107]:10704 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752211AbcD1Q1t (ORCPT ); Thu, 28 Apr 2016 12:27:49 -0400 From: Quinn Tran To: Josh Poimboeuf , Arnd Bergmann CC: Martin Jambor , "Martin K. Petersen" , James Bottomley , linux-scsi , linux-kernel , Denys Vlasenko , Thomas Graf , "Peter Zijlstra" , David Rientjes , "Andrew Morton" , Ingo Molnar , "Himanshu Madhani" , Dept-Eng QLA2xxx Upstream , Jan Hubicka Subject: Re: [PATCH, RFT] byteswap: try to avoid __builtin_constant_p gcc bug Thread-Topic: [PATCH, RFT] byteswap: try to avoid __builtin_constant_p gcc bug Thread-Index: AQHRoNBhxj/ZVaT2NkGM7i6q2ZMPYZ+eYbyAgAC9EYA= Date: Thu, 28 Apr 2016 16:27:41 +0000 Message-ID: <0BE93A68-5E0C-4372-B04E-B3209F7515D1@qlogic.com> References: <20160419085221.GA29087@gmail.com> <5298237.1Guzp0G04x@wuerfel> <20160427110503.GB24887@virgil.suse.cz> <25937441.NbUvhTZ9vo@wuerfel> <20160427221101.hiyc7ensow667sk6@treble> In-Reply-To: <20160427221101.hiyc7ensow667sk6@treble> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Microsoft-MacOutlook/0.0.0.160212 authentication-results: redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=none action=none header.from=qlogic.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [198.186.0.2] x-ms-office365-filtering-correlation-id: 08804410-5ee1-4b21-860b-08d36f8205be x-microsoft-exchange-diagnostics: 1;CO2PR11MB0103;5:zHB1852qjZbs6Vu8OJeE1rtHTLwdo5332yW7kAGtEKHHNMGg+gZByE6v6FRJojzEwMFESeNjrfkusDGbzelR6c/HJmYGy2pxYtkqGLZKVoFaB0ybamss9i5SXV0fp4QPskwpI6nfT43GalcBvFxQkw==;24:udobk8IKI0l3JYQUApYtdmNEq9UpKO5n87kpwMEJeXF77wPHXr9Aa0CmNDjXYkETX1sfmgWFwHNxfkLxCdJ3BPl5x45bswMiyZuFXpr3+Hs=;7:OP8WMOljf70NqN7mEiyAk4sdaL5fcz6Ebj6F+FegekVHcgIq/6Hk/DJFzM0n99+yCb1N/pOgqQz1HuLSSxIVgIQmMhfXy1qEZevuduBK8YRcbpHQEF3glU5a24kM1/xo7W3ZIuQJTdnL/PfpBuBwKddq+rJ3cmZ1w7pP5Afcalr6jFclKxC/sqOoeizIUOhl;20:A5/DsXjLUSFMk3gWSl3XyhwVlAf7oskZcbOHgaFbXUPXcwP5tqaKCmvoP3dPBYRdqz03fB3dWRd4yn/8r9I3xRxZwX8n/UdCIM5Yc+herUFVfR+LjQfjToJc+9hja4Xm8vAyBBp8GWS5ISm+SsSjS8xS9Ja/41jeWZ3UlCgxLZc= x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CO2PR11MB0103; x-ld-processed: 0d68a1f9-1490-4d0e-8767-a87dab3ef2ba,ExtAddr x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(9101521072)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046);SRVR:CO2PR11MB0103;BCL:0;PCL:0;RULEID:;SRVR:CO2PR11MB0103; x-forefront-prvs: 0926B0E013 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(377454003)(24454002)(13464003)(87936001)(81166005)(1220700001)(2906002)(66066001)(1096002)(3660700001)(86362001)(93886004)(3846002)(6116002)(586003)(102836003)(82746002)(33656002)(4326007)(122556002)(77096005)(5004730100002)(3280700002)(83716003)(5008740100001)(99286002)(5001770100001)(5002640100001)(4001350100001)(189998001)(92566002)(54356999)(36756003)(2950100001)(76176999)(15975445007)(19580395003)(50986999)(2900100001)(19580405001)(83506001)(106116001)(10400500002)(104396002);DIR:OUT;SFP:1102;SCL:1;SRVR:CO2PR11MB0103;H:SN1PR11MB0655.namprd11.prod.outlook.com;FPR:;SPF:None;MLV:sfv;LANG:en; spamdiagnosticoutput: 1:23 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="utf-8" Content-ID: <99228F48CF53F44AB1945FE7E2A2E13A@namprd11.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: qlogic.com X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Apr 2016 16:27:41.5549 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 0d68a1f9-1490-4d0e-8767-a87dab3ef2ba X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO2PR11MB0103 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id u3SGRulu029024 -----Original Message----- From: on behalf of Josh Poimboeuf Date: Wednesday, April 27, 2016 at 3:11 PM To: Arnd Bergmann Cc: Martin Jambor , "Martin K. Petersen" , James Bottomley , linux-scsi , linux-kernel , Denys Vlasenko , Thomas Graf , Peter Zijlstra , David Rientjes , Andrew Morton , Ingo Molnar , Himanshu Madhani , Dept-Eng QLA2xxx Upstream , Jan Hubicka Subject: Re: [PATCH, RFT] byteswap: try to avoid __builtin_constant_p gcc bug >On Thu, Apr 28, 2016 at 12:00:36AM +0200, Arnd Bergmann wrote: >> This is another attempt to avoid a regression in wwn_to_u64() >> after that started using get_unaligned_be64(), which in turn >> ran into a bug on gcc-4.9 through 6.1. >> >> As part of the problem is how __builtin_constant_p gets evaluated >> on an argument passed by reference into an inline function, this >> avoids the use of __builtin_constant_p() for all architectures >> that set CONFIG_ARCH_USE_BUILTIN_BSWAP. Most architectures do not >> set ARCH_SUPPORTS_OPTIMIZED_INLINING, which means they probably >> do not suffer from the problem in the qla2xxx driver, but they >> might still run into it elsewhere. >> >> I have not been able to reproduce the original problem, so I don't >> know if this patch solves it, but at least it leads to simpler >> code doing the same thing, so at least there should be no downsides. >> >> Please test. >> >> Signed-off-by: Arnd Bergmann > >Nice patch. I can confirm it fixes the issue with gcc 5.3.1. > >Tested-by: Josh Poimboeuf >Reviewed-by: Josh Poimboeuf > >> diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h >> index 3f10e5317b46..de56fd54428d 100644 >> --- a/include/uapi/linux/swab.h >> +++ b/include/uapi/linux/swab.h >> @@ -45,9 +45,7 @@ >> >> static inline __attribute_const__ __u16 __fswab16(__u16 val) >> { >> -#ifdef __HAVE_BUILTIN_BSWAP16__ >> - return __builtin_bswap16(val); >> -#elif defined (__arch_swab16) >> +#if defined (__arch_swab16) >> return __arch_swab16(val); >> #else >> return ___constant_swab16(val); >> @@ -56,9 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val) >> >> static inline __attribute_const__ __u32 __fswab32(__u32 val) >> { >> -#ifdef __HAVE_BUILTIN_BSWAP32__ >> - return __builtin_bswap32(val); >> -#elif defined(__arch_swab32) >> +#if defined(__arch_swab32) >> return __arch_swab32(val); >> #else >> return ___constant_swab32(val); >> @@ -67,9 +63,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val) >> >> static inline __attribute_const__ __u64 __fswab64(__u64 val) >> { >> -#ifdef __HAVE_BUILTIN_BSWAP64__ >> - return __builtin_bswap64(val); >> -#elif defined (__arch_swab64) >> +#if defined (__arch_swab64) >> return __arch_swab64(val); >> #elif defined(__SWAB_64_THRU_32__) >> __u32 h = val >> 32; >> @@ -102,28 +96,40 @@ static inline __attribute_const__ __u32 __fswahb32(__u32 val) >> * __swab16 - return a byteswapped 16-bit value >> * @x: value to byteswap >> */ >> +#ifdef __HAVE_BUILTIN_BSWAP16__ >> +#define __swab16(x) __builtin_bswap16((__u16)(x)) >> +#else >> #define __swab16(x) \ >> (__builtin_constant_p((__u16)(x)) ? \ >> ___constant_swab16(x) : \ >> __fswab16(x)) >> +#endif >> >> /** >> * __swab32 - return a byteswapped 32-bit value >> * @x: value to byteswap >> */ >> +#ifdef __HAVE_BUILTIN_BSWAP32__ >> +#define __swab32(x) __builtin_bswap32((__u32)(x)) >> +#else >> #define __swab32(x) \ >> (__builtin_constant_p((__u32)(x)) ? \ >> ___constant_swab32(x) : \ >> __fswab32(x)) >> +#endif >> >> /** >> * __swab64 - return a byteswapped 64-bit value >> * @x: value to byteswap >> */ >> +#ifdef __HAVE_BUILTIN_BSWAP64__ >> +#define __swab64(x) __builtin_bswap64((__u64)(x)) >> +#else >> #define __swab64(x) \ >> (__builtin_constant_p((__u64)(x)) ? \ >> ___constant_swab64(x) : \ >> __fswab64(x)) >> +#endif >> >> /** >> * __swahw32 - return a word-swapped 32-bit value >> The patch works. Thanks. > >-- >Josh >-- >To unsubscribe from this list: send the line "unsubscribe linux-scsi" in >the body of a message to majordomo@vger.kernel.org >More majordomo info at http://vger.kernel.org/majordomo-info.html