public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] I386 convert pae wmb to non smp
@ 2006-04-26 22:03 Zachary Amsden
  2006-04-27  0:00 ` Nick Piggin
  0 siblings, 1 reply; 5+ messages in thread
From: Zachary Amsden @ 2006-04-26 22:03 UTC (permalink / raw)
  To: Andrew Morton, Linux-Kernel, Hugh Dickins, Jan Beulich,
	Keir Fraser, Pratap Subrahmanyam, Nick Piggin, Zachary Amsden

Similar to the last bug, on set_pte, we don't want the compiler to re-order
the write of the PTE, even in non-SMP configurations, since if the write of
the low word occurs first, the TLB could prefetch a bad highmem mapping which
has been aliased into low memory.

Signed-off-by: Zachary Amsden <zach@vmware.com>

Index: linux-2.6.17-rc/include/asm-i386/pgtable-3level.h
===================================================================
--- linux-2.6.17-rc.orig/include/asm-i386/pgtable-3level.h	2006-04-26 08:38:57.000000000 -0700
+++ linux-2.6.17-rc/include/asm-i386/pgtable-3level.h	2006-04-26 14:45:12.000000000 -0700
@@ -53,7 +53,7 @@ static inline int pte_exec_kernel(pte_t 
 static inline void set_pte(pte_t *ptep, pte_t pte)
 {
 	ptep->pte_high = pte.pte_high;
-	smp_wmb();
+	wmb();
 	ptep->pte_low = pte.pte_low;
 }
 #define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] I386 convert pae wmb to non smp
  2006-04-26 22:03 [PATCH 2/2] I386 convert pae wmb to non smp Zachary Amsden
@ 2006-04-27  0:00 ` Nick Piggin
  2006-04-27  1:09   ` Zachary Amsden
  0 siblings, 1 reply; 5+ messages in thread
From: Nick Piggin @ 2006-04-27  0:00 UTC (permalink / raw)
  To: Zachary Amsden
  Cc: Andrew Morton, Linux-Kernel, Hugh Dickins, Jan Beulich,
	Keir Fraser, Pratap Subrahmanyam

Zachary Amsden wrote:

>Similar to the last bug, on set_pte, we don't want the compiler to re-order
>the write of the PTE, even in non-SMP configurations, since if the write of
>the low word occurs first, the TLB could prefetch a bad highmem mapping which
>has been aliased into low memory.
>

wmb() means that it also orders IO memory. It is no difference for
i386, but smp_wmb() actually has the right semantics of the abstract
Linux memory model.

>Signed-off-by: Zachary Amsden <zach@vmware.com>
>
>Index: linux-2.6.17-rc/include/asm-i386/pgtable-3level.h
>===================================================================
>--- linux-2.6.17-rc.orig/include/asm-i386/pgtable-3level.h	2006-04-26 08:38:57.000000000 -0700
>+++ linux-2.6.17-rc/include/asm-i386/pgtable-3level.h	2006-04-26 14:45:12.000000000 -0700
>@@ -53,7 +53,7 @@ static inline int pte_exec_kernel(pte_t 
> static inline void set_pte(pte_t *ptep, pte_t pte)
> {
> 	ptep->pte_high = pte.pte_high;
>-	smp_wmb();
>+	wmb();
> 	ptep->pte_low = pte.pte_low;
> }
> #define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
>
>  
>

Send instant messages to your online friends http://au.messenger.yahoo.com 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] I386 convert pae wmb to non smp
  2006-04-27  0:00 ` Nick Piggin
@ 2006-04-27  1:09   ` Zachary Amsden
  2006-04-27  3:30     ` Nick Piggin
  0 siblings, 1 reply; 5+ messages in thread
From: Zachary Amsden @ 2006-04-27  1:09 UTC (permalink / raw)
  To: Nick Piggin
  Cc: Andrew Morton, Linux-Kernel, Hugh Dickins, Jan Beulich,
	Keir Fraser, Pratap Subrahmanyam

