Messages in this thread | | | Date | Fri, 28 Jul 2023 17:22:45 +0200 | From | Petr Mladek <> | Subject | Re: [PATCH printk v2 2/8] printk: Provide debug_store() for nbcon debugging |
| |
On Fri 2023-07-28 02:08:27, John Ogness wrote: > To debug and validate nbcon ownership transitions, provide a new > macro debug_store() (enabled with DEBUG_NBCON) to log transition > information to the ringbuffer. If enabled, this macro only logs > to the ringbuffer and does not trigger any printing. This is to > avoid triggering recursive printing in the nbcon consoles. > > --- a/kernel/printk/printk_nbcon.c > +++ b/kernel/printk/printk_nbcon.c > @@ -10,6 +10,35 @@ > * the legacy style console_lock mechanism. > */ > > +/* > + * Define DEBUG_NBCON to allow for nbcon ownership transitions to be logged > + * to the ringbuffer. The debug_store() macro only logs to the lockless > + * ringbuffer and does not trigger any printing. > + */ > +#undef DEBUG_NBCON > + > +#ifdef DEBUG_NBCON > +/* Only write to ringbuffer. */ > +int __debug_store(const char *fmt, ...) > +{ > + va_list args; > + int r; > + > + va_start(args, fmt); > + r = vprintk_store(2, 7, NULL, fmt, args);
I have never used the facility number before. It seems that they are defined in /usr/include/sys/syslog.h, for example, see https://sites.uclouvain.be/SystInfo/usr/include/sys/syslog.h.html
They are even somehow documented in "man 3 syslog", for example, see https://linux.die.net/man/3/syslog
We should probably use one of the LOG_LOCALX numbers, e.g.
#define LOG_LOCAL0 (16<<3)
Also, please use LOGLEVEL_DEBUG instead of the hard coded "7".
> + va_end(args); > + > + return r; > +} > +#define debug_store(cond, fmt, ...) \ > + do { \ > + if (cond) \ > + __debug_store(pr_fmt("DEBUG: " fmt), ##__VA_ARGS__) \ > + } while (0) > +#else > +#define debug_store(cond, fmt, ...) > +#endif > + > /** > * nbcon_state_set - Helper function to set the console state > * @con: Console to update
Best Regards, Petr
| |