linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Al Viro <viro@ftp.linux.org.uk>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Josh Triplett <josh@freedesktop.org>,
	linux-sparse@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: sparse -Wptr-subtraction-blows: still needed?
Date: Wed, 2 May 2007 01:02:40 +0100	[thread overview]
Message-ID: <20070502000240.GI4095@ftp.linux.org.uk> (raw)
In-Reply-To: <alpine.LFD.0.98.0705011442320.3808@woody.linux-foundation.org>

On Tue, May 01, 2007 at 02:43:30PM -0700, Linus Torvalds wrote:
> 
> 
> On Tue, 1 May 2007, Josh Triplett wrote:
> > 
> > Does this still apply?  Do current versions of GCC still have this problem?
> > If not, can the option and warning go away?
> 
> Even if current versions of gcc don't triple the build time (and for the 
> kernel, I suspect it doesn't, because we've tried to clean up our header 
> files), the generated _code_ will invariably suck.
> 
> So I'd not want to remove the warning.

Note that code *will* blow: in effect, when we have a*2^b as object size,
we have to choose between
	* generic division by a*2^b (dog-slow pretty much on anything)
	* multiplication by such c that a*c == 1 (mod 2^word_size-b), then
shift down by b.
	* shift down by b, then multiplication by such c that a*c == 1
(mod 2^word_size).
And c in the above won't be small or pretty, so doing multiplication as
series of additions won't be short.

FWIW, I've seen very nasty cases (in userland code) where hot path got blown
by factor of 5 or so in size due to that; basically, it started with
#define INDEX(p) ((p)-array)
and that sucker got used a lot in other macros, so it wasn't immediately
obvious what had been going on.  So yes, we do want to be able to see
such cases.

  parent reply	other threads:[~2007-05-02  0:02 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-01 21:08 sparse -Wptr-subtraction-blows: still needed? Josh Triplett
2007-05-01 21:43 ` Linus Torvalds
2007-05-01 23:59   ` Josh Triplett
2007-05-02  0:24     ` Linus Torvalds
2007-05-02  0:35       ` Al Viro
2007-05-02 12:02       ` Alan Cox
2007-05-02 13:19         ` Andi Kleen
2007-05-02  0:26     ` Al Viro
2007-05-02  0:02   ` Al Viro [this message]
2007-05-02  2:42   ` Dave Jones
2007-05-02 13:03     ` 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=20070502000240.GI4095@ftp.linux.org.uk \
    --to=viro@ftp.linux.org.uk \
    --cc=josh@freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sparse@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /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).