History

mm/memremap_pages: Introduce memremap_compat_align()

The "sub-section memory hotplug" facility allows memremap_pages() users like libnvdimm to compensate for hardware platforms like x86 that have a section size larger than their hardware memory mapping granularity. The compensation that sub-section support affords is being tolerant of physical memory resources shifting by units smaller (64MiB on x86) than the memory-hotplug section size (128 MiB). Where the platform physical-memory mapping granularity is limited by the number and capability of address-decode-registers in the memory controller. While the sub-section support allows memremap_pages() to operate on sub-section (2MiB) granularity, the Power architecture may still require 16MiB alignment on "!radix_enabled()" platforms. In order for libnvdimm to be able to detect and manage this per-arch limitation, introduce memremap_compat_align() as a common minimum alignment across all driver-facing memory-mapping interfaces, and let Power override it to 16MiB in the "!radix_enabled()" case. The assumption / requirement for 16MiB to be a viable memremap_compat_align() value is that Power does not have platforms where its equivalent of address-decode-registers never hardware remaps a persistent memory resource on smaller than 16MiB boundaries. Note that I tried my best to not add a new Kconfig symbol, but header include entanglements defeated the #ifndef memremap_compat_align design pattern and the need to export it defeats the __weak design pattern for arch overrides. Based on an initial patch by Aneesh.

Dan Williams committed 6 years ago

Commit 9ffc1d11 parent 1d0827b7 files · +58 −1Browse files

Showing the changes to include/linux (2 of 7 files). Show all

Unified · Split

2 files
  1. include/linux/memremap.h +8 −0
  2. include/linux/mmzone.h +1 −0
include/linux/memremap.h+8−0
@@ -132,6 +132,7 @@ struct dev_pagemap *get_dev_pagemap(unsigned long pfn, · 131 unmodified lines
132 132
133unsigned long vmem_altmap_offset(struct vmem_altmap *altmap);133unsigned long vmem_altmap_offset(struct vmem_altmap *altmap);
134void vmem_altmap_free(struct vmem_altmap *altmap, unsigned long nr_pfns);134void vmem_altmap_free(struct vmem_altmap *altmap, unsigned long nr_pfns);
135unsigned long memremap_compat_align(void);
135#else136#else
136static inline void *devm_memremap_pages(struct device *dev,137static inline void *devm_memremap_pages(struct device *dev,
137 struct dev_pagemap *pgmap)138 struct dev_pagemap *pgmap)
@@ -165,6 +166,12 @@ static inline void vmem_altmap_free(struct vmem_altmap *altmap, · 27 unmodified lines
165 unsigned long nr_pfns)166 unsigned long nr_pfns)
166{167{
167}168}
169
170/* when memremap_pages() is disabled all archs can remap a single page */
171static inline unsigned long memremap_compat_align(void)
172{
173 return PAGE_SIZE;
174}
168#endif /* CONFIG_ZONE_DEVICE */175#endif /* CONFIG_ZONE_DEVICE */
169 176
170static inline void put_dev_pagemap(struct dev_pagemap *pgmap)177static inline void put_dev_pagemap(struct dev_pagemap *pgmap)
@@ -172,4 +179,5 @@ static inline void put_dev_pagemap(struct dev_pagemap *pgmap) · 1 unmodified line
172 if (pgmap)179 if (pgmap)
173 percpu_ref_put(pgmap->ref);180 percpu_ref_put(pgmap->ref);
174}181}
182
175#endif /* _LINUX_MEMREMAP_H_ */183#endif /* _LINUX_MEMREMAP_H_ */
include/linux/mmzone.h+1−0
@@ -1170,6 +1170,7 @@ static inline unsigned long section_nr_to_pfn(unsigned long sec) · 1169 unmodified lines
1170#define SECTION_ALIGN_DOWN(pfn) ((pfn) & PAGE_SECTION_MASK)1170#define SECTION_ALIGN_DOWN(pfn) ((pfn) & PAGE_SECTION_MASK)
1171 1171
1172#define SUBSECTION_SHIFT 211172#define SUBSECTION_SHIFT 21
1173#define SUBSECTION_SIZE (1UL << SUBSECTION_SHIFT)
1173 1174
1174#define PFN_SUBSECTION_SHIFT (SUBSECTION_SHIFT - PAGE_SHIFT)1175#define PFN_SUBSECTION_SHIFT (SUBSECTION_SHIFT - PAGE_SHIFT)
1175#define PAGES_PER_SUBSECTION (1UL << PFN_SUBSECTION_SHIFT)1176#define PAGES_PER_SUBSECTION (1UL << PFN_SUBSECTION_SHIFT)