diff options
| author | Robin Murphy <robin.murphy@arm.com> | 2019-07-16 19:30:47 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-07-16 22:23:25 -0400 |
| commit | 175967318c3018d01931ac950c82adab5deb47ca (patch) | |
| tree | 50f6ae5525c0bfe5a01e5480ee32a85911426e42 | |
| parent | 7588adf8dff12c4b358557a13796a25fef796548 (diff) | |
mm: introduce ARCH_HAS_PTE_DEVMAP
ARCH_HAS_ZONE_DEVICE is somewhat meaningless in itself, and combined
with the long-out-of-date comment can lead to the impression than an
architecture may just enable it (since __add_pages() now "comprehends
device memory" for itself) and expect things to work.
In practice, however, ZONE_DEVICE users have little chance of
functioning correctly without __HAVE_ARCH_PTE_DEVMAP, so let's clean
that up the same way as ARCH_HAS_PTE_SPECIAL and make it the proper
dependency so the real situation is clearer.
Link: http://lkml.kernel.org/r/87554aa78478a02a63f2c4cf60a847279ae3eb3b.1558547956.git.robin.murphy@arm.com
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Acked-by: Dan Williams <dan.j.williams@intel.com>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Acked-by: Oliver O'Halloran <oohall@gmail.com>
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Jerome Glisse <jglisse@redhat.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Will Deacon <will.deacon@arm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
| -rw-r--r-- | arch/powerpc/Kconfig | 2 | ||||
| -rw-r--r-- | arch/powerpc/include/asm/book3s/64/pgtable.h | 1 | ||||
| -rw-r--r-- | arch/x86/Kconfig | 2 | ||||
| -rw-r--r-- | arch/x86/include/asm/pgtable.h | 4 | ||||
| -rw-r--r-- | arch/x86/include/asm/pgtable_types.h | 1 | ||||
| -rw-r--r-- | include/linux/mm.h | 4 | ||||
| -rw-r--r-- | include/linux/pfn_t.h | 4 | ||||
| -rw-r--r-- | mm/Kconfig | 5 | ||||
| -rw-r--r-- | mm/gup.c | 2 |
9 files changed, 11 insertions, 14 deletions
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index f516796dd819..d8dcd8820369 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig | |||
| @@ -129,6 +129,7 @@ config PPC | |||
| 129 | select ARCH_HAS_MMIOWB if PPC64 | 129 | select ARCH_HAS_MMIOWB if PPC64 |
| 130 | select ARCH_HAS_PHYS_TO_DMA | 130 | select ARCH_HAS_PHYS_TO_DMA |
| 131 | select ARCH_HAS_PMEM_API if PPC64 | 131 | select ARCH_HAS_PMEM_API if PPC64 |
| 132 | select ARCH_HAS_PTE_DEVMAP if PPC_BOOK3S_64 | ||
| 132 | select ARCH_HAS_PTE_SPECIAL | 133 | select ARCH_HAS_PTE_SPECIAL |
| 133 | select ARCH_HAS_MEMBARRIER_CALLBACKS | 134 | select ARCH_HAS_MEMBARRIER_CALLBACKS |
| 134 | select ARCH_HAS_SCALED_CPUTIME if VIRT_CPU_ACCOUNTING_NATIVE && PPC64 | 135 | select ARCH_HAS_SCALED_CPUTIME if VIRT_CPU_ACCOUNTING_NATIVE && PPC64 |
| @@ -136,7 +137,6 @@ config PPC | |||
| 136 | select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST | 137 | select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST |
| 137 | select ARCH_HAS_UACCESS_FLUSHCACHE if PPC64 | 138 | select ARCH_HAS_UACCESS_FLUSHCACHE if PPC64 |
| 138 | select ARCH_HAS_UBSAN_SANITIZE_ALL | 139 | select ARCH_HAS_UBSAN_SANITIZE_ALL |
| 139 | select ARCH_HAS_ZONE_DEVICE if PPC_BOOK3S_64 | ||
| 140 | select ARCH_HAVE_NMI_SAFE_CMPXCHG | 140 | select ARCH_HAVE_NMI_SAFE_CMPXCHG |
| 141 | select ARCH_KEEP_MEMBLOCK | 141 | select ARCH_KEEP_MEMBLOCK |
| 142 | select ARCH_MIGHT_HAVE_PC_PARPORT | 142 | select ARCH_MIGHT_HAVE_PC_PARPORT |
diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h index 62e6ea0a7650..8308f32e9782 100644 --- a/arch/powerpc/include/asm/book3s/64/pgtable.h +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h | |||
| @@ -90,7 +90,6 @@ | |||
| 90 | #define _PAGE_SOFT_DIRTY _RPAGE_SW3 /* software: software dirty tracking */ | 90 | #define _PAGE_SOFT_DIRTY _RPAGE_SW3 /* software: software dirty tracking */ |
| 91 | #define _PAGE_SPECIAL _RPAGE_SW2 /* software: special page */ | 91 | #define _PAGE_SPECIAL _RPAGE_SW2 /* software: special page */ |
| 92 | #define _PAGE_DEVMAP _RPAGE_SW1 /* software: ZONE_DEVICE page */ | 92 | #define _PAGE_DEVMAP _RPAGE_SW1 /* software: ZONE_DEVICE page */ |
| 93 | #define __HAVE_ARCH_PTE_DEVMAP | ||
| 94 | 93 | ||
| 95 | /* | 94 | /* |
| 96 | * Drivers request for cache inhibited pte mapping using _PAGE_NO_CACHE | 95 | * Drivers request for cache inhibited pte mapping using _PAGE_NO_CACHE |
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 879741336771..4a55bd01e918 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig | |||
| @@ -70,6 +70,7 @@ config X86 | |||
| 70 | select ARCH_HAS_KCOV if X86_64 | 70 | select ARCH_HAS_KCOV if X86_64 |
| 71 | select ARCH_HAS_MEMBARRIER_SYNC_CORE | 71 | select ARCH_HAS_MEMBARRIER_SYNC_CORE |
| 72 | select ARCH_HAS_PMEM_API if X86_64 | 72 | select ARCH_HAS_PMEM_API if X86_64 |
| 73 | select ARCH_HAS_PTE_DEVMAP if X86_64 | ||
| 73 | select ARCH_HAS_PTE_SPECIAL | 74 | select ARCH_HAS_PTE_SPECIAL |
| 74 | select ARCH_HAS_REFCOUNT | 75 | select ARCH_HAS_REFCOUNT |
| 75 | select ARCH_HAS_UACCESS_FLUSHCACHE if X86_64 | 76 | select ARCH_HAS_UACCESS_FLUSHCACHE if X86_64 |
| @@ -80,7 +81,6 @@ config X86 | |||
| 80 | select ARCH_HAS_STRICT_MODULE_RWX | 81 | select ARCH_HAS_STRICT_MODULE_RWX |
| 81 | select ARCH_HAS_SYNC_CORE_BEFORE_USERMODE | 82 | select ARCH_HAS_SYNC_CORE_BEFORE_USERMODE |
| 82 | select ARCH_HAS_UBSAN_SANITIZE_ALL | 83 | select ARCH_HAS_UBSAN_SANITIZE_ALL |
| 83 | select ARCH_HAS_ZONE_DEVICE if X86_64 | ||
| 84 | select ARCH_HAVE_NMI_SAFE_CMPXCHG | 84 | select ARCH_HAVE_NMI_SAFE_CMPXCHG |
| 85 | select ARCH_MIGHT_HAVE_ACPI_PDC if ACPI | 85 | select ARCH_MIGHT_HAVE_ACPI_PDC if ACPI |
| 86 | select ARCH_MIGHT_HAVE_PC_PARPORT | 86 | select ARCH_MIGHT_HAVE_PC_PARPORT |
diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index 5e0509b41986..0bc530c4eb13 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h | |||
| @@ -271,7 +271,7 @@ static inline int has_transparent_hugepage(void) | |||
| 271 | return boot_cpu_has(X86_FEATURE_PSE); | 271 | return boot_cpu_has(X86_FEATURE_PSE); |
| 272 | } | 272 | } |
| 273 | 273 | ||
| 274 | #ifdef __HAVE_ARCH_PTE_DEVMAP | 274 | #ifdef CONFIG_ARCH_HAS_PTE_DEVMAP |
| 275 | static inline int pmd_devmap(pmd_t pmd) | 275 | static inline int pmd_devmap(pmd_t pmd) |
| 276 | { | 276 | { |
| 277 | return !!(pmd_val(pmd) & _PAGE_DEVMAP); | 277 | return !!(pmd_val(pmd) & _PAGE_DEVMAP); |
| @@ -732,7 +732,7 @@ static inline int pte_present(pte_t a) | |||
| 732 | return pte_flags(a) & (_PAGE_PRESENT | _PAGE_PROTNONE); | 732 | return pte_flags(a) & (_PAGE_PRESENT | _PAGE_PROTNONE); |
| 733 | } | 733 | } |
| 734 | 734 | ||
| 735 | #ifdef __HAVE_ARCH_PTE_DEVMAP | 735 | #ifdef CONFIG_ARCH_HAS_PTE_DEVMAP |
| 736 | static inline int pte_devmap(pte_t a) | 736 | static inline int pte_devmap(pte_t a) |
| 737 | { | 737 | { |
| 738 | return (pte_flags(a) & _PAGE_DEVMAP) == _PAGE_DEVMAP; | 738 | return (pte_flags(a) & _PAGE_DEVMAP) == _PAGE_DEVMAP; |
diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h index d6ff0bbdb394..b5e49e6bac63 100644 --- a/arch/x86/include/asm/pgtable_types.h +++ b/arch/x86/include/asm/pgtable_types.h | |||
| @@ -103,7 +103,6 @@ | |||
| 103 | #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE) | 103 | #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE) |
| 104 | #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX) | 104 | #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX) |
| 105 | #define _PAGE_DEVMAP (_AT(u64, 1) << _PAGE_BIT_DEVMAP) | 105 | #define _PAGE_DEVMAP (_AT(u64, 1) << _PAGE_BIT_DEVMAP) |
| 106 | #define __HAVE_ARCH_PTE_DEVMAP | ||
| 107 | #else | 106 | #else |
| 108 | #define _PAGE_NX (_AT(pteval_t, 0)) | 107 | #define _PAGE_NX (_AT(pteval_t, 0)) |
| 109 | #define _PAGE_DEVMAP (_AT(pteval_t, 0)) | 108 | #define _PAGE_DEVMAP (_AT(pteval_t, 0)) |
diff --git a/include/linux/mm.h b/include/linux/mm.h index baa8b8761d8c..f43f4de4de68 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h | |||
| @@ -547,7 +547,7 @@ static inline void vma_set_anonymous(struct vm_area_struct *vma) | |||
| 547 | struct mmu_gather; | 547 | struct mmu_gather; |
| 548 | struct inode; | 548 | struct inode; |
| 549 | 549 | ||
| 550 | #if !defined(__HAVE_ARCH_PTE_DEVMAP) || !defined(CONFIG_TRANSPARENT_HUGEPAGE) | 550 | #if !defined(CONFIG_ARCH_HAS_PTE_DEVMAP) || !defined(CONFIG_TRANSPARENT_HUGEPAGE) |
| 551 | static inline int pmd_devmap(pmd_t pmd) | 551 | static inline int pmd_devmap(pmd_t pmd) |
| 552 | { | 552 | { |
| 553 | return 0; | 553 | return 0; |
| @@ -1750,7 +1750,7 @@ static inline void sync_mm_rss(struct mm_struct *mm) | |||
| 1750 | } | 1750 | } |
| 1751 | #endif | 1751 | #endif |
| 1752 | 1752 | ||
| 1753 | #ifndef __HAVE_ARCH_PTE_DEVMAP | 1753 | #ifndef CONFIG_ARCH_HAS_PTE_DEVMAP |
| 1754 | static inline int pte_devmap(pte_t pte) | 1754 | static inline int pte_devmap(pte_t pte) |
| 1755 | { | 1755 | { |
| 1756 | return 0; | 1756 | return 0; |
diff --git a/include/linux/pfn_t.h b/include/linux/pfn_t.h index 01e8037023f7..2d9148221e9a 100644 --- a/include/linux/pfn_t.h +++ b/include/linux/pfn_t.h | |||
| @@ -97,7 +97,7 @@ static inline pud_t pfn_t_pud(pfn_t pfn, pgprot_t pgprot) | |||
| 97 | #endif | 97 | #endif |
| 98 | #endif | 98 | #endif |
| 99 | 99 | ||
| 100 | #ifdef __HAVE_ARCH_PTE_DEVMAP | 100 | #ifdef CONFIG_ARCH_HAS_PTE_DEVMAP |
| 101 | static inline bool pfn_t_devmap(pfn_t pfn) | 101 | static inline bool pfn_t_devmap(pfn_t pfn) |
| 102 | { | 102 | { |
| 103 | const u64 flags = PFN_DEV|PFN_MAP; | 103 | const u64 flags = PFN_DEV|PFN_MAP; |
| @@ -115,7 +115,7 @@ pmd_t pmd_mkdevmap(pmd_t pmd); | |||
| 115 | defined(CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD) | 115 | defined(CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD) |
| 116 | pud_t pud_mkdevmap(pud_t pud); | 116 | pud_t pud_mkdevmap(pud_t pud); |
| 117 | #endif | 117 | #endif |
| 118 | #endif /* __HAVE_ARCH_PTE_DEVMAP */ | 118 | #endif /* CONFIG_ARCH_HAS_PTE_DEVMAP */ |
| 119 | 119 | ||
| 120 | #ifdef CONFIG_ARCH_HAS_PTE_SPECIAL | 120 | #ifdef CONFIG_ARCH_HAS_PTE_SPECIAL |
| 121 | static inline bool pfn_t_special(pfn_t pfn) | 121 | static inline bool pfn_t_special(pfn_t pfn) |
diff --git a/mm/Kconfig b/mm/Kconfig index 495d7368ced8..56cec636a1fc 100644 --- a/mm/Kconfig +++ b/mm/Kconfig | |||
| @@ -649,8 +649,7 @@ config IDLE_PAGE_TRACKING | |||
| 649 | See Documentation/admin-guide/mm/idle_page_tracking.rst for | 649 | See Documentation/admin-guide/mm/idle_page_tracking.rst for |
| 650 | more details. | 650 | more details. |
| 651 | 651 | ||
| 652 | # arch_add_memory() comprehends device memory | 652 | config ARCH_HAS_PTE_DEVMAP |
| 653 | config ARCH_HAS_ZONE_DEVICE | ||
| 654 | bool | 653 | bool |
| 655 | 654 | ||
| 656 | config ZONE_DEVICE | 655 | config ZONE_DEVICE |
| @@ -658,7 +657,7 @@ config ZONE_DEVICE | |||
| 658 | depends on MEMORY_HOTPLUG | 657 | depends on MEMORY_HOTPLUG |
| 659 | depends on MEMORY_HOTREMOVE | 658 | depends on MEMORY_HOTREMOVE |
| 660 | depends on SPARSEMEM_VMEMMAP | 659 | depends on SPARSEMEM_VMEMMAP |
| 661 | depends on ARCH_HAS_ZONE_DEVICE | 660 | depends on ARCH_HAS_PTE_DEVMAP |
| 662 | select XARRAY_MULTI | 661 | select XARRAY_MULTI |
| 663 | 662 | ||
| 664 | help | 663 | help |
| @@ -1895,7 +1895,7 @@ static int gup_pte_range(pmd_t pmd, unsigned long addr, unsigned long end, | |||
| 1895 | } | 1895 | } |
| 1896 | #endif /* CONFIG_ARCH_HAS_PTE_SPECIAL */ | 1896 | #endif /* CONFIG_ARCH_HAS_PTE_SPECIAL */ |
| 1897 | 1897 | ||
| 1898 | #if defined(__HAVE_ARCH_PTE_DEVMAP) && defined(CONFIG_TRANSPARENT_HUGEPAGE) | 1898 | #if defined(CONFIG_ARCH_HAS_PTE_DEVMAP) && defined(CONFIG_TRANSPARENT_HUGEPAGE) |
| 1899 | static int __gup_device_huge(unsigned long pfn, unsigned long addr, | 1899 | static int __gup_device_huge(unsigned long pfn, unsigned long addr, |
| 1900 | unsigned long end, struct page **pages, int *nr) | 1900 | unsigned long end, struct page **pages, int *nr) |
| 1901 | { | 1901 | { |
