mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@suse.cz>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>, linux-kernel@vger.kernel.org
Subject: Re: VM-related Oops: 2.4.15pre1
Date: Wed, 21 Nov 2001 02:31:37 +0000	[thread overview]
Message-ID: <20011121023137.D37@toy.ucw.cz> (raw)
In-Reply-To: <E165QhG-00035D-00@the-village.bc.nu> <Pine.LNX.4.33.0111181756260.7482-100000@penguin.transmeta.com>
In-Reply-To: <Pine.LNX.4.33.0111181756260.7482-100000@penguin.transmeta.com>; from torvalds@transmeta.com on Sun, Nov 18, 2001 at 06:02:17PM -0800

Hi!

> > Why is it a compiler bug. You've not declared that variable to be volatile
> > therefore it is only touched in the code flow the compiler is analysing.
> 
> Even without volatile, the compiler is very arguably buggy if it writes
> values to your variables that were never supposed to be there.
> 
> Take this, for example:
> 
> 	sig_atomic_t value = 1;
> 
> 	int fn()
> 	{
> 		value = 2;
> 	}
> 
> And a signal comes in. Even without the volatile, if gcc has written
> _anything_ else than 1 or 2 into the variable, gcc is BROKEN.

imagine 

typedef volatile int sig_atomic_t;

> There's no point being a language lawyer and saying that gcc "could write
> anything to value before it writes the final 2". Tha's not true. A compile
> rthat does that is
> 
>  (a) buggy as hell from a POSIX standpoint
>  (b) even apart from POSIX, from a Q-of-I standpoint complete and utter
>      crap.

Imagine this:

if (likely(foo))
	c = 1
else	c = 2

I could see it optimized as

c = 1
if (unlikely(foo))
	c = 2

Given enough register pressure.... I've seen similar optimalizations proposed
in "advanced compilers" book.
								Pavel
PS: but wrapping access to current->flags in macro is probably okay for now.
I just wanted to show that writing unwanted value is not as broken as you
think.

-- 
Philips Velo 1: 1"x4"x8", 300gram, 60, 12MB, 40bogomips, linux, mutt,
details at http://atrey.karlin.mff.cuni.cz/~pavel/velo/index.html.


  parent reply	other threads:[~2001-11-22 10:43 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-11-16 22:23 Simon Kirby
2001-11-17 22:53 ` Christian Ehrhardt
2001-11-18  3:12 ` Linus Torvalds
2001-11-18  4:10   ` Andrea Arcangeli
2001-11-18  6:24     ` Linus Torvalds
2001-11-18  6:37       ` Andrea Arcangeli
2001-11-18  7:31         ` Linus Torvalds
2001-11-18 12:05           ` Alan Cox
2001-11-19  2:02             ` Linus Torvalds
2001-11-19  2:27               ` Linus Torvalds
2001-11-19 18:40                 ` kuznet
2001-11-19 10:15               ` Alan Cox
2001-11-19 16:39                 ` Linus Torvalds
2001-11-19 18:03                   ` Eric W. Biederman
2001-11-19 19:04                     ` Linus Torvalds
2001-11-19 23:52                   ` John Alvord
2001-11-21  2:31               ` Pavel Machek [this message]
     [not found]         ` <200111180731.fAI7VFa01371@penguin.transmeta.com>
2001-11-18  7:51           ` Andrea Arcangeli
2001-11-18 17:10       ` Horst von Brand
2001-11-19  2:04         ` Linus Torvalds
2001-11-19  3:22           ` Jeff V. Merkey
2001-11-19  8:44           ` David Woodhouse
2001-11-19 16:57             ` Linus Torvalds
2001-11-19 17:56               ` Simon Kirby
2001-11-19 18:03                 ` Linus Torvalds
2001-11-19 18:31                   ` Simon Kirby
2001-11-19 20:01                   ` Marcelo Tosatti
2001-11-19 21:26                     ` Linus Torvalds
2001-11-19 21:49                       ` Rik van Riel
2001-11-19 22:40                         ` Linus Torvalds
2001-11-19 22:59                           ` Rik van Riel
2001-11-19 23:03                             ` Linus Torvalds
2001-11-20  0:06                               ` Rik van Riel
2001-11-20  0:08                                 ` Linus Torvalds
2001-11-20  0:27                                   ` Rik van Riel
2001-11-19 23:27                   ` Simon Kirby
2001-11-19 23:38                     ` Linus Torvalds
2001-11-19 23:52                       ` Simon Kirby

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=20011121023137.D37@toy.ucw.cz \
    --to=pavel@suse.cz \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@transmeta.com \
    /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

all inboxes | Powered by JetHome®