lkml.org 
[lkml]   [2020]   [Sep]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH printk 5/5] printk: remove nmi safe buffers
On Tue 2020-09-22 17:44:16, John Ogness wrote:
> Since the ringbuffer is now lockless, new records can be inserted
> directly from NMI context. There is no need for the NMI safe
> buffers. Handle all NMI printk() calls using defer_console_output()
> to avoid calling console drivers that might have their own locks.
>
> Signed-off-by: John Ogness <john.ogness@linutronix.de>
> ---
> kernel/printk/printk_safe.c | 47 ++++---------------------------------
> 1 file changed, 4 insertions(+), 43 deletions(-)
>
> diff --git a/kernel/printk/printk_safe.c b/kernel/printk/printk_safe.c
> index 7c186cefdb50..720935d19a3e 100644
> --- a/kernel/printk/printk_safe.c
> +++ b/kernel/printk/printk_safe.c
> @@ -355,10 +324,11 @@ __printf(1, 0) int vprintk_func(const char *fmt, va_list args)
> #endif
>
> /*
> - * Try to use the main logbuf even in NMI. But avoid calling console
> + * Use the main ringbuffer in NMI. But avoid calling console
> * drivers that might have their own locks.
> */
> - if ((this_cpu_read(printk_context) & PRINTK_NMI_DIRECT_CONTEXT_MASK)) {
> + if ((this_cpu_read(printk_context) &
> + (PRINTK_NMI_CONTEXT_MASK | PRINTK_NMI_DIRECT_CONTEXT_MASK))) {
> int len;
>
> len = vprintk_store(0, LOGLEVEL_DEFAULT, NULL, fmt, args);
> @@ -366,10 +336,6 @@ __printf(1, 0) int vprintk_func(const char *fmt, va_list args)
> return len;
> }
>
> - /* Use extra buffer in NMI. */
> - if (this_cpu_read(printk_context) & PRINTK_NMI_CONTEXT_MASK)
> - return vprintk_nmi(fmt, args);
> -
> /* Use extra buffer to prevent a recursion deadlock in safe mode. */
> if (this_cpu_read(printk_context) & PRINTK_SAFE_CONTEXT_MASK)
> return vprintk_safe(fmt, args);

I still hope that we will be able to get rid of printk_safe completely.

I would expect that only two situations would need special handling
with the lockless ringbuffer:

+ call vkdb_printf() in kdb context
+ defer console in NMI context

Eventually we should prevent too big level of recursion.

Best Regards,
Petr

\
 
 \ /
  Last update: 2020-09-23 18:37    [W:0.221 / U:4.320 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site