Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1710166

[PATCH 2/3] libnvdimm, pfn, dax: show supported dax/pfn region alignments in sysfs

From Dan Williams <dan.j.williams@intel.com>
Newsgroups linux.kernel
Subject [PATCH 2/3] libnvdimm, pfn, dax: show supported dax/pfn region alignments in sysfs
Date 2017-08-12 07:20 +0200
Message-ID <udx06-4QR-11@gated-at.bofh.it> (permalink)
References <udx06-4QR-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Oliver O'Halloran <oohall@gmail.com>

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 it's 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.

Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
[djbw: integrate with nd_size_select_show() rename and other fixups]
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 drivers/nvdimm/pfn_devs.c |   28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c
index 2ae9a000b090..610dd17a17f6 100644
--- a/drivers/nvdimm/pfn_devs.c
+++ b/drivers/nvdimm/pfn_devs.c
@@ -111,6 +111,26 @@ static ssize_t align_show(struct device *dev,
 	return sprintf(buf, "%ld\n", nd_pfn->align);
 }
 
+static const unsigned long *nd_pfn_supported_alignments(void)
+{
+	/*
+	 * This needs to be a local variable because the *_SIZE macros
+	 * aren't always constants.
+	 */
+	static const 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 supported_alignments;
+}
+
 static ssize_t __align_store(struct nd_pfn *nd_pfn, const char *buf)
 {
 	unsigned long val;
@@ -260,6 +280,13 @@ 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)
+{
+	return nd_size_select_show(0, nd_pfn_supported_alignments(), buf);
+}
+static DEVICE_ATTR_RO(supported_alignments);
+
 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,
 };
 

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/3] libnvdimm: export supported page size alignments Dan Williams <dan.j.williams@intel.com> - 2017-08-12 07:20 +0200
  [PATCH 3/3] libnvdimm, pfn,  dax: limit namespace alignments to the supported set Dan Williams <dan.j.williams@intel.com> - 2017-08-12 07:20 +0200
  [PATCH 2/3] libnvdimm, pfn,  dax: show supported dax/pfn region alignments in sysfs Dan Williams <dan.j.williams@intel.com> - 2017-08-12 07:20 +0200
    Re: [PATCH 2/3] libnvdimm, pfn, dax: show supported dax/pfn region  alignments in sysfs Oliver <oohall@gmail.com> - 2017-08-15 08:50 +0200
      Re: [PATCH 2/3] libnvdimm, pfn, dax: show supported dax/pfn region  alignments in sysfs Dan Williams <dan.j.williams@intel.com> - 2017-08-15 17:50 +0200
        Re: [PATCH 2/3] libnvdimm, pfn, dax: show supported dax/pfn region  alignments in sysfs Oliver <oohall@gmail.com> - 2017-08-16 07:30 +0200

csiph-web