[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210126211551.26536-11-john.ogness@linutronix.de>
Date: Tue, 26 Jan 2021 22:21:49 +0106
From: John Ogness <john.ogness@...utronix.de>
To: Petr Mladek <pmladek@...e.com>
Cc: Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>,
Sergey Senozhatsky <sergey.senozhatsky@...il.com>,
Steven Rostedt <rostedt@...dmis.org>,
Thomas Gleixner <tglx@...utronix.de>,
linux-kernel@...r.kernel.org
Subject: [PATCH printk-rework 10/12] hv: synchronize kmsg_dumper
In preparation for removing printk's @logbuf_lock, dumpers that have
assumed to be protected against parallel calls must provide their own
synchronization. Add a locally static spinlock to synchronize the
kmsg_dump call.
Signed-off-by: John Ogness <john.ogness@...utronix.de>
---
drivers/hv/vmbus_drv.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index fbeddef90941..08db95e1a139 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -1362,23 +1362,27 @@ static void hv_kmsg_dump(struct kmsg_dumper *dumper,
enum kmsg_dump_reason reason,
struct kmsg_dumper_iter *iter)
{
+ static DEFINE_SPINLOCK(lock);
size_t bytes_written;
phys_addr_t panic_pa;
+ unsigned long flags;
/* We are only interested in panics. */
if ((reason != KMSG_DUMP_PANIC) || (!sysctl_record_panic_msg))
return;
+ if (!spin_trylock_irqsave(&lock, flags))
+ return;
+
panic_pa = virt_to_phys(hv_panic_page);
- /*
- * Write dump contents to the page. No need to synchronize; panic should
- * be single-threaded.
- */
+ /* Write dump contents to the page. */
kmsg_dump_get_buffer(iter, false, hv_panic_page, HV_HYP_PAGE_SIZE,
&bytes_written);
if (bytes_written)
hyperv_report_panic_msg(panic_pa, bytes_written);
+
+ spin_unlock_irqrestore(&lock, flags);
}
static struct kmsg_dumper hv_kmsg_dumper = {
--
2.20.1
Powered by blists - more mailing lists