Skip to contentSkip to conversation

acpi: Eliminate misleading erst pstore console message

PATCH Superseded Lenny Szubowicz 2 participants 7 messages Jun 28, 2013

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover acpi: Eliminate misleading erst pstore console message

On systems that have a valid ACPI ERST table, if the pstore.backend kernel parameter selects a specific facility other than erst, then during boot the following console message is displayed:

ERST: Could not register with persistent store

This message makes it seem that something has gone wrong. In fact the same message is used when you want ERST to be used by pstore and some real error precludes registration.

The primary purpose of this 3 patch set is to avoid displaying this console error message when another facility is explicitly selected as the backend for pstore. Details are in the individual patches.

Lenny Szubowicz (3):
pstore: Return unique error if backend registration excluded by kernel
param
acpi: Eliminate console msg if pstore.backend excludes ERST
efivars: If pstore_register fails, free unneeded pstore buffer

 drivers/acpi/apei/erst.c          | 20 ++++++++++++++------
 drivers/firmware/efi/efi-pstore.c |  6 +++++-
 fs/pstore/platform.c              | 11 ++++++-----
 3 files changed, 25 insertions(+), 12 deletions(-)
Signature · 1 line
1.8.2.1
#1 lore raw

PATCH 1/3 pstore: Return unique error if backend registration excluded by kernel param

This is patch 1/3 of a patch set that avoids what misleadingly appears to be a error during boot:

ERST: Could not register with persistent store

This message is displayed if the system has a valid ACPI ERST table and the pstore.backend kernel parameter has been used to disable use of ERST by pstore. But this same message is used for errors that preclude registration.

As part of fixing this, return a unique error status from pstore_register if the pstore.backend kernel parameter selects a specific facility other than the requesting facility and check for this condition before any others. This allows the caller to distinquish this benign case from the other failure cases.

Also, print an informational console message about which facility successfully registered as the pstore backend. Since there are various kernel parameters, config build options, and boot-time errors that can influence which facility registers with pstore, it's useful to have a positive indication.

---
 fs/pstore/platform.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
fs/pstore/platform.c +6 -5
index 86d1038..84f3ca7 100644
@@ -239,17 +239,15 @@ int pstore_register(struct pstore_info *psi)
 {
 	struct module *owner = psi->owner;
 
+	if (backend && strcmp(backend, psi->name))
+		return -EINVAL;
+
 	spin_lock(&pstore_lock);
 	if (psinfo) {
 		spin_unlock(&pstore_lock);
 		return -EBUSY;
 	}
 
-	if (backend && strcmp(backend, psi->name)) {
-		spin_unlock(&pstore_lock);
-		return -EINVAL;
-	}
-
 	if (!psi->write)
 		psi->write = pstore_write_compat;
 	psinfo = psi;
@@ -274,6 +272,9 @@ int pstore_register(struct pstore_info *psi)
 		add_timer(&pstore_timer);
 	}
 
+	pr_info("pstore: Registered %s as persistent store backend\n",
+		psi->name);
+
 	return 0;
 }
 EXPORT_SYMBOL_GPL(pstore_register);
Signature · 1 line
1.8.2.1
#2 lore raw

PATCH 2/3 acpi: Eliminate console msg if pstore.backend excludes ERST

In reply to Lenny Szubowicz

This is patch 2/3 of a patch set that avoids what misleadingly appears to be a error during boot:

ERST: Could not register with persistent store

This message is displayed if the system has a valid ACPI ERST table and the pstore.backend kernel parameter has been used to disable use of ERST by pstore. But this same message is used for errors that preclude registration.

In erst_init don't complain if the setting of kernel parameter pstore.backend precludes use of ACPI ERST for pstore. Routine pstore_register will inform about the facility that does register.

Also, don't leave a dangling pointer to deallocated mem for the pstore buffer when registration fails.

---
 drivers/acpi/apei/erst.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
drivers/acpi/apei/erst.c +14 -6
index 6d894bf..f7b3b39 100644
@@ -1180,20 +1180,28 @@ static int __init erst_init(void)
 	if (!erst_erange.vaddr)
 		goto err_release_erange;
 
