[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20170703153414.65ab12e3@gandalf.local.home>
Date: Mon, 3 Jul 2017 15:34:14 -0400
From: Steven Rostedt <rostedt@...dmis.org>
To: Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>
Cc: Petr Mladek <pmladek@...e.com>,
Sergey Senozhatsky <sergey.senozhatsky@...il.com>,
Jan Kara <jack@...e.cz>,
Andrew Morton <akpm@...ux-foundation.org>,
Peter Zijlstra <peterz@...radead.org>,
"Rafael J . Wysocki" <rjw@...ysocki.net>,
Eric Biederman <ebiederm@...ssion.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Jiri Slaby <jslaby@...e.com>, Pavel Machek <pavel@....cz>,
Andreas Mohr <andi@...as.de>,
Tetsuo Handa <penguin-kernel@...ove.SAKURA.ne.jp>,
linux-kernel@...r.kernel.org
Subject: Re: [RFC][PATCHv3 2/5] printk: introduce printing kernel thread
On Mon, 3 Jul 2017 20:11:30 +0900
Sergey Senozhatsky <sergey.senozhatsky.work@...il.com> wrote:
> +#define PRINTK_FLOOD_DEFAULT_DELAY 10
> +
> int printk_delay_msec __read_mostly;
>
> +static inline void __printk_delay(int m)
> +{
> + while (m--) {
> + mdelay(1);
> + touch_nmi_watchdog();
> + }
> +}
> +
> static inline void printk_delay(void)
> {
> - if (unlikely(printk_delay_msec)) {
> - int m = printk_delay_msec;
> + unsigned long flags;
> + u64 console_seen = 0, console_to_see;
>
> - while (m--) {
> - mdelay(1);
> - touch_nmi_watchdog();
> - }
> + if (printk_delay_msec) {
> + __printk_delay(printk_delay_msec);
> + return;
> + }
> +
This had better be an option, and not default. And what happens if the
printk caller happens to preempt the one doing the writes to consoles?
-- Steve
> + /*
> + * Check if consoles are far behind the loguf head and
> + * throttle printk() callers if so.
> + */
> + logbuf_lock_irqsave(flags);
> + if (console_seq > log_first_seq)
> + console_seen = console_seq - log_first_seq;
> + console_to_see = log_next_seq - console_seq;
> + logbuf_unlock_irqrestore(flags);
> +
> + if (console_seen < 4 * console_to_see) {
> + if (printk_delay_msec)
> + __printk_delay(printk_delay_msec);
> + else
> + __printk_delay(PRINTK_FLOOD_DEFAULT_DELAY);
> }
> }
>
Powered by blists - more mailing lists