Skip to contentSkip to conversation

habanalabs: improve error messages

PATCH In review Oded Gabbay 3 participants 5 messages Mar 28, 2019 – Mar 29, 2019 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 habanalabs: improve error messages

This patch improves two error messages to help the user to better understand what error occurred.

---
 drivers/misc/habanalabs/command_submission.c | 3 ++-
 drivers/misc/habanalabs/memory.c             | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/misc/habanalabs/command_submission.c +2 -1
index f908643f871f..02c48da0b645 100644
@@ -261,7 +261,8 @@ static void cs_timedout(struct work_struct *work)
 	ctx_asid = cs->ctx->asid;
 
 	/* TODO: add information about last signaled seq and last emitted seq */
-	dev_err(hdev->dev, "CS %d.%llu got stuck!\n", ctx_asid, cs->sequence);
+	dev_err(hdev->dev, "User %d command submission %llu got stuck!\n",
+		ctx_asid, cs->sequence);
 
 	cs_put(cs);
 
drivers/misc/habanalabs/memory.c +1 -1
index ce1fda40a8b8..39788b1cf8d0 100644
@@ -109,7 +109,7 @@ static int alloc_device_memory(struct hl_ctx *ctx, struct hl_mem_in *args,
 							page_size);
 			if (!phys_pg_pack->pages[i]) {
 				dev_err(hdev->dev,
-					"ioctl failed to allocate page\n");
+					"Failed to allocate device memory (out of memory)\n");
 				rc = -ENOMEM;
 				goto page_err;
 			}
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 28 lines · Oded Gabbay

This patch improves two error messages to help the user to better understand what error occurred.

---
 drivers/misc/habanalabs/command_submission.c | 3 ++-
 drivers/misc/habanalabs/memory.c             | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/misc/habanalabs/command_submission.c +2 -1
index f908643f871f..02c48da0b645 100644
@@ -261,7 +261,8 @@ static void cs_timedout(struct work_struct *work)
 	ctx_asid = cs->ctx->asid;
 
 	/* TODO: add information about last signaled seq and last emitted seq */
-	dev_err(hdev->dev, "CS %d.%llu got stuck!\n", ctx_asid, cs->sequence);
+	dev_err(hdev->dev, "User %d command submission %llu got stuck!\n",
+		ctx_asid, cs->sequence);
 
 	cs_put(cs);
 
drivers/misc/habanalabs/memory.c +0 -0
index ce1fda40a8b8..39788b1cf8d0 100644

drivers/misc/habanalabs/memory.c static int alloc_device_memory(struct hl_ctx *ctx, struct hl_mem_in *args, · line 112

Quoted 5 lines
drivers/misc/habanalabs/memory.c +1 -1
@@ -109,7 +109,7 @@ static int alloc_device_memory(struct hl_ctx *ctx, struct hl_mem_in *args,
 							page_size);
 			if (!phys_pg_pack->pages[i]) {
 				dev_err(hdev->dev,
-					"ioctl failed to allocate page\n");
+					"Failed to allocate device memory (out of memory)\n");

No need for a message at all here, right? The core should have already told you you had a problem.

greg k-h

#2 lore raw
Quoted 3 lines · Greg KH
Quoted 2 lines · Oded Gabbay

This patch improves two error messages to help the user to better understand what error occurred.

[]

Quoted 1 line

drivers/misc/habanalabs/memory.c

Quoted 1 line
drivers/misc/habanalabs/memory.c +0 -0

[]

Quoted 9 lines

drivers/misc/habanalabs/memory.c static int alloc_device_memory(struct hl_ctx *ctx, struct hl_mem_in *args, · line 112

Quoted 6 lines
drivers/misc/habanalabs/memory.c +1 -1
@@ -109,7 +109,7 @@ static int alloc_device_memory(struct hl_ctx *ctx, struct hl_mem_in *args,
 							page_size);
 			if (!phys_pg_pack->pages[i]) {
 				dev_err(hdev->dev,
-					"ioctl failed to allocate page\n");
+					"Failed to allocate device memory (out of memory)\n");

No need for a message at all here, right? The core should have already told you you had a problem.

I do not understand this code all that well, but I am uncertain if all the possible pool allocation functions emit an OOM message on failure.

Also, there is another pool allocation for the contiguous allocation attempt that has a similar OOM in this function.

#3 lore raw
In reply to Greg KH
Quoted 39 lines · Greg KH
Quoted 28 lines · Oded Gabbay

This patch improves two error messages to help the user to better understand what error occurred.

---
 drivers/misc/habanalabs/command_submission.c | 3 ++-
 drivers/misc/habanalabs/memory.c             | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/misc/habanalabs/command_submission.c +2 -1
index f908643f871f..02c48da0b645 100644
@@ -261,7 +261,8 @@ static void cs_timedout(struct work_struct *work)
      ctx_asid = cs->ctx->asid;
 
      /* TODO: add information about last signaled seq and last emitted seq */
-     dev_err(hdev->dev, "CS %d.%llu got stuck!\n", ctx_asid, cs->sequence);
+     dev_err(hdev->dev, "User %d command submission %llu got stuck!\n",
+             ctx_asid, cs->sequence);
 
      cs_put(cs);
 
drivers/misc/habanalabs/memory.c +0 -0
index ce1fda40a8b8..39788b1cf8d0 100644

drivers/misc/habanalabs/memory.c static int alloc_device_memory(struct hl_ctx *ctx, struct hl_mem_in *args, · line 112

Quoted 5 lines
drivers/misc/habanalabs/memory.c +1 -1
@@ -109,7 +109,7 @@ static int alloc_device_memory(struct hl_ctx *ctx, struct hl_mem_in *args,
                                                      page_size);
                      if (!phys_pg_pack->pages[i]) {
                              dev_err(hdev->dev,
-                                     "ioctl failed to allocate page\n");
+                                     "Failed to allocate device memory (out of memory)\n");

No need for a message at all here, right? The core should have already told you you had a problem.

Quoted 1 line

greg k-h

No, I don't think so, because this function is called for allocating memory in the device's DRAM. So we don't pass through the Linux core code inside.
We use the generic genalloc module to implement the device's DRAM physical page allocator, and AFAIK, you won't get any message in case genalloc fails to find a free memory in its pool.
Even if genalloc prints something, I would prefer to display a more meaningful message to the user in this case. This allocation is directly requested by the user (its part of the IOCTL code) and he should know how it failed, no ?

Oded

maintainer
#4 lore raw
Quoted 42 lines · Oded Gabbay
Quoted 39 lines · Greg KH
Quoted 28 lines · Oded Gabbay

This patch improves two error messages to help the user to better understand what error occurred.

---
 drivers/misc/habanalabs/command_submission.c | 3 ++-
 drivers/misc/habanalabs/memory.c             | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/misc/habanalabs/command_submission.c +2 -1
index f908643f871f..02c48da0b645 100644
@@ -261,7 +261,8 @@ static void cs_timedout(struct work_struct *work)
      ctx_asid = cs->ctx->asid;
 
      /* TODO: add information about last signaled seq and last emitted seq */
-     dev_err(hdev->dev, "CS %d.%llu got stuck!\n", ctx_asid, cs->sequence);
+     dev_err(hdev->dev, "User %d command submission %llu got stuck!\n",
+             ctx_asid, cs->sequence);
 
      cs_put(cs);
 
drivers/misc/habanalabs/memory.c +0 -0
index ce1fda40a8b8..39788b1cf8d0 100644

drivers/misc/habanalabs/memory.c static int alloc_device_memory(struct hl_ctx *ctx, struct hl_mem_in *args, · line 112

Quoted 5 lines
drivers/misc/habanalabs/memory.c +1 -1
@@ -109,7 +109,7 @@ static int alloc_device_memory(struct hl_ctx *ctx, struct hl_mem_in *args,
                                                      page_size);
                      if (!phys_pg_pack->pages[i]) {
                              dev_err(hdev->dev,
-                                     "ioctl failed to allocate page\n");
+                                     "Failed to allocate device memory (out of memory)\n");

No need for a message at all here, right? The core should have already told you you had a problem.

Quoted 1 line

greg k-h

Quoted 10 lines

No, I don't think so, because this function is called for allocating memory in the device's DRAM. So we don't pass through the Linux core code inside.
We use the generic genalloc module to implement the device's DRAM physical page allocator, and AFAIK, you won't get any message in case genalloc fails to find a free memory in its pool.
Even if genalloc prints something, I would prefer to display a more meaningful message to the user in this case. This allocation is directly requested by the user (its part of the IOCTL code) and he should know how it failed, no ?

Ok, that sounds reasonable, nevermind :)

greg k-h