Messages in this thread | | | Subject | Re: [PATCH v5] printk: Userspace format enumeration support | From | Rasmus Villemoes <> | Date | Mon, 19 Apr 2021 09:27:43 +0200 |
| |
On 16/04/2021 15.56, Chris Down wrote: > Hey Petr, Rasmus,
>> This is great point! There are many other subsystem specific wrappers, >> e,g, ata_dev_printk(), netdev_printk(), snd_printk(), dprintk(). >> We should make it easy to index them as well. > > These would be nice to have, but we should agree about how we store > things internally. > > For example, in printk we typically store the level inline as part of > the format string at compile time. However, for `dev_printk`, it's > passed entirely separately from the format string after preprocessing is > already concluded (or at least, not in a way we can easily parse it the > same way we do for printk()): > > void dev_printk(const char *level, const struct device *dev, const > char *fmt, ...)
Hm, yeah, for "naked" dev_printk() calls there's no easy way to grab the level, for dev_err and friends it's somewhat easier as you could just hook into the definition of the dev_err macro. I'm not saying you need to handle everything at once, but doing dev_err and netdev_err would get you a very long way
> 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?
Rasmus
| |