Re: [QUESTION] printk: time namespaces and printk timestamps

From: Petr Mladek

Date: Mon May 25 2026 - 04:41:04 EST


On Sat 2026-05-23 17:20:45, Thomas Weißschuh wrote:
> Hi everyone,
>
> It looks like the monotonic timestamps of printk records do not take the
> callers time namespace into account when emitted through /dev/kmsg,
> /proc/kmsg and syslog(2).
>
> To me this looks like a bug. What do you think? Should it be changed?

To be honest, I have never heard about time namespaces before ;-)

So, you propose to use the timestamp with the namespace-specific
offset when a message is added from the given namespace, e.g. via:

echo "This message is from another time space" > /dev/kmsg

Do I get it correctly?

I see two potential problems:

1. printk() historically used a monotonic clock. I am not sure if any
usespace application depends on it but there is a risk of breaking
something.

Anyway, the printk messages are used to debug kernel problems.
And the order of events might be important. IMHO, messages with
random offsets might create confusion.


2. printk() has to work in any context, including NMI. It requires
a lockless way to get the timestamps. I am not sure if the
namespace timestamps might be read a lockless way and if
it would be worth the effort.


Best Regards,
Petr