public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Florian Fainelli <f.fainelli@gmail.com>
Cc: linux-kernel@vger.kernel.org, opendmb@gmail.com,
	Barret Rhoden <brho@google.com>, Arnd Bergmann <arnd@arndb.de>
Subject: Re: [PATCH] initramfs: Panic with memory information
Date: Sun, 17 Jan 2021 13:33:55 -0800	[thread overview]
Message-ID: <20210117133355.10fe86c628279161bb3435d4@linux-foundation.org> (raw)
In-Reply-To: <20210114231517.1854379-1-f.fainelli@gmail.com>

On Thu, 14 Jan 2021 15:15:16 -0800 Florian Fainelli <f.fainelli@gmail.com> wrote:

> On systems with large amounts of reserved memory we may fail to
> successfully complete unpack_to_rootfs() and be left with:
> 
>  Kernel panic - not syncing: write error
> 
> this is not too helpful to understand what happened, so let's wrap the
> panic() calls with a surrounding show_mem() such that we have a chance
> of understanding the memory conditions leading to these allocation
> failures.

Seems sensible.

> @@ -45,6 +46,11 @@ static void __init error(char *x)
>  		message = x;
>  }
>  
> +#define panic_show_mem(...) {	\
> +	show_mem(0, NULL);	\
> +	panic(__VA_ARGS__);	\
> +}
> +

But can we replace nasty macro with pleasing C code?

--- a/init/initramfs.c~initramfs-panic-with-memory-information-fix
+++ a/init/initramfs.c
@@ -46,9 +46,14 @@ static void __init error(char *x)
 		message = x;
 }
 
-#define panic_show_mem(...) {	\
-	show_mem(0, NULL);	\
-	panic(__VA_ARGS__);	\
+static void panic_show_mem(const char *fmt, ...)
+{
+	va_list args;
+
+	show_mem(0, NULL);
+	va_start(args, fmt);
+	panic(fmt, args);
+	va_end(args);
 }
 
 /* link hash */
_


  reply	other threads:[~2021-01-17 21:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-14 23:15 [PATCH] initramfs: Panic with memory information Florian Fainelli
2021-01-17 21:33 ` Andrew Morton [this message]
2021-01-18  3:09   ` Florian Fainelli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210117133355.10fe86c628279161bb3435d4@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=brho@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=opendmb@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox