linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Richard Gooch <rgooch@ras.ucalgary.ca>
To: Andrea Arcangeli <andrea@suse.de>
Cc: Chris Friesen <cfriesen@nortelnetworks.com>,
	Linus Torvalds <torvalds@transmeta.com>,
	Jeff Dike <jdike@karaya.com>,
	user-mode-linux-user <user-mode-linux-user@lists.sourceforge.net>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	Jan Hubicka <jh@suse.cz>
Subject: Re: user-mode port 0.44-2.4.7
Date: Mon, 23 Jul 2001 17:47:04 -0600	[thread overview]
Message-ID: <200107232347.f6NNl4u14416@vindaloo.ras.ucalgary.ca> (raw)
In-Reply-To: <20010724000933.I16919@athlon.random>
In-Reply-To: <Pine.LNX.4.33.0107231259520.13272-100000@penguin.transmeta.com> <3B5C8C96.FE53F5BA@nortelnetworks.com> <20010723231136.E16919@athlon.random> <200107232150.f6NLosh13126@vindaloo.ras.ucalgary.ca> <20010724000933.I16919@athlon.random>

Andrea Arcangeli writes:
> On Mon, Jul 23, 2001 at 03:50:54PM -0600, Richard Gooch wrote:
> > Andrea Arcangeli writes:
> > > cases if the code breaks in the actual usages of xtime it is likely that
> > > gcc is doing something stupid in terms of performance. but GCC if it
> > > wants to is allowed to compile this code:
> > > 
> > > 	printf("%lx\n", xtime.tv_sec);
> > > 
> > > as:
> > > 
> > > 	unsigned long sec = xtime.tv_sec;
> > > 	if (sec != xtime.tv_sec)
> > > 		BUG();
> > > 	printf("%lx\n", sec);
> > 
> > And if it does that, it's stupid. Why on earth would GCC add extra
> > code to check if a value hasn't changed? I want it to produce
> 
> GCC will obviously _never_ introduce a BUG(), I never said that, the
> above example is only meant to show what GCC is _allowed_ to do and
> what we have to do to write correct C code.

I don't think it should be allowed to do that. That's a whipping
offence. I think that example is a red herring.

> The real life case of the BUG() is when gcc optimize `case' with a
> jump table the equivalent of BUG() will be you derferencing a
> dangling pointer at runtime. Same can happen in other cases but
> don't ask me the other cases as I'm not a gcc developer and I've no
> idea what they plans to do for other things (ask Honza for those
> details).

So grab a local snapshot of the variable, as Linus suggested. In fact,
the switch example is interesting, because one could argue the
opposite way, that declaring the switch variable as "volatile" means
that if GCC needs to internally re-"get" the variable, it should grab
it from memory, and thus definately fail. Without "volatile", GCC is
implicitely allowed to cache the variable (which is of course safe).

So, really, the switch example requires an "antivolatile"
declaration. Oh, wait! I get the same with " ".

				Regards,

					Richard....
Permanent: rgooch@atnf.csiro.au
Current:   rgooch@ras.ucalgary.ca

  parent reply	other threads:[~2001-07-23 23:47 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-23  5:08 user-mode port 0.44-2.4.7 Jeff Dike
2001-07-23 15:56 ` Andrea Arcangeli
2001-07-23 15:59   ` Andrea Arcangeli
2001-07-23 16:17     ` Andrea Arcangeli
2001-07-23 16:51       ` Andrea Arcangeli
2001-07-23 16:33   ` Linus Torvalds
2001-07-23 16:45     ` Andrea Arcangeli
2001-07-23 17:32       ` Linus Torvalds
2001-07-23 17:50         ` Andrea Arcangeli
2001-07-23 18:11           ` Linus Torvalds
2001-07-23 18:27             ` Andrea Arcangeli
2001-07-23 20:00               ` Linus Torvalds
2001-07-23 20:15                 ` Jonathan Lundell
2001-07-23 22:51                   ` Linus Torvalds
2001-07-24  3:45                     ` Jonathan Lundell
2001-07-24 15:41                       ` Davide Libenzi
2001-07-24 15:46                         ` Alexander Viro
2001-07-24 16:01                           ` Davide Libenzi
2001-07-24 16:08                             ` Alexander Viro
2001-07-24 16:52                               ` Davide Libenzi
2001-07-24 16:59                                 ` Linus Torvalds
2001-07-24 17:31                                   ` Davide Libenzi
2001-07-24 17:38                                     ` Linus Torvalds
2001-07-24 18:07                               ` Anton Altaparmakov
2001-07-23 20:44                 ` Chris Friesen
2001-07-23 21:11                   ` Andrea Arcangeli
2001-07-23 21:50                   ` Richard Gooch
2001-07-23 22:09                     ` Andrea Arcangeli
2001-07-23 13:20                       ` Rob Landley
2001-07-23 22:27                         ` Andrea Arcangeli
2001-07-23 17:50                           ` Rob Landley
2001-07-23 23:47                     ` Richard Gooch [this message]
2001-07-24  0:04                       ` Andrea Arcangeli
2001-07-24  9:02                         ` Jan Hubicka
2001-07-24 15:35                           ` Linus Torvalds
2001-07-24 16:04                         ` Linus Torvalds
2001-07-25 22:49                           ` Andrea Arcangeli
2001-07-25 23:16                             ` Linus Torvalds
2001-07-25 23:37                               ` Chris Friesen
2001-07-26 18:28                             ` Jan Hubicka
2001-07-26 18:35                               ` Alan Cox
2001-07-23 22:53                   ` Linus Torvalds
2001-07-23 23:13                     ` Alan Cox
2001-07-23 20:25   ` Jeff Dike
     [not found] <no.id>
2001-07-23 20:57 ` Alan Cox
2001-07-23 21:14   ` Chris Friesen
2001-07-25 19:12 ` Alan Cox
2001-07-25 23:49 ` Alan Cox
2001-07-25 19:03 James W. Lake

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=200107232347.f6NNl4u14416@vindaloo.ras.ucalgary.ca \
    --to=rgooch@ras.ucalgary.ca \
    --cc=andrea@suse.de \
    --cc=cfriesen@nortelnetworks.com \
    --cc=jdike@karaya.com \
    --cc=jh@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@transmeta.com \
    --cc=user-mode-linux-user@lists.sourceforge.net \
    /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).