Re: Question: dev_err_probe() vs Printk Index

From: Greg KH
Date: Sun Aug 07 2022 - 02:58:14 EST


On Sat, Aug 06, 2022 at 10:53:16AM +0200, Christophe JAILLET wrote:
> Hi,
>
> When a driver is using dev_err(), part of it is inlined and it:
> - takes advantage of dev_fmt() [1]
> - implements Printk Index [2]
>
> Printk Index works with some __builtin_constant_p() magic in it.
> In case of a use in a probe, 99.99% of the time the log level and the format
> will be constant and the logic for Printk Index will be put in place.
>
>
> In case dev_err_probe(), the format will be an argument passed to the
> function and will not be constant, so nothing will be generated in the
> 'printk'_index section.
>
>
> In case dev_err_probe(), a potential dev_fmt() defined in the drivers' file
> can't be taken into consideration.
> (trusting my grep, we never use in files that define dev_fmt() in the .c
> file. I've not checked if it is true via #include "<something.h>")
>
>
> Even if I've read [3], I don't fully understand the real need of this Printk
> Index mechanism (at least for my own needs :))
>
>
> My questions are:
> - is my analysis right?
> - is the lack of these 2 functionalities (dev_fmt and Printk Index)
> expected, when dev_err_probe() is used?
> - if not, is it a issue?
> - should it be at least documented?

The printk index stuff is odd, and always seemed like a "check box"
option that some people wanted for a niche enterprise market. It's up
to them to keep that working well if they really need it, driver authors
should not worry about this.

thanks,

greg k-h