Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755517AbdLTPmd (ORCPT ); Wed, 20 Dec 2017 10:42:33 -0500 Received: from mail-lf0-f67.google.com ([209.85.215.67]:45751 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755085AbdLTPm3 (ORCPT ); Wed, 20 Dec 2017 10:42:29 -0500 X-Google-Smtp-Source: ACJfBotf9p5pKm+Sy/QvwYDKmpiOCZsQcYwXdtY6tCVYe7XycD5CTbr97xK6Hl/0b6kVIaeN5DK4MUC0ddLpapboUFs= MIME-Version: 1.0 In-Reply-To: <1c1d0ffa8ee140bf9adbc78f1559b1e8@AcuMS.aculab.com> References: <20171220142001.18161-1-cmo@melexis.com> <1c1d0ffa8ee140bf9adbc78f1559b1e8@AcuMS.aculab.com> From: Crt Mori Date: Wed, 20 Dec 2017 16:41:46 +0100 Message-ID: Subject: Re: [PATCH v10 1/3] lib: Add strongly typed 64bit int_sqrt To: David Laight Cc: Jonathan Cameron , 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 961 Lines: 28 On 20 December 2017 at 15:39, David Laight wrote: > 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. > OK, noted. This is from new changed function indeed - will change in v11. > 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. > I need precision not the performance. That is why I would like to leave int_sqrt as one for good performance while my will be used when you require a precision. > David >