Skip to contentSkip to conversation

kexec: Use %pe format specifier for error pointer printing

PATCH In review Zhu Yanjun 3 participants 8 messages Oct 16, 2025 – Nov 1, 2025

Subsystems (4)
lore
Share & tools
lore

Zhu Yanjun

author
#0 lore raw

PATCH 1/1 kexec: Use %pe format specifier for error pointer printing

Make pr_xxx() call to use the %pe format specifier instead of %d. The %pe specifier prints a symbolic error string (e.g., -ENOMEM, -EINVAL) when given an error pointer created with ERR_PTR(err).

This change enhances the clarity and diagnostic value of the error message by showing a descriptive error name rather than a numeric error code.

---
 kernel/kexec_handover.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
kernel/kexec_handover.c +9 -9
index 76f0940fb485..77af377022b0 100644
@@ -1095,7 +1095,7 @@ static int kho_abort(void)
 	err = notifier_to_errno(err);
 
 	if (err)
-		pr_err("Failed to abort KHO finalization: %d\n", err);
+		pr_err("Failed to abort KHO finalization: %pe\n", ERR_PTR(err));
 
 	return err;
 }
@@ -1142,7 +1142,7 @@ static int kho_finalize(void)
 
 abort:
 	if (err) {
-		pr_err("Failed to convert KHO state tree: %d\n", err);
+		pr_err("Failed to convert KHO state tree: %pe\n", ERR_PTR(err));
 		kho_abort();
 	}
 
@@ -1355,8 +1355,8 @@ static __init int kho_in_debugfs_init(const void *fdt)
 		err = kho_debugfs_fdt_add(&kho_in.fdt_list, sub_fdt_dir, name,
 					  phys_to_virt(*fdt_phys));
 		if (err) {
-			pr_warn("failed to add fdt `%s` to debugfs: %d\n", name,
-				err);
+			pr_warn("failed to add fdt `%s` to debugfs: %pe\n", name,
+				ERR_PTR(err));
 			continue;
 		}
 	}
@@ -1400,8 +1400,8 @@ static __init int kho_init(void)
 		 * kexec.
 		 */
 		if (err)
-			pr_err("failed exposing handover FDT in debugfs: %d\n",
-			       err);
+			pr_err("failed exposing handover FDT in debugfs: %pe\n",
+			       ERR_PTR(err));
 
 		return 0;
 	}
