Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Nikita Yushchenko <nyushchenko@dev.rtsoft.ru>
To: kexec@lists.infradead.org,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>,
	Anton Blanchard <anton@samba.org>,
	Hari Bathini <hbathini@linux.vnet.ibm.com>,
	Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>,
	linuxppc-dev@lists.ozlabs.org
Cc: yadviga@dev.rtsoft.ru, nyushchenko@dev.rtsoft.ru,
	lugovskoy@dev.rtsoft.ru, linux-kernel@vger.kernel.org
Subject: [PATCH] kexec/powerpc: fix exporting memory limit
Date: Thu,  6 Mar 2014 18:24:14 +0400	[thread overview]
Message-ID: <1394115854-11709-1-git-send-email-nyushchenko@dev.rtsoft.ru> (raw)

When preparing dump-capturing kernel, kexec userspace tool needs to know
actual amount of memory used by the running kernel. This may differ from
extire available DRAM for a couple of reasons. To address this issue,
kdump kernel support code injects several attributes into device tree that
are later captured by userspace kexec tool via /proc interface.

One such attrubute is 'chosen/linux,memory_limit' that is used to pass
memory limit of the running kernel.

This was initialized using kernel's 'memory_limit' variable, that is set
by early init code based on mem= kernel parameter and other reasons.

But there are cases when memory_limit variable does not contain proper
information. One such case is when !CONFIG_HIGHMEM kernel runs on system
with memory large enough not to fit into lowmem.

This patch fixes initialization of 'chosen/linux,memory_limit' to use
values from memblock subsystem. These are adjusted at kernel memory
management init and thus always contain values that match reality.

Signed-off-by: Nikita Yushchenko <nyushchenko@dev.rtsoft.ru>
---
 arch/powerpc/kernel/machine_kexec.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/machine_kexec.c b/arch/powerpc/kernel/machine_kexec.c
index 015ae55..372cda5 100644
--- a/arch/powerpc/kernel/machine_kexec.c
+++ b/arch/powerpc/kernel/machine_kexec.c
@@ -250,8 +250,14 @@ static void __init export_crashk_values(struct device_node *node)
 	/*
 	 * memory_limit is required by the kexec-tools to limit the
 	 * crash regions to the actual memory used.
+	 *
+	 * There are cases when memory_limit variable does not hold actual
+	 * limit, for example when memory was limited by no kernel support
+	 * for HIGHMEM. Reliable information is known by memblock because
+	 * memory management init adjusts it.
 	 */
-	mem_limit = cpu_to_be_ulong(memory_limit);
+	mem_limit = cpu_to_be_ulong(memblock_end_of_DRAM() -
+					memblock_start_of_DRAM());
 	of_update_property(node, &memory_limit_prop);
 }
 
-- 
1.7.10.4


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

             reply	other threads:[~2014-03-06 14:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-06 14:24 Nikita Yushchenko [this message]
2014-03-07  0:47 ` [PATCH] kexec/powerpc: fix exporting memory limit Michael Ellerman
2014-03-07  4:38   ` Nikita Yushchenko
2022-03-11 15:26     ` Christophe Leroy

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=1394115854-11709-1-git-send-email-nyushchenko@dev.rtsoft.ru \
    --to=nyushchenko@dev.rtsoft.ru \
    --cc=anton@samba.org \
    --cc=benh@kernel.crashing.org \
    --cc=hbathini@linux.vnet.ibm.com \
    --cc=kexec@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=lugovskoy@dev.rtsoft.ru \
    --cc=mahesh@linux.vnet.ibm.com \
    --cc=paulus@samba.org \
    --cc=yadviga@dev.rtsoft.ru \
    /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