* Re: [PATCH] x86/PAE: Fix pte_clear for the >4GB RAM case
[not found] <200604272001.k3RK1dmX007637@hera.kernel.org>
@ 2006-04-28 5:18 ` Andi Kleen
2006-04-28 5:23 ` Chris Wright
0 siblings, 1 reply; 7+ messages in thread
From: Andi Kleen @ 2006-04-28 5:18 UTC (permalink / raw)
To: Linux Kernel Mailing List; +Cc: zach, torvalds
Linux Kernel Mailing List <linux-kernel@vger.kernel.org> writes:
> +/*
> + * For PTEs and PDEs, we must clear the P-bit first when clearing a page table
> + * entry, so clear the bottom half first and enforce ordering with a compiler
> + * barrier.
> + */
> +static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
> +{
> + ptep->pte_low = 0;
> + smp_wmb();
> + ptep->pte_high = 0;
> +}
> +
> +static inline void pmd_clear(pmd_t *pmd)
> +{
> + u32 *tmp = (u32 *)pmd;
> + *tmp = 0;
> + smp_wmb();
> + *(tmp + 1) = 0;
> +}
I think that's still wrong - it should be wmb() not smp_wmb because this
problem can happen on a UP kernel already.
-Andi
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] x86/PAE: Fix pte_clear for the >4GB RAM case
2006-04-28 5:18 ` [PATCH] x86/PAE: Fix pte_clear for the >4GB RAM case Andi Kleen
@ 2006-04-28 5:23 ` Chris Wright
2006-04-28 6:08 ` Andi Kleen
0 siblings, 1 reply; 7+ messages in thread
From: Chris Wright @ 2006-04-28 5:23 UTC (permalink / raw)
To: Andi Kleen; +Cc: Linux Kernel Mailing List, zach, torvalds
* Andi Kleen (ak@suse.de) wrote:
> > +static inline void pmd_clear(pmd_t *pmd)
> > +{
> > + u32 *tmp = (u32 *)pmd;
> > + *tmp = 0;
> > + smp_wmb();
> > + *(tmp + 1) = 0;
> > +}
>
> I think that's still wrong - it should be wmb() not smp_wmb because this
> problem can happen on a UP kernel already.
I thought the barrier is to keep compiler from reordering not processor.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] x86/PAE: Fix pte_clear for the >4GB RAM case
2006-04-28 5:23 ` Chris Wright
@ 2006-04-28 6:08 ` Andi Kleen
2006-04-28 6:27 ` Chris Wright
0 siblings, 1 reply; 7+ messages in thread
From: Andi Kleen @ 2006-04-28 6:08 UTC (permalink / raw)
To: Chris Wright; +Cc: Linux Kernel Mailing List, zach, torvalds
On Friday 28 April 2006 07:23, Chris Wright wrote:
> * Andi Kleen (ak@suse.de) wrote:
> > > +static inline void pmd_clear(pmd_t *pmd)
> > > +{
> > > + u32 *tmp = (u32 *)pmd;
> > > + *tmp = 0;
> > > + smp_wmb();
> > > + *(tmp + 1) = 0;
> > > +}
> >
> > I think that's still wrong - it should be wmb() not smp_wmb because this
> > problem can happen on a UP kernel already.
>
> I thought the barrier is to keep compiler from reordering not processor.
Yes, but with smp_wmb() it will go away on UP. And even on UP the
CPU is free to speculate.
-Andi
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] x86/PAE: Fix pte_clear for the >4GB RAM case
2006-04-28 6:08 ` Andi Kleen
@ 2006-04-28 6:27 ` Chris Wright
2006-04-28 6:29 ` Andi Kleen
0 siblings, 1 reply; 7+ messages in thread
From: Chris Wright @ 2006-04-28 6:27 UTC (permalink / raw)
To: Andi Kleen; +Cc: Chris Wright, Linux Kernel Mailing List, zach, torvalds
* Andi Kleen (ak@suse.de) wrote:
> On Friday 28 April 2006 07:23, Chris Wright wrote:
> > * Andi Kleen (ak@suse.de) wrote:
> > > > +static inline void pmd_clear(pmd_t *pmd)
> > > > +{
> > > > + u32 *tmp = (u32 *)pmd;
> > > > + *tmp = 0;
> > > > + smp_wmb();
> > > > + *(tmp + 1) = 0;
> > > > +}
> > >
> > > I think that's still wrong - it should be wmb() not smp_wmb because this
> > > problem can happen on a UP kernel already.
> >
> > I thought the barrier is to keep compiler from reordering not processor.
>
> Yes, but with smp_wmb() it will go away on UP. And even on UP the
> CPU is free to speculate.
I must be confused. Doesn't that become a barrier() on UP?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] x86/PAE: Fix pte_clear for the >4GB RAM case
2006-04-28 6:27 ` Chris Wright
@ 2006-04-28 6:29 ` Andi Kleen
2006-04-28 7:20 ` Nick Piggin
2006-04-28 14:54 ` Linus Torvalds
0 siblings, 2 replies; 7+ messages in thread
From: Andi Kleen @ 2006-04-28 6:29 UTC (permalink / raw)
To: Chris Wright; +Cc: Linux Kernel Mailing List, zach, torvalds
On Friday 28 April 2006 08:27, Chris Wright wrote:
> * Andi Kleen (ak@suse.de) wrote:
> > On Friday 28 April 2006 07:23, Chris Wright wrote:
> > > * Andi Kleen (ak@suse.de) wrote:
> > > > > +static inline void pmd_clear(pmd_t *pmd)
> > > > > +{
> > > > > + u32 *tmp = (u32 *)pmd;
> > > > > + *tmp = 0;
> > > > > + smp_wmb();
> > > > > + *(tmp + 1) = 0;
> > > > > +}
> > > >
> > > > I think that's still wrong - it should be wmb() not smp_wmb because this
> > > > problem can happen on a UP kernel already.
> > >
> > > I thought the barrier is to keep compiler from reordering not processor.
> >
> > Yes, but with smp_wmb() it will go away on UP. And even on UP the
> > CPU is free to speculate.
>
> I must be confused. Doesn't that become a barrier() on UP?
No it was me who was confused sorry. Somehow i thought it was defined
away for !SMP
(which would make sense because why would you want a compile barrier
for a barrier that is only needed on SMP?)
-Andi
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] x86/PAE: Fix pte_clear for the >4GB RAM case
2006-04-28 6:29 ` Andi Kleen
@ 2006-04-28 7:20 ` Nick Piggin
2006-04-28 14:54 ` Linus Torvalds
1 sibling, 0 replies; 7+ messages in thread
From: Nick Piggin @ 2006-04-28 7:20 UTC (permalink / raw)
To: Andi Kleen; +Cc: Chris Wright, Linux Kernel Mailing List, zach, torvalds
Andi Kleen wrote:
> No it was me who was confused sorry. Somehow i thought it was defined
> away for !SMP
>
> (which would make sense because why would you want a compile barrier
> for a barrier that is only needed on SMP?)
It is maybe not clearly named. smp_wmb() is a memory barrier to the
regular (eg. RAM) cache coherency domain AFAICT. wmb() is also a
barrier to io memory.
There is nothing to distinguish SMP and UP. I guess sometimes smp_
barriers would not even have to be a barrier() on UP, but other
times they would have to be (eg. in the case of concurrent
interrupts, context switches).
--
SUSE Labs, Novell Inc.
Send instant messages to your online friends http://au.messenger.yahoo.com
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] x86/PAE: Fix pte_clear for the >4GB RAM case
2006-04-28 6:29 ` Andi Kleen
2006-04-28 7:20 ` Nick Piggin
@ 2006-04-28 14:54 ` Linus Torvalds
1 sibling, 0 replies; 7+ messages in thread
From: Linus Torvalds @ 2006-04-28 14:54 UTC (permalink / raw)
To: Andi Kleen; +Cc: Chris Wright, Linux Kernel Mailing List, zach
On Fri, 28 Apr 2006, Andi Kleen wrote:
> >
> > I must be confused. Doesn't that become a barrier() on UP?
>
> No it was me who was confused sorry. Somehow i thought it was defined
> away for !SMP
>
> (which would make sense because why would you want a compile barrier
> for a barrier that is only needed on SMP?)
If the write barrier is needed on SMP, then UP needs a compiler barrier.
Even UP has interrupts (and preemption) that can expose ordering of the
interrupted code.
Linus
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2006-04-28 14:57 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <200604272001.k3RK1dmX007637@hera.kernel.org>
2006-04-28 5:18 ` [PATCH] x86/PAE: Fix pte_clear for the >4GB RAM case Andi Kleen
2006-04-28 5:23 ` Chris Wright
2006-04-28 6:08 ` Andi Kleen
2006-04-28 6:27 ` Chris Wright
2006-04-28 6:29 ` Andi Kleen
2006-04-28 7:20 ` Nick Piggin
2006-04-28 14:54 ` Linus Torvalds
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox