Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933266AbbBBTjV (ORCPT ); Mon, 2 Feb 2015 14:39:21 -0500 Received: from mail-ig0-f177.google.com ([209.85.213.177]:60480 "EHLO mail-ig0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754474AbbBBTjU (ORCPT ); Mon, 2 Feb 2015 14:39:20 -0500 MIME-Version: 1.0 In-Reply-To: <1422904256.30476.11.camel@perches.com> References: <1422897162-111998-1-git-send-email-aksgarg1989@gmail.com> <1422904256.30476.11.camel@perches.com> Date: Mon, 2 Feb 2015 11:39:19 -0800 X-Google-Sender-Auth: lhuHkxgP-d-lCiAmKb_brkBiPqI Message-ID: Subject: Re: [PATCH] lib/int_sqrt.c: Optimize square root function From: Linus Torvalds To: Joe Perches Cc: Anshul Garg , Linux Kernel Mailing List , anshul.g@samsung.com 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: 1272 Lines: 26 On Mon, Feb 2, 2015 at 11:10 AM, Joe Perches wrote: > > Perhaps removing the while and using fls(x) would be better. No. fls is often slow, and you then do have to also round it down to an even bit number etc, so it gets somewhat complex too. We *probably* have some argument range that we care more about, which is why I'd like to know what the profile is that triggered this optimization, and what the common argument range is. For example, one user is the cpu frequency governor, which seems to try to predict the length of the next sleep. The values can probably be anything (it has protections for overflowing into "long long"), but presumably the onyl time we care about performance is when it's called very very often, in which case I'm going out on a limb and saying that the intervals will be short, and the standard deviation of those intervals will also be small. So *maybe* that function really only cares about performance when we have small arguments. I dunno. Linus -- 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/