Re: [PATCH v10 1/2] printk: Make printk() completely async

From: Sergey Senozhatsky
Date: Fri Aug 26 2016 - 04:21:01 EST


On (08/26/16 10:56), Sergey Senozhatsky wrote:


> but every lock we take is potentially dangerous as well.
...
> vprintk_emit()
> {
> alt_printk_enter();
> ...
> log_store();
> ...
> alt_printk_exit();
>
> wakep_up_process() /* direct from async printk,
> or indirect from console_unlock()->up() */
> alt_printk_enter();
> ... enqueue task
> alt_printk_exit();
> }


OTOH, after a very quick thought, up() also takes a spin lock, which
may spindump. so I'll probably prefer to keep the entire alt-printk
thing entirely in printk(). something like this

vprintk_emit()
{
alt_printk_enter()
log_store()
alt_printk_exit()

if (async_printk)
{
alt_printk_enter()
wake_up_process()
alt_printk_exit()
} else {
if (console_trylock()) {
console_unlock()
{
....
alt_printk_enter()
up()
alt_printk_exit()
}
}
}
}

this leaves console_trylock() `unprotected'. so I guess I'll do
something like this:

} else {
int ret;

alt_printk_enter()
ret = console_trylock();
alt_printk_exit()

if (ret)
console_unlock();
}

a bit ugly, but well, it is what it is. will think more about it.

-ss