Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mm: x86 pgtable: require X86_64 for soft-dirty tracker

Tracking dirty status on 2 level pages requires very ugly macros and
taking into account how old the machines who can operate without PAE
mode only are, lets drop soft dirty tracker from them for code
simplicity (note I can't drop all the macros from 2 level pages by now
since _PAGE_BIT_PROTNONE and _PAGE_BIT_FILE are still used even without
tracker).

Linus proposed to completely rip off softdirty support on x86-32 (even
with PAE) and since for CRIU we're not planning to support native x86-32
mode, lets do that.

(Softdirty tracker is relatively new feature which is mostly used by
CRIU so I don't expect if such API change would cause problems for
userspace).

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Peter Anvin <hpa@zytor.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Steven Noonan <steven@uplinklabs.net>
Cc: Rik van Riel <riel@redhat.com>
Cc: David Vrabel <david.vrabel@citrix.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Cyrill Gorcunov and committed by
Linus Torvalds
2bf01f9f 2373eaec

+6 -50
+1 -1
arch/x86/Kconfig
··· 105 105 select HAVE_ARCH_SECCOMP_FILTER 106 106 select BUILDTIME_EXTABLE_SORT 107 107 select GENERIC_CMOS_UPDATE 108 - select HAVE_ARCH_SOFT_DIRTY 108 + select HAVE_ARCH_SOFT_DIRTY if X86_64 109 109 select CLOCKSOURCE_WATCHDOG 110 110 select GENERIC_CLOCKEVENTS 111 111 select ARCH_CLOCKSOURCE_DATA
-49
arch/x86/include/asm/pgtable-2level.h
··· 62 62 return ((value >> rightshift) & mask) << leftshift; 63 63 } 64 64 65 - #ifdef CONFIG_MEM_SOFT_DIRTY 66 - 67 - /* 68 - * Bits _PAGE_BIT_PRESENT, _PAGE_BIT_FILE, _PAGE_BIT_SOFT_DIRTY and 69 - * _PAGE_BIT_PROTNONE are taken, split up the 28 bits of offset 70 - * into this range. 71 - */ 72 - #define PTE_FILE_MAX_BITS 28 73 - #define PTE_FILE_SHIFT1 (_PAGE_BIT_PRESENT + 1) 74 - #define PTE_FILE_SHIFT2 (_PAGE_BIT_FILE + 1) 75 - #define PTE_FILE_SHIFT3 (_PAGE_BIT_PROTNONE + 1) 76 - #define PTE_FILE_SHIFT4 (_PAGE_BIT_SOFT_DIRTY + 1) 77 - #define PTE_FILE_BITS1 (PTE_FILE_SHIFT2 - PTE_FILE_SHIFT1 - 1) 78 - #define PTE_FILE_BITS2 (PTE_FILE_SHIFT3 - PTE_FILE_SHIFT2 - 1) 79 - #define PTE_FILE_BITS3 (PTE_FILE_SHIFT4 - PTE_FILE_SHIFT3 - 1) 80 - 81 - #define PTE_FILE_MASK1 ((1U << PTE_FILE_BITS1) - 1) 82 - #define PTE_FILE_MASK2 ((1U << PTE_FILE_BITS2) - 1) 83 - #define PTE_FILE_MASK3 ((1U << PTE_FILE_BITS3) - 1) 84 - 85 - #define PTE_FILE_LSHIFT2 (PTE_FILE_BITS1) 86 - #define PTE_FILE_LSHIFT3 (PTE_FILE_BITS1 + PTE_FILE_BITS2) 87 - #define PTE_FILE_LSHIFT4 (PTE_FILE_BITS1 + PTE_FILE_BITS2 + PTE_FILE_BITS3) 88 - 89 - static __always_inline pgoff_t pte_to_pgoff(pte_t pte) 90 - { 91 - return (pgoff_t) 92 - (pte_bitop(pte.pte_low, PTE_FILE_SHIFT1, PTE_FILE_MASK1, 0) + 93 - pte_bitop(pte.pte_low, PTE_FILE_SHIFT2, PTE_FILE_MASK2, PTE_FILE_LSHIFT2) + 94 - pte_bitop(pte.pte_low, PTE_FILE_SHIFT3, PTE_FILE_MASK3, PTE_FILE_LSHIFT3) + 95 - pte_bitop(pte.pte_low, PTE_FILE_SHIFT4, -1UL, PTE_FILE_LSHIFT4)); 96 - } 97 - 98 - static __always_inline pte_t pgoff_to_pte(pgoff_t off) 99 - { 100 - return (pte_t){ 101 - .pte_low = 102 - pte_bitop(off, 0, PTE_FILE_MASK1, PTE_FILE_SHIFT1) + 103 - pte_bitop(off, PTE_FILE_LSHIFT2, PTE_FILE_MASK2, PTE_FILE_SHIFT2) + 104 - pte_bitop(off, PTE_FILE_LSHIFT3, PTE_FILE_MASK3, PTE_FILE_SHIFT3) + 105 - pte_bitop(off, PTE_FILE_LSHIFT4, -1UL, PTE_FILE_SHIFT4) + 106 - _PAGE_FILE, 107 - }; 108 - } 109 - 110 - #else /* CONFIG_MEM_SOFT_DIRTY */ 111 - 112 65 /* 113 66 * Bits _PAGE_BIT_PRESENT, _PAGE_BIT_FILE and _PAGE_BIT_PROTNONE are taken, 114 67 * split up the 29 bits of offset into this range. ··· 97 144 _PAGE_FILE, 98 145 }; 99 146 } 100 - 101 - #endif /* CONFIG_MEM_SOFT_DIRTY */ 102 147 103 148 /* Encode and de-code a swap entry */ 104 149 #define SWP_TYPE_BITS (_PAGE_BIT_FILE - _PAGE_BIT_PRESENT - 1)
+5
arch/x86/include/asm/pgtable.h
··· 297 297 return pmd_clear_flags(pmd, _PAGE_PRESENT); 298 298 } 299 299 300 + #ifdef CONFIG_HAVE_ARCH_SOFT_DIRTY 300 301 static inline int pte_soft_dirty(pte_t pte) 301 302 { 302 303 return pte_flags(pte) & _PAGE_SOFT_DIRTY; ··· 332 331 { 333 332 return pte_flags(pte) & _PAGE_SOFT_DIRTY; 334 333 } 334 + 335 + #endif /* CONFIG_HAVE_ARCH_SOFT_DIRTY */ 335 336 336 337 /* 337 338 * Mask out unsupported bits in a present pgprot. Non-present pgprots ··· 868 865 { 869 866 } 870 867 868 + #ifdef CONFIG_HAVE_ARCH_SOFT_DIRTY 871 869 static inline pte_t pte_swp_mksoft_dirty(pte_t pte) 872 870 { 873 871 VM_BUG_ON(pte_present_nonuma(pte)); ··· 886 882 VM_BUG_ON(pte_present_nonuma(pte)); 887 883 return pte_clear_flags(pte, _PAGE_SWP_SOFT_DIRTY); 888 884 } 885 + #endif 889 886 890 887 #include <asm-generic/pgtable.h> 891 888 #endif /* __ASSEMBLY__ */