Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Kiper <daniel.kiper@oracle.com>
To: kexec@lists.infradead.org, linux-kernel@vger.kernel.org,
	xen-devel@lists.xenproject.org
Cc: andrew.cooper3@citrix.com, horms@verge.net.au, keir@xen.org,
	david.vrabel@citrix.com, konrad.wilk@oracle.com
Subject: [PATCH 04/14] crashdump/x86: Add print_crashkernel_region_size() function
Date: Tue,  8 Dec 2015 22:57:37 +0100	[thread overview]
Message-ID: <1449611867-15672-5-git-send-email-daniel.kiper@oracle.com> (raw)
In-Reply-To: <1449611867-15672-1-git-send-email-daniel.kiper@oracle.com>

Crash kernel region size is available via sysfs on Linux running on
bare metal. However, this does not work when Linux runs as Xen dom0.
In this case Xen crash kernel region size should be established using
__HYPERVISOR_kexec_op hypercall (Linux kernel kexec functionality does
not make a lot of sense in Xen dom0). Sadly hypercalls are not easily
accessible using shell scripts or something like that. Potentially we
can check "xl dmesg" output for crashkernel option but this is not nice.
So, let's add this functionality, for Linux running on bare metal and
as Xen dom0, to kexec-tools. This way kdump scripts may establish crash
kernel region size in one way regardless of platform. All burden of
platform detection lies on kexec-tools.

Figure (and unit) displayed by this new kexec-tools functionality is
the same as one taken from /sys/kernel/kexec_crash_size.

This patch just adds print_crashkernel_region_size() function, which
prints crash kernel region size, for x86 arch. Next patches will add
same named function for other archs supported by kexec-tools. Last patch
of this series will export this functionality to the userspace via
separate kexec utility option.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
---
 kexec/arch/i386/crashdump-x86.c |   18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/kexec/arch/i386/crashdump-x86.c b/kexec/arch/i386/crashdump-x86.c
index bbc0f35..10a56a8 100644
--- a/kexec/arch/i386/crashdump-x86.c
+++ b/kexec/arch/i386/crashdump-x86.c
@@ -1056,7 +1056,7 @@ static int crashkernel_mem_callback(void *UNUSED(data), int nr,
 	return 0;
 }
 
-int is_crashkernel_mem_reserved(void)
+static int get_crashkernel_region(void)
 {
 	int ret;
 
@@ -1079,3 +1079,19 @@ int is_crashkernel_mem_reserved(void)
 
 	return !!crash_reserved_mem_nr;
 }
+
+int is_crashkernel_mem_reserved(void)
+{
+	return get_crashkernel_region();
+}
+
+void print_crashkernel_region_size(void)
+{
+	uint64_t start, end;
+
+	if (get_crashkernel_region()) {
+		get_crash_kernel_load_range(&start, &end);
+		printf("%lu\n", end - start + 1);
+	} else
+		printf("0\n");
+}
-- 
1.7.10.4


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

  parent reply	other threads:[~2015-12-08 21:58 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-08 21:57 [PATCH 00/14] kexec: Add option to get crash kernel region size Daniel Kiper
2015-12-08 21:57 ` [PATCH 01/14] purgatory: Add purgatory.map and purgatory.ro.sym to clean recipe Daniel Kiper
2015-12-08 21:57 ` [PATCH 02/14] kexec: Remove redundant space from help message Daniel Kiper
2015-12-08 21:57 ` [PATCH 03/14] crashdump: Remove stray get_crashkernel_region() declaration Daniel Kiper
2015-12-08 21:57 ` Daniel Kiper [this message]
2015-12-08 21:57 ` [PATCH 05/14] crashdump/arm: Add print_crashkernel_region_size() function Daniel Kiper
2015-12-08 21:57 ` [PATCH 06/14] crashdump/cris: " Daniel Kiper
2015-12-09  2:55   ` Dave Young
2015-12-08 21:57 ` [PATCH 07/14] crashdump/ia64: " Daniel Kiper
2015-12-08 21:57 ` [PATCH 08/14] crashdump/m68k: " Daniel Kiper
2015-12-08 21:57 ` [PATCH 09/14] crashdump/mips: " Daniel Kiper
2015-12-08 21:57 ` [PATCH 10/14] crashdump/ppc: " Daniel Kiper
2015-12-09  2:51   ` Dave Young
2015-12-08 21:57 ` [PATCH 11/14] crashdump/ppc64: " Daniel Kiper
2015-12-09  2:52   ` Dave Young
2015-12-08 21:57 ` [PATCH 12/14] crashdump/s390: " Daniel Kiper
2015-12-08 21:57 ` [PATCH 13/14] crashdump/sh: " Daniel Kiper
2015-12-08 21:57 ` [PATCH 14/14] kexec: Add option to get crash kernel region size Daniel Kiper

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=1449611867-15672-5-git-send-email-daniel.kiper@oracle.com \
    --to=daniel.kiper@oracle.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=david.vrabel@citrix.com \
    --cc=horms@verge.net.au \
    --cc=keir@xen.org \
    --cc=kexec@lists.infradead.org \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=xen-devel@lists.xenproject.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