Re: [BUG] long freezes on thinkpad t60

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linus Torvalds
Date: Wednesday, June 27, 2007 - 5:46 pm

On Wed, 27 Jun 2007, Davide Libenzi wrote:


That optimization manual was confused. 

The Intel memory ordering documentation *clearly* states that only reads 
pass writes, not the other way around.

Some very confused people have thought that "pass" is a two-way thing. 
It's not. "Passing" in the Intel memory ordering means "go _ahead_ of", 
exactly the same way it means in traffic. You don't "pass" people by 
falling behind them.

It's also obvious from reading the manual, because any other reading would 
be very strange: it says

 1. Reads can be carried out speculatively and in any order

 2. Reads can pass buffered writes, but the processor is self-consistent

 3. Writes to memory are always carried out in program order [.. and then 
    lists exceptions that are not interesting - it's clflush and the 
    non-temporal stores, not any normal writes ]

 4. Writes can be buffered

 5. Writes are not performed speculatively; they are only performed for 
    instructions that have actually been retired.

 6. Data from buffered writes can be forwarded to waiting reads within the 
    processor.

 7. Reads or writes cannot pass (be carried out ahead of) I/O 
    instructions, locked instructions or serializing instructions.

 8. Reads cannot pass LFENCE and MFENCE instructions.

 9. Writes cannot pass SFENCE or MFENCE instructions.

The thing to note is:

 a) in (1), Intel says that reads can occur in any order, but (2) makes it 
    clear that that is only relevant wrt other _reads_

 b) in (2), they say "pass", but then they actually explain that "pass" 
    means "be carried out ahead of" in (7). 

    HOWEVER, it should be obvious in (2) even _without_ the explicit 
    clarification in (7) that "pass" is a one-way thing, because otherwise 
    (2) is totally _meaningless_. It would be meaningless for two reasons:

     - (1) already said that reads can be done in any order, so if that 
       was a "any order wrt writes", then (2) would be pointless. So (2) 
       must mean something *else* than "any order", and the only sane 
       reading of it that isn't "any order" is that "pass" is a one-way 
       thing: you pass somebody when you go ahead of them, you do *not* 
       pass somebody when you fall behind them!

     - if (2) really meant that reads and writes can just be re-ordered, 
       then the choice of words makes no sense. It would be much more 
       sensible to say that "reads can be carried out in any order wrt 
       writes", instead of talking explicitly about "passing buffered 
       writes"

Anyway, I'm pretty damn sure my reading is correct. And no, it's not a "it 
happens to work". It's _architecturally_required_ to work, and nobody has 
ever complained about the use of a simple store to unlock a spinlock 
(which would only work if the "reads can pass" only means "*later* reads 
can pass *earlier* writes").

And it turns out that I think #1 is going away. Yes, the uarch will 
internally re-order reads, wrt each other, but if it isn't architecturally 
visible, then from an architectural standpoint #1 simply doesn't happen.

I can't guarantee that will happen, of course, but from talking to both 
AMD and Intel people, I think that they'll just document the stricter 
rules as the de-facto rules.

		Linus
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[BUG] long freezes on thinkpad t60, Miklos Szeredi, (Thu May 24, 5:04 am)
Re: [BUG] long freezes on thinkpad t60, Ingo Molnar, (Thu May 24, 5:54 am)
Re: [BUG] long freezes on thinkpad t60, Miklos Szeredi, (Thu May 24, 7:03 am)
Re: [BUG] long freezes on thinkpad t60, Ingo Molnar, (Thu May 24, 7:10 am)
Re: [BUG] long freezes on thinkpad t60, Miklos Szeredi, (Thu May 24, 7:28 am)
Re: [BUG] long freezes on thinkpad t60, Ingo Molnar, (Thu May 24, 7:42 am)
Re: [BUG] long freezes on thinkpad t60, Ingo Molnar, (Thu May 24, 7:44 am)
Re: [BUG] long freezes on thinkpad t60, Miklos Szeredi, (Thu May 24, 10:09 am)
Re: [BUG] long freezes on thinkpad t60, Ingo Molnar, (Thu May 24, 2:01 pm)
Re: [BUG] long freezes on thinkpad t60, Henrique de Moraes H ..., (Thu May 24, 3:08 pm)
Re: [BUG] long freezes on thinkpad t60, Kok, Auke, (Thu May 24, 3:13 pm)
Re: [BUG] long freezes on thinkpad t60, Ingo Molnar, (Thu May 24, 11:58 pm)
Re: [BUG] long freezes on thinkpad t60, Miklos Szeredi, (Fri May 25, 2:51 am)
Re: [BUG] long freezes on thinkpad t60, Miklos Szeredi, (Thu Jun 14, 9:04 am)
Re: [BUG] long freezes on thinkpad t60, Chuck Ebbert, (Fri Jun 15, 2:25 pm)
Re: [BUG] long freezes on thinkpad t60, Ingo Molnar, (Sat Jun 16, 3:37 am)
Re: [BUG] long freezes on thinkpad t60, Miklos Szeredi, (Sun Jun 17, 2:46 pm)
Re: [BUG] long freezes on thinkpad t60, Ingo Molnar, (Sun Jun 17, 11:43 pm)
Re: [BUG] long freezes on thinkpad t60, Miklos Szeredi, (Mon Jun 18, 12:24 am)
Re: [BUG] long freezes on thinkpad t60, Ingo Molnar, (Mon Jun 18, 1:12 am)
Re: [BUG] long freezes on thinkpad t60, Andrew Morton, (Mon Jun 18, 1:20 am)
Re: [BUG] long freezes on thinkpad t60, Miklos Szeredi, (Mon Jun 18, 1:25 am)
Re: [BUG] long freezes on thinkpad t60, Ingo Molnar, (Mon Jun 18, 1:31 am)
Re: [BUG] long freezes on thinkpad t60, Miklos Szeredi, (Mon Jun 18, 1:34 am)
Re: [BUG] long freezes on thinkpad t60, Ingo Molnar, (Mon Jun 18, 2:18 am)
Re: [BUG] long freezes on thinkpad t60, Ingo Molnar, (Mon Jun 18, 2:38 am)
Re: [BUG] long freezes on thinkpad t60, Ingo Molnar, (Mon Jun 18, 2:44 am)
Re: [BUG] long freezes on thinkpad t60, Miklos Szeredi, (Mon Jun 18, 3:18 am)
Re: [BUG] long freezes on thinkpad t60, Ingo Molnar, (Mon Jun 18, 5:36 am)
Re: [BUG] long freezes on thinkpad t60, Miklos Szeredi, (Mon Jun 18, 6:10 am)
Re: [BUG] long freezes on thinkpad t60, Linus Torvalds, (Mon Jun 18, 9:34 am)
Re: [BUG] long freezes on thinkpad t60, Miklos Szeredi, (Mon Jun 18, 10:41 am)
Re: [BUG] long freezes on thinkpad t60, Linus Torvalds, (Mon Jun 18, 10:48 am)
Re: [BUG] long freezes on thinkpad t60, Ingo Molnar, (Mon Jun 18, 11:00 am)
Re: [BUG] long freezes on thinkpad t60, Ingo Molnar, (Mon Jun 18, 11:02 am)
Re: [BUG] long freezes on thinkpad t60, Linus Torvalds, (Mon Jun 18, 11:25 am)
Re: [BUG] long freezes on thinkpad t60, Ravikiran G Thirumalai, (Mon Jun 18, 9:22 pm)
Re: [BUG] long freezes on thinkpad t60, Jarek Poplawski, (Wed Jun 20, 2:36 am)
Re: [BUG] long freezes on thinkpad t60, Linus Torvalds, (Wed Jun 20, 10:34 am)
Re: [BUG] long freezes on thinkpad t60, Ingo Molnar, (Thu Jun 21, 12:30 am)
Re: [BUG] long freezes on thinkpad t60, Jarek Poplawski, (Thu Jun 21, 12:38 am)
Re: [BUG] long freezes on thinkpad t60, Ingo Molnar, (Thu Jun 21, 1:39 am)
Re: [BUG] long freezes on thinkpad t60, Jarek Poplawski, (Thu Jun 21, 4:09 am)
Re: [BUG] long freezes on thinkpad t60, Linus Torvalds, (Thu Jun 21, 8:50 am)
Re: [BUG] long freezes on thinkpad t60, Linus Torvalds, (Thu Jun 21, 9:01 am)
Re: [BUG] long freezes on thinkpad t60, Ingo Molnar, (Thu Jun 21, 9:08 am)
Re: [BUG] long freezes on thinkpad t60, Linus Torvalds, (Thu Jun 21, 9:32 am)
Re: [BUG] long freezes on thinkpad t60, Chuck Ebbert, (Thu Jun 21, 9:44 am)
Re: [BUG] long freezes on thinkpad t60, Linus Torvalds, (Thu Jun 21, 10:31 am)
Re: [BUG] long freezes on thinkpad t60, Eric Dumazet, (Thu Jun 21, 11:29 am)
Re: [BUG] long freezes on thinkpad t60, Linus Torvalds, (Thu Jun 21, 11:44 am)
Re: [BUG] long freezes on thinkpad t60, Linus Torvalds, (Thu Jun 21, 12:35 pm)
Re: [BUG] long freezes on thinkpad t60, Ingo Molnar, (Thu Jun 21, 12:56 pm)
Re: [BUG] long freezes on thinkpad t60, Ingo Molnar, (Thu Jun 21, 1:09 pm)
Re: [BUG] long freezes on thinkpad t60, Linus Torvalds, (Thu Jun 21, 1:10 pm)
Re: [BUG] long freezes on thinkpad t60, Ingo Molnar, (Thu Jun 21, 1:12 pm)
Re: [BUG] long freezes on thinkpad t60, Linus Torvalds, (Thu Jun 21, 1:14 pm)
Re: [BUG] long freezes on thinkpad t60, Ingo Molnar, (Thu Jun 21, 1:16 pm)
Re: [BUG] long freezes on thinkpad t60, Ingo Molnar, (Thu Jun 21, 1:18 pm)
Re: [BUG] long freezes on thinkpad t60, Ingo Molnar, (Thu Jun 21, 1:23 pm)
Re: [BUG] long freezes on thinkpad t60, Ingo Molnar, (Thu Jun 21, 1:30 pm)
Re: [BUG] long freezes on thinkpad t60, Linus Torvalds, (Thu Jun 21, 1:36 pm)
Re: [BUG] long freezes on thinkpad t60, Eric Dumazet, (Thu Jun 21, 1:36 pm)
[patch] spinlock debug: make looping nicer, Ingo Molnar, (Thu Jun 21, 1:42 pm)
Re: [BUG] long freezes on thinkpad t60, Linus Torvalds, (Thu Jun 21, 1:48 pm)
Re: [patch] spinlock debug: make looping nicer, Linus Torvalds, (Thu Jun 21, 1:58 pm)
Re: [BUG] long freezes on thinkpad t60, Ingo Molnar, (Thu Jun 21, 2:06 pm)
Re: [patch] spinlock debug: make looping nicer, Ingo Molnar, (Thu Jun 21, 2:15 pm)
Re: [patch] spinlock debug: make looping nicer, Jarek Poplawski, (Fri Jun 22, 12:00 am)
Re: [BUG] long freezes on thinkpad t60, Ingo Molnar, (Fri Jun 22, 1:17 am)
Re: [BUG] long freezes on thinkpad t60, Jarek Poplawski, (Fri Jun 22, 3:38 am)
Re: [BUG] long freezes on thinkpad t60, Miklos Szeredi, (Sat Jun 23, 3:36 am)
Re: [BUG] long freezes on thinkpad t60, Linus Torvalds, (Sat Jun 23, 9:39 am)
Re: [BUG] long freezes on thinkpad t60, Jarek Poplawski, (Sun Jun 24, 11:45 pm)
Re: [BUG] long freezes on thinkpad t60, Nick Piggin, (Tue Jun 26, 1:42 am)
Re: [BUG] long freezes on thinkpad t60, Jarek Poplawski, (Tue Jun 26, 3:56 am)
Re: [BUG] long freezes on thinkpad t60, Linus Torvalds, (Tue Jun 26, 10:23 am)
Re: [BUG] long freezes on thinkpad t60, Nick Piggin, (Tue Jun 26, 10:23 pm)
Re: [BUG] long freezes on thinkpad t60, Linus Torvalds, (Tue Jun 26, 11:04 pm)
Re: [BUG] long freezes on thinkpad t60, Nick Piggin, (Tue Jun 26, 11:20 pm)
Re: [BUG] long freezes on thinkpad t60, Linus Torvalds, (Wed Jun 27, 12:47 pm)
Re: [BUG] long freezes on thinkpad t60, Ingo Molnar, (Wed Jun 27, 1:10 pm)
Re: [BUG] long freezes on thinkpad t60, Davide Libenzi, (Wed Jun 27, 1:17 pm)
Re: [BUG] long freezes on thinkpad t60, Linus Torvalds, (Wed Jun 27, 3:11 pm)
Re: [BUG] long freezes on thinkpad t60, Davide Libenzi, (Wed Jun 27, 4:30 pm)
Re: [BUG] long freezes on thinkpad t60, Linus Torvalds, (Wed Jun 27, 5:46 pm)
Re: [BUG] long freezes on thinkpad t60, Davide Libenzi, (Wed Jun 27, 8:03 pm)
Re: [BUG] long freezes on thinkpad t60, Nick Piggin, (Mon Jul 2, 12:06 am)