[RFC][PATCH v4 -next 4/4] Skip spin_lock of efi_pstore_write() inpanic case

From: Seiji Aguchi
Date: Thu Jan 05 2012 - 12:42:23 EST


This patch skips spin_lock of efi_pstore_write() in panic path for these reasons.
- efi_pstore_write() is serialized via smp_send_stop().
- SetVariable runtime service is guaranteed to work correctly if you call
it a second time when you have taken an exception in trying
to execute them already.

We can avoid deadlock of spin_lock(&efivars->lock) in panic path and get panic log
reliably.


Signed-off-by: Seiji Aguchi <seiji.aguchi@xxxxxxx>

---
drivers/firmware/efivars.c | 13 +++++++++++--
1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
index d25599f..657e6f1 100644
--- a/drivers/firmware/efivars.c
+++ b/drivers/firmware/efivars.c
@@ -510,7 +510,15 @@ static int efi_pstore_write(enum pstore_type_id type,
sprintf(stub_name, "dump-type%u-%u-", type, part);
sprintf(name, "%s%lu", stub_name, get_seconds());

- spin_lock(&efivars->lock);
+ /*
+ * We don't need to take any locks in panic path for these reasons.
+ * - efi_pstore_write() is serialized via smp_send_stop().
+ * - SetVariable runtime service is guaranteed to work correctly
+ * if you call it a second time when you have taken an exception
+ * in trying to execute them already.
+ */
+ if (reason != KMSG_DUMP_PANIC)
+ spin_lock(&efivars->lock);

for (i = 0; i < DUMP_NAME_LEN; i++)
efi_name[i] = stub_name[i];
@@ -548,7 +556,8 @@ static int efi_pstore_write(enum pstore_type_id type,
efivars->ops->set_variable(efi_name, &vendor, PSTORE_EFI_ATTRIBUTES,
size, psi->buf);

- spin_unlock(&efivars->lock);
+ if (reason != KMSG_DUMP_PANIC)
+ spin_unlock(&efivars->lock);

if (found)
efivar_unregister(found);
--
1.7.1



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