On Fri, Jan 24, 2020 at 9:07 AM Aneesh Kumar K.V <aneesh.ku...@linux.ibm.com> wrote: > > On 1/24/20 10:15 PM, Dan Williams wrote: > > On Thu, Jan 23, 2020 at 11:34 PM Aneesh Kumar K.V > > <aneesh.ku...@linux.ibm.com> wrote: > >> > >> On 1/24/20 11:27 AM, Dan Williams wrote: > >>> On Mon, Jan 20, 2020 at 6:08 AM Aneesh Kumar K.V > >>> > >> > >> .... > >> > >>>> > >>>> +unsigned long arch_namespace_map_size(void) > >>>> +{ > >>>> + return PAGE_SIZE; > >>>> +} > >>>> +EXPORT_SYMBOL_GPL(arch_namespace_map_size); > >>>> + > >>>> + > >>>> static void __cpa_flush_all(void *arg) > >>>> { > >>>> unsigned long cache = (unsigned long)arg; > >>>> diff --git a/include/linux/libnvdimm.h b/include/linux/libnvdimm.h > >>>> index 9df091bd30ba..a3476dbd2656 100644 > >>>> --- a/include/linux/libnvdimm.h > >>>> +++ b/include/linux/libnvdimm.h > >>>> @@ -284,4 +284,5 @@ static inline void arch_invalidate_pmem(void *addr, > >>>> size_t size) > >>>> } > >>>> #endif > >>>> > >>>> +unsigned long arch_namespace_map_size(void); > >>> > >>> This property is more generic than the nvdimm namespace mapping size, > >>> it's more the fundamental remap granularity that the architecture > >>> supports. So I would expect this to be defined in core header files. > >>> Something like: > >>> > >>> diff --git a/include/linux/io.h b/include/linux/io.h > >>> index a59834bc0a11..58b3b2091dbb 100644 > >>> --- a/include/linux/io.h > >>> +++ b/include/linux/io.h > >>> @@ -155,6 +155,13 @@ enum { > >>> void *memremap(resource_size_t offset, size_t size, unsigned long > >>> flags); > >>> void memunmap(void *addr); > >>> > >>> +#ifndef memremap_min_align > >>> +static inline unsigned int memremap_min_align(void) > >>> +{ > >>> + return PAGE_SIZE; > >>> +} > >>> +#endif > >>> + > >> > >> > >> Should that be memremap_pages_min_align()? > > > > No, and on second look it needs to be a common value that results in > > properly aligned / sized namespaces across architectures. > > > > What would it take for Power to make it's minimum mapping granularity > > SUBSECTION_SIZE? The minute that the minimum alignment changes across > > architectures we lose compatibility. > > > > The namespaces need to be sized such that the mode can be changed freely. > > > > Linux on ppc64 with hash translation use just one page size for direct > mapping and that is 16MB.
Ok, I think this means that the dream of SUBSECTION_SIZE being the minimum compat alignment is dead, or at least a dream deferred. Let's do this, change the name of this function to: memremap_compat_align() ...and define it to be the max() of all the alignment constraints that the arch may require through either memremap(), or memremap_pages(). Then, teach ndctl to make its default alignment compatible by default, 16MiB, with an override to allow namespace creation with the current architecture's memremap_compat_align(), exported via sysfs, if it happens to be less then 16MiB. Finally, cross our fingers and hope that Power remains the only arch that violates the SUBSECTION_SIZE minimum value for memremap_compat_align().