Commit 2971317a authored by Guoyun Sun's avatar Guoyun Sun Committed by Thomas Bogendoerfer

mips/mm: Add page soft dirty tracking

User space checkpoint and restart tool (CRIU) needs the page's change
to be soft tracked. This allows to do a pre checkpoint and then dump
only touched pages.
Signed-off-by: default avatarGuoyun Sun <sunguoyun@loongson.cn>
Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
parent ac44d672
...@@ -55,6 +55,9 @@ enum pgtable_bits { ...@@ -55,6 +55,9 @@ enum pgtable_bits {
#if defined(CONFIG_ARCH_HAS_PTE_SPECIAL) #if defined(CONFIG_ARCH_HAS_PTE_SPECIAL)
_PAGE_SPECIAL_SHIFT, _PAGE_SPECIAL_SHIFT,
#endif #endif
#if defined(CONFIG_HAVE_ARCH_SOFT_DIRTY)
_PAGE_SOFT_DIRTY_SHIFT,
#endif
}; };
/* /*
...@@ -84,6 +87,9 @@ enum pgtable_bits { ...@@ -84,6 +87,9 @@ enum pgtable_bits {
#if defined(CONFIG_ARCH_HAS_PTE_SPECIAL) #if defined(CONFIG_ARCH_HAS_PTE_SPECIAL)
_PAGE_SPECIAL_SHIFT, _PAGE_SPECIAL_SHIFT,
#endif #endif
#if defined(CONFIG_HAVE_ARCH_SOFT_DIRTY)
_PAGE_SOFT_DIRTY_SHIFT,
#endif
}; };
#elif defined(CONFIG_CPU_R3K_TLB) #elif defined(CONFIG_CPU_R3K_TLB)
...@@ -99,6 +105,9 @@ enum pgtable_bits { ...@@ -99,6 +105,9 @@ enum pgtable_bits {
#if defined(CONFIG_ARCH_HAS_PTE_SPECIAL) #if defined(CONFIG_ARCH_HAS_PTE_SPECIAL)
_PAGE_SPECIAL_SHIFT, _PAGE_SPECIAL_SHIFT,
#endif #endif
#if defined(CONFIG_HAVE_ARCH_SOFT_DIRTY)
_PAGE_SOFT_DIRTY_SHIFT,
#endif
/* Used by TLB hardware (placed in EntryLo) */ /* Used by TLB hardware (placed in EntryLo) */
_PAGE_GLOBAL_SHIFT = 8, _PAGE_GLOBAL_SHIFT = 8,
...@@ -125,7 +134,9 @@ enum pgtable_bits { ...@@ -125,7 +134,9 @@ enum pgtable_bits {
#if defined(CONFIG_ARCH_HAS_PTE_SPECIAL) #if defined(CONFIG_ARCH_HAS_PTE_SPECIAL)
_PAGE_SPECIAL_SHIFT, _PAGE_SPECIAL_SHIFT,
#endif #endif
#if defined(CONFIG_HAVE_ARCH_SOFT_DIRTY)
_PAGE_SOFT_DIRTY_SHIFT,
#endif
/* Used by TLB hardware (placed in EntryLo*) */ /* Used by TLB hardware (placed in EntryLo*) */
#if defined(CONFIG_CPU_HAS_RIXI) #if defined(CONFIG_CPU_HAS_RIXI)
_PAGE_NO_EXEC_SHIFT, _PAGE_NO_EXEC_SHIFT,
...@@ -152,6 +163,11 @@ enum pgtable_bits { ...@@ -152,6 +163,11 @@ enum pgtable_bits {
#else #else
# define _PAGE_SPECIAL 0 # define _PAGE_SPECIAL 0
#endif #endif
#if defined(CONFIG_HAVE_ARCH_SOFT_DIRTY)
# define _PAGE_SOFT_DIRTY (1 << _PAGE_SOFT_DIRTY_SHIFT)
#else
# define _PAGE_SOFT_DIRTY 0
#endif
/* Used by TLB hardware (placed in EntryLo*) */ /* Used by TLB hardware (placed in EntryLo*) */
#if defined(CONFIG_XPA) #if defined(CONFIG_XPA)
...@@ -269,6 +285,6 @@ static inline uint64_t pte_to_entrylo(unsigned long pte_val) ...@@ -269,6 +285,6 @@ static inline uint64_t pte_to_entrylo(unsigned long pte_val)
#define __WRITEABLE (_PAGE_SILENT_WRITE | _PAGE_WRITE | _PAGE_MODIFIED) #define __WRITEABLE (_PAGE_SILENT_WRITE | _PAGE_WRITE | _PAGE_MODIFIED)
#define _PAGE_CHG_MASK (_PAGE_ACCESSED | _PAGE_MODIFIED | \ #define _PAGE_CHG_MASK (_PAGE_ACCESSED | _PAGE_MODIFIED | \
_PFN_MASK | _CACHE_MASK) _PAGE_SOFT_DIRTY | _PFN_MASK | _CACHE_MASK)
#endif /* _ASM_PGTABLE_BITS_H */ #endif /* _ASM_PGTABLE_BITS_H */
...@@ -400,7 +400,7 @@ static inline pte_t pte_mkwrite(pte_t pte) ...@@ -400,7 +400,7 @@ static inline pte_t pte_mkwrite(pte_t pte)
static inline pte_t pte_mkdirty(pte_t pte) static inline pte_t pte_mkdirty(pte_t pte)
{ {
pte_val(pte) |= _PAGE_MODIFIED; pte_val(pte) |= _PAGE_MODIFIED | _PAGE_SOFT_DIRTY;
if (pte_val(pte) & _PAGE_WRITE) if (pte_val(pte) & _PAGE_WRITE)
pte_val(pte) |= _PAGE_SILENT_WRITE; pte_val(pte) |= _PAGE_SILENT_WRITE;
return pte; return pte;
...@@ -423,6 +423,30 @@ static inline pte_t pte_mkhuge(pte_t pte) ...@@ -423,6 +423,30 @@ static inline pte_t pte_mkhuge(pte_t pte)
return pte; return pte;
} }
#endif /* CONFIG_MIPS_HUGE_TLB_SUPPORT */ #endif /* CONFIG_MIPS_HUGE_TLB_SUPPORT */
#ifdef CONFIG_HAVE_ARCH_SOFT_DIRTY
static inline bool pte_soft_dirty(pte_t pte)
{
return pte_val(pte) & _PAGE_SOFT_DIRTY;
}
#define pte_swp_soft_dirty pte_soft_dirty
static inline pte_t pte_mksoft_dirty(pte_t pte)
{
pte_val(pte) |= _PAGE_SOFT_DIRTY;
return pte;
}
#define pte_swp_mksoft_dirty pte_mksoft_dirty
static inline pte_t pte_clear_soft_dirty(pte_t pte)
{
pte_val(pte) &= ~(_PAGE_SOFT_DIRTY);
return pte;
}
#define pte_swp_clear_soft_dirty pte_clear_soft_dirty
#endif /* CONFIG_HAVE_ARCH_SOFT_DIRTY */
#endif #endif
/* /*
...@@ -576,7 +600,7 @@ static inline pmd_t pmd_mkclean(pmd_t pmd) ...@@ -576,7 +600,7 @@ static inline pmd_t pmd_mkclean(pmd_t pmd)
static inline pmd_t pmd_mkdirty(pmd_t pmd) static inline pmd_t pmd_mkdirty(pmd_t pmd)
{ {
pmd_val(pmd) |= _PAGE_MODIFIED; pmd_val(pmd) |= _PAGE_MODIFIED | _PAGE_SOFT_DIRTY;
if (pmd_val(pmd) & _PAGE_WRITE) if (pmd_val(pmd) & _PAGE_WRITE)
pmd_val(pmd) |= _PAGE_SILENT_WRITE; pmd_val(pmd) |= _PAGE_SILENT_WRITE;
...@@ -605,6 +629,26 @@ static inline pmd_t pmd_mkyoung(pmd_t pmd) ...@@ -605,6 +629,26 @@ static inline pmd_t pmd_mkyoung(pmd_t pmd)
return pmd; return pmd;
} }
#ifdef CONFIG_HAVE_ARCH_SOFT_DIRTY
static inline int pmd_soft_dirty(pmd_t pmd)
{
return !!(pmd_val(pmd) & _PAGE_SOFT_DIRTY);
}
static inline pmd_t pmd_mksoft_dirty(pmd_t pmd)
{
pmd_val(pmd) |= _PAGE_SOFT_DIRTY;
return pmd;
}
static inline pmd_t pmd_clear_soft_dirty(pmd_t pmd)
{
pmd_val(pmd) &= ~(_PAGE_SOFT_DIRTY);
return pmd;
}
#endif /* CONFIG_HAVE_ARCH_SOFT_DIRTY */
/* Extern to avoid header file madness */ /* Extern to avoid header file madness */
extern pmd_t mk_pmd(struct page *page, pgprot_t prot); extern pmd_t mk_pmd(struct page *page, pgprot_t prot);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment