Re: [PATCH] ppc64: Fix possible race with set_pte on a present PTE

From: Linus Torvalds
Date: Tue May 25 2004 - 17:04:48 EST




On Tue, 25 May 2004, Linus Torvalds wrote:
>
>
> On Wed, 26 May 2004, Benjamin Herrenschmidt wrote:
> >
> > Well, just setting one of those 2 bits doesn't require a hash table
> > invalidate as long as nothing else changes.
>
> Ok. And nothing ever writes to the SW page tables outside the page table
> lock, right? So on ppc64, we could just do
>
> #define ptep_update_dirty_accessed(ptep, entry, dirty) \
> *(ptep) = (entry)
>
> and be done with it. No?

No. I'm an idiot. We do need to keep the "hashed" bit atomically, so it
would need to be something on the order of

static inline void ptep_update_dirty_accessed(pte_t *ptep, pte_t entry, int dirty)
{
unsigned long bits = pte_value(entry) & (_PAGE_DIRTY | _PAGE_ACCESSED);
unsigned long tmp;

__asm__ __volatile__(
"1: lwarx %0,0,%3\n\
or %0,%2,%0\n\
stwcx. %0,0,%3\n\
bne- 1b"
:"=&r" (tmp), "=m" (*ptep)
:"r" (bits), "r" (ptep)
:"cc");
}

/* Make asm-generic/pgtable.h know about it.. */
#define ptep_update_dirty_accessed ptep_update_dirty_accessed

or whatever.

Anyway, I don't feel competent enough to commit it, so..

Linus
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/