Re: [RFC][PATCHv2 2/4] printk: move printk_safe macros to printk header

2018-10-22 Thread Sergey Senozhatsky
On (10/16/18 14:54), Peter Zijlstra wrote: > > No, no wakups. irq_work to wake the printk-thread, at most. > There are cases when we probably prefer to be in "direct printk" mode. E.g. sysrq or late PM stages (probably). Doing irq_work->wake_up_process->printk_kthread from sysrq probably might

Re: [RFC][PATCHv2 2/4] printk: move printk_safe macros to printk header

2018-10-22 Thread Petr Mladek
On Wed 2018-10-17 16:00:44, Peter Zijlstra wrote: > On Wed, Oct 17, 2018 at 12:50:15PM +0200, Petr Mladek wrote: > > Also note that by deferred printk I mean deferring the console > > handling! IMHO, there are _no more problems_ with storing > > the messages into the buffer if we accept that the cu

Re: [RFC][PATCHv2 2/4] printk: move printk_safe macros to printk header

2018-10-17 Thread Peter Zijlstra
On Wed, Oct 17, 2018 at 12:50:15PM +0200, Petr Mladek wrote: > > If you have a lockless buffer and a trailing printk thread, that's > > deferred. > > > > And earlycon _should_ be lockless (yes, I know, some suck) > > > > But if you do this deferred nonsense that's currently in printk, then > > y

Re: [RFC][PATCHv2 2/4] printk: move printk_safe macros to printk header

2018-10-17 Thread Sergey Senozhatsky
On (10/17/18 09:57), Peter Zijlstra wrote: > On Wed, Oct 17, 2018 at 01:32:51PM +0900, Sergey Senozhatsky wrote: > > This probably will be a bit more hairy. logbuf is written to by many > > sources and is read from by many sides, including user-space [both read() > > and write()]. So we will need m

Re: [RFC][PATCHv2 2/4] printk: move printk_safe macros to printk header

2018-10-17 Thread Petr Mladek
On Tue 2018-10-16 14:17:52, Peter Zijlstra wrote: > On Tue, Oct 16, 2018 at 01:40:06PM +0200, Petr Mladek wrote: > > On Tue 2018-10-16 09:27:19, Peter Zijlstra wrote: > > > > Instead of this tinkering around the edges, why don't you make the main > > > logbuf a lockless ringbuffer and then delegat

Re: [RFC][PATCHv2 2/4] printk: move printk_safe macros to printk header

2018-10-17 Thread Peter Zijlstra
On Wed, Oct 17, 2018 at 01:32:51PM +0900, Sergey Senozhatsky wrote: > This probably will be a bit more hairy. logbuf is written to by many > sources and is read from by many sides, including user-space [both read() > and write()]. So we will need more flags/magic around memcpy(). A simple, > "grab

Re: [RFC][PATCHv2 2/4] printk: move printk_safe macros to printk header

2018-10-16 Thread Sergey Senozhatsky
On (10/16/18 14:54), Peter Zijlstra wrote: > On Tue, Oct 16, 2018 at 09:27:34PM +0900, Sergey Senozhatsky wrote: > > per-CPU printk_safe _semi-magic_ makes some things simple to handle. > > We can't just remove per-CPU buffers and add a wake_up_process() at > > the bottom of vprintk_emit(). Because

Re: [RFC][PATCHv2 2/4] printk: move printk_safe macros to printk header

2018-10-16 Thread Peter Zijlstra
On Tue, Oct 16, 2018 at 02:54:15PM +0200, Peter Zijlstra wrote: > printk will determine the current context: > > task, softirq, hardirq or NMI > > and pick the corresponding per-cpu line buffer and do the vsnprintf() We need 4, but we don't need to do the exact context determination for this.

Re: [RFC][PATCHv2 2/4] printk: move printk_safe macros to printk header

2018-10-16 Thread Peter Zijlstra
On Tue, Oct 16, 2018 at 09:27:34PM +0900, Sergey Senozhatsky wrote: > per-CPU printk_safe _semi-magic_ makes some things simple to handle. > We can't just remove per-CPU buffers and add a wake_up_process() at > the bottom of vprintk_emit(). Because this will deadlock: > > printk() >wake_up_p

Re: [RFC][PATCHv2 2/4] printk: move printk_safe macros to printk header

2018-10-16 Thread Peter Zijlstra
On Tue, Oct 16, 2018 at 09:27:34PM +0900, Sergey Senozhatsky wrote: > On (10/16/18 09:27), Peter Zijlstra wrote: > > > > So I really _really_ hate all this. Utterly detest it. > > I learned a new word today - detest. I can haz re-entrant consoles now please? early_serial_write() not haz a lock a

Re: [RFC][PATCHv2 2/4] printk: move printk_safe macros to printk header

2018-10-16 Thread Sergey Senozhatsky
On (10/16/18 09:27), Peter Zijlstra wrote: > > So I really _really_ hate all this. Utterly detest it. I learned a new word today - detest. I can haz re-entrant consoles now please? > That whole magic 'safe' printk buffer crap is just that crap. No, I don't see it this way; printk_safe is *semi-

Re: [RFC][PATCHv2 2/4] printk: move printk_safe macros to printk header

2018-10-16 Thread Peter Zijlstra
On Tue, Oct 16, 2018 at 01:40:06PM +0200, Petr Mladek wrote: > On Tue 2018-10-16 09:27:19, Peter Zijlstra wrote: > > Instead of this tinkering around the edges, why don't you make the main > > logbuf a lockless ringbuffer and then delegate the actual printing of > > that buffer to a kthread, excep

Re: [RFC][PATCHv2 2/4] printk: move printk_safe macros to printk header

2018-10-16 Thread Petr Mladek
On Tue 2018-10-16 09:27:19, Peter Zijlstra wrote: > On Tue, Oct 16, 2018 at 02:04:26PM +0900, Sergey Senozhatsky wrote: > > Make printk_safe_enter_irqsave()/etc macros available to the > > rest of the kernel. > > > > Signed-off-by: Sergey Senozhatsky > > --- > > include/linux/printk.h | 40

Re: [RFC][PATCHv2 2/4] printk: move printk_safe macros to printk header

2018-10-16 Thread Peter Zijlstra
On Tue, Oct 16, 2018 at 02:04:26PM +0900, Sergey Senozhatsky wrote: > Make printk_safe_enter_irqsave()/etc macros available to the > rest of the kernel. > > Signed-off-by: Sergey Senozhatsky > --- > include/linux/printk.h | 40 + > kernel/printk/internal.

[RFC][PATCHv2 2/4] printk: move printk_safe macros to printk header

2018-10-15 Thread Sergey Senozhatsky
Make printk_safe_enter_irqsave()/etc macros available to the rest of the kernel. Signed-off-by: Sergey Senozhatsky --- include/linux/printk.h | 40 + kernel/printk/internal.h| 37 -- kernel/printk/printk_safe.c | 6 +++