Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1369407
| From | Petr Mladek <pmladek@suse.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [RFC][PATCH v9 1/2] printk: Make printk() completely async |
| Date | 2016-04-01 17:10 +0200 |
| Message-ID | <rj8RY-6cF-27@gated-at.bofh.it> (permalink) |
| References | <rj85A-5zZ-3@gated-at.bofh.it> <rj85A-5zZ-1@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Fri 2016-04-01 23:10:04, Sergey Senozhatsky wrote:
> This patch makes printk() completely asynchronous (similar to what
>
> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> index bfbf284..2e50c48 100644
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
> @@ -2722,6 +2761,47 @@ static int __init printk_late_init(void)
> late_initcall(printk_late_init);
>
> #if defined CONFIG_PRINTK
> +static int printk_kthread_func(void *data)
> +{
> + while (1) {
> + set_current_state(TASK_INTERRUPTIBLE);
> + if (!printk_kthread_need_flush_console)
> + schedule();
> +
> + __set_current_state(TASK_RUNNING);
> +
> + console_lock();
> + console_unlock();
> + /*
> + * Avoid an infinite loop when console_unlock() cannot
> + * access consoles, e.g. because console_suspended is
> + * true. schedule(), someone else will print the messages
> + * from resume_console().
> + */
> + printk_kthread_need_flush_console = false;
You need to move this assigment right above the console_lock()/console_unlock()
calls. Otherwise, there is a race:
CPU0: CPU1
printk_kthread_func()
console_unlock()
printk()
printk_kthread_need_flush_console = true;
wake_up_process(printk_kthread);
printk_kthread_need_flush_console = false;
set_current_state(TASK_INTERRUPTIBLE);
if (!printk_kthread_need_flush_console)
schedule();
=> sleeping without processing the last message.
You could safely set it false before calling
console_lock()/console_unlock() because you are calling the commands
that are requested by the flag.
With the above described change:
Reviewed-by: Petr Mladek <pmladek@suse.com>
Best Regards,
Petr
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[RFC][PATCH v9 1/2] printk: Make printk() completely async Sergey Senozhatsky <sergey.senozhatsky@gmail.com> - 2016-04-01 16:20 +0200
Re: [RFC][PATCH v9 1/2] printk: Make printk() completely async Petr Mladek <pmladek@suse.com> - 2016-04-01 17:10 +0200
Re: [RFC][PATCH v9 1/2] printk: Make printk() completely async Sergey Senozhatsky <sergey.senozhatsky@gmail.com> - 2016-04-01 18:50 +0200
Re: [RFC][PATCH v9 1/2] printk: Make printk() completely async Sergey Senozhatsky <sergey.senozhatsky@gmail.com> - 2016-04-01 18:40 +0200
csiph-web