[PATCH v14 14/20] arm64/kexec: Add pr_debug output

James Morse james.morse at arm.com
Fri Mar 11 03:39:51 PST 2016


Hi Geoff,

On 04/03/16 23:51, Geoff Levand wrote:
> To aid in debugging kexec problems or when adding new functionality to kexec add
> a new routine kexec_image_info() and several inline pr_debug statements.
> 
> Signed-off-by: Geoff Levand <geoff at infradead.org>

[ ... snip ...]

> +/**
> + * kexec_image_info - For debugging output.
> + */
> +#define kexec_image_info(_i) _kexec_image_info(__func__, __LINE__, _i)
> +static void _kexec_image_info(const char *func, int line,
> +	const struct kimage *kimage)
> +{
> +	unsigned long i;
> +

> +#ifndef DEBUG
> +	return;
> +#endif

>From include/linux/printk.h on pr_foo():
> * All of these will print unconditionally, although note that pr_debug()
> * and other debug macros are compiled out unless either DEBUG is defined

So you can remove the #ifdef ... return, as all the pr_debug() calls will be
removed by the compiler in this case. (which also explains why it doesn't
complain about unreachable code!)


> +	pr_debug("%s:%d:\n", func, line);
> +	pr_debug("  kexec kimage info:\n");
> +	pr_debug("    type:        %d\n", kimage->type);
> +	pr_debug("    start:       %lx\n", kimage->start);
> +	pr_debug("    head:        %lx\n", kimage->head);
> +	pr_debug("    nr_segments: %lu\n", kimage->nr_segments);
> +
> +	for (i = 0; i < kimage->nr_segments; i++) {
> +		pr_debug("      segment[%lu]: %016lx - %016lx, 0x%lx bytes, %lu pages%s\n",
> +			i,
> +			kimage->segment[i].mem,
> +			kimage->segment[i].mem + kimage->segment[i].memsz,
> +			kimage->segment[i].memsz,
> +			kimage->segment[i].memsz /  PAGE_SIZE,
> +			(kexec_is_dtb(kimage->segment[i].buf) ?
> +				", dtb segment" : ""));
> +	}
> +}
> +
>  void machine_kexec_cleanup(struct kimage *kimage)
>  {
>  	/* Empty routine needed to avoid build errors. */


Thanks,

James





More information about the linux-arm-kernel mailing list