Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755464AbdLTOjP convert rfc822-to-8bit (ORCPT ); Wed, 20 Dec 2017 09:39:15 -0500 Received: from smtp-out4.electric.net ([192.162.216.195]:53497 "EHLO smtp-out4.electric.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755285AbdLTOjO (ORCPT ); Wed, 20 Dec 2017 09:39:14 -0500 From: David Laight To: "'Crt Mori'" , Jonathan Cameron CC: Ingo Molnar , Andrew Morton , Kees Cook , Rusty Russell , "Ian Abbott" , Larry Finger , "Niklas Soderlund" , Thomas Gleixner , Krzysztof Kozlowski , Masahiro Yamada , "linux-kernel@vger.kernel.org" , "linux-iio@vger.kernel.org" , Peter Zijlstra , "Joe Perches" Subject: RE: [PATCH v10 1/3] lib: Add strongly typed 64bit int_sqrt Thread-Topic: [PATCH v10 1/3] lib: Add strongly typed 64bit int_sqrt Thread-Index: AQHTeZ24vj4uJGdJVEmg6EfyY0tMJ6NMSiFA Date: Wed, 20 Dec 2017 14:39:26 +0000 Message-ID: <1c1d0ffa8ee140bf9adbc78f1559b1e8@AcuMS.aculab.com> References: <20171220142001.18161-1-cmo@melexis.com> In-Reply-To: <20171220142001.18161-1-cmo@melexis.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.33] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-Outbound-IP: 156.67.243.126 X-Env-From: David.Laight@ACULAB.COM X-Proto: esmtps X-Revdns: X-HELO: AcuMS.aculab.com X-TLS: TLSv1.2:ECDHE-RSA-AES256-SHA384:256 X-Authenticated_ID: X-PolicySMART: 3396946, 3397078 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 613 Lines: 18 From: Crt Mori > Sent: 20 December 2017 14:20 > > There is no option to perform 64bit integer sqrt on 32bit platform. > Added stronger typed int_sqrt64 enables the 64bit calculations to > be performed on 32bit platforms. Although int_sqrt() is a rough > approximation, the same algorithm is used in int_sqrt64() as good > enough on 32bit platform. The algorithm used gives an exact (rounded down) square root, not an approximation. With minor changes it ought to be possible to remove most of the 64bit arithmetic and shifts. If you care about performance then using 32 bit maths will be much faster. David