Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: kexec@lists.infradead.org
Cc: David Hildenbrand <david@redhat.com>, Simon Horman <horms@verge.net.au>
Subject: [PATCH v1 3/3] crashdump/x86: increase CRASH_MAX_MEMORY_RANGES to 32k
Date: Tue, 23 Mar 2021 11:01:10 +0100	[thread overview]
Message-ID: <20210323100111.8365-4-david@redhat.com> (raw)
In-Reply-To: <20210323100111.8365-1-david@redhat.com>

virtio-mem in Linux adds/removes individual memory blocks (e.g., 128 MB
each). Linux merges adjacent memory blocks added by virtio-mem devices, but
we can still end up with a very sparse memory layout when unplugging
memory in corner cases.

Let's increase the maximum number of crash memory ranges from ~2k to 32k.
32k should be sufficient for a very long time.

e_phnum field in the header is 16 bits wide, so we can fit a maximum of
~64k entries in there, shared with other entries (i.e., CPU). Therefore,
using up to 32k memory ranges is fine. (if we ever need more than ~64k,
we can switch to the sh_info field)

Move the temporary xen ranges off the stack, dynamically allocating
memory for them.

Note: We don't have to increase MAX_MEMORY_RANGES, because virtio-mem
added memory is driver managed and always detected and added by a
driver in the kexec'ed kernel; for ordinary kexec, we must not expose
these ranges in the firmware-provided memmap.

Cc: Simon Horman <horms@verge.net.au>
Signed-off-by: David Hildenbrand <david@redhat.com>
---
 kexec/arch/i386/crashdump-x86.c | 6 ++++--
 kexec/arch/i386/crashdump-x86.h | 3 ++-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/kexec/arch/i386/crashdump-x86.c b/kexec/arch/i386/crashdump-x86.c
index 43e830a..df84185 100644
--- a/kexec/arch/i386/crashdump-x86.c
+++ b/kexec/arch/i386/crashdump-x86.c
@@ -355,8 +355,8 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges,
 static int get_crash_memory_ranges_xen(struct memory_range **range,
 					int *ranges, unsigned long lowmem_limit)
 {
+	struct e820entry *e820entries;
 	int j, rc, ret = -1;
-	struct e820entry e820entries[CRASH_MAX_MEMORY_RANGES];
 	unsigned int i;
 	xc_interface *xc;
 
@@ -367,6 +367,8 @@ static int get_crash_memory_ranges_xen(struct memory_range **range,
 		return -1;
 	}
 
+	e820entries = xmalloc(sizeof(*e820entries) * CRASH_MAX_MEMORY_RANGES);
+
 	rc = xc_get_machine_memory_map(xc, e820entries, CRASH_MAX_MEMORY_RANGES);
 
 	if (rc < 0) {
@@ -395,7 +397,7 @@ static int get_crash_memory_ranges_xen(struct memory_range **range,
 
 err:
 	xc_interface_close(xc);
-
+	free(e820entries);
 	return ret;
 }
 #else
diff --git a/kexec/arch/i386/crashdump-x86.h b/kexec/arch/i386/crashdump-x86.h
index e4fdc82..479a549 100644
--- a/kexec/arch/i386/crashdump-x86.h
+++ b/kexec/arch/i386/crashdump-x86.h
@@ -22,7 +22,8 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline,
 #define X86_64_KERNEL_TEXT_SIZE  (512UL*1024*1024)
 
 #define CRASH_MAX_MEMMAP_NR	1024
-#define CRASH_MAX_MEMORY_RANGES	(MAX_MEMORY_RANGES + 2)
+
+#define CRASH_MAX_MEMORY_RANGES	32768
 
 /* Backup Region, First 640K of System RAM. */
 #define BACKUP_SRC_START	0x00000000
-- 
2.29.2


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

  parent reply	other threads:[~2021-03-23 10:01 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-23 10:01 [PATCH v1 0/3] crashdump/x86: dump dax/kmem and virito-mem added System RAM David Hildenbrand
2021-03-23 10:01 ` [PATCH v1 1/3] crashdump/x86: dump any kind of "System RAM" David Hildenbrand
2021-03-31 15:47   ` Dave Hansen
2021-03-23 10:01 ` [PATCH v1 2/3] crashdump/x86: iterate only over actual crash memory ranges David Hildenbrand
2021-03-23 10:01 ` David Hildenbrand [this message]
2021-03-30  8:58 ` [PATCH v1 0/3] crashdump/x86: dump dax/kmem and virito-mem added System RAM David Hildenbrand
2021-04-02 10:06   ` Simon Horman
2021-04-02 11:06     ` David Hildenbrand

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=20210323100111.8365-4-david@redhat.com \
    --to=david@redhat.com \
    --cc=horms@verge.net.au \
    --cc=kexec@lists.infradead.org \
    /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