Device-memory-related cleanups
Subsystems (7)
cover Device-memory-related cleanups
Hi,
As promised, these are my preparatory cleanup patches that have so far fallen out of pmem DAX work for arm64. Patch #1 has already been out for a ride in Anshuman's hot-remove series, so I've collected the acks already given.
Since we have various things in flight at the moment touching arm64 pagetable code, I'm wary of conflicts and cross-tree dependencies for our actual ARCH_HAS_PTE_DEVMAP implementation. Thus it would be nice if these could be picked up for 5.2 via mm or nvdimm as appropriate, such that we can then handle the devmap patch itself via arm64 next cycle.
Robin.
Robin Murphy (3):
mm/memremap: Rename and consolidate SECTION_SIZE
mm: clean up is_device_*_page() definitions
mm: introduce ARCH_HAS_PTE_DEVMAP
arch/powerpc/Kconfig | 2 +- arch/powerpc/include/asm/book3s/64/pgtable.h | 1 - arch/x86/Kconfig | 2 +- arch/x86/include/asm/pgtable.h | 4 +- arch/x86/include/asm/pgtable_types.h | 1 - include/linux/mm.h | 47 +++++++------------- include/linux/mmzone.h | 1 + include/linux/pfn_t.h | 4 +- kernel/memremap.c | 10 ++--- mm/Kconfig | 5 +-- mm/gup.c | 2 +- mm/hmm.c | 2 - 12 files changed, 29 insertions(+), 52 deletions(-)
Signature · 1 line
2.21.0.dirty
PATCH 1/3 mm/memremap: Rename and consolidate SECTION_SIZE
Trying to activatee ZONE_DEVICE for arm64 reveals that memremap's internal helpers for sparsemem sections conflict with and arm64's definitions for hugepages, which inherit the name of "sections" from earlier versions of the ARM architecture.
Disambiguate memremap (and now HMM too) by propagating sparsemem's PA_ prefix, to clarify that these values are in terms of addresses rather than PFNs (and because it's a heck of a lot easier than changing all the arch code). SECTION_MASK is unused, so it can just go.
[anshuman: Consolidated mm/hmm.c instance and updated the commit message]
--- include/linux/mmzone.h | 1 + kernel/memremap.c | 10 ++++------ mm/hmm.c | 2 -- 3 files changed, 5 insertions(+), 8 deletions(-)
include/linux/mmzone.h +1 -0
@@ -1081,6 +1081,7 @@ static inline unsigned long early_pfn_to_nid(unsigned long pfn)* PFN_SECTION_SHIFT pfn to/from section number */ #define PA_SECTION_SHIFT (SECTION_SIZE_BITS) +#define PA_SECTION_SIZE (1UL << PA_SECTION_SHIFT)#define PFN_SECTION_SHIFT (SECTION_SIZE_BITS - PAGE_SHIFT)#define NR_MEM_SECTIONS (1UL << SECTIONS_SHIFT)
kernel/memremap.c +4 -6
@@ -14,8 +14,6 @@#include <linux/hmm.h> static DEFINE_XARRAY (pgmap_array); -#define SECTION_MASK ~((1UL << PA_SECTION_SHIFT) - 1) -#define SECTION_SIZE (1UL << PA_SECTION_SHIFT)#if IS_ENABLED (CONFIG_DEVICE_PRIVATE ) vm_fault_t device_private_entry_fault(struct vm_area_struct *vma,
@@ -98,8 +96,8 @@ static void devm_memremap_pages_release(void *data)put_page (pfn_to_page (pfn));/* pages are dead and unused, undo the arch mapping */ - align_start = res->start & ~(SECTION_SIZE -1 ); - align_size =ALIGN (res->start +resource_size (res),SECTION_SIZE ) + align_start = res->start & ~(PA_SECTION_SIZE -1 ); + align_size =ALIGN (res->start +resource_size (res),PA_SECTION_SIZE ) - align_start; nid =page_to_nid (pfn_to_page (align_start >>PAGE_SHIFT ));
@@ -154,8 +152,8 @@ void *devm_memremap_pages(struct device *dev, struct dev_pagemap *pgmap)if (!pgmap->ref || !pgmap->kill)return ERR_PTR (-EINVAL ); - align_start = res->start & ~(SECTION_SIZE -1 ); - align_size =ALIGN (res->start +resource_size (res),SECTION_SIZE ) + align_start = res->start & ~(PA_SECTION_SIZE -1 ); + align_size =ALIGN (res->start +resource_size (res),PA_SECTION_SIZE ) - align_start; align_end = align_start + align_size -1 ;
mm/hmm.c +0 -2
@@ -33,8 +33,6 @@#include <linux/mmu_notifier.h> #include <linux/memory_hotplug.h> -#define PA_SECTION_SIZE (1UL << PA_SECTION_SHIFT) -#if IS_ENABLED (CONFIG_HMM_MIRROR )static const struct mmu_notifier_ops hmm_mmu_notifier_ops;
Signature · 1 line
2.21.0.dirty
Re: [PATCH 1/3] mm/memremap: Rename and consolidate SECTION_SIZE
Quoted 2 lines · Robin Murphy
Trying to activatee
ZONE_DEVICEfor arm64 reveals that memremap's
s/activatee/activate/
Quoted 8 lines
internal helpers for sparsemem sections conflict with and arm64's definitions for hugepages, which inherit the name of "sections" from earlier versions of the ARM architecture.
Disambiguate memremap (and now HMM too) by propagating sparsemem's
PA_prefix, to clarify that these values are in terms of addresses rather than PFNs (and because it's a heck of a lot easier than changing all the arch code).SECTION_MASKis unused, so it can just go.
Looks good to me. So good that it collides with a similar change in the "sub-section" support series.
PATCH 2/3 mm: clean up is_device_*_page() definitions
In reply to Robin MurphyRefactor is_device_{public,private}_page() with is_pci_p2pdma_page() to make them all consistent in depending on their respective config options even when CONFIG_DEV_PAGEMAP_OPS is enabled for other reasons. This allows a little more compile-time optimisation as well as the conceptual and cosmetic cleanup.
--- include/linux/mm.h | 43 +++++++++++++------------------------------ 1 file changed, 13 insertions(+), 30 deletions(-)
include/linux/mm.h +13 -30
@@ -910,32 +910,6 @@ static inline bool put_devmap_managed_page(struct page *page) }return false; } - -static inline bool is_device_private_page (const struct page *page) -{ -return is_zone_device_page (page) && - page->pgmap->type ==MEMORY_DEVICE_PRIVATE ; -} - -static inline bool is_device_public_page (const struct page *page) -{ -return is_zone_device_page (page) && - page->pgmap->type ==MEMORY_DEVICE_PUBLIC ; -} - -#ifdef CONFIG_PCI_P2PDMA -static inline bool is_pci_p2pdma_page (const struct page *page) -{ -return is_zone_device_page (page) && - page->pgmap->type ==MEMORY_DEVICE_PCI_P2PDMA ; -} -#else /* CONFIG_PCI_P2PDMA */ -static inline bool is_pci_p2pdma_page (const struct page *page) -{ -return false; -} -#endif /* CONFIG_PCI_P2PDMA */ -#else /* CONFIG_DEV_PAGEMAP_OPS */ static inline void dev_pagemap_get_ops (void ) {
@@ -949,22 +923,31 @@ static inline bool put_devmap_managed_page(struct page *page) {return false; } +#endif /* CONFIG_DEV_PAGEMAP_OPS */ static inline bool is_device_private_page (const struct page *page) { -return false; +return IS_ENABLED (CONFIG_DEV_PAGEMAP_OPS ) && +IS_ENABLED (CONFIG_DEVICE_PRIVATE ) && +is_zone_device_page (page) && + page->pgmap->type ==MEMORY_DEVICE_PRIVATE ; }static inline bool is_device_public_page (const struct page *page) { -return false; +return IS_ENABLED (CONFIG_DEV_PAGEMAP_OPS ) && +IS_ENABLED (CONFIG_DEVICE_PUBLIC ) && +is_zone_device_page (page) && + page->pgmap->type ==MEMORY_DEVICE_PUBLIC ; }static inline bool is_pci_p2pdma_page (const struct page *page) { -return false; +return IS_ENABLED (CONFIG_DEV_PAGEMAP_OPS ) && +IS_ENABLED (CONFIG_PCI_P2PDMA ) && +is_zone_device_page (page) && + page->pgmap->type ==MEMORY_DEVICE_PCI_P2PDMA ; } -#endif /* CONFIG_DEV_PAGEMAP_OPS */ static inline void get_page (struct page *page) {
Signature · 1 line
2.21.0.dirty
Re: [PATCH RESEND 2/3] mm: clean up is_device_*_page() definitions
Quoted 8 lines · Robin Murphy
Refactor is_device_{public,private}_page() with
is_pci_p2pdma_page()to make them all consistent in depending on their respective config options even whenCONFIG_DEV_PAGEMAP_OPSis enabled for other reasons. This allows a little more compile-time optimisation as well as the conceptual and cosmetic cleanup.Suggested-by Jerome Glisse <[email protected]>Signed-off-by Robin Murphy <[email protected]>
PATCH 3/3 mm: introduce ARCH_HAS_PTE_DEVMAP
In reply to Robin MurphyARCH_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.
--- arch/powerpc/Kconfig | 2 +- arch/powerpc/include/asm/book3s/64/pgtable.h | 1 - arch/x86/Kconfig | 2 +- arch/x86/include/asm/pgtable.h | 4 ++-- arch/x86/include/asm/pgtable_types.h | 1 - include/linux/mm.h | 4 ++-- include/linux/pfn_t.h | 4 ++-- mm/Kconfig | 5 ++--- mm/gup.c | 2 +- 9 files changed, 11 insertions(+), 14 deletions(-)
arch/powerpc/Kconfig +1 -1
@@ -135,6 +135,7 @@ config PPC select ARCH_HAS_MMIOWB if PPC64 select ARCH_HAS_PHYS_TO_DMA select ARCH_HAS_PMEM_API if PPC64 + select ARCH_HAS_PTE_DEVMAP if PPC_BOOK3S_64 select ARCH_HAS_PTE_SPECIAL select ARCH_HAS_MEMBARRIER_CALLBACKS select ARCH_HAS_SCALED_CPUTIME if VIRT_CPU_ACCOUNTING_NATIVE && PPC64
@@ -142,7 +143,6 @@ config PPC select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST select ARCH_HAS_UACCESS_FLUSHCACHE if PPC64 select ARCH_HAS_UBSAN_SANITIZE_ALL - select ARCH_HAS_ZONE_DEVICE if PPC_BOOK3S_64 select ARCH_HAVE_NMI_SAFE_CMPXCHG select ARCH_MIGHT_HAVE_PC_PARPORT select ARCH_MIGHT_HAVE_PC_SERIO
arch/powerpc/include/asm/book3s/64/pgtable.h +0 -1
@@ -90,7 +90,6 @@#define _PAGE_SOFT_DIRTY _RPAGE_SW3/* software: software dirty tracking */ #define _PAGE_SPECIAL _RPAGE_SW2/* software: special page */ #define _PAGE_DEVMAP _RPAGE_SW1/* software: ZONE_DEVICE page */ -#define __HAVE_ARCH_PTE_DEVMAP/* * Drivers request for cache inhibited pte mapping using _PAGE_NO_CACHE
arch/x86/Kconfig +1 -1
@@ -60,6 +60,7 @@ config X86 select ARCH_HAS_KCOV if X86_64 select ARCH_HAS_MEMBARRIER_SYNC_CORE select ARCH_HAS_PMEM_API if X86_64 + select ARCH_HAS_PTE_DEVMAP if X86_64 select ARCH_HAS_PTE_SPECIAL select ARCH_HAS_REFCOUNT select ARCH_HAS_UACCESS_FLUSHCACHE if X86_64
@@ -69,7 +70,6 @@ config X86 select ARCH_HAS_STRICT_MODULE_RWX select ARCH_HAS_SYNC_CORE_BEFORE_USERMODE select ARCH_HAS_UBSAN_SANITIZE_ALL - select ARCH_HAS_ZONE_DEVICE if X86_64 select ARCH_HAVE_NMI_SAFE_CMPXCHG select ARCH_MIGHT_HAVE_ACPI_PDC if ACPI select ARCH_MIGHT_HAVE_PC_PARPORT
arch/x86/include/asm/pgtable.h +2 -2
@@ -254,7 +254,7 @@ static inline int has_transparent_hugepage(void)return boot_cpu_has (X86_FEATURE_PSE ); } -#ifdef __HAVE_ARCH_PTE_DEVMAP +#ifdef CONFIG_ARCH_HAS_PTE_DEVMAP static inline int pmd_devmap (pmd_t pmd) {return !!(pmd_val (pmd) & _PAGE_DEVMAP);
@@ -715,7 +715,7 @@ static inline int pte_present(pte_t a)return pte_flags (a) & (_PAGE_PRESENT | _PAGE_PROTNONE); } -#ifdef __HAVE_ARCH_PTE_DEVMAP +#ifdef CONFIG_ARCH_HAS_PTE_DEVMAP static inline int pte_devmap (pte_t a) {return (pte_flags (a) & _PAGE_DEVMAP) == _PAGE_DEVMAP;
arch/x86/include/asm/pgtable_types.h +0 -1
@@ -103,7 +103,6 @@#if defined(CONFIG_X86_64 ) || defined(CONFIG_X86_PAE )#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)#define _PAGE_DEVMAP (_AT(u64, 1) << _PAGE_BIT_DEVMAP) -#define __HAVE_ARCH_PTE_DEVMAP#else #define _PAGE_NX (_AT(pteval_t, 0))#define _PAGE_DEVMAP (_AT(pteval_t, 0))
include/linux/mm.h +2 -2
@@ -504,7 +504,7 @@ struct inode;#define page_private (page) ((page)->private)#define set_page_private (page, v) ((page)->private = (v)) -#if !defined(__HAVE_ARCH_PTE_DEVMAP) || !defined(CONFIG_TRANSPARENT_HUGEPAGE ) +#if !defined(CONFIG_ARCH_HAS_PTE_DEVMAP ) || !defined(CONFIG_TRANSPARENT_HUGEPAGE )static inline int pmd_devmap (pmd_t pmd) {return 0 ;
@@ -1698,7 +1698,7 @@ static inline void sync_mm_rss(struct mm_struct *mm) }#endif -#ifndef __HAVE_ARCH_PTE_DEVMAP +#ifndef CONFIG_ARCH_HAS_PTE_DEVMAP static inline int pte_devmap (pte_t pte) {return 0 ;
include/linux/pfn_t.h +2 -2
@@ -104,7 +104,7 @@ static inline pud_t pfn_t_pud(pfn_t pfn, pgprot_t pgprot)#endif #endif -#ifdef __HAVE_ARCH_PTE_DEVMAP +#ifdef CONFIG_ARCH_HAS_PTE_DEVMAP static inline bool pfn_t_devmap (pfn_t pfn) {const u64 flags =PFN_DEV |PFN_MAP ;
@@ -122,7 +122,7 @@ pmd_t pmd_mkdevmap(pmd_t pmd);defined (CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD) pud_t pud_mkdevmap(pud_t pud);#endif -#endif /* __HAVE_ARCH_PTE_DEVMAP */ +#endif /* CONFIG_ARCH_HAS_PTE_DEVMAP */ #ifdef CONFIG_ARCH_HAS_PTE_SPECIAL static inline bool pfn_t_special (pfn_t pfn)
mm/Kconfig +2 -3
@@ -655,8 +655,7 @@ config IDLE_PAGE_TRACKING See Documentation/admin-guide/mm/idle_page_tracking.rst for more details. -# arch_add_memory() comprehends device memory -config ARCH_HAS_ZONE_DEVICE +config ARCH_HAS_PTE_DEVMAP bool config ZONE_DEVICE
@@ -664,7 +663,7 @@ config ZONE_DEVICE depends on MEMORY_HOTPLUG depends on MEMORY_HOTREMOVE depends on SPARSEMEM_VMEMMAP - depends on ARCH_HAS_ZONE_DEVICE + depends on ARCH_HAS_PTE_DEVMAP select XARRAY_MULTI help
mm/gup.c +1 -1
@@ -1623,7 +1623,7 @@ static int gup_pte_range(pmd_t pmd, unsigned long addr, unsigned long end, }#endif /* CONFIG_ARCH_HAS_PTE_SPECIAL */ -#if defined(__HAVE_ARCH_PTE_DEVMAP) && defined(CONFIG_TRANSPARENT_HUGEPAGE ) +#if defined(CONFIG_ARCH_HAS_PTE_DEVMAP ) && defined(CONFIG_TRANSPARENT_HUGEPAGE )static int __gup_device_huge (unsigned long pfn,unsigned long addr,unsigned long end,struct page **pages,int *nr) {
Signature · 1 line
2.21.0.dirty
Re: [PATCH RESEND 3/3] mm: introduce ARCH_HAS_PTE_DEVMAP
Quoted 10 lines · Robin Murphy
ARCH_HAS_ZONE_DEVICEis 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_DEVICEusers have little chance of functioning correctly without__HAVE_ARCH_PTE_DEVMAP, so let's clean that up the same way asARCH_HAS_PTE_SPECIALand make it the proper dependency so the real situation is clearer.
Looks good to me.
Re: [PATCH 3/3] mm: introduce ARCH_HAS_PTE_DEVMAP
In reply to Robin MurphyQuoted 11 lines · Robin Murphy
ARCH_HAS_ZONE_DEVICEis 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_DEVICEusers have little chance of functioning correctly without__HAVE_ARCH_PTE_DEVMAP, so let's clean that up the same way asARCH_HAS_PTE_SPECIALand make it the proper dependency so the real situation is clearer.Signed-off-by Robin Murphy <[email protected]>
Quoted 183 lines
--- arch/powerpc/Kconfig | 2 +- arch/powerpc/include/asm/book3s/64/pgtable.h | 1 - arch/x86/Kconfig | 2 +- arch/x86/include/asm/pgtable.h | 4 ++-- arch/x86/include/asm/pgtable_types.h | 1 - include/linux/mm.h | 4 ++-- include/linux/pfn_t.h | 4 ++-- mm/Kconfig | 5 ++--- mm/gup.c | 2 +- 9 files changed, 11 insertions(+), 14 deletions(-)arch/powerpc/Kconfig +1
-1@@ -135,6 +135,7 @@ config PPC select ARCH_HAS_MMIOWB if PPC64 select ARCH_HAS_PHYS_TO_DMA select ARCH_HAS_PMEM_API if PPC64 + select ARCH_HAS_PTE_DEVMAP if PPC_BOOK3S_64 select ARCH_HAS_PTE_SPECIAL select ARCH_HAS_MEMBARRIER_CALLBACKS select ARCH_HAS_SCALED_CPUTIME if VIRT_CPU_ACCOUNTING_NATIVE && PPC64@@ -142,7 +143,6 @@ config PPC select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST select ARCH_HAS_UACCESS_FLUSHCACHE if PPC64 select ARCH_HAS_UBSAN_SANITIZE_ALL - select ARCH_HAS_ZONE_DEVICE if PPC_BOOK3S_64 select ARCH_HAVE_NMI_SAFE_CMPXCHG select ARCH_MIGHT_HAVE_PC_PARPORT select ARCH_MIGHT_HAVE_PC_SERIOarch/powerpc/include/asm/book3s/64/pgtable.h +0
-1@@ -90,7 +90,6 @@#define _PAGE_SOFT_DIRTY _RPAGE_SW3/* software: software dirty tracking */ #define _PAGE_SPECIAL _RPAGE_SW2/* software: special page */ #define _PAGE_DEVMAP _RPAGE_SW1/* software: ZONE_DEVICE page */ -#define __HAVE_ARCH_PTE_DEVMAP/* * Drivers request for cache inhibited pte mapping using _PAGE_NO_CACHE arch/x86/Kconfig +1
-1@@ -60,6 +60,7 @@ config X86 select ARCH_HAS_KCOV if X86_64 select ARCH_HAS_MEMBARRIER_SYNC_CORE select ARCH_HAS_PMEM_API if X86_64 + select ARCH_HAS_PTE_DEVMAP if X86_64 select ARCH_HAS_PTE_SPECIAL select ARCH_HAS_REFCOUNT select ARCH_HAS_UACCESS_FLUSHCACHE if X86_64@@ -69,7 +70,6 @@ config X86 select ARCH_HAS_STRICT_MODULE_RWX select ARCH_HAS_SYNC_CORE_BEFORE_USERMODE select ARCH_HAS_UBSAN_SANITIZE_ALL - select ARCH_HAS_ZONE_DEVICE if X86_64 select ARCH_HAVE_NMI_SAFE_CMPXCHG select ARCH_MIGHT_HAVE_ACPI_PDC if ACPI select ARCH_MIGHT_HAVE_PC_PARPORTarch/x86/include/asm/pgtable.h +2
-2@@ -254,7 +254,7 @@ static inline int has_transparent_hugepage(void)return boot_cpu_has (X86_FEATURE_PSE ); } -#ifdef __HAVE_ARCH_PTE_DEVMAP +#ifdef CONFIG_ARCH_HAS_PTE_DEVMAP static inline int pmd_devmap (pmd_t pmd) {return !!(pmd_val (pmd) & _PAGE_DEVMAP);@@ -715,7 +715,7 @@ static inline int pte_present(pte_t a)return pte_flags (a) & (_PAGE_PRESENT | _PAGE_PROTNONE); } -#ifdef __HAVE_ARCH_PTE_DEVMAP +#ifdef CONFIG_ARCH_HAS_PTE_DEVMAP static inline int pte_devmap (pte_t a){
arch/x86/include/asm/pgtable.h +0
-0return (pte_flags (a) & _PAGE_DEVMAP) == _PAGE_DEVMAP;arch/x86/include/asm/pgtable_types.h +0
-1@@ -103,7 +103,6 @@#if defined(CONFIG_X86_64 ) || defined(CONFIG_X86_PAE )#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)#define _PAGE_DEVMAP (_AT(u64, 1) << _PAGE_BIT_DEVMAP) -#define __HAVE_ARCH_PTE_DEVMAP#else #define _PAGE_NX (_AT(pteval_t, 0))#define _PAGE_DEVMAP (_AT(pteval_t, 0))include/linux/mm.h +2
-2@@ -504,7 +504,7 @@ struct inode;#define page_private (page) ((page)->private)#define set_page_private (page, v) ((page)->private = (v)) -#if !defined(__HAVE_ARCH_PTE_DEVMAP) || !defined(CONFIG_TRANSPARENT_HUGEPAGE ) +#if !defined(CONFIG_ARCH_HAS_PTE_DEVMAP ) || !defined(CONFIG_TRANSPARENT_HUGEPAGE )static inline int pmd_devmap (pmd_t pmd) {return 0 ;@@ -1698,7 +1698,7 @@ static inline void sync_mm_rss(struct mm_struct *mm) }#endif -#ifndef __HAVE_ARCH_PTE_DEVMAP +#ifndef CONFIG_ARCH_HAS_PTE_DEVMAP static inline int pte_devmap (pte_t pte) {return 0 ;include/linux/pfn_t.h +2
-2@@ -104,7 +104,7 @@ static inline pud_t pfn_t_pud(pfn_t pfn, pgprot_t pgprot)#endif #endif -#ifdef __HAVE_ARCH_PTE_DEVMAP +#ifdef CONFIG_ARCH_HAS_PTE_DEVMAP static inline bool pfn_t_devmap (pfn_t pfn) {const u64 flags =PFN_DEV |PFN_MAP ;@@ -122,7 +122,7 @@ pmd_t pmd_mkdevmap(pmd_t pmd);defined (CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD) pud_t pud_mkdevmap(pud_t pud);#endif -#endif /* __HAVE_ARCH_PTE_DEVMAP */ +#endif /* CONFIG_ARCH_HAS_PTE_DEVMAP */ #ifdef CONFIG_ARCH_HAS_PTE_SPECIAL static inline bool pfn_t_special (pfn_t pfn)mm/Kconfig +2
-3@@ -655,8 +655,7 @@ config IDLE_PAGE_TRACKING See Documentation/admin-guide/mm/idle_page_tracking.rst for more details. -# arch_add_memory() comprehends device memory -config ARCH_HAS_ZONE_DEVICE +config ARCH_HAS_PTE_DEVMAP bool config ZONE_DEVICE@@ -664,7 +663,7 @@ config ZONE_DEVICE depends on MEMORY_HOTPLUG depends on MEMORY_HOTREMOVE depends on SPARSEMEM_VMEMMAP - depends on ARCH_HAS_ZONE_DEVICE + depends on ARCH_HAS_PTE_DEVMAP select XARRAY_MULTI helpmm/gup.c +1
-1@@ -1623,7 +1623,7 @@ static int gup_pte_range(pmd_t pmd, unsigned long addr, unsigned long end, }#endif /* CONFIG_ARCH_HAS_PTE_SPECIAL */ -#if defined(__HAVE_ARCH_PTE_DEVMAP) && defined(CONFIG_TRANSPARENT_HUGEPAGE ) +#if defined(CONFIG_ARCH_HAS_PTE_DEVMAP ) && defined(CONFIG_TRANSPARENT_HUGEPAGE )static int __gup_device_huge (unsigned long pfn,unsigned long addr,unsigned long end,struct page **pages,int *nr) {Signature · 1 line
2.21.0.dirty
Re: [PATCH 3/3] mm: introduce ARCH_HAS_PTE_DEVMAP
In reply to Robin MurphyQuoted 5 lines · Robin Murphy
ARCH_HAS_ZONE_DEVICEis 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.
Good cleanup. ARCH_HAS_ZONE_DEVICE made sense at the time, but it probably should have been renamed after the memory hotplug rework.
+cc mpe since he does the merging, and
Quoted 187 lines
In practice, however,
ZONE_DEVICEusers have little chance of functioning correctly without__HAVE_ARCH_PTE_DEVMAP, so let's clean that up the same way asARCH_HAS_PTE_SPECIALand make it the proper dependency so the real situation is clearer.Signed-off-by Robin Murphy <[email protected]>--- arch/powerpc/Kconfig | 2 +- arch/powerpc/include/asm/book3s/64/pgtable.h | 1 - arch/x86/Kconfig | 2 +- arch/x86/include/asm/pgtable.h | 4 ++-- arch/x86/include/asm/pgtable_types.h | 1 - include/linux/mm.h | 4 ++-- include/linux/pfn_t.h | 4 ++-- mm/Kconfig | 5 ++--- mm/gup.c | 2 +- 9 files changed, 11 insertions(+), 14 deletions(-)arch/powerpc/Kconfig +1
-1@@ -135,6 +135,7 @@ config PPC select ARCH_HAS_MMIOWB if PPC64 select ARCH_HAS_PHYS_TO_DMA select ARCH_HAS_PMEM_API if PPC64 + select ARCH_HAS_PTE_DEVMAP if PPC_BOOK3S_64 select ARCH_HAS_PTE_SPECIAL select ARCH_HAS_MEMBARRIER_CALLBACKS select ARCH_HAS_SCALED_CPUTIME if VIRT_CPU_ACCOUNTING_NATIVE && PPC64@@ -142,7 +143,6 @@ config PPC select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST select ARCH_HAS_UACCESS_FLUSHCACHE if PPC64 select ARCH_HAS_UBSAN_SANITIZE_ALL - select ARCH_HAS_ZONE_DEVICE if PPC_BOOK3S_64 select ARCH_HAVE_NMI_SAFE_CMPXCHG select ARCH_MIGHT_HAVE_PC_PARPORT select ARCH_MIGHT_HAVE_PC_SERIOarch/powerpc/include/asm/book3s/64/pgtable.h +0
-1@@ -90,7 +90,6 @@#define _PAGE_SOFT_DIRTY _RPAGE_SW3/* software: software dirty tracking */ #define _PAGE_SPECIAL _RPAGE_SW2/* software: special page */ #define _PAGE_DEVMAP _RPAGE_SW1/* software: ZONE_DEVICE page */ -#define __HAVE_ARCH_PTE_DEVMAP/* * Drivers request for cache inhibited pte mapping using _PAGE_NO_CACHE arch/x86/Kconfig +1
-1@@ -60,6 +60,7 @@ config X86 select ARCH_HAS_KCOV if X86_64 select ARCH_HAS_MEMBARRIER_SYNC_CORE select ARCH_HAS_PMEM_API if X86_64 + select ARCH_HAS_PTE_DEVMAP if X86_64 select ARCH_HAS_PTE_SPECIAL select ARCH_HAS_REFCOUNT select ARCH_HAS_UACCESS_FLUSHCACHE if X86_64@@ -69,7 +70,6 @@ config X86 select ARCH_HAS_STRICT_MODULE_RWX select ARCH_HAS_SYNC_CORE_BEFORE_USERMODE select ARCH_HAS_UBSAN_SANITIZE_ALL - select ARCH_HAS_ZONE_DEVICE if X86_64 select ARCH_HAVE_NMI_SAFE_CMPXCHG select ARCH_MIGHT_HAVE_ACPI_PDC if ACPI select ARCH_MIGHT_HAVE_PC_PARPORTarch/x86/include/asm/pgtable.h +2
-2@@ -254,7 +254,7 @@ static inline int has_transparent_hugepage(void)return boot_cpu_has (X86_FEATURE_PSE ); } -#ifdef __HAVE_ARCH_PTE_DEVMAP +#ifdef CONFIG_ARCH_HAS_PTE_DEVMAP static inline int pmd_devmap (pmd_t pmd) {return !!(pmd_val (pmd) & _PAGE_DEVMAP);@@ -715,7 +715,7 @@ static inline int pte_present(pte_t a)return pte_flags (a) & (_PAGE_PRESENT | _PAGE_PROTNONE); } -#ifdef __HAVE_ARCH_PTE_DEVMAP +#ifdef CONFIG_ARCH_HAS_PTE_DEVMAP static inline int pte_devmap (pte_t a) {return (pte_flags (a) & _PAGE_DEVMAP) == _PAGE_DEVMAP;arch/x86/include/asm/pgtable_types.h +0
-1@@ -103,7 +103,6 @@#if defined(CONFIG_X86_64 ) || defined(CONFIG_X86_PAE )#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)#define _PAGE_DEVMAP (_AT(u64, 1) << _PAGE_BIT_DEVMAP) -#define __HAVE_ARCH_PTE_DEVMAP#else #define _PAGE_NX (_AT(pteval_t, 0))#define _PAGE_DEVMAP (_AT(pteval_t, 0))include/linux/mm.h +2
-2@@ -504,7 +504,7 @@ struct inode;#define page_private (page) ((page)->private)#define set_page_private (page, v) ((page)->private = (v)) -#if !defined(__HAVE_ARCH_PTE_DEVMAP) || !defined(CONFIG_TRANSPARENT_HUGEPAGE ) +#if !defined(CONFIG_ARCH_HAS_PTE_DEVMAP ) || !defined(CONFIG_TRANSPARENT_HUGEPAGE )static inline int pmd_devmap (pmd_t pmd) {return 0 ;@@ -1698,7 +1698,7 @@ static inline void sync_mm_rss(struct mm_struct *mm) }#endif -#ifndef __HAVE_ARCH_PTE_DEVMAP +#ifndef CONFIG_ARCH_HAS_PTE_DEVMAP static inline int pte_devmap (pte_t pte) {return 0 ;include/linux/pfn_t.h +2
-2@@ -104,7 +104,7 @@ static inline pud_t pfn_t_pud(pfn_t pfn, pgprot_t pgprot)#endif #endif -#ifdef __HAVE_ARCH_PTE_DEVMAP +#ifdef CONFIG_ARCH_HAS_PTE_DEVMAP static inline bool pfn_t_devmap (pfn_t pfn) {const u64 flags =PFN_DEV |PFN_MAP ;@@ -122,7 +122,7 @@ pmd_t pmd_mkdevmap(pmd_t pmd);defined (CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD) pud_t pud_mkdevmap(pud_t pud);#endif -#endif /* __HAVE_ARCH_PTE_DEVMAP */ +#endif /* CONFIG_ARCH_HAS_PTE_DEVMAP */ #ifdef CONFIG_ARCH_HAS_PTE_SPECIAL static inline bool pfn_t_special (pfn_t pfn)mm/Kconfig +2
-3@@ -655,8 +655,7 @@ config IDLE_PAGE_TRACKING See Documentation/admin-guide/mm/idle_page_tracking.rst for more details. -# arch_add_memory() comprehends device memory -config ARCH_HAS_ZONE_DEVICE +config ARCH_HAS_PTE_DEVMAP bool config ZONE_DEVICE@@ -664,7 +663,7 @@ config ZONE_DEVICE depends on MEMORY_HOTPLUG depends on MEMORY_HOTREMOVE depends on SPARSEMEM_VMEMMAP - depends on ARCH_HAS_ZONE_DEVICE + depends on ARCH_HAS_PTE_DEVMAP select XARRAY_MULTI helpmm/gup.c +1
-2@@ -1623,7 +1623,7 @@ static int gup_pte_range(pmd_t pmd, unsigned long addr, unsigned long end, }#endif /* CONFIG_ARCH_HAS_PTE_SPECIAL */ -#if defined(__HAVE_ARCH_PTE_DEVMAP) && defined(CONFIG_TRANSPARENT_HUGEPAGE ) +#if defined(CONFIG_ARCH_HAS_PTE_DEVMAP ) && defined(CONFIG_TRANSPARENT_HUGEPAGE )static int __gup_device_huge (unsigned long pfn,unsigned long addr,unsigned long end,struct page **pages,int *nr) { --2.21.0.dirty
Re: [PATCH RESEND 3/3] mm: introduce ARCH_HAS_PTE_DEVMAP
In reply to Robin MurphyQuoted 11 lines · Robin Murphy
ARCH_HAS_ZONE_DEVICEis 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_DEVICEusers have little chance of functioning correctly without__HAVE_ARCH_PTE_DEVMAP, so let's clean that up the same way asARCH_HAS_PTE_SPECIALand make it the proper dependency so the real situation is clearer.Signed-off-by Robin Murphy <[email protected]>