From: Daniel Kiper <daniel.kiper-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
To: konrad.wilk-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org,
andrew.cooper3-Sxgqhf6Nn4DQT0dZR+AlfA@public.gmane.org,
olaf-QOLJcTWqO2uzQB+pC5nmwQ@public.gmane.org,
jbeulich-IBi9RG/b67k@public.gmane.org,
ptesarik-AlSwsSmVLrQ@public.gmane.org,
kexec-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
xen-devel-GuqFBffKawuULHF6PoxzQEEOCMrvLtNR@public.gmane.org
Subject: [PATCH 4/7] kexec: Add segregate_lowmem_region()
Date: Mon, 10 Sep 2012 13:57:48 +0200 [thread overview]
Message-ID: <1347278271-5211-5-git-send-email-daniel.kiper@oracle.com> (raw)
In-Reply-To: <1347278271-5211-4-git-send-email-daniel.kiper-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
Extract code segregating lowmem region and move it to new
segregate_lowmem_region(). This function will be used by
fixed Xen kdump support, too.
Signed-off-by: Daniel Kiper <daniel.kiper-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
---
kexec/arch/i386/crashdump-x86.c | 38 +++++++++++++++++++++++++++-----------
1 files changed, 27 insertions(+), 11 deletions(-)
diff --git a/kexec/arch/i386/crashdump-x86.c b/kexec/arch/i386/crashdump-x86.c
index ec9432b..77a1329 100644
--- a/kexec/arch/i386/crashdump-x86.c
+++ b/kexec/arch/i386/crashdump-x86.c
@@ -159,6 +159,7 @@ static int get_kernel_vaddr_and_size(struct kexec_info *UNUSED(info),
}
/* Forward Declaration. */
+static void segregate_lowmem_region(int *nr_ranges, unsigned long lowmem_limit);
static int exclude_region(int *nr_ranges, uint64_t start, uint64_t end);
/* Stores a sorted list of RAM memory ranges for which to create elf headers.
@@ -235,19 +236,10 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges,
crash_memory_range[memory_ranges].start = start;
crash_memory_range[memory_ranges].end = end;
crash_memory_range[memory_ranges].type = type;
- memory_ranges++;
- /* Segregate linearly mapped region. */
- if (lowmem_limit &&
- (lowmem_limit - 1) >= start && (lowmem_limit - 1) <= end) {
- crash_memory_range[memory_ranges-1].end = lowmem_limit -1;
+ segregate_lowmem_region(&memory_ranges, lowmem_limit);
- /* Add segregated region. */
- crash_memory_range[memory_ranges].start = lowmem_limit;
- crash_memory_range[memory_ranges].end = end;
- crash_memory_range[memory_ranges].type = type;
- memory_ranges++;
- }
+ memory_ranges++;
}
fclose(fp);
if (kexec_flags & KEXEC_PRESERVE_CONTEXT) {
@@ -289,6 +281,30 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges,
return 0;
}
+static void segregate_lowmem_region(int *nr_ranges, unsigned long lowmem_limit)
+{
+ unsigned long long end, start;
+ unsigned type;
+
+ start = crash_memory_range[*nr_ranges].start;
+ end = crash_memory_range[*nr_ranges].end;
+ type = crash_memory_range[*nr_ranges].type;
+
+ if (!(lowmem_limit && lowmem_limit > start && lowmem_limit < end))
+ return;
+
+ crash_memory_range[*nr_ranges].end = lowmem_limit - 1;
+
+ if (*nr_ranges >= CRASH_MAX_MEMORY_RANGES - 1)
+ return;
+
+ ++*nr_ranges;
+
+ crash_memory_range[*nr_ranges].start = lowmem_limit;
+ crash_memory_range[*nr_ranges].end = end;
+ crash_memory_range[*nr_ranges].type = type;
+}
+
/* Removes crash reserve region from list of memory chunks for whom elf program
* headers have to be created. Assuming crash reserve region to be a single
* continuous area fully contained inside one of the memory chunks */
--
1.5.6.5
next prev parent reply other threads:[~2012-09-10 11:57 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-10 11:57 [PATCH 0/7] kdump: Xen fixes Daniel Kiper
[not found] ` <1347278271-5211-1-git-send-email-daniel.kiper-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2012-09-10 11:57 ` [PATCH 1/7] kexec: Define some constants and structures conditionally Daniel Kiper
[not found] ` <1347278271-5211-2-git-send-email-daniel.kiper-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2012-09-10 11:57 ` [PATCH 2/7] xen: Rename e820_to_kexec_type() to xen_e820_to_kexec_type() and export it Daniel Kiper
[not found] ` <1347278271-5211-3-git-send-email-daniel.kiper-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2012-09-10 11:57 ` [PATCH 3/7] kexec: Move crash kernel area placement and size detection to is_crashkernel_mem_reserved() Daniel Kiper
[not found] ` <1347278271-5211-4-git-send-email-daniel.kiper-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2012-09-10 11:57 ` Daniel Kiper [this message]
[not found] ` <1347278271-5211-5-git-send-email-daniel.kiper-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2012-09-10 11:57 ` [PATCH 5/7] kexec: Get backup area start address and size directly from mem_range Daniel Kiper
[not found] ` <1347278271-5211-6-git-send-email-daniel.kiper-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2012-09-10 11:57 ` [PATCH 6/7] kexec: Move crash memory ranges logging Daniel Kiper
[not found] ` <1347278271-5211-7-git-send-email-daniel.kiper-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2012-09-10 11:57 ` [PATCH 7/7] xen: Fix Xen kdump support Daniel Kiper
2012-09-14 3:30 ` [PATCH 0/7] kdump: Xen fixes Simon Horman
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=1347278271-5211-5-git-send-email-daniel.kiper@oracle.com \
--to=daniel.kiper-qhclzuegtsvqt0dzr+alfa@public.gmane.org \
--cc=andrew.cooper3-Sxgqhf6Nn4DQT0dZR+AlfA@public.gmane.org \
--cc=jbeulich-IBi9RG/b67k@public.gmane.org \
--cc=kexec-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=konrad.wilk-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org \
--cc=olaf-QOLJcTWqO2uzQB+pC5nmwQ@public.gmane.org \
--cc=ptesarik-AlSwsSmVLrQ@public.gmane.org \
--cc=xen-devel-GuqFBffKawuULHF6PoxzQEEOCMrvLtNR@public.gmane.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;
as well as URLs for NNTP newsgroup(s).