From mboxrd@z Thu Jan 1 00:00:00 1970 From: "H. Peter Anvin" Date: Thu, 09 Mar 2017 04:36:30 +0000 Subject: Re: [PATCH 1/3] futex: remove duplicated code Message-Id: <201703090437.v294b0RE021699@mail.zytor.com> List-Id: References: <20170303122712.13353-1-jslaby@suse.cz> <20170304130550.GT21222@n2100.armlinux.org.uk> <23e5808b-2a20-518d-b49a-4d95dd23cfde@landley.net> In-Reply-To: <23e5808b-2a20-518d-b49a-4d95dd23cfde@landley.net> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Rob Landley , Russell King - ARM Linux , Jiri Slaby Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org, Richard Henderson , Ivan Kokshaysky , Matt Turner , Vineet Gupta , Catalin Marinas , Will Deacon , Richard Kuo , Tony Luck , Fenghua Yu , Michal Simek , Ralf Baechle , Jonas Bonn , Stefan Kristiansson , Stafford Horne , "James E.J. Bottomley" , Helge Deller , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Martin Schwidefsky , Heiko Carstens , Yoshinori Sato , Rich Felker , "David S. Miller" , Chris.Metcalf@zytor.com ,Thomas Gleixner ,Ingo Molnar ,Chris Zankel ,Max Filippov ,Arnd Bergmann ,x86@kernel.org,linux-alpha@vger.kernel.org,linux-snps-arc@lists.infradead.org,linux-arm-kernel@lists.infradead.org,linux-hexagon@vger.kernel.org,linux-ia64@vger.kernel.org,linux-mips@linux-mips.org,openrisc@lists.librecores.org,linux-parisc@vger.kernel.org,linuxppc-dev@lists.ozlabs.org,linux-s390@vger.kernel.org,linux-sh@vger.kernel.org,sparclinux@vger.kernel.org,linux-xtensa@linux-xtensa.org,linux-arch@vger.kernel.org From: hpa@zytor.com Message-ID: <83324528-AAA1-4BED-B0C7-48426ECBA261@zytor.com> On March 8, 2017 8:16:49 PM PST, Rob Landley wrote: >On 03/04/2017 07:05 AM, Russell King - ARM Linux wrote: >> On Fri, Mar 03, 2017 at 01:27:10PM +0100, Jiri Slaby wrote: >>> diff --git a/kernel/futex.c b/kernel/futex.c >>> index b687cb22301c..c5ff9850952f 100644 >>> --- a/kernel/futex.c >>> +++ b/kernel/futex.c >>> @@ -1457,6 +1457,42 @@ futex_wake(u32 __user *uaddr, unsigned int >flags, int nr_wake, u32 bitset) >>> return ret; >>> } >>> >>> +static int futex_atomic_op_inuser(int encoded_op, u32 __user >*uaddr) >>> +{ >>> + int op = (encoded_op >> 28) & 7; >>> + int cmp = (encoded_op >> 24) & 15; >>> + int oparg = (encoded_op << 8) >> 20; >>> + int cmparg = (encoded_op << 20) >> 20; >> >> Hmm. oparg and cmparg look like they're doing these shifts to get >sign >> extension of the 12-bit values by assuming that "int" is 32-bit - >> probably worth a comment, or for safety, they should be "s32" so it's >> not dependent on the bit-width of "int". > >I thought Linux depended on the LP64 standard for all architectures? > >Standard: http://www.unix.org/whitepapers/64bit.html >Rationale: http://www.unix.org/version2/whatsnew/lp64_wp.html > >So int has a defined bit width (32) on linux? > >Rob Linux is ILP32 on 32-bit architectures and LP64 on 64-bit architectures, but that doesn't inherently make this stuff clear. -- Sent from my Android device with K-9 Mail. Please excuse my brevity. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750895AbdCIFIA convert rfc822-to-8bit (ORCPT ); Thu, 9 Mar 2017 00:08:00 -0500 Received: from terminus.zytor.com ([65.50.211.136]:38340 "EHLO mail.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750724AbdCIFHz (ORCPT ); Thu, 9 Mar 2017 00:07:55 -0500 From: "H. Peter Anvin" Message-Id: <201703090437.v294b0RE021699@mail.zytor.com> Date: Wed, 08 Mar 2017 20:36:30 -0800 User-Agent: K-9 Mail for Android In-Reply-To: <23e5808b-2a20-518d-b49a-4d95dd23cfde@landley.net> References: <20170303122712.13353-1-jslaby@suse.cz> <20170304130550.GT21222@n2100.armlinux.org.uk> <23e5808b-2a20-518d-b49a-4d95dd23cfde@landley.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Subject: Re: [PATCH 1/3] futex: remove duplicated code To: Rob Landley , Russell King - ARM Linux , Jiri Slaby CC: akpm@linux-foundation.org, linux-kernel@vger.kernel.org, Richard Henderson , Ivan Kokshaysky , Matt Turner , Vineet Gupta , Catalin Marinas , Will Deacon , Richard Kuo , Tony Luck , Fenghua Yu , Michal Simek , Ralf Baechle , Jonas Bonn , Stefan Kristiansson , Stafford Horne , "James E.J. Bottomley" , Helge Deller , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Martin Schwidefsky , Heiko Carstens , Yoshinori Sato , Rich Felker , "David S. Miller" , Chris.Metcalf@zytor.com Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ,Thomas Gleixner ,Ingo Molnar ,Chris Zankel ,Max Filippov ,Arnd Bergmann ,x86@kernel.org,linux-alpha@vger.kernel.org,linux-snps-arc@lists.infradead.org,linux-arm-kernel@lists.infradead.org,linux-hexagon@vger.kernel.org,linux-ia64@vger.kernel.org,linux-mips@linux-mips.org,openrisc@lists.librecores.org,linux-parisc@vger.kernel.org,linuxppc-dev@lists.ozlabs.org,linux-s390@vger.kernel.org,linux-sh@vger.kernel.org,sparclinux@vger.kernel.org,linux-xtensa@linux-xtensa.org,linux-arch@vger.kernel.org From: hpa@zytor.com Message-ID: <83324528-AAA1-4BED-B0C7-48426ECBA261@zytor.com> On March 8, 2017 8:16:49 PM PST, Rob Landley wrote: >On 03/04/2017 07:05 AM, Russell King - ARM Linux wrote: >> On Fri, Mar 03, 2017 at 01:27:10PM +0100, Jiri Slaby wrote: >>> diff --git a/kernel/futex.c b/kernel/futex.c >>> index b687cb22301c..c5ff9850952f 100644 >>> --- a/kernel/futex.c >>> +++ b/kernel/futex.c >>> @@ -1457,6 +1457,42 @@ futex_wake(u32 __user *uaddr, unsigned int >flags, int nr_wake, u32 bitset) >>> return ret; >>> } >>> >>> +static int futex_atomic_op_inuser(int encoded_op, u32 __user >*uaddr) >>> +{ >>> + int op = (encoded_op >> 28) & 7; >>> + int cmp = (encoded_op >> 24) & 15; >>> + int oparg = (encoded_op << 8) >> 20; >>> + int cmparg = (encoded_op << 20) >> 20; >> >> Hmm. oparg and cmparg look like they're doing these shifts to get >sign >> extension of the 12-bit values by assuming that "int" is 32-bit - >> probably worth a comment, or for safety, they should be "s32" so it's >> not dependent on the bit-width of "int". > >I thought Linux depended on the LP64 standard for all architectures? > >Standard: http://www.unix.org/whitepapers/64bit.html >Rationale: http://www.unix.org/version2/whatsnew/lp64_wp.html > >So int has a defined bit width (32) on linux? > >Rob Linux is ILP32 on 32-bit architectures and LP64 on 64-bit architectures, but that doesn't inherently make this stuff clear. -- Sent from my Android device with K-9 Mail. Please excuse my brevity. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.zytor.com (unknown [IPv6:2001:1868:a000:17::138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3vdyst2xb1zDqXh for ; Thu, 9 Mar 2017 16:01:33 +1100 (AEDT) From: "H. Peter Anvin" Message-Id: <201703090437.v294b0RE021699@mail.zytor.com> Date: Wed, 08 Mar 2017 20:36:30 -0800 In-Reply-To: <23e5808b-2a20-518d-b49a-4d95dd23cfde@landley.net> References: <20170303122712.13353-1-jslaby@suse.cz> <20170304130550.GT21222@n2100.armlinux.org.uk> <23e5808b-2a20-518d-b49a-4d95dd23cfde@landley.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Subject: Re: [PATCH 1/3] futex: remove duplicated code To: Rob Landley , Russell King - ARM Linux , Jiri Slaby CC: akpm@linux-foundation.org, linux-kernel@vger.kernel.org, Richard Henderson , Ivan Kokshaysky , Matt Turner , Vineet Gupta , Catalin Marinas , Will Deacon , Richard Kuo , Tony Luck , Fenghua Yu , Michal Simek , Ralf Baechle , Jonas Bonn , Stefan Kristiansson , Stafford Horne , "James E.J. Bottomley" , Helge Deller , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Martin Schwidefsky , Heiko Carstens , Yoshinori Sato , Rich Felker , "David S. Miller" , Chris.Metcalf@zytor.com List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , ,Thomas Gleixner ,Ingo Molnar ,Chris Zankel ,Max Filippov ,Arnd Bergmann ,x86@kernel.org,linux-alpha@vger.kernel.org,linux-snps-arc@lists.infradead.org,linux-arm-kernel@lists.infradead.org,linux-hexagon@vger.kernel.org,linux-ia64@vger.kernel.org,linux-mips@linux-mips.org,openrisc@lists.librecores.org,linux-parisc@vger.kernel.org,linuxppc-dev@lists.ozlabs.org,linux-s390@vger.kernel.org,linux-sh@vger.kernel.org,sparclinux@vger.kernel.org,linux-xtensa@linux-xtensa.org,linux-arch@vger.kernel.org From: hpa@zytor.com Message-ID: <83324528-AAA1-4BED-B0C7-48426ECBA261@zytor.com> On March 8, 2017 8:16:49 PM PST, Rob Landley wrote: >On 03/04/2017 07:05 AM, Russell King - ARM Linux wrote: >> On Fri, Mar 03, 2017 at 01:27:10PM +0100, Jiri Slaby wrote: >>> diff --git a/kernel/futex=2Ec b/kernel/futex=2Ec >>> index b687cb22301c=2E=2Ec5ff9850952f 100644 >>> --- a/kernel/futex=2Ec >>> +++ b/kernel/futex=2Ec >>> @@ -1457,6 +1457,42 @@ futex_wake(u32 __user *uaddr, unsigned int >flags, int nr_wake, u32 bitset) >>> return ret; >>> } >>> =20 >>> +static int futex_atomic_op_inuser(int encoded_op, u32 __user >*uaddr) >>> +{ >>> + int op =3D (encoded_op >> 28) & 7; >>> + int cmp =3D (encoded_op >> 24) & 15; >>> + int oparg =3D (encoded_op << 8) >> 20; >>> + int cmparg =3D (encoded_op << 20) >> 20; >>=20 >> Hmm=2E oparg and cmparg look like they're doing these shifts to get >sign >> extension of the 12-bit values by assuming that "int" is 32-bit - >> probably worth a comment, or for safety, they should be "s32" so it's >> not dependent on the bit-width of "int"=2E > >I thought Linux depended on the LP64 standard for all architectures? > >Standard: http://www=2Eunix=2Eorg/whitepapers/64bit=2Ehtml >Rationale: http://www=2Eunix=2Eorg/version2/whatsnew/lp64_wp=2Ehtml > >So int has a defined bit width (32) on linux? > >Rob Linux is ILP32 on 32-bit architectures and LP64 on 64-bit architectures, b= ut that doesn't inherently make this stuff clear=2E --=20 Sent from my Android device with K-9 Mail=2E Please excuse my brevity=2E From mboxrd@z Thu Jan 1 00:00:00 1970 From: hpa@zytor.com (H. Peter Anvin) Date: Wed, 08 Mar 2017 20:36:30 -0800 Subject: [PATCH 1/3] futex: remove duplicated code In-Reply-To: <23e5808b-2a20-518d-b49a-4d95dd23cfde@landley.net> References: <20170303122712.13353-1-jslaby@suse.cz> <20170304130550.GT21222@n2100.armlinux.org.uk> <23e5808b-2a20-518d-b49a-4d95dd23cfde@landley.net> List-ID: Message-ID: <201703090437.v294b0RE021699@mail.zytor.com> To: linux-snps-arc@lists.infradead.org ,Thomas Gleixner ,Ingo Molnar ,Chris Zankel ,Max Filippov ,Arnd Bergmann ,x86 at kernel.org,linux-alpha at vger.kernel.org,linux-snps-arc at lists.infradead.org,linux-arm-kernel at lists.infradead.org,linux-hexagon at vger.kernel.org,linux-ia64 at vger.kernel.org,linux-mips at linux-mips.org,openrisc at lists.librecores.org,linux-parisc at vger.kernel.org,linuxppc-dev at lists.ozlabs.org,linux-s390 at vger.kernel.org,linux-sh at vger.kernel.org,sparclinux at vger.kernel.org,linux-xtensa at linux-xtensa.org,linux-arch at vger.kernel.org From: hpa@zytor.com List-ID: To: linux-snps-arc@lists.infradead.org Message-ID: <83324528-AAA1-4BED-B0C7-48426ECBA261 at zytor.com> On March 8, 2017 8:16:49 PM PST, Rob Landley wrote: >On 03/04/2017 07:05 AM, Russell King - ARM Linux wrote: >> On Fri, Mar 03, 2017@01:27:10PM +0100, Jiri Slaby wrote: >>> diff --git a/kernel/futex.c b/kernel/futex.c >>> index b687cb22301c..c5ff9850952f 100644 >>> --- a/kernel/futex.c >>> +++ b/kernel/futex.c >>> @@ -1457,6 +1457,42 @@ futex_wake(u32 __user *uaddr, unsigned int >flags, int nr_wake, u32 bitset) >>> return ret; >>> } >>> >>> +static int futex_atomic_op_inuser(int encoded_op, u32 __user >*uaddr) >>> +{ >>> + int op = (encoded_op >> 28) & 7; >>> + int cmp = (encoded_op >> 24) & 15; >>> + int oparg = (encoded_op << 8) >> 20; >>> + int cmparg = (encoded_op << 20) >> 20; >> >> Hmm. oparg and cmparg look like they're doing these shifts to get >sign >> extension of the 12-bit values by assuming that "int" is 32-bit - >> probably worth a comment, or for safety, they should be "s32" so it's >> not dependent on the bit-width of "int". > >I thought Linux depended on the LP64 standard for all architectures? > >Standard: http://www.unix.org/whitepapers/64bit.html >Rationale: http://www.unix.org/version2/whatsnew/lp64_wp.html > >So int has a defined bit width (32) on linux? > >Rob Linux is ILP32 on 32-bit architectures and LP64 on 64-bit architectures, but that doesn't inherently make this stuff clear. -- Sent from my Android device with K-9 Mail. Please excuse my brevity.