Skip to contentSkip to conversation

cxl/region: Add dev_dbg() detail on failure to allocate HPA space

PATCH Superseded [email protected] 3 participants 4 messages Nov 14, 2023 – Nov 15, 2023 CXL

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 1/1 cxl/region: Add dev_dbg() detail on failure to allocate HPA space

From: Alison Schofield <[email protected]>

When the region driver fails while allocating HPA space for a new region it can be because the parent resource, the CXL Window, has no more available space.

In that case, the debug user sees this message:
cxl_core:alloc_hpa:555: cxl region2: failed to allocate HPA: -34

Expand the message like this:
cxl_core:alloc_hpa:555: cxl region8: failed to allocate HPA:-34 size:0x20000000 in CXL Window 0 [mem 0xf010000000-0xf04fffffff flags 0x200]

Now the debug user can examine /proc/iomem and consider actions like removing other allocations in that space or reducing the size of their region request.

---
 drivers/cxl/core/region.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/cxl/core/region.c +3 -2
index 56e575c79bb4..0e6a378f1913 100644
@@ -552,8 +552,9 @@ static int alloc_hpa(struct cxl_region *cxlr, resource_size_t size)
 	res = alloc_free_mem_region(cxlrd->res, size, SZ_256M,
 				    dev_name(&cxlr->dev));
 	if (IS_ERR(res)) {
-		dev_dbg(&cxlr->dev, "failed to allocate HPA: %ld\n",
-			PTR_ERR(res));
+		dev_dbg(&cxlr->dev,
+			"failed to allocate HPA:%ld size:%#llx in %s %pr\n",
+			PTR_ERR(res), size, cxlrd->res->name, cxlrd->res);
 		return PTR_ERR(res);
 	}
 

base-commit: b85ea95d086471afb4ad062012a4d73cd328fa86

Signature · 1 line
2.37.3
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 12 lines · On 11/13/23 21:01, [email protected] wrote:

From: Alison Schofield <[email protected]>

When the region driver fails while allocating HPA space for a new region it can be because the parent resource, the CXL Window, has no more available space.

In that case, the debug user sees this message:
cxl_core:alloc_hpa:555: cxl region2: failed to allocate HPA: -34

Expand the message like this:
cxl_core:alloc_hpa:555: cxl region8: failed to allocate HPA:-34 size:0x20000000 in CXL Window 0 [mem 0xf010000000-0xf04fffffff flags 0x200]

Quoted 6 lines

Now the debug user can examine /proc/iomem and consider actions like removing other allocations in that space or reducing the size of their region request.

Quoted 22 lines
---
 drivers/cxl/core/region.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/cxl/core/region.c +3 -2
index 56e575c79bb4..0e6a378f1913 100644
@@ -552,8 +552,9 @@ static int alloc_hpa(struct cxl_region *cxlr, resource_size_t size)
 	res = alloc_free_mem_region(cxlrd->res, size, SZ_256M,
 				    dev_name(&cxlr->dev));
 	if (IS_ERR(res)) {
-		dev_dbg(&cxlr->dev, "failed to allocate HPA: %ld\n",
-			PTR_ERR(res));
+		dev_dbg(&cxlr->dev,
+			"failed to allocate HPA:%ld size:%#llx in %s %pr\n",
+			PTR_ERR(res), size, cxlrd->res->name, cxlrd->res);
 		return PTR_ERR(res);
 	}
 

base-commit: b85ea95d086471afb4ad062012a4d73cd328fa86

maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to [email protected]
Quoted 27 lines · On Mon, 2023-11-13 at 20:01 -0800, [email protected] wrote:

From: Alison Schofield <[email protected]>

When the region driver fails while allocating HPA space for a new region it can be because the parent resource, the CXL Window, has no more available space.

In that case, the debug user sees this message:
cxl_core:alloc_hpa:555: cxl region2: failed to allocate HPA: -34

Expand the message like this:
cxl_core:alloc_hpa:555: cxl region8: failed to allocate HPA:-34 size:0x20000000 in CXL Window 0 [mem 0xf010000000-0xf04fffffff flags 0x200]

Now the debug user can examine /proc/iomem and consider actions like removing other allocations in that space or reducing the size of their region request.

---
 drivers/cxl/core/region.c | 5 +++--

 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/cxl/core/region.c +0 -0
index 56e575c79bb4..0e6a378f1913 100644

drivers/cxl/core/region.c static int alloc_hpa(struct cxl_region *cxlr, resource_size_t size) · line 557

Quoted 8 lines
drivers/cxl/core/region.c +3 -2
@@ -552,8 +552,9 @@ static int alloc_hpa(struct cxl_region *cxlr, resource_size_t size)
         res = alloc_free_mem_region(cxlrd->res, size, SZ_256M,
                                     dev_name(&cxlr->dev));
         if (IS_ERR(res)) {
-               dev_dbg(&cxlr->dev, "failed to allocate HPA: %ld\n",
-                       PTR_ERR(res));
+               dev_dbg(&cxlr->dev,
+                       "failed to allocate HPA:%ld size:%#llx in %s %pr\n",
+                       PTR_ERR(res), size, cxlrd->res->name, cxlrd->res);

Very minor, but the format of this print can make it seem like we're talking about HPA -34 instead of an error code of -34. Might be nice to take the chance to reword it to something like:

"HPA allocation error (%d) for size: %llx in %s ..."

Other than that, looks good,

Quoted 5 lines
drivers/cxl/core/region.c +0 -0
                 return PTR_ERR(res);
         }

base-commit: b85ea95d086471afb4ad062012a4d73cd328fa86

author maintainer
#3 lore raw
Quoted 41 lines · Vishal Verma
Quoted 27 lines · On Mon, 2023-11-13 at 20:01 -0800, [email protected] wrote:

From: Alison Schofield <[email protected]>

When the region driver fails while allocating HPA space for a new region it can be because the parent resource, the CXL Window, has no more available space.

In that case, the debug user sees this message:
cxl_core:alloc_hpa:555: cxl region2: failed to allocate HPA: -34

Expand the message like this:
cxl_core:alloc_hpa:555: cxl region8: failed to allocate HPA:-34 size:0x20000000 in CXL Window 0 [mem 0xf010000000-0xf04fffffff flags 0x200]

Now the debug user can examine /proc/iomem and consider actions like removing other allocations in that space or reducing the size of their region request.

---
 drivers/cxl/core/region.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/cxl/core/region.c +0 -0
index 56e575c79bb4..0e6a378f1913 100644

drivers/cxl/core/region.c static int alloc_hpa(struct cxl_region *cxlr, resource_size_t size) · line 557

Quoted 8 lines
drivers/cxl/core/region.c +3 -2
@@ -552,8 +552,9 @@ static int alloc_hpa(struct cxl_region *cxlr, resource_size_t size)
        res = alloc_free_mem_region(cxlrd->res, size, SZ_256M,
                                    dev_name(&cxlr->dev));
        if (IS_ERR(res)) {
-               dev_dbg(&cxlr->dev, "failed to allocate HPA: %ld\n",
-                       PTR_ERR(res));
+               dev_dbg(&cxlr->dev,
+                       "failed to allocate HPA:%ld size:%#llx in %s %pr\n",
+                       PTR_ERR(res), size, cxlrd->res->name, cxlrd->res);

Very minor, but the format of this print can make it seem like we're talking about HPA -34 instead of an error code of -34. Might be nice to take the chance to reword it to something like:

Quoted 1 line

"HPA allocation error (%d) for size: %llx in %s ..."

Yes - much clearer. Will do.
Thanks!

Quoted 13 lines

Other than that, looks good,

Quoted 5 lines
drivers/cxl/core/region.c +0 -0
                return PTR_ERR(res);
        }
 

base-commit: b85ea95d086471afb4ad062012a4d73cd328fa86

--