The patch titled Subject: mips/mm: add page soft dirty tracking has been added to the -mm tree. Its filename is mips-mm-add-page-soft-dirty-tracking.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/mips-mm-add-page-soft-dirty-tracking.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/mips-mm-add-page-soft-dirty-tracking.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Guoyun Sun <sunguoyun@xxxxxxxxxxx> Subject: 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. Link: http://lkml.kernel.org/r/1587460527-13986-1-git-send-email-sunguoyun@xxxxxxxxxxx Signed-off-by: Guoyun Sun <sunguoyun@xxxxxxxxxxx> Cc: Thomas Bogendoerfer <tsbogend@xxxxxxxxxxxxxxxx> Cc: Paul Burton <paulburton@xxxxxxxxxx> Cc: Daniel Silsby <dansilsby@xxxxxxxxx> Cc: Jiaxun Yang <jiaxun.yang@xxxxxxxxxxx> Cc: Paul Cercueil <paul@xxxxxxxxxxxxxxx> Cc: Dmitry Korotin <dkorotin@xxxxxxxxxxxx> Cc: Steven Price <steven.price@xxxxxxx> Cc: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx> Cc: Mike Rapoport <rppt@xxxxxxxxxxxxx> Cc: Anshuman Khandual <anshuman.khandual@xxxxxxx> Cc: Guoyun Sun <sunguoyun@xxxxxxxxxxx> Cc: TieZhu Yang <yangtiezhu@xxxxxxxxxxx> Cc: Xuefeng Li <lixuefeng@xxxxxxxxxxx> Cc: Konstantin Khlebnikov <koct9i@xxxxxxxxx> Cc: Pavel Emelyanov <xemul@xxxxxxxxxx> Cc: Cyrill Gorcunov <gorcunov@xxxxxxxxx> Cc: Ralf Baechle <ralf@xxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- arch/mips/Kconfig | 1 arch/mips/include/asm/pgtable-bits.h | 8 +++- arch/mips/include/asm/pgtable.h | 48 +++++++++++++++++++++++-- 3 files changed, 53 insertions(+), 4 deletions(-) --- a/arch/mips/include/asm/pgtable-bits.h~mips-mm-add-page-soft-dirty-tracking +++ a/arch/mips/include/asm/pgtable-bits.h @@ -55,6 +55,7 @@ enum pgtable_bits { #if defined(CONFIG_ARCH_HAS_PTE_SPECIAL) _PAGE_SPECIAL_SHIFT, #endif + _PAGE_SOFT_DIRTY_SHIFT, }; /* @@ -84,6 +85,7 @@ enum pgtable_bits { #if defined(CONFIG_ARCH_HAS_PTE_SPECIAL) _PAGE_SPECIAL_SHIFT, #endif + _PAGE_SOFT_DIRTY_SHIFT, }; #elif defined(CONFIG_CPU_R3K_TLB) @@ -99,6 +101,7 @@ enum pgtable_bits { #if defined(CONFIG_ARCH_HAS_PTE_SPECIAL) _PAGE_SPECIAL_SHIFT, #endif + _PAGE_SOFT_DIRTY_SHIFT, /* Used by TLB hardware (placed in EntryLo) */ _PAGE_GLOBAL_SHIFT = 8, @@ -125,7 +128,7 @@ enum pgtable_bits { #if defined(CONFIG_ARCH_HAS_PTE_SPECIAL) _PAGE_SPECIAL_SHIFT, #endif - + _PAGE_SOFT_DIRTY_SHIFT, /* Used by TLB hardware (placed in EntryLo*) */ #if defined(CONFIG_CPU_HAS_RIXI) _PAGE_NO_EXEC_SHIFT, @@ -152,6 +155,7 @@ enum pgtable_bits { #else # define _PAGE_SPECIAL 0 #endif +#define _PAGE_SOFT_DIRTY (1 << _PAGE_SOFT_DIRTY_SHIFT) /* Used by TLB hardware (placed in EntryLo*) */ #if defined(CONFIG_XPA) @@ -269,6 +273,6 @@ static inline uint64_t pte_to_entrylo(un #define __WRITEABLE (_PAGE_SILENT_WRITE | _PAGE_WRITE | _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 */ --- a/arch/mips/include/asm/pgtable.h~mips-mm-add-page-soft-dirty-tracking +++ a/arch/mips/include/asm/pgtable.h @@ -400,7 +400,7 @@ static inline pte_t pte_mkwrite(pte_t pt 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) pte_val(pte) |= _PAGE_SILENT_WRITE; return pte; @@ -423,6 +423,30 @@ static inline pte_t pte_mkhuge(pte_t pte return pte; } #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 /* @@ -576,7 +600,7 @@ static inline pmd_t pmd_mkclean(pmd_t pm 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) pmd_val(pmd) |= _PAGE_SILENT_WRITE; @@ -605,6 +629,26 @@ static inline pmd_t pmd_mkyoung(pmd_t pm 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 pmd_t mk_pmd(struct page *page, pgprot_t prot); --- a/arch/mips/Kconfig~mips-mm-add-page-soft-dirty-tracking +++ a/arch/mips/Kconfig @@ -495,6 +495,7 @@ config MACH_LOONGSON64 select COMMON_CLK select USE_OF select BUILTIN_DTB + select HAVE_ARCH_SOFT_DIRTY help This enables the support of Loongson-2/3 family of machines. _ Patches currently in -mm which might be from sunguoyun@xxxxxxxxxxx are mips-mm-add-page-soft-dirty-tracking.patch