+	pr_info(ERST_PFX
+	"Error Record Serialization Table (ERST) support is initialized.\n");
+
 	buf = kmalloc(erst_erange.size, GFP_KERNEL);
 	spin_lock_init(&erst_info.buf_lock);
 	if (buf) {
 		erst_info.buf = buf + sizeof(struct cper_pstore_record);
 		erst_info.bufsize = erst_erange.size -
 				    sizeof(struct cper_pstore_record);
-		if (pstore_register(&erst_info)) {
-			pr_info(ERST_PFX "Could not register with persistent store\n");
+		rc = pstore_register(&erst_info);
+		if (rc) {
+			if (rc != -EPERM)
+				pr_info(ERST_PFX
+				"Could not register with persistent store\n");
+			erst_info.buf = NULL;
+			erst_info.bufsize = 0;
 			kfree(buf);
 		}
-	}
-
-	pr_info(ERST_PFX
-	"Error Record Serialization Table (ERST) support is initialized.\n");
+	} else
+		pr_err(ERST_PFX
+		"Failed to allocate %lld bytes for persistent store error log\n",
+		erst_erange.size);
 
 	return 0;
 
Signature · 1 line
1.8.2.1
#3 lore raw

Re: [PATCH 2/3] acpi: Eliminate console msg if pstore.backend excludes ERST

drivers/acpi/apei/erst.c static int __init erst_init(void) · line 1198

Quoted 9 lines · Lenny Szubowicz
drivers/acpi/apei/erst.c +7 -2
-               if (pstore_register(&erst_info)) {
-                       pr_info(ERST_PFX "Could not register with persistent store\n");
+               rc = pstore_register(&erst_info);
+               if (rc) {
+                       if (rc != -EPERM)
+                               pr_info(ERST_PFX
+                               "Could not register with persistent store\n");
+                       erst_info.buf = NULL;
+                       erst_info.bufsize = 0;

Mismatch between part 1 and part 2 here ... we return -EINVAL if our name doesn't match the desired backend ... but you only suppress the "Could not register" message for -EPERM

Or am I confused while just looking at patch fragments?

-Tony

#4 lore raw

Re: [PATCH 2/3] acpi: Eliminate console msg if pstore.backend excludes ERST

----- Original Message -----

Quoted 25 lines

From: "Tony Luck" <[email protected]>
To: "Lenny Szubowicz" <[email protected]>
Cc: "Anton Vorontsov" <[email protected]>, "Matt Fleming" <[email protected]>, "Linux Kernel Mailing List" <[email protected]>, "n hamaguchi" <[email protected]>, "Don Zickus" <[email protected]>
Sent: Friday, June 28, 2013 4:44:51 PM
Subject: Re: [PATCH 2/3] acpi: Eliminate console msg if pstore.backend excludes ERST

drivers/acpi/apei/erst.c static int __init erst_init(void) · line 1198

Quoted 11 lines · Lenny Szubowicz
(quoted diff) +0 -2
-               if (pstore_register(&erst_info)) {
-                       pr_info(ERST_PFX "Could not register with

persistent store\n");

drivers/acpi/apei/erst.c +5 -0
+               rc = pstore_register(&erst_info);
+               if (rc) {
+                       if (rc != -EPERM)
+                               pr_info(ERST_PFX
+                               "Could not register with persistent

store\n");

drivers/acpi/apei/erst.c +2 -0
+                       erst_info.buf = NULL;
+                       erst_info.bufsize = 0;

Mismatch between part 1 and part 2 here ... we return -EINVAL if our name doesn't match the desired backend ... but you only suppress the "Could not register" message for -EPERM

Quoted 9 lines

Or am I confused while just looking at patch fragments?

-Tony
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Yes, you are absolutely correct. My [PATCH 1/3] is not what I intended. Thanks!

                         -Lenny.
#5 lore raw

PATCH 3/3 efivars: If pstore_register fails, free unneeded pstore buffer

In reply to Lenny Szubowicz

This is patch 3/3 of a patch set that cleans up pstore_register failure paths.

If efivars fails to register with pstore, there is no point to keeping the 4 KB buffer around. It's only used by the pstore read/write routines.

---
 drivers/firmware/efi/efi-pstore.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/firmware/efi/efi-pstore.c +5 -1
index 202d2c8..66c0c76 100644
@@ -236,7 +236,11 @@ static __init int efivars_pstore_init(void)
 	efi_pstore_info.bufsize = 1024;
 	spin_lock_init(&efi_pstore_info.buf_lock);
 
-	pstore_register(&efi_pstore_info);
+	if (pstore_register(&efi_pstore_info)) {
+		kfree(efi_pstore_info.buf);
+		efi_pstore_info.buf = NULL;
+		efi_pstore_info.bufsize = 0;
+	}
 
 	return 0;
 }
Signature · 1 line
1.8.2.1
#6 lore raw
In reply to Lenny Szubowicz
Quoted 5 lines · Lenny Szubowicz

On systems that have a valid ACPI ERST table, if the pstore.backend kernel parameter selects a specific facility other than erst, then during boot the following console message is displayed:

ERST: Could not register with persistent store

Applied (using revised version of part 1).

Thanks

-Tony