public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: John Ogness <john.ogness@linutronix.de>
To: Michael Kelley <mikelley@microsoft.com>, Petr Mladek <pmladek@suse.com>
Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
	Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	"linux-kernel\@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH printk-rework 10/12] hv: synchronize kmsg_dumper
Date: Mon, 01 Feb 2021 12:02:06 +0106	[thread overview]
Message-ID: <87mtwojbuh.fsf@jogness.linutronix.de> (raw)
In-Reply-To: <MWHPR21MB1593C37614E7F1334EB0AA7FD7BB9@MWHPR21MB1593.namprd21.prod.outlook.com>

On 2021-01-27, Michael Kelley <mikelley@microsoft.com> wrote:
>> 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@linutronix.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
>
> I don't think this patch is needed.   Per some of the unmodified code
> above, and the comment, we proceed to the call to kmsg_dump_get_buffer()
> only in the panic path.  Code in the panic path prior to invoking kmsg_dump()
> ensures that we are single-threaded on a single CPU.   So I think everything
> is good here without the new spin lock.  The subsequent call to
> hyperv_report_panic_msg() also assumes that we are single-threaded.

You are correct. I will withdraw this patch from the series. Thanks for
the feedback.

John Ogness

  reply	other threads:[~2021-02-01 10:57 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-26 21:15 [PATCH printk-rework 00/12] printk: remove logbuf_lock John Ogness
2021-01-26 21:15 ` [PATCH printk-rework 01/12] printk: kmsg_dump: remove unused fields John Ogness
2021-01-26 21:15 ` [PATCH printk-rework 02/12] printk: refactor kmsg_dump_get_buffer() John Ogness
2021-01-26 21:15 ` [PATCH printk-rework 03/12] printk: consolidate kmsg_dump_get_buffer/syslog_print_all code John Ogness
     [not found]   ` <YBQgTQYTA5p6Wgj6@alley>
2021-02-01  9:49     ` John Ogness
2021-02-02 12:31       ` Petr Mladek
2021-01-26 21:15 ` [PATCH printk-rework 04/12] printk: define CONSOLE_LOG_MAX in printk.h John Ogness
     [not found]   ` <YBQtbKrdwUAZQB9v@alley>
2021-02-01  8:24     ` LINE_MAX: was: " John Ogness
2021-02-02 11:22       ` Petr Mladek
2021-01-26 21:15 ` [PATCH printk-rework 05/12] printk: use seqcount_latch for clear_seq John Ogness
2021-01-26 21:15 ` [PATCH printk-rework 06/12] printk: use atomic64_t for devkmsg_user.seq John Ogness
2021-01-26 21:15 ` [PATCH printk-rework 07/12] printk: add syslog_lock John Ogness
2021-02-01 12:26   ` Petr Mladek
2021-02-01 13:11     ` John Ogness
2021-02-02 12:50       ` Petr Mladek
2021-01-26 21:15 ` [PATCH printk-rework 08/12] printk: introduce a kmsg_dump iterator John Ogness
2021-02-01 13:17   ` Petr Mladek
2021-02-01 13:32     ` John Ogness
2021-01-26 21:15 ` [PATCH printk-rework 09/12] um: synchronize kmsg_dumper John Ogness
2021-02-01 10:26   ` Petr Mladek
2021-02-01 14:15   ` Petr Mladek
2021-02-01 16:51     ` John Ogness
2021-02-01 16:54       ` Richard Weinberger
2021-02-01 20:25         ` John Ogness
2021-02-01 20:40           ` Richard Weinberger
2021-02-02 13:26       ` Petr Mladek
2021-01-26 21:15 ` [PATCH printk-rework 10/12] hv: " John Ogness
2021-01-27 21:32   ` Michael Kelley
2021-02-01 10:56     ` John Ogness [this message]
2021-01-26 21:15 ` [PATCH printk-rework 11/12] printk: remove logbuf_lock John Ogness
2021-02-02  9:15   ` Petr Mladek
2021-02-02 11:41     ` John Ogness
2021-02-02 16:11       ` Petr Mladek
2021-01-26 21:15 ` [PATCH printk-rework 12/12] printk: kmsg_dump: remove _nolock() variants John Ogness
2021-02-02  9:45   ` Petr Mladek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mtwojbuh.fsf@jogness.linutronix.de \
    --to=john.ogness@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mikelley@microsoft.com \
    --cc=pmladek@suse.com \
    --cc=rostedt@goodmis.org \
    --cc=sergey.senozhatsky.work@gmail.com \
    --cc=sergey.senozhatsky@gmail.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox