linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <matthew@wil.cx>
To: Al Viro <viro@ZenIV.linux.org.uk>
Cc: Andi Kleen <andi@firstfloor.org>,
	Namhyung Kim <namhyung@gmail.com>, Arnd Bergmann <arnd@arndb.de>,
	linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC][PATCH] introduce ptr_diff()
Date: Fri, 20 Aug 2010 06:49:58 -0600	[thread overview]
Message-ID: <20100820124958.GJ12892@parisc-linux.org> (raw)
In-Reply-To: <20100820120737.GS31363@ZenIV.linux.org.uk>

On Fri, Aug 20, 2010 at 01:07:37PM +0100, Al Viro wrote:
> On Thu, Aug 19, 2010 at 02:23:09PM +0200, Andi Kleen wrote:
> > IMHO it would be better to simply disable the warning in sparse instead
> > of uglying the code just to work around sparse bogosity. It doesnt' seem
> > to make much sense. A subtraction followed by a shift is not expensive.
> 
> "Bogosity" in question is quite real and proposed "fix" actually makes the
> things even worse.  At least gcc bothers to optimize the division in there...
> 
> Basically, sparse warns about pointer subtractions that divide by constants
> that are not powers of two.  Which _does_ have non-trivial price, even with
> optimizations done by gcc.

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.

-- 
Matthew Wilcox				Intel Open Source Technology Centre
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."

  reply	other threads:[~2010-08-20 12:50 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-19 11:37 [RFC][PATCH] introduce ptr_diff() Namhyung Kim
2010-08-19 11:57 ` Bernd Petrovitsch
2010-08-19 12:03 ` David Howells
2010-08-19 12:23 ` Andi Kleen
2010-08-19 12:40   ` Matthew Wilcox
2010-08-19 12:58     ` Andi Kleen
2010-08-19 12:58       ` Andi Kleen
2010-08-19 12:48   ` Bernd Petrovitsch
2010-08-19 12:48     ` Bernd Petrovitsch
2010-08-19 12:59     ` Andi Kleen
2010-08-19 13:05       ` Bernd Petrovitsch
2010-08-19 13:39         ` Andi Kleen
2010-08-20 12:12       ` Al Viro
2010-08-19 15:53   ` Namhyung Kim
2010-08-19 16:04     ` Bernd Petrovitsch
2010-08-19 16:12       ` Namhyung Kim
2010-08-20 12:07   ` Al Viro
2010-08-20 12:49     ` Matthew Wilcox [this message]
2010-08-20 12:57       ` Andi Kleen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100820124958.GJ12892@parisc-linux.org \
    --to=matthew@wil.cx \
    --cc=andi@firstfloor.org \
    --cc=arnd@arndb.de \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=namhyung@gmail.com \
    --cc=viro@ZenIV.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).