Re: [PATCH printk v2 2/8] printk: Provide debug_store() for nbcon debugging

From: John Ogness
Date: Fri Jul 28 2023 - 05:53:20 EST


On 2023-07-28, John Ogness <john.ogness@xxxxxxxxxxxxx> wrote:
> +/*
> + * 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);
> + va_end(args);
> +
> + return r;
> +}
> +#define debug_store(cond, fmt, ...) \
> + do { \
> + if (cond) \
> + __debug_store(pr_fmt("DEBUG: " fmt), ##__VA_ARGS__) \

Missing a semi-colon here. Wrapping this with a do-while was a
last-minute change requested by checkpatch.pl. Probably nobody would
notice because you must manually define DEBUG_NBCON by changing the
source code. Fixed for v3 (assuming Petr allows me to keep this
debugging code in place).

> + } while (0)
> +#else
> +#define debug_store(cond, fmt, ...)
> +#endif

John