@@ -1524,8 +1524,8 @@ void __init kho_populate(phys_addr_t fdt_phys, u64 fdt_len,
 		memblock_add(area->addr, size);
 		err = memblock_mark_kho_scratch(area->addr, size);
 		if (WARN_ON(err)) {
-			pr_warn("failed to mark the scratch region 0x%pa+0x%pa: %d",
-				&area->addr, &size, err);
+			pr_warn("failed to mark the scratch region 0x%pa+0x%pa: %pe",
+				&area->addr, &size, ERR_PTR(err));
 			goto out;
 		}
 		pr_debug("Marked 0x%pa+0x%pa as scratch", &area->addr, &size);
@@ -1553,7 +1553,7 @@ void __init kho_populate(phys_addr_t fdt_phys, u64 fdt_len,
 	if (scratch)
 		early_memunmap(scratch, scratch_len);
 	if (err)
-		pr_warn("disabling KHO revival: %d\n", err);
+		pr_warn("disabling KHO revival: %pe\n", ERR_PTR(err));
 }
 
 /* Helper functions for kexec_file_load */
Signature · 1 line
2.51.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Zhu Yanjun

Make pr_xxx() call to use the %pe format specifier instead of %d. The %pe specifier prints a symbolic error string (e.g., -ENOMEM, -EINVAL) when given an error pointer created with ERR_PTR(err).

This change enhances the clarity and diagnostic value of the error message by showing a descriptive error name rather than a numeric error code.

Thanks,

This looks good to me, even though I note that this file has moved in linux-next.

author
#2 lore raw
Quoted 9 lines · Simon Horman
Quoted 8 lines · Zhu Yanjun

Make pr_xxx() call to use the %pe format specifier instead of %d. The %pe specifier prints a symbolic error string (e.g., -ENOMEM, -EINVAL) when given an error pointer created with ERR_PTR(err).

This change enhances the clarity and diagnostic value of the error message by showing a descriptive error name rather than a numeric error code.

Quoted 5 lines
Quoted 1 line

Thanks,

This looks good to me, even though I note that this file has moved in linux-next.

Thanks a lot.

Yanjun.Zhu

Quoted 2 lines
Signature · 2 lines
Best Regards,
Yanjun.Zhu
author
#3 lore raw
In reply to Simon Horman
Quoted 9 lines · Simon Horman
Quoted 8 lines · Zhu Yanjun

Make pr_xxx() call to use the %pe format specifier instead of %d. The %pe specifier prints a symbolic error string (e.g., -ENOMEM, -EINVAL) when given an error pointer created with ERR_PTR(err).

This change enhances the clarity and diagnostic value of the error message by showing a descriptive error name rather than a numeric error code.

Quoted 6 lines
Quoted 1 line

Thanks,

This looks good to me, even though I note that this file has moved in linux-next.

Thank you very much. In next-20251021, I noticed that the directory is now kernel/liveupdate/.

If a new commit is needed to reflect this change, please feel free to let me know.

Yanjun.Zhu

Quoted 3 lines
author
#4 lore raw
In reply to Simon Horman

Hi, Pasha

I noticed that you are moving |kexec_handover.c| from the |kernel/| directory to |kernel/liveupdate/|.

Several developers suggested that I resend my patch after your patch series is merged upstream.
Therefore, I’d like to ask if you could include my patch in your series. This would help avoid extra work on my side to resend the commit later.

Thanks,

Yanjun.Zhu

Quoted 16 lines · Simon Horman
Quoted 9 lines · Zhu Yanjun

Make pr_xxx() call to use the %pe format specifier instead of %d. The %pe specifier prints a symbolic error string (e.g., -ENOMEM, -EINVAL) when given an error pointer created with ERR_PTR(err).

This change enhances the clarity and diagnostic value of the error message by showing a descriptive error name rather than a numeric error code.

Thanks,

This looks good to me, even though I note that this file has moved in linux-next.

maintainer
#5 lore raw

Sure. Will include it

Quoted 36 lines · Yanjun.Zhu

Hi, Pasha

I noticed that you are moving kexec_handover.c from the kernel/ directory to kernel/liveupdate/.

Several developers suggested that I resend my patch after your patch series is merged upstream.
Therefore, I’d like to ask if you could include my patch in your series. This would help avoid extra work on my side to resend the commit later.

Thanks,

Yanjun.Zhu
On 10/21/25 2:41 AM, Simon Horman wrote:

On Thu, Oct 16, 2025 at 08:03:20PM +0000, Zhu Yanjun wrote:

Make pr_xxx() call to use the %pe format specifier instead of %d. The %pe specifier prints a symbolic error string (e.g., -ENOMEM, -EINVAL) when given an error pointer created with ERR_PTR(err).

This change enhances the clarity and diagnostic value of the error message by showing a descriptive error name rather than a numeric error code.

Thanks,

This looks good to me, even though I note that this file has moved in linux-next.

author
#6 lore raw
Quoted 1 line · Pasha Tatashin

Sure. Will include it

Thanks a lot. Appreciate your helps.

Yanjun.Zhu

Quoted 36 lines · Yanjun.Zhu

Hi, Pasha

I noticed that you are moving |kexec_handover.c| from the |kernel/| directory to |kernel/liveupdate/|.

Several developers suggested that I resend my patch after your patch series is merged upstream.
Therefore, I’d like to ask if you could include my patch in your series. This would help avoid extra work on my side to resend the commit later.

Thanks,

Yanjun.Zhu

Quoted 16 lines · Simon Horman
    On Thu, Oct 16, 2025 at 08:03:20PM +0000, Zhu Yanjun wrote:
Quoted 9 lines

Make pr_xxx() call to use the %pe format specifier instead of %d. The %pe specifier prints a symbolic error string (e.g., -ENOMEM, -EINVAL) when given an error pointer created with ERR_PTR(err).

This change enhances the clarity and diagnostic value of the error message by showing a descriptive error name rather than a numeric error code.

Thanks,

This looks good to me, even though I note that this file has moved in linux-next.

maintainer
#7 lore raw
In reply to Zhu Yanjun
Quoted 34 lines · Zhu Yanjun

Make pr_xxx() call to use the %pe format specifier instead of %d. The %pe specifier prints a symbolic error string (e.g., -ENOMEM, -EINVAL) when given an error pointer created with ERR_PTR(err).

This change enhances the clarity and diagnostic value of the error message by showing a descriptive error name rather than a numeric error code.

---
 kernel/kexec_handover.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
kernel/kexec_handover.c +1 -1
index 76f0940fb485..77af377022b0 100644
@@ -1095,7 +1095,7 @@ static int kho_abort(void)
        err = notifier_to_errno(err);
 
        if (err)
-               pr_err("Failed to abort KHO finalization: %d\n", err);
+               pr_err("Failed to abort KHO finalization: %pe\n", ERR_PTR(err));
 
        return err;
 }

kernel/kexec_handover.c static int kho_finalize(void) · line 1145

Quoted 5 lines
kernel/kexec_handover.c +1 -1
@@ -1142,7 +1142,7 @@ static int kho_finalize(void)
 
 abort:
        if (err) {
-               pr_err("Failed to convert KHO state tree: %d\n", err);
+               pr_err("Failed to convert KHO state tree: %pe\n", ERR_PTR(err));

The problem here (and in some other places below) is err a not an -errno, but fdt error:
see: scripts/dtc/libfdt/libfdt.h

%pe ERR_PTR(err) will output garbage, and make the debugging even harder.