Skip to contentSkip to conversation

nvdimm: Remove minimum size requirement

PATCH In review Matthew Wilcox 4 participants 13 messages Jul 10, 2017 – Sep 1, 2017 4 messages not in the archive libnvdimm: non-volatile memory device

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvdimm: Remove minimum size requirement

From: Matthew Wilcox <[email protected]>

There was no need to have a minimum size of 4MB for NV-DIMMs; it was just a sanity check. Keep a check that it's at least one page in size because we really can't add less than a page to the memory map. Promote the print statement from 'debug' level to 'warning', since there was no information for my colleague who stumbled over this problem while attempting to add a 2MB chunk of memory.

---
 drivers/nvdimm/namespace_devs.c | 6 +++---
 include/uapi/linux/ndctl.h      | 4 ----
 2 files changed, 3 insertions(+), 7 deletions(-)
drivers/nvdimm/namespace_devs.c +3 -3
index 5f1c6756e57c..95169308078a 100644
@@ -1689,9 +1689,9 @@ struct nd_namespace_common *nvdimm_namespace_common_probe(struct device *dev)
 	}
 
 	size = nvdimm_namespace_capacity(ndns);
-	if (size < ND_MIN_NAMESPACE_SIZE) {
-		dev_dbg(&ndns->dev, "%pa, too small must be at least %#x\n",
-				&size, ND_MIN_NAMESPACE_SIZE);
+	if (size < PAGE_SIZE) {
+		dev_warn(&ndns->dev, "%pa, too small must be at least %ld\n",
+				&size, PAGE_SIZE);
 		return ERR_PTR(-ENODEV);
 	}
 
include/uapi/linux/ndctl.h +0 -4
index 6d3c54264d8e..3ad1623bb585 100644
@@ -299,10 +299,6 @@ enum nd_driver_flags {
 	ND_DRIVER_DAX_PMEM	  = 1 << ND_DEVICE_DAX_PMEM,
 };
 
-enum {
-	ND_MIN_NAMESPACE_SIZE = 0x00400000,
-};
-
 enum ars_masks {
 	ARS_STATUS_MASK = 0x0000FFFF,
 	ARS_EXT_STATUS_SHIFT = 16,
Signature · 6 lines
2.11.0

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#1 lore raw
Quoted 9 lines · Matthew Wilcox

From: Matthew Wilcox <[email protected]>

There was no need to have a minimum size of 4MB for NV-DIMMs; it was just a sanity check. Keep a check that it's at least one page in size because we really can't add less than a page to the memory map. Promote the print statement from 'debug' level to 'warning', since there was no information for my colleague who stumbled over this problem while attempting to add a 2MB chunk of memory.

Quoted 6 lines
---
 drivers/nvdimm/namespace_devs.c | 6 +++---
 include/uapi/linux/ndctl.h      | 4 ----
 2 files changed, 3 insertions(+), 7 deletions(-)

Looks good to me, just one fix up:

drivers/nvdimm/namespace_devs.c struct nd_namespace_common *nvdimm_namespace_common_probe(struct device *dev) · line 1692

Quoted 13 lines
drivers/nvdimm/namespace_devs.c +1 -3
index 5f1c6756e57c..95169308078a 100644
@@ -1689,9 +1689,9 @@ struct nd_namespace_common *nvdimm_namespace_common_probe(struct device *dev)
        }
 
        size = nvdimm_namespace_capacity(ndns);
-       if (size < ND_MIN_NAMESPACE_SIZE) {
-               dev_dbg(&ndns->dev, "%pa, too small must be at least %#x\n",
-                               &size, ND_MIN_NAMESPACE_SIZE);
+       if (size < PAGE_SIZE) {

If we're going to change the print level away from 'debug' then I think this should be "if (size && size < PAGE_SIZE)". The sub-system pre-creates 0-sized devices that are later configured into full namespaces, in those cases we shouldn't fire the warning.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#2 lore raw
Quoted 10 lines · Dan Williams

drivers/nvdimm/namespace_devs.c struct nd_namespace_common *nvdimm_namespace_common_probe(struct device *dev) · line 1692

Quoted 5 lines
        size = nvdimm_namespace_capacity(ndns);
drivers/nvdimm/namespace_devs.c +1 -3
-       if (size < ND_MIN_NAMESPACE_SIZE) {
-               dev_dbg(&ndns->dev, "%pa, too small must be at least %#x\n",
-                               &size, ND_MIN_NAMESPACE_SIZE);
+       if (size < PAGE_SIZE) {

If we're going to change the print level away from 'debug' then I think this should be "if (size && size < PAGE_SIZE)". The sub-system pre-creates 0-sized devices that are later configured into full namespaces, in those cases we shouldn't fire the warning.

Should we allow drivers to claim zero-sized devices? If not, then the dev_warn() should be predicated on size being non-zero, but the return -ENODEV should still trigger.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#3 lore raw
Quoted 7 lines · Matthew Wilcox
Quoted 6 lines · Dan Williams
Quoted 5 lines
        size = nvdimm_namespace_capacity(ndns);
drivers/nvdimm/namespace_devs.c +1 -3
-       if (size < ND_MIN_NAMESPACE_SIZE) {
-               dev_dbg(&ndns->dev, "%pa, too small must be at least %#x\n",
-                               &size, ND_MIN_NAMESPACE_SIZE);
+       if (size < PAGE_SIZE) {
Quoted 8 lines
Quoted 4 lines

If we're going to change the print level away from 'debug' then I think this should be "if (size && size < PAGE_SIZE)". The sub-system pre-creates 0-sized devices that are later configured into full namespaces, in those cases we shouldn't fire the warning.

Should we allow drivers to claim zero-sized devices? If not, then the dev_warn() should be predicated on size being non-zero, but the return -ENODEV should still trigger.

You're right. It should return -ENODEV regardless, but the warning should be for non-zero too small namespaces.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#4 lore raw
Quoted 2 lines

You're right. It should return -ENODEV regardless, but the warning should be for non-zero too small namespaces.

OK, try this:

---- 8< ----

From: Matthew Wilcox <[email protected]>
Date: Mon, 10 Jul 2017 14:26:59 -0400
Subject: [PATCH] nvdimm: Remove minimum size requirement

There was no need to have a minimum size of 4MB for NV-DIMMs; it was just a sanity check. Keep a check that it's at least one page in size because we really can't add less than a page to the memory map.

Promote the print statement from 'debug' level to 'warning', since there was no information for my colleague who stumbled over this problem while attempting to add a 2MB chunk of memory. There may be some zero-sized devices on the list, and those are not warned about.

Truncate the resource_size_t to an int and print it using %d rather than printing it in hex as a pointer to an address. We know it's less than PAGE_SIZE, so it'll fit in an int.

---
 drivers/nvdimm/namespace_devs.c | 7 ++++---
 include/uapi/linux/ndctl.h      | 4 ----
 2 files changed, 4 insertions(+), 7 deletions(-)
drivers/nvdimm/namespace_devs.c +4 -3
index 5f1c6756e57c..518c3507f67f 100644
@@ -1689,9 +1689,10 @@ struct nd_namespace_common *nvdimm_namespace_common_probe(struct device *dev)
 	}
 
 	size = nvdimm_namespace_capacity(ndns);
-	if (size < ND_MIN_NAMESPACE_SIZE) {
-		dev_dbg(&ndns->dev, "%pa, too small must be at least %#x\n",
-				&size, ND_MIN_NAMESPACE_SIZE);
+	if (size < PAGE_SIZE) {
+		if (size)
+			dev_warn(&ndns->dev, "%d too small must be at least %ld\n",
+					(int)size, PAGE_SIZE);
 		return ERR_PTR(-ENODEV);
 	}
 
include/uapi/linux/ndctl.h +0 -4
index 6d3c54264d8e..3ad1623bb585 100644
@@ -299,10 +299,6 @@ enum nd_driver_flags {
 	ND_DRIVER_DAX_PMEM	  = 1 << ND_DEVICE_DAX_PMEM,
 };
 
-enum {
-	ND_MIN_NAMESPACE_SIZE = 0x00400000,
-};
-
 enum ars_masks {
 	ARS_STATUS_MASK = 0x0000FFFF,
 	ARS_EXT_STATUS_SHIFT = 16,
Signature · 6 lines
2.11.0

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#5 lore raw
Quoted 54 lines · Matthew Wilcox
Quoted 2 lines

You're right. It should return -ENODEV regardless, but the warning should be for non-zero too small namespaces.

OK, try this:

---- 8< ----

From: Matthew Wilcox <[email protected]>
Date: Mon, 10 Jul 2017 14:26:59 -0400
Subject: [PATCH] nvdimm: Remove minimum size requirement

There was no need to have a minimum size of 4MB for NV-DIMMs; it was just a sanity check. Keep a check that it's at least one page in size because we really can't add less than a page to the memory map.

Promote the print statement from 'debug' level to 'warning', since there was no information for my colleague who stumbled over this problem while attempting to add a 2MB chunk of memory. There may be some zero-sized devices on the list, and those are not warned about.

Truncate the resource_size_t to an int and print it using %d rather than printing it in hex as a pointer to an address. We know it's less than PAGE_SIZE, so it'll fit in an int.

---
 drivers/nvdimm/namespace_devs.c | 7 ++++---
 include/uapi/linux/ndctl.h      | 4 ----
 2 files changed, 4 insertions(+), 7 deletions(-)
drivers/nvdimm/namespace_devs.c +4 -3
index 5f1c6756e57c..518c3507f67f 100644
@@ -1689,9 +1689,10 @@ struct nd_namespace_common *nvdimm_namespace_common_probe(struct device *dev)
        }
 
        size = nvdimm_namespace_capacity(ndns);
-       if (size < ND_MIN_NAMESPACE_SIZE) {
-               dev_dbg(&ndns->dev, "%pa, too small must be at least %#x\n",
-                               &size, ND_MIN_NAMESPACE_SIZE);
+       if (size < PAGE_SIZE) {
+               if (size)
+                       dev_warn(&ndns->dev, "%d too small must be at least %ld\n",
+                                       (int)size, PAGE_SIZE);
                return ERR_PTR(-ENODEV);
        }
 
include/uapi/linux/ndctl.h +0 -0
index 6d3c54264d8e..3ad1623bb585 100644

include/uapi/linux/ndctl.h enum nd_driver_flags { · line 305

Quoted 7 lines
include/uapi/linux/ndctl.h +0 -4
@@ -299,10 +299,6 @@ enum nd_driver_flags {
        ND_DRIVER_DAX_PMEM        = 1 << ND_DEVICE_DAX_PMEM,
 };
 
-enum {
-       ND_MIN_NAMESPACE_SIZE = 0x00400000,
-};
-

I ran this patch through the unit tests. We'll need to keep this definition around until we can kill it's usage in ndctl since it's part of the uapi. I also need to go fix up the dpa-alloc test to understand the new assumptions.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

A message that is not in the archive (sent off-list or not yet received): CAPcyv4h_=L=F9Gtf9NARH1vV4L0GBtRaUiSjZH-j5OeAdkV5Qg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#7 lore raw

Thanks great to hear.

Dan,
Could you share the patch you ran though the unittests?

I would like to give the new patch a try in my scenario.

Thanks
Cheng-mean

Quoted 73 lines · Dan Williams
Quoted 54 lines · Matthew Wilcox
Quoted 2 lines

You're right. It should return -ENODEV regardless, but the warning should be for non-zero too small namespaces.

OK, try this:

---- 8< ----

From: Matthew Wilcox <[email protected]>
Date: Mon, 10 Jul 2017 14:26:59 -0400
Subject: [PATCH] nvdimm: Remove minimum size requirement

There was no need to have a minimum size of 4MB for NV-DIMMs; it was just a sanity check. Keep a check that it's at least one page in size because we really can't add less than a page to the memory map.

Promote the print statement from 'debug' level to 'warning', since there was no information for my colleague who stumbled over this problem while attempting to add a 2MB chunk of memory. There may be some zero-sized devices on the list, and those are not warned about.

Truncate the resource_size_t to an int and print it using %d rather than printing it in hex as a pointer to an address. We know it's less than PAGE_SIZE, so it'll fit in an int.

---
drivers/nvdimm/namespace_devs.c | 7 ++++---
include/uapi/linux/ndctl.h | 4 ----

2 files changed, 4 insertions(+), 7 deletions(-)
drivers/nvdimm/namespace_devs.c +4 -3
index 5f1c6756e57c..518c3507f67f 100644
@@ -1689,9 +1689,10 @@ struct nd_namespace_common *nvdimm_namespace_common_probe(struct device *dev)
       }
 
       size = nvdimm_namespace_capacity(ndns);
-       if (size < ND_MIN_NAMESPACE_SIZE) {
-               dev_dbg(&ndns->dev, "%pa, too small must be at least %#x\n",
-                               &size, ND_MIN_NAMESPACE_SIZE);
+       if (size < PAGE_SIZE) {
+               if (size)
+                       dev_warn(&ndns->dev, "%d too small must be at least %ld\n",
+                                       (int)size, PAGE_SIZE);
               return ERR_PTR(-ENODEV);
       }
 
include/uapi/linux/ndctl.h +0 -0
index 6d3c54264d8e..3ad1623bb585 100644

include/uapi/linux/ndctl.h enum nd_driver_flags { · line 305

Quoted 7 lines
include/uapi/linux/ndctl.h +0 -4
@@ -299,10 +299,6 @@ enum nd_driver_flags {
       ND_DRIVER_DAX_PMEM        = 1 << ND_DEVICE_DAX_PMEM,
 };
 
-enum {
-       ND_MIN_NAMESPACE_SIZE = 0x00400000,
-};
-

I ran this patch through the unit tests. We'll need to keep this definition around until we can kill it's usage in ndctl since it's part of the uapi. I also need to go fix up the dpa-alloc test to understand the new assumptions.
_______________________________________________
Linux-nvdimm mailing list [email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#8 lore raw
Quoted 4 lines · Socer Liu

Thanks great to hear.

Dan,
Could you share the patch you ran though the unittests?

That patch is still failing the unit tests, so I have some more work to do to fix the test to understand the new minimum.

Quoted 1 line

I would like to give the new patch a try in my scenario.

I'll share it when I have the tests running again.
_______________________________________________
Linux-nvdimm mailing list [email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

A message that is not in the archive (sent off-list or not yet received): CAPcyv4jhGSo4RZtiXHKFNwzYwM_YcfoVZx0d4V=iLzdX622rKg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#10 lore raw

Hi Dan:

I am wondering if failing on those unittests is still an issue for this minimum size requirement change.

Thanks
Cheng-mean

-----Original Message-----
From: Dan Williams [mailto:[email protected]]
Sent: Thursday, July 13, 2017 5:14 PM
To: Socer Liu <soccer_liu-/[email protected]>
Cc: Matthew Wilcox <[email protected]>; Cheng-mean Liu (SOCCER) <[email protected]>; Matthew Wilcox <[email protected]>; [email protected]
Subject: Re: [PATCH] nvdimm: Remove minimum size requirement

Quoted 4 lines · Socer Liu

Thanks great to hear.

Dan,
Could you share the patch you ran though the unittests?

That patch is still failing the unit tests, so I have some more work to do to fix the test to understand the new minimum.

Quoted 1 line

I would like to give the new patch a try in my scenario.

I'll share it when I have the tests running again.

#11 lore raw
Quoted 3 lines · Cheng-mean Liu (SOCCER)

Hi Dan:

I am wondering if failing on those unittests is still an issue for this minimum size requirement change.

Yes, I just haven't had a chance to circle back and get this fixed up.

You can reproduce by running:

make TESTS=dpa-alloc check

...in a checkout of the ndctl project: https://github.com/pmem/ndctl

If you attempt that, note the required setup of the nfit_test modules documented in README.md in that same repository.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#12 lore raw
Quoted 8 lines · Dan Williams
Quoted 3 lines · Cheng-mean Liu (SOCCER)

Hi Dan:

I am wondering if failing on those unittests is still an issue for this minimum size requirement change.

Yes, I just haven't had a chance to circle back and get this fixed up.

Quoted 8 lines

You can reproduce by running:

make TESTS=dpa-alloc check

...in a checkout of the ndctl project: https://github.com/pmem/ndctl

If you attempt that, note the required setup of the nfit_test modules documented in README.md in that same repository.

I have not had any time to fix up the unit test for this. Soccer, can you take a look?
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

A message that is not in the archive (sent off-list or not yet received): CAPcyv4iA1ObGd9miPSOCc=YRziAxWXhC9NSL_TDo97g2t=dp_Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#14 lore raw

Sure, I will look into this.
Thanks for the instructions

Quoted 22 lines · Dan Williams
Quoted 10 lines · Dan Williams
Quoted 3 lines · Cheng-mean Liu (SOCCER)

Hi Dan:

I am wondering if failing on those unittests is still an issue for this minimum size requirement change.

Yes, I just haven't had a chance to circle back and get this fixed up.

Quoted 8 lines

You can reproduce by running:

make TESTS=dpa-alloc check

...in a checkout of the ndctl project: https://github.com/pmem/ndctl

If you attempt that, note the required setup of the nfit_test modules documented in README.md in that same repository.

I have not had any time to fix up the unit test for this. Soccer, can you take a look?

A message that is not in the archive (sent off-list or not yet received): 20170710203012.GB22476-PfSpb0PWhxZc2C7mugBRk2EX/[email protected]

#16 lore raw

I have tough time to image any scenarios that could make sense a zero-sized device.

-----Original Message-----
From: Matthew Wilcox [mailto:[email protected]]
Sent: Monday, July 10, 2017 1:30 PM
To: Dan Williams <[email protected]>
Cc: [email protected]; Cheng-mean Liu (SOCCER) <[email protected]>; Matthew Wilcox <[email protected]>
Subject: Re: [PATCH] nvdimm: Remove minimum size requirement

Quoted 10 lines · Dan Williams

drivers/nvdimm/namespace_devs.c struct nd_namespace_common *nvdimm_namespace_common_probe(struct device *dev) · line 1692

Quoted 5 lines
        size = nvdimm_namespace_capacity(ndns);
drivers/nvdimm/namespace_devs.c +1 -3
-       if (size < ND_MIN_NAMESPACE_SIZE) {
-               dev_dbg(&ndns->dev, "%pa, too small must be at least %#x\n",
-                               &size, ND_MIN_NAMESPACE_SIZE);
+       if (size < PAGE_SIZE) {

If we're going to change the print level away from 'debug' then I think this should be "if (size && size < PAGE_SIZE)". The sub-system pre-creates 0-sized devices that are later configured into full namespaces, in those cases we shouldn't fire the warning.

Should we allow drivers to claim zero-sized devices? If not, then the
dev_warn() should be predicated on size being non-zero, but the return -ENODEV should still trigger.