[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1422938501.2293.1.camel@stgolabs.net>
Date: Mon, 02 Feb 2015 20:41:41 -0800
From: Davidlohr Bueso <dave@...olabs.net>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Anshul Garg <aksgarg1989@...il.com>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
anshul.g@...sung.com
Subject: Re: [PATCH] lib/int_sqrt.c: Optimize square root function
On Mon, 2015-02-02 at 11:13 -0800, Linus Torvalds wrote:
> IOW, instead of
>
> m = 1UL << (BITS_PER_LONG - 2);
>
> perhaps something like
>
> m = 1UL << (BITS_PER_LONG/2- 2);
> if (m < x)
> m <<= BITS_PER_LONG/2;
>
> (assuming gcc can change that code into a "cmov") might cut down the
> "lots of empty loops" case in half for small values of 'x'.
Makes a lot of sense.
> There's probably some other better cheap initial guess value estimator.
Just to get a feeling for the normal arg range in the non-driver parts
that use this thing:
fs/ceph/super.h: congestion_kb = (16*int_sqrt(totalram_pages)) << (PAGE_SHIFT-10);
fs/nfs/write.c: nfs_congestion_kb = (16*int_sqrt(totalram_pages)) << (PAGE_SHIFT-10);
fs/nfsd/nfscache.c: limit = (16 * int_sqrt(low_pages)) << (PAGE_SHIFT-10);
kernel/rcu/tree_plugin.h: ls = int_sqrt(nr_cpu_ids);
mm/memcontrol.c: inactive_ratio = int_sqrt(10 * gb);
mm/page_alloc.c: ratio = int_sqrt(10 * gb);
mm/page_alloc.c: new_min_free_kbytes = int_sqrt(lowmem_kbytes * 16);
So mostly values that scale according to mem or cpu.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists