linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kexec/powerpc: fix exporting memory limit
@ 2014-03-06 14:24 Nikita Yushchenko
  2014-03-07  0:47 ` Michael Ellerman
  0 siblings, 1 reply; 4+ messages in thread
From: Nikita Yushchenko @ 2014-03-06 14:24 UTC (permalink / raw)
  To: kexec, Benjamin Herrenschmidt, Paul Mackerras, Anton Blanchard,
	Hari Bathini, Mahesh Salgaonkar, linuxppc-dev
  Cc: yadviga, nyushchenko, lugovskoy, linux-kernel

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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] kexec/powerpc: fix exporting memory limit
  2014-03-06 14:24 [PATCH] kexec/powerpc: fix exporting memory limit Nikita Yushchenko
@ 2014-03-07  0:47 ` Michael Ellerman
  2014-03-07  4:38   ` Nikita Yushchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Michael Ellerman @ 2014-03-07  0:47 UTC (permalink / raw)
  To: Nikita Yushchenko
  Cc: yadviga, lugovskoy, kexec, linux-kernel, Paul Mackerras,
	Anton Blanchard, Mahesh Salgaonkar, Hari Bathini, linuxppc-dev

On Thu, 2014-03-06 at 18:24 +0400, Nikita Yushchenko wrote:
> 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.

Why doesn't the !CONFIG_HIGHMEM code update memory_limit to reflect reality.

cheers

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] kexec/powerpc: fix exporting memory limit
  2014-03-07  0:47 ` Michael Ellerman
@ 2014-03-07  4:38   ` Nikita Yushchenko
  2022-03-11 15:26     ` Christophe Leroy
  0 siblings, 1 reply; 4+ messages in thread
From: Nikita Yushchenko @ 2014-03-07  4:38 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: yadviga, lugovskoy, kexec, linux-kernel, Paul Mackerras,
	Anton Blanchard, Mahesh Salgaonkar, Hari Bathini, linuxppc-dev

> On Thu, 2014-03-06 at 18:24 +0400, Nikita Yushchenko wrote:
> > 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.
>
> Why doesn't the !CONFIG_HIGHMEM code update memory_limit to reflect
> reality.

I guess because memory_limit is used for ... well, memory limit, set by 
mem=. And for the rest memblock is used (and it *is* updated).

And code elsewhere does use memblock, see e.g. numa_enforce_memory_limit() 
in arch/powerpc/mm/numa.c

In MMU init (MMU_init() in arch/powerpc/mm/init_32.c -which is the point 
where final memory configuration is set) memblock, not memory_limit, is 
both used and updated.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] kexec/powerpc: fix exporting memory limit
  2014-03-07  4:38   ` Nikita Yushchenko
@ 2022-03-11 15:26     ` Christophe Leroy
  0 siblings, 0 replies; 4+ messages in thread
From: Christophe Leroy @ 2022-03-11 15:26 UTC (permalink / raw)
  To: Nikita Yushchenko, Michael Ellerman
  Cc: yadviga, Mahesh Salgaonkar, lugovskoy, kexec, linux-kernel,
	Paul Mackerras, Anton Blanchard, Hari Bathini, linuxppc-dev



Le 07/03/2014 à 05:38, Nikita Yushchenko a écrit :
>> On Thu, 2014-03-06 at 18:24 +0400, Nikita Yushchenko wrote:
>>> 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.
>>
>> Why doesn't the !CONFIG_HIGHMEM code update memory_limit to reflect
>> reality.
> 
> I guess because memory_limit is used for ... well, memory limit, set by
> mem=. And for the rest memblock is used (and it *is* updated).
> 
> And code elsewhere does use memblock, see e.g. numa_enforce_memory_limit()
> in arch/powerpc/mm/numa.c
> 
> In MMU init (MMU_init() in arch/powerpc/mm/init_32.c -which is the point
> where final memory configuration is set) memblock, not memory_limit, is
> both used and updated.


We still have this patch as "New" in patchwork.

I don't know if it is relevant but directory structure has changed so if 
still needed this patch needs rebase.

Christophe

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-03-11 15:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-06 14:24 [PATCH] kexec/powerpc: fix exporting memory limit Nikita Yushchenko
2014-03-07  0:47 ` Michael Ellerman
2014-03-07  4:38   ` Nikita Yushchenko
2022-03-11 15:26     ` Christophe Leroy

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).