Re: [PATCH v3 1/2] printk: add print_hex_dump_devel()

From: John Ogness

Date: Thu Mar 19 2026 - 05:46:27 EST


On 2026-03-19, Thorsten Blum <thorsten.blum@xxxxxxxxx> wrote:
> Add print_hex_dump_devel() as the hex dump equivalent of pr_devel(),
> which emits output only when DEBUG is enabled, but keeps call sites
> compiled otherwise.
>
> Suggested-by: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
> Signed-off-by: Thorsten Blum <thorsten.blum@xxxxxxxxx>
> ---
> include/linux/printk.h | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/include/linux/printk.h b/include/linux/printk.h
> index 63d516c873b4..54e3c621fec3 100644
> --- a/include/linux/printk.h
> +++ b/include/linux/printk.h
> @@ -801,6 +801,19 @@ static inline void print_hex_dump_debug(const char *prefix_str, int prefix_type,
> }
> #endif
>
> +#if defined(DEBUG)
> +#define print_hex_dump_devel(prefix_str, prefix_type, rowsize, \
> + groupsize, buf, len, ascii) \
> + print_hex_dump(KERN_DEBUG, prefix_str, prefix_type, rowsize, \
> + groupsize, buf, len, ascii)
> +#else
> +static inline void print_hex_dump_devel(const char *prefix_str, int prefix_type,
> + int rowsize, int groupsize,
> + const void *buf, size_t len, bool ascii)
> +{
> +}

If you look at the implementation of pr_devel(), it is using no_printk()
in the !DEBUG case. I believe this is to validate correct arg
formatting, even if the code will optimized out.

John Ogness