Re: x86 ptep_get_and_clear question

From: Manfred Spraul (
Date: Fri Feb 16 2001 - 10:54:44 EST

Jamie Lokier wrote:
> /* mprotect.c */
> entry = ptep_get_and_clear(pte);
> set_pte(pte, pte_modify(entry, newprot));
> I.e. the only code with the race condition is code which explicitly
> clears the dirty bit, in vmscan.c.
> Do you see any possibility of losing a dirty bit here?
Of course.
Just check the output after preprocessing.
        int entry;
        entry = *pte;
        entry &= ~_PAGE_CHG_MASK;
        entry |= pgprot_val(newprot)
        *pte = entry;

We need
        atomic_clear_mask (_PAGE_CHG_MASK, pte);
        atomic_set_mask (pgprot_val(newprot), *pte);

for multi threaded apps.

> If not, there's no need for the intricate "gather" or "double scan"
> schemes for mprotect() and it can stay as fast as possible.
Correct, but we need a platform specific "update_pte", and perhaps
update_begin, update_end hooks (empty on i386) for other archs.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

This archive was generated by hypermail 2b29 : Fri Feb 23 2001 - 21:00:13 EST