All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libnvdimm: show supported dax/pfn region alignments in sysfs
@ 2017-06-27  9:56 Oliver O'Halloran
  2017-07-10 23:40 ` Dan Williams
  0 siblings, 1 reply; 3+ messages in thread
From: Oliver O'Halloran @ 2017-06-27  9:56 UTC (permalink / raw)
  To: linux-nvdimm

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.

Signed-off-by: Oliver O'Halloran <oohall@gmail.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..505d50ef9a91 100644
--- a/drivers/nvdimm/pfn_devs.c
+++ b/drivers/nvdimm/pfn_devs.c
@@ -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,
 };
 
-- 
2.9.4

_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] libnvdimm: show supported dax/pfn region alignments in sysfs
  2017-06-27  9:56 [PATCH] libnvdimm: show supported dax/pfn region alignments in sysfs Oliver O'Halloran
@ 2017-07-10 23:40 ` Dan Williams
  2017-07-11  4:38   ` Oliver
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Williams @ 2017-07-10 23:40 UTC (permalink / raw)
  To: Oliver O'Halloran; +Cc: linux-nvdimm

On Tue, Jun 27, 2017 at 2:56 AM, Oliver O'Halloran <oohall@gmail.com> wrote:
> 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.

>
> Signed-off-by: Oliver O'Halloran <oohall@gmail.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..505d50ef9a91 100644
> --- a/drivers/nvdimm/pfn_devs.c
> +++ b/drivers/nvdimm/pfn_devs.c
> @@ -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);

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
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] libnvdimm: show supported dax/pfn region alignments in sysfs
  2017-07-10 23:40 ` Dan Williams
@ 2017-07-11  4:38   ` Oliver
  0 siblings, 0 replies; 3+ messages in thread
From: Oliver @ 2017-07-11  4:38 UTC (permalink / raw)
  To: Dan Williams; +Cc: linux-nvdimm

On Tue, Jul 11, 2017 at 9:40 AM, Dan Williams <dan.j.williams@intel.com> wrote:
> On Tue, Jun 27, 2017 at 2:56 AM, Oliver O'Halloran <oohall@gmail.com> wrote:
>> 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.
>
>>
>> Signed-off-by: Oliver O'Halloran <oohall@gmail.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..505d50ef9a91 100644
>> --- a/drivers/nvdimm/pfn_devs.c
>> +++ b/drivers/nvdimm/pfn_devs.c
>> @@ -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);
>
> 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.

Bleh, knew I forgot to do something.
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-07-11  4:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-27  9:56 [PATCH] libnvdimm: show supported dax/pfn region alignments in sysfs Oliver O'Halloran
2017-07-10 23:40 ` Dan Williams
2017-07-11  4:38   ` Oliver

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.