]> git.neil.brown.name Git - history.git/commitdiff
Introduce architecture-specific "ptep_update_dirty_accessed()"
authorLinus Torvalds <torvalds@ppc970.osdl.org>
Tue, 25 May 2004 06:04:59 +0000 (23:04 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Tue, 25 May 2004 06:04:59 +0000 (23:04 -0700)
helper function to write-back the dirty and accessed bits from
ptep_establish().

Right now this defaults to the same old "set_pte()" that we've
always done, except for x86 where we now fix the (unlikely)
race in updating accessed bits and dropping a concurrent dirty
bit.

include/asm-generic/pgtable.h
include/asm-i386/pgtable.h

index fc380ce905ad0204e110183f94d3ed411e25ea15..e9a387cdd37ab52d2c0167f25bce1627f07bcaec 100644 (file)
@@ -2,6 +2,11 @@
 #define _ASM_GENERIC_PGTABLE_H
 
 #ifndef __HAVE_ARCH_PTEP_ESTABLISH
+
+#ifndef ptep_update_dirty_accessed
+#define ptep_update_dirty_accessed(__ptep, __entry, __dirty) set_pte(__ptep, __entry)
+#endif
+
 /*
  * Establish a new mapping:
  *  - flush the old one
@@ -12,7 +17,7 @@
  */
 #define ptep_establish(__vma, __address, __ptep, __entry, __dirty)     \
 do {                                                                   \
-       set_pte(__ptep, __entry);                                       \
+       ptep_update_dirty_accessed(__ptep, __entry, __dirty);           \
        flush_tlb_page(__vma, __address);                               \
 } while (0)
 #endif
index e510ad494a5e687a3c7c486ebf251b5e4cf7eb31..c408168b22e294c8bde8d64bff8cd35292783d14 100644 (file)
@@ -317,8 +317,18 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
 /*
  * The i386 doesn't have any external MMU info: the kernel page
  * tables contain all the necessary information.
+ *
+ * Also, we only update the dirty/accessed state if we set
+ * the dirty bit by hand in the kernel, since the hardware
+ * will do the accessed bit for us, and we don't want to
+ * race with other CPU's that might be updating the dirty
+ * bit at the same time.
  */
 #define update_mmu_cache(vma,address,pte) do { } while (0)
+#define ptep_update_dirty_accessed(__ptep, __entry, __dirty)   \
+       do {                                                    \
+               if (__dirty) set_pte(__ptep, __entry);          \
+       } while (0)
 
 /* Encode and de-code a swap entry */
 #define __swp_type(x)                  (((x).val >> 1) & 0x1f)