public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Petr Mladek <pmladek@suse.com>
To: John Ogness <john.ogness@linutronix.de>
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,
	Miquel Raynal <miquel.raynal@bootlin.com>,
	Richard Weinberger <richard@nod.at>,
	Vignesh Raghavendra <vigneshr@ti.com>,
	linux-mtd@lists.infradead.org
Subject: Re: [PATCH next v3 02/15] mtd: mtdoops: synchronize kmsg_dumper
Date: Tue, 2 Mar 2021 13:48:23 +0100	[thread overview]
Message-ID: <YD40FzHeLkpMXkxn@alley> (raw)
In-Reply-To: <87tuptq1fc.fsf@jogness.linutronix.de>

On Tue 2021-03-02 11:45:27, John Ogness wrote:
> On 2021-03-01, Petr Mladek <pmladek@suse.com> wrote:
> >> The kmsg_dumper can be called from any context and CPU, possibly
> >> from multiple CPUs simultaneously. Since the writing of the buffer
> >> can occur from a later scheduled work queue, the oops buffer must
> >> be protected against simultaneous dumping.
> >> 
> >> Use an atomic bit to mark when the buffer is protected. Release the
> >> protection in between setting the buffer and the actual writing in
> >> order for a possible panic (immediate write) to be written during
> >> the scheduling of a previous oops (delayed write).
> >
> > Just to be sure. You did not use spin lock to prevent problems
> > with eventual double unlock in panic(). Do I get it correctly,
> > please?
> 
> I do not understand what possible double unlock you are referring to.

I was wrong. I meant the tricks that are under in console drivrers,
for example:

static void mvebu_uart_console_write(struct console *co, const char *s,
				     unsigned int count)
{
	int locked = 1;

	if (oops_in_progress)
		locked = spin_trylock_irqsave(&port->lock, flags);
	else
		spin_lock_irqsave(&port->lock, flags);

	/* do the job */

	if (locked)
		spin_unlock_irqrestore(&port->lock, flags);
}

But this is not a problem here because the kmsg dumper bails out
when the lock could not be taken.

> I chose not to use spinlocks because I wanted something that does not
> cause any scheduling or preemption side-effects for mtd. The mtd dumper
> sometimes dumps directly, sometimes delayed (via scheduled work), and
> they use different mtd callbacks in different contexts.
>
> mtd_write() expects to be called in a non-atomic context. The callbacks
> can take a mutex.

Makes sense. Could you please mention this in the commit message?

Best Regards,
Petr

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

  reply	other threads:[~2021-03-03 20:35 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-25 20:24 [PATCH next v3 00/15] printk: remove logbuf_lock John Ogness
2021-02-25 20:24 ` [PATCH next v3 02/15] mtd: mtdoops: synchronize kmsg_dumper John Ogness
2021-03-01 12:13   ` Petr Mladek
2021-03-02 10:45     ` John Ogness
2021-03-02 12:48       ` Petr Mladek [this message]
2021-02-25 20:24 ` [PATCH next v3 12/15] printk: introduce a kmsg_dump iterator John Ogness
2021-02-25 21:59   ` Kees Cook
2021-02-26  7:59   ` John Ogness
2021-03-01 18:07   ` Petr Mladek
2021-03-02 13:20     ` John Ogness
2021-03-02 13:55       ` 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=YD40FzHeLkpMXkxn@alley \
    --to=pmladek@suse.com \
    --cc=john.ogness@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=richard@nod.at \
    --cc=rostedt@goodmis.org \
    --cc=sergey.senozhatsky.work@gmail.com \
    --cc=sergey.senozhatsky@gmail.com \
    --cc=tglx@linutronix.de \
    --cc=vigneshr@ti.com \
    /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