[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20100820125745.GA1771@one.firstfloor.org>
Date: Fri, 20 Aug 2010 14:57:45 +0200
From: Andi Kleen <andi@...stfloor.org>
To: Matthew Wilcox <matthew@....cx>
Cc: Al Viro <viro@...IV.linux.org.uk>,
Andi Kleen <andi@...stfloor.org>,
Namhyung Kim <namhyung@...il.com>,
Arnd Bergmann <arnd@...db.de>, linux-arch@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [RFC][PATCH] introduce ptr_diff()
> I'm not sure the price is so high. I googled around and came across
> http://mdfs.net/Docs/Comp/ARM/Cookbook/cook3 (section 3.3). Dividing by
> 2^n, (2^n + 2^m) or (2^n - 2^m) can be done using a small series of adds
> and subtractions (important on ARM as it had no divide instruction at
> the time). Most structures are going to be of one of these sizes ...
> and in particular, struct page is 56 bytes in my config, which is 64 - 8.
> Maybe sparse needs to be taught that dividing by 2^n [+-] 2^m is cheap
> enough to not warn about.
Usually you can just use x/n = x*(1/n) and generate *(1/n) with 1/n
being computed at compile time. Multiplications are fast in hardware.
gcc only does that when -Os is not set though (friends don't let friends
compile with -Os...)
-Andi
--
ak@...ux.intel.com -- Speaking for myself only.
--
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