* [PATCH v2 0/2][powerpc] Export memory_limit via device tree
@ 2012-08-21 11:42 Suzuki K. Poulose
2012-08-21 11:42 ` [PATCH v2 1/2] [powerpc] Change memory_limit from phys_addr_t to unsigned long long Suzuki K. Poulose
2012-08-21 11:42 ` [PATCH v2 2/2] [powerpc] Export memory limit via device tree Suzuki K. Poulose
0 siblings, 2 replies; 5+ messages in thread
From: Suzuki K. Poulose @ 2012-08-21 11:42 UTC (permalink / raw)
To: linuxppc-dev; +Cc: mahesh, benh, linux-kernel
The following series exports the linux memory_limit set by
the mem= parameter via device-tree, so that kexec-tools
can limit the crash regions to the actual memory used by
the kernel.
Change since V1:
* Added a patch to change the type of memory_limit to a
fixed size(unsigned long long) from 'phys_addr_t' (which
is 32bit on some ppc32 and 64 bit on ppc64 and some ppc32)
* Rebased the patch to use recently fixed prom_update_property()
which would add the property if it didn't exist.
---
Suzuki K. Poulose (2):
[powerpc] Change memory_limit from phys_addr_t to unsigned long long
[powerpc] Export memory limit via device tree
arch/powerpc/include/asm/setup.h | 2 +-
arch/powerpc/kernel/fadump.c | 3 +--
arch/powerpc/kernel/machine_kexec.c | 14 +++++++++++++-
arch/powerpc/kernel/prom.c | 2 +-
arch/powerpc/mm/mem.c | 2 +-
5 files changed, 17 insertions(+), 6 deletions(-)
--
Suzuki
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/2] [powerpc] Change memory_limit from phys_addr_t to unsigned long long
2012-08-21 11:42 [PATCH v2 0/2][powerpc] Export memory_limit via device tree Suzuki K. Poulose
@ 2012-08-21 11:42 ` Suzuki K. Poulose
2012-09-07 1:35 ` Benjamin Herrenschmidt
2012-08-21 11:42 ` [PATCH v2 2/2] [powerpc] Export memory limit via device tree Suzuki K. Poulose
1 sibling, 1 reply; 5+ messages in thread
From: Suzuki K. Poulose @ 2012-08-21 11:42 UTC (permalink / raw)
To: linuxppc-dev; +Cc: mahesh, benh, linux-kernel
There are some device-tree nodes, whose values are of type phys_addr_t.
The phys_addr_t is variable sized based on the CONFIG_PHSY_T_64BIT.
Change these to a fixed unsigned long long for consistency.
This patch does the change only for memory_limit.
The following is a list of such variables which need the change:
1) kernel_end, crashk_size - in arch/powerpc/kernel/machine_kexec.c
2) (struct resource *)crashk_res.start - We could export a local static
variable from machine_kexec.c.
Changing the above values might break the kexec-tools. So, I will
fix kexec-tools first to handle the different sized values and then change
the above.
Suggested-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Suzuki K. Poulose <suzuki@in.ibm.com>
---
arch/powerpc/include/asm/setup.h | 2 +-
arch/powerpc/kernel/fadump.c | 3 +--
arch/powerpc/kernel/machine_kexec.c | 2 +-
arch/powerpc/kernel/prom.c | 2 +-
arch/powerpc/mm/mem.c | 2 +-
5 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/arch/powerpc/include/asm/setup.h b/arch/powerpc/include/asm/setup.h
index d084ce1..8b9a306 100644
--- a/arch/powerpc/include/asm/setup.h
+++ b/arch/powerpc/include/asm/setup.h
@@ -9,7 +9,7 @@ extern void ppc_printk_progress(char *s, unsigned short hex);
extern unsigned int rtas_data;
extern int mem_init_done; /* set on boot once kmalloc can be called */
extern int init_bootmem_done; /* set once bootmem is available */
-extern phys_addr_t memory_limit;
+extern unsigned long long memory_limit;
extern unsigned long klimit;
extern void *zalloc_maybe_bootmem(size_t size, gfp_t mask);
diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c
index 18bdf74..06c8202 100644
--- a/arch/powerpc/kernel/fadump.c
+++ b/arch/powerpc/kernel/fadump.c
@@ -289,8 +289,7 @@ int __init fadump_reserve_mem(void)
else
memory_limit = memblock_end_of_DRAM();
printk(KERN_INFO "Adjusted memory_limit for firmware-assisted"
- " dump, now %#016llx\n",
- (unsigned long long)memory_limit);
+ " dump, now %#016llx\n", memory_limit);
}
if (memory_limit)
memory_boundary = memory_limit;
diff --git a/arch/powerpc/kernel/machine_kexec.c b/arch/powerpc/kernel/machine_kexec.c
index 5df7777..4074eff 100644
--- a/arch/powerpc/kernel/machine_kexec.c
+++ b/arch/powerpc/kernel/machine_kexec.c
@@ -165,7 +165,7 @@ void __init reserve_crashkernel(void)
if (memory_limit && memory_limit <= crashk_res.end) {
memory_limit = crashk_res.end + 1;
printk("Adjusted memory limit for crashkernel, now 0x%llx\n",
- (unsigned long long)memory_limit);
+ memory_limit);
}
printk(KERN_INFO "Reserving %ldMB of memory at %ldMB "
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index f191bf0..c82c77d 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -78,7 +78,7 @@ static int __init early_parse_mem(char *p)
return 1;
memory_limit = PAGE_ALIGN(memparse(p, &p));
- DBG("memory limit = 0x%llx\n", (unsigned long long)memory_limit);
+ DBG("memory limit = 0x%llx\n", memory_limit);
return 0;
}
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index baaafde..0a8f353 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -62,7 +62,7 @@
int init_bootmem_done;
int mem_init_done;
-phys_addr_t memory_limit;
+unsigned long long memory_limit;
#ifdef CONFIG_HIGHMEM
pte_t *kmap_pte;
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 2/2] [powerpc] Export memory limit via device tree
2012-08-21 11:42 [PATCH v2 0/2][powerpc] Export memory_limit via device tree Suzuki K. Poulose
2012-08-21 11:42 ` [PATCH v2 1/2] [powerpc] Change memory_limit from phys_addr_t to unsigned long long Suzuki K. Poulose
@ 2012-08-21 11:42 ` Suzuki K. Poulose
1 sibling, 0 replies; 5+ messages in thread
From: Suzuki K. Poulose @ 2012-08-21 11:42 UTC (permalink / raw)
To: linuxppc-dev; +Cc: mahesh, benh, linux-kernel
The powerpc kernel doesn't export the memory limit enforced by 'mem='
kernel parameter. This is required for building the ELF header in
kexec-tools to limit the vmcore to capture only the used memory. On
powerpc the kexec-tools depends on the device-tree for memory related
information, unlike /proc/iomem on the x86.
Without this information, the kexec-tools assumes the entire System
RAM and vmcore creates an unnecessarily larger dump.
This patch exports the memory limit, if present, via
chosen/linux,memory-limit
property, so that the vmcore can be limited to the memory limit.
The prom_init seems to export this value in the same node. But doesn't
really
appear there. Also the memory_limit gets adjusted with the processing of
crashkernel= parameter. This patch makes sure we get the actual limit.
The kexec-tools will use the value to limit the 'end' of the memory
regions.
Tested this patch on ppc64 and ppc32(ppc440) with a kexec-tools
patch by Mahesh.
Signed-off-by: Suzuki K. Poulose <suzuki@in.ibm.com>
Tested-by: Mahesh J. Salgaonkar <mahesh@linux.vnet.ibm.com>
---
arch/powerpc/kernel/machine_kexec.c | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/arch/powerpc/kernel/machine_kexec.c b/arch/powerpc/kernel/machine_kexec.c
index 4074eff..fa9f6c7 100644
--- a/arch/powerpc/kernel/machine_kexec.c
+++ b/arch/powerpc/kernel/machine_kexec.c
@@ -204,6 +204,12 @@ static struct property crashk_size_prop = {
.value = &crashk_size,
};
+static struct property memory_limit_prop = {
+ .name = "linux,memory-limit",
+ .length = sizeof(unsigned long long),
+ .value = &memory_limit,
+};
+
static void __init export_crashk_values(struct device_node *node)
{
struct property *prop;
@@ -223,6 +229,12 @@ static void __init export_crashk_values(struct device_node *node)
crashk_size = resource_size(&crashk_res);
prom_add_property(node, &crashk_size_prop);
}
+
+ /*
+ * memory_limit is required by the kexec-tools to limit the
+ * crash regions to the actual memory used.
+ */
+ prom_update_property(node, &memory_limit_prop);
}
static int __init kexec_setup(void)
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/2] [powerpc] Change memory_limit from phys_addr_t to unsigned long long
2012-08-21 11:42 ` [PATCH v2 1/2] [powerpc] Change memory_limit from phys_addr_t to unsigned long long Suzuki K. Poulose
@ 2012-09-07 1:35 ` Benjamin Herrenschmidt
2012-09-07 10:01 ` Suzuki K. Poulose
0 siblings, 1 reply; 5+ messages in thread
From: Benjamin Herrenschmidt @ 2012-09-07 1:35 UTC (permalink / raw)
To: Suzuki K. Poulose; +Cc: linuxppc-dev, mahesh, linux-kernel
On Tue, 2012-08-21 at 17:12 +0530, Suzuki K. Poulose wrote:
> There are some device-tree nodes, whose values are of type phys_addr_t.
> The phys_addr_t is variable sized based on the CONFIG_PHSY_T_64BIT.
>
> Change these to a fixed unsigned long long for consistency.
>
> This patch does the change only for memory_limit.
>
> The following is a list of such variables which need the change:
>
> 1) kernel_end, crashk_size - in arch/powerpc/kernel/machine_kexec.c
>
> 2) (struct resource *)crashk_res.start - We could export a local static
> variable from machine_kexec.c.
>
> Changing the above values might break the kexec-tools. So, I will
> fix kexec-tools first to handle the different sized values and then change
> the above.
>
> Suggested-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Signed-off-by: Suzuki K. Poulose <suzuki@in.ibm.com>
> ---
Breaks the build on some configs (with 32-bit phys_addr_t):
/home/benh/linux-powerpc-test/arch/powerpc/kernel/prom.c: In function
'early_init_devtree':
/home/benh/linux-powerpc-test/arch/powerpc/kernel/prom.c:664:25: error:
comparison of distinct pointer types lacks a cast
I'm fixing that myself this time but please be more careful.
Cheers,
Ben.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/2] [powerpc] Change memory_limit from phys_addr_t to unsigned long long
2012-09-07 1:35 ` Benjamin Herrenschmidt
@ 2012-09-07 10:01 ` Suzuki K. Poulose
0 siblings, 0 replies; 5+ messages in thread
From: Suzuki K. Poulose @ 2012-09-07 10:01 UTC (permalink / raw)
To: Benjamin Herrenschmidt; +Cc: linuxppc-dev, mahesh, linux-kernel
On 09/07/2012 07:05 AM, Benjamin Herrenschmidt wrote:
> On Tue, 2012-08-21 at 17:12 +0530, Suzuki K. Poulose wrote:
>> There are some device-tree nodes, whose values are of type phys_addr_t.
>> The phys_addr_t is variable sized based on the CONFIG_PHSY_T_64BIT.
>>
>> Change these to a fixed unsigned long long for consistency.
>>
>> This patch does the change only for memory_limit.
>>
>> The following is a list of such variables which need the change:
>>
>> 1) kernel_end, crashk_size - in arch/powerpc/kernel/machine_kexec.c
>>
>> 2) (struct resource *)crashk_res.start - We could export a local static
>> variable from machine_kexec.c.
>>
>> Changing the above values might break the kexec-tools. So, I will
>> fix kexec-tools first to handle the different sized values and then change
>> the above.
>>
>> Suggested-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
>> Signed-off-by: Suzuki K. Poulose <suzuki@in.ibm.com>
>> ---
>
> Breaks the build on some configs (with 32-bit phys_addr_t):
Sorry for that.
>
> /home/benh/linux-powerpc-test/arch/powerpc/kernel/prom.c: In function
> 'early_init_devtree':
> /home/benh/linux-powerpc-test/arch/powerpc/kernel/prom.c:664:25: error:
> comparison of distinct pointer types lacks a cast
>
> I'm fixing that myself this time but please be more careful.
Sure. Thanks Ben for fixing that.
Suzuki
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-09-07 10:02 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-21 11:42 [PATCH v2 0/2][powerpc] Export memory_limit via device tree Suzuki K. Poulose
2012-08-21 11:42 ` [PATCH v2 1/2] [powerpc] Change memory_limit from phys_addr_t to unsigned long long Suzuki K. Poulose
2012-09-07 1:35 ` Benjamin Herrenschmidt
2012-09-07 10:01 ` Suzuki K. Poulose
2012-08-21 11:42 ` [PATCH v2 2/2] [powerpc] Export memory limit via device tree Suzuki K. Poulose
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).