Skip to contentSkip to conversation

x86/PAE: Fix pte_clear for the >4GB RAM case

PATCH Andi Kleen 4 participants 7 messages Apr 28, 2006 1 message not in the archive

lore
Share & tools
lore

Andi Kleen

author
#1 lore raw
In reply to a message not in the archive
Quoted 9 lines · Linux Kernel Mailing List
(quoted diff) +9 -0
+/*
+ * 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();

Review

Quoted 10 lines
(quoted diff) +10 -0
+	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

#2 lore raw
Quoted 10 lines · * Andi Kleen ([email protected]) wrote:

Review

Quoted 7 lines
(quoted diff) +7 -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.

I thought the barrier is to keep compiler from reordering not processor.

author
#3 lore raw
Quoted 12 lines · Chris Wright
Quoted 10 lines · * Andi Kleen ([email protected]) wrote:

Review

Quoted 7 lines
(quoted diff) +7 -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.

Quoted 1 line

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

#4 lore raw
Quoted 13 lines · * Andi Kleen ([email protected]) wrote:
Quoted 12 lines · Chris Wright
Quoted 10 lines · * Andi Kleen ([email protected]) wrote:

Review

Quoted 7 lines
(quoted diff) +7 -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.

Quoted 4 lines
Quoted 1 line

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?

author
#5 lore raw
Quoted 14 lines · Chris Wright
Quoted 13 lines · * Andi Kleen ([email protected]) wrote:
Quoted 12 lines · Chris Wright
Quoted 10 lines · * Andi Kleen ([email protected]) wrote:

Review

Quoted 7 lines
(quoted diff) +7 -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.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

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

#6 lore raw
Quoted 5 lines · Andi Kleen

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).

Signature · 2 lines
SUSE Labs, Novell Inc.
Send instant messages to your online friends http://au.messenger.yahoo.com 
#7 lore raw
In reply to Andi Kleen
Quoted 8 lines · Andi Kleen
Quoted 2 lines

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