Re: [PATCH v5] printk: Userspace format enumeration support

From: Joe Perches
Date: Thu Apr 22 2021 - 08:38:09 EST


On Wed, 2021-04-21 at 14:14 +0100, Chris Down wrote:
> Rasmus Villemoes writes:
> > > One (ugly) way to handle this would be to have a new "level" field in
> > > the printk index entry, with semantics that if it's some sentinel value,
> > > look at the format itself for the format, otherwise if it's some other
> > > value, the level field itself is the level.
> > >
> > > This will work, but it's pretty ugly. Any better suggestions? :-)
> >
> > Well, that was more or less exactly what I suggested when I wrote
> >
> > > One could also record the function a format is being used with - without
> > > that, the display probably can't show a reasonable <level> for those
> > > dev_* function.
> >
> > But, I think the real question is, why are we/you interested in the
> > level at all? Isn't the format string itself enough for the purpose of
> > tracking which printks have come and gone? IOW, what about, on the
> > display side, simply skipping over some KERN_* prefix if present?
[]
> Judging by the conversation there's no immediately obvious better way, so
> unless you or Petr object, I'll send a patch in the v6 series which implements
> the "ugly" way with dev_printk support as the first user. That should make it
> easier to add other printk-likes in future as needed.

There are dozens of these types of printks extensions in the kernel.
Today, your test case .config uses btrfs which has its own too.

You really should evaluate the utility of log level monitoring and
reconsider adding some compiler extension use of __printf to generate
this format tracking ability.