Re: [PATCH v4 08/10] pmem: convert to generic memremap

Christoph Hellwig
2015-08-11T12:56:00Z

On Mon, Aug 10, 2015 at 11:38:33PM -0400, Dan Williams wrote:
> Update memremap_pmem() to query the architecture for the mapping type of
> the given persistent memory range and then pass those flags to generic
> memremap(). arch_memremap_pmem_flags() is provided an address range to
> evaluate in the event an arch has a need for different mapping types by
> address range. For example the ACPI NFIT carries EFI mapping types in
> its memory range description table.
>
> Cc: Ross Zwisler <ross.zwisler@linux.intel.com>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>

Looks generally good, but a little nipick related to my comment
from two patches ago:

> +unsigned long arch_memremap_pmem_flags(resource_size_t offset, size_t size)
> +{
> + /*
> + * The expectation is that pmem is always WB capable range on
> + * x86, i.e. no need to walk the range.
> + */
> + return MEMREMAP_WB;
> +}
> +EXPORT_SYMBOL(arch_memremap_pmem_flags);

Why not just add a

/*
* The expectation is that pmem is always WB capable range on x86, i.e. no
* need to walk the range.
*/
#define ARCH_MEMREMAP_PMEM MEMREMAP_WB

in io.h, and then kill all these little pmem wrappers and:

> static inline void __pmem *memremap_pmem(resource_size_t offset,
> unsigned long size)
> {
> + unsigned long flags;
> +
> if (arch_has_pmem_api())
> - return arch_memremap_pmem(offset, size);
> - return default_memremap_pmem(offset, size);
> + flags = arch_memremap_pmem_flags(offset, size);
> + else
> + flags = default_memremap_pmem_flags();
> +
> + return (void __pmem *) memremap(offset, size, flags);

#ifdef ARCH_MEMREMAP_PMEM
return (void __pmem *) memremap(offset, size, ARCH_MEMREMAP_PMEM);
#else
return (void __pmem *) memremap(offset, size, MEMREMAP_WT);
#endif