libnvdimm: show supported dax/pfn region alignments in sysfs
PATCH 1/1 libnvdimm: show supported dax/pfn region alignments in sysfs
The alignment of a DAX and PFN regions dictates the page sizes that can be used to map the region. Even if the hardware page sizes are known the actual range of supported page sizes that can be used with DAX depends on the kernel configuration. As a result its best that the kernel advertises the alignments that should be used with these region types.
This patch adds the 'supported_alignments' region attribute to expose this information to userspace.
--- drivers/nvdimm/pfn_devs.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
drivers/nvdimm/pfn_devs.c +28 -0
@@ -260,6 +260,33 @@ static ssize_t size_show(struct device *dev, }static DEVICE_ATTR_RO (size); +static ssize_t supported_alignments_show (struct device *dev, +struct device_attribute *attr,char *buf) +{ +/* +* This needs to be a local variable because the *_SIZE macros +* aren't always constants. +*/ +unsigned long supported_alignments[] = { +PAGE_SIZE , +#ifdef CONFIG_TRANSPARENT_HUGEPAGE +HPAGE_PMD_SIZE , +#ifdef CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD +HPAGE_PUD_SIZE , +#endif +#endif +0 , + }; + +return nd_sector_size_show (0 , supported_alignments, buf); +} +DEVICE_ATTR_RO (supported_alignments); + +static struct attribute *nd_dax_attributes[] = { + &dev_attr_supported_alignments.attr, +NULL , +}; +static struct attribute *nd_pfn_attributes[] = { &dev_attr_mode.attr, &dev_attr_namespace.attr,
@@ -267,6 +294,7 @@ static struct attribute *nd_pfn_attributes[] = { &dev_attr_align.attr, &dev_attr_resource.attr, &dev_attr_size.attr, + &dev_attr_supported_alignments.attr, NULL, };
Signature · 6 lines
2.9.4 _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
Quoted 8 lines · Oliver O'Halloran
The alignment of a DAX and PFN regions dictates the page sizes that can be used to map the region. Even if the hardware page sizes are known the actual range of supported page sizes that can be used with DAX depends on the kernel configuration. As a result its best that the kernel advertises the alignments that should be used with these region types.
This patch adds the '
supported_alignments' region attribute to expose this information to userspace.
Agh, sorry I missed this for 4.13.
Quoted 23 lines
Signed-off-by Oliver O'Halloran <[email protected]>--- drivers/nvdimm/pfn_devs.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)drivers/nvdimm/pfn_devs.c +9
-0@@ -260,6 +260,33 @@ static ssize_t size_show(struct device *dev, }static DEVICE_ATTR_RO (size); +static ssize_t supported_alignments_show (struct device *dev, +struct device_attribute *attr,char *buf) +{ +/* +* This needs to be a local variable because the *_SIZE macros +* aren't always constants. +*/ +unsigned long supported_alignments[] = { +PAGE_SIZE ,
drivers/nvdimm/pfn_devs.c static ssize_t size_show(struct device *dev, · line 281
Quoted 10 lines
drivers/nvdimm/pfn_devs.c +10
-0+#ifdef CONFIG_TRANSPARENT_HUGEPAGE + HPAGE_PMD_SIZE, +#ifdef CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD + HPAGE_PUD_SIZE, +#endif +#endif + 0, + }; + +return nd_sector_size_show (0 , supported_alignments, buf);
Can you go ahead and change nd_sector_size_show() to nd_size_list_show() or some other name to reflect that it's just a generic helper for an array of possibilities.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Quoted 41 lines · Dan Williams
Quoted 8 lines · Oliver O'Halloran
The alignment of a DAX and PFN regions dictates the page sizes that can be used to map the region. Even if the hardware page sizes are known the actual range of supported page sizes that can be used with DAX depends on the kernel configuration. As a result its best that the kernel advertises the alignments that should be used with these region types.
This patch adds the '
supported_alignments' region attribute to expose this information to userspace.Agh, sorry I missed this for 4.13.
Quoted 29 lines
Signed-off-by Oliver O'Halloran <[email protected]>--- drivers/nvdimm/pfn_devs.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)drivers/nvdimm/pfn_devs.c +15
-0@@ -260,6 +260,33 @@ static ssize_t size_show(struct device *dev, }static DEVICE_ATTR_RO (size); +static ssize_t supported_alignments_show (struct device *dev, +struct device_attribute *attr,char *buf) +{ +/* +* This needs to be a local variable because the *_SIZE macros +* aren't always constants. +*/ +unsigned long supported_alignments[] = { +PAGE_SIZE , +#ifdef CONFIG_TRANSPARENT_HUGEPAGE +HPAGE_PMD_SIZE , +#ifdef CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD +HPAGE_PUD_SIZE , +#endif +#endif
Quoted 8 lines
drivers/nvdimm/pfn_devs.c static ssize_t size_show(struct device *dev, · line 281
Quoted 4 lines
drivers/nvdimm/pfn_devs.c +4
-0+ 0, + }; + +return nd_sector_size_show (0 , supported_alignments, buf);Can you go ahead and change
nd_sector_size_show()tond_size_list_show()or some other name to reflect that it's just a generic helper for an array of possibilities.
Bleh, knew I forgot to do something.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm