[lkml]   [2018]   [Nov]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH v6 1/3] printk: Add line-buffered printk() API.
On (11/07/18 11:21), Petr Mladek wrote:
> > [..]
> > - The printk-fallback sounds like a hint that the existing 'cont' handling
> > better stay in the kernel. I don't see how the existing 'cont' is
> > significantly worse than
> > bpr_warn(NULL, ...)->printk() // no 'cont' support
> > I don't see why would we want to do it, sorry. I don't see "it takes 16
> > printk-buffers to make a thing go right" as a sure thing.
> I see it the following way:
> + mixed cont lines are very rare but they happen
> + 16 buffers are more than 1 so it could only be better [*]

Right, so this is where things go a bit shady. I'll try to explain.

What is the problem:
- we have tons of CPUs, with tons of tasks running on them, with preemption,
and interrupts, and potentially printk-s coming from various
contexts/CPUs/tasks etc. so one 'cont' buffer is not enough.

What is the proposed solution:
- if 1 is not enough then 16 will do. And if 16 is not enough then this
is not our problem anymore, it's a kernel misconfiguration and users'

So, maybe it is a "common" kernel development pattern, I really don't know;
but it looks like we are just throwing the issue over the fence; and atop
of that we are killing off the existing 'cont'.

> Anyway, I do not think that both implementations are worth it.
> We could keep both for some transition period but we should
> remove the old one later.
> This would prevent removing the fallback to struct cont. OOM is
> one important scenario where continuous lines are used.

Let's have one more look at what we will fix and what we will break.

'cont' has premature flushes.

- it's annoying in some cases
- it's good otherwise

Why is it good.
It preserves the correct order of events.

pr_cont("calling foo->init()....");
printk("Can't allocate buffer\n"); // premature flush

Will end up in the logbuf as:
[12345.123] calling foo->init()....
[12345.124] Can't allocate buffer
[12345.125] ...blah

Where buffered printk will endup as:
[12345.123] Can't allocate buffer
[12345.124] calling foo->init().......blah

It's very different.

Not to mention that buffered printk does not flush on panic.
So, frankly, as of now, I don't see buffered printk as a 'cont'

If our problem is OOM and lockdep print outs, then let's address only
those two; let's not "fix" the rest of the kernel, especially the early
boot, - we can break more things than we can mend.

> I opened this problem once and it got lost. So I did not want to
> complicate it at this moment.

Right, I saw it. We have similar points; I raised those in private talks:

- we don't need buffered printk in printk_safe/printk_nmi

- we don't need br_cont()

- unlike 'cont' buffer there is no way for us to flush buffered printk
buffers on panic

- I don't exactly like the completely of the vprintk_buffered. If
buffered printk is for single line, then it must be for single
line only. And I'm not buying the "we will need this for printk
origin info injection" argument.
Linus was very clear about this whole idea:

Linus Torvalds wrote:
: Sergey Senozhatsky wrote:
: >
: > so... I think we don't have to update 'struct printk_log'. we can store
: > that "extended data" at the beginning of every message, right after the
: > prefix.
: No, we really can't. That just means that all the tools would have to
: be changed to get the normal messages without the extra crud. And
: since it will have lost the difference, that's not even easy to do.
: So this is exactly the wrong way around.
: If people want to see the extra data, it really should be extra data
: that you can get with a new interface from the kernel logs. Not a
: "let's just a add it to all lines and make every line uglier and
: harder to read.

So the "we need all that complexity to inject printk info in later
patches" push doesn't look right.

- It seems that buffered printk attempts to solve too many problems.
I'd prefer it to address just one.


 \ /
  Last update: 2018-11-08 03:22    [W:0.182 / U:0.204 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site