Re: output: was: Re: [PATCH v4] printk: Userspace format enumeration support

From: Chris Down
Date: Tue Feb 16 2021 - 11:54:04 EST


Hey Petr,

Petr Mladek writes:
This produces something like:

3Warning: unable to open an initial console.
3Failed to execute %s (error %d)
6Kernel memory protection disabled.
3Starting init: %s exists but couldn't execute it (error %d)
6Run %s as init process
7initcall %pS returned %d after %lld usecs
7calling %pS @ %i
2initrd overwritten (0x%08lx < 0x%08lx) - disabling it.

The loglevel is not well separated. It is neither human readable
nor safe for a machine processing . It works only for single digit.
[...]
It looks in less like: [...]

Hmm, why is it important that debugfs output is human readable? My impression was that it's fine to have machine-readable stuff there.

Re: not being not safe for machine processing because it only works for a single digit, I'm a little confused. KERN_* levels are, as far as I know, only a single byte wide, and we rely on that already (eg. in printk_skip_header()). We also already have precedent for null-separation/control characters in (for example) /proc/pid/cmdline.

What am I missing? :-)

Well, it still might be non-trivial to find the string in the code
and see what exactly has changed. It might be pretty useful
to mention even the source_file:line, for example:

<3> init/main.c:1489: Warning: unable to open an initial console.\n
<3> init/main.c:1446: Failed to execute %s (error %d)\n
<6> init/main.c:1398: Kernel memory protection disabled.\n
<3> init/main.c:1366: Starting init: %s exists but couldn't execute it (error %d)\n

Almost certainly a theoretical concern, but I am not a big fan of this format, because it relies on a character (":") which is legal in paths (although as you'd expect, we don't have any cases in the kernel right now). That's one of the reasons why I preferred to use nulls, which can't be in a filename.