Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1473023

Re: [PATCH] printk/nmi: avoid direct printk()-s from __printk_nmi_flush()

From Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Newsgroups linux.kernel
Subject Re: [PATCH] printk/nmi: avoid direct printk()-s from __printk_nmi_flush()
Date 2016-08-31 06:10 +0200
Message-ID <sc50B-5Ti-13@gated-at.bofh.it> (permalink)
References (1 earlier) <sbwvT-v8-15@gated-at.bofh.it> <sbM7D-1Ul-7@gated-at.bofh.it> <sbNdo-2Ps-23@gated-at.bofh.it> <sbNGp-2Zk-1@gated-at.bofh.it> <sbPfb-44D-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On (08/30/16 13:19), Petr Mladek wrote:
[..]
> > yes, x86 has a per-cpu nmi_state to handle the case when NMI is
> > loosing its NMI context. But other arch-s, as far as I can see,
> > don't do that. Does it mean that we are safe only on x86?
> 
> My understanding is that the kernel would crash on the other
> architectures if a double iret was called. By other words,
> they would have bigger problems than the nmi_enter()/nmi_exit()
> calls. So, we should be on the safe side.
> 
> > this printk_func_saved thing is still will be needed, I think,
> > for alt_printk.
> > 
> > Example:
> > 
> > process abc
> > 	printk()
> > 		alt_printk_enter()
> > 			this_cpu_write(printk_func, vprintk_alt);
> > ->	NMI
> > 	:	printk_nmi_enter()
> > 	:		this_cpu_write(printk_func, vprintk_nmi);
> > 	:	printk_nmi_exit()
> > 	:		this_cpu_write(printk_func, vprintk_default);
> > 	return NMI
> > 
> > 		printk()  <<<<  nested printk -> vprintk_default(), set by nmi_exit()
> > 		alt_printk_exit()
> > 	...
> 
> I see. But then we will need to be more careful because printk_func
> and printk_func_saved will be manipulated in different contexts:
> normal, irq, nmi. A solution might be using an atomic counter
> and selecting the right vprintk_func according to the value.

yes, I thought about something like this.
... or we can use the one and only 'nmi_seq' buffer and share it between
NMI and alt_printk, adding a special prefix to every message

	if (in_nmi())
		sprintf("NMI:%s", message)
	else
		sprintf("%s", message)

so, yes, it can get hairy, but at least it will be grep-able, still
better than nothing.

> Well, I am still afraid that yet another alt_printk is not
> the way to go.

well, it might be and it might be not.

	-ss

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] printk/nmi: avoid direct printk()-s from __printk_nmi_flush() Sergey Senozhatsky <sergey.senozhatsky@gmail.com> - 2016-08-29 14:40 +0200
  Re: [PATCH] printk/nmi: avoid direct printk()-s from  __printk_nmi_flush() Petr Mladek <pmladek@suse.com> - 2016-08-29 17:20 +0200
    Re: [PATCH] printk/nmi: avoid direct printk()-s from  __printk_nmi_flush() Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2016-08-30 03:10 +0200
    Re: [PATCH] printk/nmi: avoid direct printk()-s from  __printk_nmi_flush() Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2016-08-30 10:00 +0200
      Re: [PATCH] printk/nmi: avoid direct printk()-s from  __printk_nmi_flush() Petr Mladek <pmladek@suse.com> - 2016-08-30 11:10 +0200
        Re: [PATCH] printk/nmi: avoid direct printk()-s from  __printk_nmi_flush() Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2016-08-30 11:40 +0200
          Re: [PATCH] printk/nmi: avoid direct printk()-s from  __printk_nmi_flush() Petr Mladek <pmladek@suse.com> - 2016-08-30 13:20 +0200
            Re: [PATCH] printk/nmi: avoid direct printk()-s from  __printk_nmi_flush() Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2016-08-31 06:10 +0200
            Re: [PATCH] printk/nmi: avoid direct printk()-s from  __printk_nmi_flush() Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2016-09-01 10:00 +0200
              Re: [PATCH] printk/nmi: avoid direct printk()-s from  __printk_nmi_flush() Petr Mladek <pmladek@suse.com> - 2016-09-01 10:20 +0200

csiph-web