Nick Piggin wrote:
> Zachary Amsden wrote:
>
>> Similar to the last bug, on set_pte, we don't want the compiler to 
>> re-order
>> the write of the PTE, even in non-SMP configurations, since if the 
>> write of
>> the low word occurs first, the TLB could prefetch a bad highmem 
>> mapping which
>> has been aliased into low memory.
>>
>
> wmb() means that it also orders IO memory. It is no difference for
> i386, but smp_wmb() actually has the right semantics of the abstract
> Linux memory model.

The name is pretty confused.  smp_wmb seems to imply an SMP-only 
barrier, whereas we want here a write barrier on regular memory.  Both 
smp_wmb and wmb() are identical in that they both reduce to barrier 
today, but I confess not to know which one semantically is correct.  
Your call on this patch - it is unecessary, I thought it was more 
semantically correct, but you probably know that better than me.  So, 
drop part 2 of this patch?

Zach

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] I386 convert pae wmb to non smp
  2006-04-27  1:09   ` Zachary Amsden
@ 2006-04-27  3:30     ` Nick Piggin
  2006-04-27  8:21       ` Keir Fraser
  0 siblings, 1 reply; 5+ messages in thread
From: Nick Piggin @ 2006-04-27  3:30 UTC (permalink / raw)
  To: Zachary Amsden
  Cc: Andrew Morton, Linux-Kernel, Hugh Dickins, Jan Beulich,
	Keir Fraser, Pratap Subrahmanyam

Zachary Amsden wrote:

> Nick Piggin wrote:
>
>> wmb() means that it also orders IO memory. It is no difference for
>> i386, but smp_wmb() actually has the right semantics of the abstract
>> Linux memory model.
>
>
> The name is pretty confused.  smp_wmb seems to imply an SMP-only 
> barrier, whereas we want here a write barrier on regular memory.


That is just a compiler barrier (barrier()). A CPU should always be 
consistent with
itself so memory ordering doesn't really apply there (hence smp_ prefix, 
which also
are compiler barriers, of course).

>   Both smp_wmb and wmb() are identical in that they both reduce to 
> barrier today, but I confess not to know which one semantically is 
> correct.


Well you're only looking at i386. True it is i386 specific code, but 
sticking
to the Linux memory model is more clear and consistent I think.

>   Your call on this patch - it is unecessary, I thought it was more 
> semantically correct, but you probably know that better than me.  So, 
> drop part 2 of this patch?


Yes, and make part 1 use smp_wmb.

--

Send instant messages to your online friends http://au.messenger.yahoo.com 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] I386 convert pae wmb to non smp
  2006-04-27  3:30     ` Nick Piggin
@ 2006-04-27  8:21       ` Keir Fraser
  0 siblings, 0 replies; 5+ messages in thread
From: Keir Fraser @ 2006-04-27  8:21 UTC (permalink / raw)
  To: Nick Piggin
  Cc: Zachary Amsden, Pratap Subrahmanyam, Hugh Dickins, Linux-Kernel,
	Andrew Morton, Jan Beulich


On 27 Apr 2006, at 04:30, Nick Piggin wrote:

>> The name is pretty confused.  smp_wmb seems to imply an SMP-only 
>> barrier, whereas we want here a write barrier on regular memory.
>
> That is just a compiler barrier (barrier()). A CPU should always be 
> consistent with
> itself so memory ordering doesn't really apply there (hence smp_ 
> prefix, which also
> are compiler barriers, of course).

This would be an issue of consistency between a CPU and its TLB, so I 
doubt the usual self-consistency argument would hold. I would consider 
the TLB as logically external and separate from the core execution 
logic of the CPU. Of course it's an academic point either way since no 
PAE-capable x86 processor ever reorders stores to WB memory -- my 
original point was simply that smp_wmb() is a misleading name in this 
context, even barrier() would be clearer imo, but I'm in no way a Linux 
abstract memory model expert.

  -- Keir


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-04-27  8:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-26 22:03 [PATCH 2/2] I386 convert pae wmb to non smp Zachary Amsden
2006-04-27  0:00 ` Nick Piggin
2006-04-27  1:09   ` Zachary Amsden
2006-04-27  3:30     ` Nick Piggin
2006-04-27  8:21       ` Keir Fraser

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox