[PATCH next v4 02/15] mtd: mtdoops: synchronize kmsg_dumper

Miquel Raynal miquel.raynal at bootlin.com
Thu Mar 11 09:50:55 GMT 2021


Hello,

John Ogness <john.ogness at linutronix.de> wrote on Wed,  3 Mar 2021
11:15:15 +0100:

> 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).
> 
> An atomic bit (rather than a spinlock) was chosen so that no
> scheduling or preemption side-effects would be introduced. The MTD
> kmsg_dumper may dump directly or it may be delayed (via scheduled
> work). Depending on the context, different MTD callbacks are used.
> For example, mtd_write() expects to be called in a non-atomic
> context and may take a mutex.
> 
> Signed-off-by: John Ogness <john.ogness at linutronix.de>
> Reviewed-by: Petr Mladek <pmladek at suse.com>

Reviewed-by: Miquel Raynal <miquel.raynal at bootlin.com>

Thanks,
Miquèl



More information about the linux-mtd mailing list