* [PATCH 1/2] doc: update mem= option's spec
@ 2012-06-14 8:10 Wen Congyang
2012-06-14 8:12 ` [PATCH 2/2] x86: reimplement mem boot option Wen Congyang
2012-06-14 20:22 ` [PATCH 1/2] doc: update mem= option's spec Rob Landley
0 siblings, 2 replies; 9+ messages in thread
From: Wen Congyang @ 2012-06-14 8:10 UTC (permalink / raw)
To: rob, tglx, Ingo Molnar, x86, linux-kernel, bhelgaas, H. Peter Anvin
Current mem= implementation seems buggy because specification and
implementation doesn't match. Current mem= has been working
for many years and it's not buggy, it works as expected. So
we should update the specification.
Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
---
Documentation/kernel-parameters.txt | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index a92c5eb..924b1a4 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -1471,9 +1471,10 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
mem=nn[KMG] [KNL,BOOT] Force usage of a specific amount of memory
Amount of memory to be used when the kernel is not able
to see the whole system memory or for test.
- [X86-32] Use together with memmap= to avoid physical
- address space collisions. Without memmap= PCI devices
- could be placed at addresses belonging to unused RAM.
+ [X86-32] Work as limiting max address. Use together
+ with memmap= to avoid physical address space collisions.
+ Without memmap= PCI devices could be placed at addresses
+ belonging to unused RAM.
mem=nopentium [BUGS=X86-32] Disable usage of 4MB pages for kernel
memory.
--
1.7.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/2] x86: reimplement mem boot option
2012-06-14 8:10 [PATCH 1/2] doc: update mem= option's spec Wen Congyang
@ 2012-06-14 8:12 ` Wen Congyang
2012-06-28 1:29 ` Wen Congyang
2012-08-21 8:11 ` [PATCH v2 " Wen Congyang
2012-06-14 20:22 ` [PATCH 1/2] doc: update mem= option's spec Rob Landley
1 sibling, 2 replies; 9+ messages in thread
From: Wen Congyang @ 2012-06-14 8:12 UTC (permalink / raw)
To: rob, tglx, Ingo Molnar, x86, linux-kernel, bhelgaas, H. Peter Anvin
Current mem boot option only can work for non efi environment. If the user
specifies add_efi_memmap, it cannot work for efi environment. In
the efi environment, we call e820_add_region() to add the memory map. So
we can modify __e820_add_region() and the mem boot option can work for
efi environment.
Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
---
arch/x86/kernel/e820.c | 29 +++++++++++++++++++++++++----
1 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index 4185797..20bc467 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -47,6 +47,7 @@ unsigned long pci_mem_start = 0xaeedbabe;
#ifdef CONFIG_PCI
EXPORT_SYMBOL(pci_mem_start);
#endif
+static u64 mem_limit = ~0ULL;
/*
* This function checks if any part of the range <start,end> is mapped
@@ -119,6 +120,20 @@ static void __init __e820_add_region(struct e820map *e820x, u64 start, u64 size,
return;
}
+ if (start >= mem_limit) {
+ printk(KERN_ERR "e820: ignoring [mem %#010llx-%#010llx]\n",
+ (unsigned long long)start,
+ (unsigned long long)(start + size - 1));
+ return;
+ }
+
+ if (mem_limit - start < size) {
+ printk(KERN_ERR "e820: ingoring [mem %#010llx-%#010llx]\n",
+ (unsigned long long)mem_limit,
+ (unsigned long long)(start + size - 1));
+ size = mem_limit - start;
+ }
+
e820x->map[x].addr = start;
e820x->map[x].size = size;
e820x->map[x].type = type;
@@ -809,7 +824,7 @@ static int userdef __initdata;
/* "mem=nopentium" disables the 4MB page tables. */
static int __init parse_memopt(char *p)
{
- u64 mem_size;
+ char *oldp;
if (!p)
return -EINVAL;
@@ -825,11 +840,11 @@ static int __init parse_memopt(char *p)
}
userdef = 1;
- mem_size = memparse(p, &p);
+ oldp = p;
+ mem_limit = memparse(p, &p);
/* don't remove all of memory when handling "mem={invalid}" param */
- if (mem_size == 0)
+ if (mem_limit == 0 || p == oldp)
return -EINVAL;
- e820_remove_range(mem_size, ULLONG_MAX - mem_size, E820_RAM, 1);
return 0;
}
@@ -881,6 +896,12 @@ early_param("memmap", parse_memmap_opt);
void __init finish_e820_parsing(void)
{
+ if (mem_limit != ~0ULL) {
+ userdef = 1;
+ e820_remove_range(mem_limit, ULLONG_MAX - mem_limit,
+ E820_RAM, 1);
+ }
+
if (userdef) {
u32 nr = e820.nr_map;
--
1.7.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] x86: reimplement mem boot option
2012-06-14 8:12 ` [PATCH 2/2] x86: reimplement mem boot option Wen Congyang
@ 2012-06-28 1:29 ` Wen Congyang
2012-07-17 5:22 ` Wen Congyang
2012-08-21 8:11 ` [PATCH v2 " Wen Congyang
1 sibling, 1 reply; 9+ messages in thread
From: Wen Congyang @ 2012-06-28 1:29 UTC (permalink / raw)
To: rob, tglx, Ingo Molnar, x86, linux-kernel, bhelgaas, H. Peter Anvin
Pin......
At 06/14/2012 04:12 PM, Wen Congyang Wrote:
> Current mem boot option only can work for non efi environment. If the user
> specifies add_efi_memmap, it cannot work for efi environment. In
> the efi environment, we call e820_add_region() to add the memory map. So
> we can modify __e820_add_region() and the mem boot option can work for
> efi environment.
>
> Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
> ---
> arch/x86/kernel/e820.c | 29 +++++++++++++++++++++++++----
> 1 files changed, 25 insertions(+), 4 deletions(-)
>
> diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
> index 4185797..20bc467 100644
> --- a/arch/x86/kernel/e820.c
> +++ b/arch/x86/kernel/e820.c
> @@ -47,6 +47,7 @@ unsigned long pci_mem_start = 0xaeedbabe;
> #ifdef CONFIG_PCI
> EXPORT_SYMBOL(pci_mem_start);
> #endif
> +static u64 mem_limit = ~0ULL;
>
> /*
> * This function checks if any part of the range <start,end> is mapped
> @@ -119,6 +120,20 @@ static void __init __e820_add_region(struct e820map *e820x, u64 start, u64 size,
> return;
> }
>
> + if (start >= mem_limit) {
> + printk(KERN_ERR "e820: ignoring [mem %#010llx-%#010llx]\n",
> + (unsigned long long)start,
> + (unsigned long long)(start + size - 1));
> + return;
> + }
> +
> + if (mem_limit - start < size) {
> + printk(KERN_ERR "e820: ingoring [mem %#010llx-%#010llx]\n",
> + (unsigned long long)mem_limit,
> + (unsigned long long)(start + size - 1));
> + size = mem_limit - start;
> + }
> +
> e820x->map[x].addr = start;
> e820x->map[x].size = size;
> e820x->map[x].type = type;
> @@ -809,7 +824,7 @@ static int userdef __initdata;
> /* "mem=nopentium" disables the 4MB page tables. */
> static int __init parse_memopt(char *p)
> {
> - u64 mem_size;
> + char *oldp;
>
> if (!p)
> return -EINVAL;
> @@ -825,11 +840,11 @@ static int __init parse_memopt(char *p)
> }
>
> userdef = 1;
> - mem_size = memparse(p, &p);
> + oldp = p;
> + mem_limit = memparse(p, &p);
> /* don't remove all of memory when handling "mem={invalid}" param */
> - if (mem_size == 0)
> + if (mem_limit == 0 || p == oldp)
> return -EINVAL;
> - e820_remove_range(mem_size, ULLONG_MAX - mem_size, E820_RAM, 1);
>
> return 0;
> }
> @@ -881,6 +896,12 @@ early_param("memmap", parse_memmap_opt);
>
> void __init finish_e820_parsing(void)
> {
> + if (mem_limit != ~0ULL) {
> + userdef = 1;
> + e820_remove_range(mem_limit, ULLONG_MAX - mem_limit,
> + E820_RAM, 1);
> + }
> +
> if (userdef) {
> u32 nr = e820.nr_map;
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] x86: reimplement mem boot option
2012-06-28 1:29 ` Wen Congyang
@ 2012-07-17 5:22 ` Wen Congyang
2012-07-18 9:16 ` Ingo Molnar
0 siblings, 1 reply; 9+ messages in thread
From: Wen Congyang @ 2012-07-17 5:22 UTC (permalink / raw)
To: rob, tglx, Ingo Molnar, x86, linux-kernel, bhelgaas,
H. Peter Anvin, Andrew Morton
At 06/28/2012 09:29 AM, Wen Congyang Wrote:
> Pin......
Ping again........
>
> At 06/14/2012 04:12 PM, Wen Congyang Wrote:
>> Current mem boot option only can work for non efi environment. If the user
>> specifies add_efi_memmap, it cannot work for efi environment. In
>> the efi environment, we call e820_add_region() to add the memory map. So
>> we can modify __e820_add_region() and the mem boot option can work for
>> efi environment.
>>
>> Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
>> ---
>> arch/x86/kernel/e820.c | 29 +++++++++++++++++++++++++----
>> 1 files changed, 25 insertions(+), 4 deletions(-)
>>
>> diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
>> index 4185797..20bc467 100644
>> --- a/arch/x86/kernel/e820.c
>> +++ b/arch/x86/kernel/e820.c
>> @@ -47,6 +47,7 @@ unsigned long pci_mem_start = 0xaeedbabe;
>> #ifdef CONFIG_PCI
>> EXPORT_SYMBOL(pci_mem_start);
>> #endif
>> +static u64 mem_limit = ~0ULL;
>>
>> /*
>> * This function checks if any part of the range <start,end> is mapped
>> @@ -119,6 +120,20 @@ static void __init __e820_add_region(struct e820map *e820x, u64 start, u64 size,
>> return;
>> }
>>
>> + if (start >= mem_limit) {
>> + printk(KERN_ERR "e820: ignoring [mem %#010llx-%#010llx]\n",
>> + (unsigned long long)start,
>> + (unsigned long long)(start + size - 1));
>> + return;
>> + }
>> +
>> + if (mem_limit - start < size) {
>> + printk(KERN_ERR "e820: ingoring [mem %#010llx-%#010llx]\n",
>> + (unsigned long long)mem_limit,
>> + (unsigned long long)(start + size - 1));
>> + size = mem_limit - start;
>> + }
>> +
>> e820x->map[x].addr = start;
>> e820x->map[x].size = size;
>> e820x->map[x].type = type;
>> @@ -809,7 +824,7 @@ static int userdef __initdata;
>> /* "mem=nopentium" disables the 4MB page tables. */
>> static int __init parse_memopt(char *p)
>> {
>> - u64 mem_size;
>> + char *oldp;
>>
>> if (!p)
>> return -EINVAL;
>> @@ -825,11 +840,11 @@ static int __init parse_memopt(char *p)
>> }
>>
>> userdef = 1;
>> - mem_size = memparse(p, &p);
>> + oldp = p;
>> + mem_limit = memparse(p, &p);
>> /* don't remove all of memory when handling "mem={invalid}" param */
>> - if (mem_size == 0)
>> + if (mem_limit == 0 || p == oldp)
>> return -EINVAL;
>> - e820_remove_range(mem_size, ULLONG_MAX - mem_size, E820_RAM, 1);
>>
>> return 0;
>> }
>> @@ -881,6 +896,12 @@ early_param("memmap", parse_memmap_opt);
>>
>> void __init finish_e820_parsing(void)
>> {
>> + if (mem_limit != ~0ULL) {
>> + userdef = 1;
>> + e820_remove_range(mem_limit, ULLONG_MAX - mem_limit,
>> + E820_RAM, 1);
>> + }
>> +
>> if (userdef) {
>> u32 nr = e820.nr_map;
>>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] x86: reimplement mem boot option
2012-07-17 5:22 ` Wen Congyang
@ 2012-07-18 9:16 ` Ingo Molnar
0 siblings, 0 replies; 9+ messages in thread
From: Ingo Molnar @ 2012-07-18 9:16 UTC (permalink / raw)
To: Wen Congyang
Cc: rob, tglx, Ingo Molnar, x86, linux-kernel, bhelgaas,
H. Peter Anvin, Andrew Morton
* Wen Congyang <wency@cn.fujitsu.com> wrote:
> At 06/28/2012 09:29 AM, Wen Congyang Wrote:
> > Pin......
>
> Ping again........
I guess when hpa gets back from the road he'll have a look.
Thanks,
Ingo
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 2/2] x86: reimplement mem boot option
2012-06-14 8:12 ` [PATCH 2/2] x86: reimplement mem boot option Wen Congyang
2012-06-28 1:29 ` Wen Congyang
@ 2012-08-21 8:11 ` Wen Congyang
2012-09-05 9:28 ` Wen Congyang
1 sibling, 1 reply; 9+ messages in thread
From: Wen Congyang @ 2012-08-21 8:11 UTC (permalink / raw)
To: rob, tglx, Ingo Molnar, x86, linux-kernel, bhelgaas, H. Peter Anvin
Current mem boot option only can work for non efi environment. If the user
specifies add_efi_memmap, it cannot work for efi environment. In
the efi environment, we call e820_add_region() to add the memory map. So
we can modify __e820_add_region() and the mem boot option can work for
efi environment.
Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
---
arch/x86/kernel/e820.c | 29 +++++++++++++++++++++++++----
1 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index 4185797..20bc467 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -47,6 +47,7 @@ unsigned long pci_mem_start = 0xaeedbabe;
#ifdef CONFIG_PCI
EXPORT_SYMBOL(pci_mem_start);
#endif
+static u64 mem_limit = ~0ULL;
/*
* This function checks if any part of the range <start,end> is mapped
@@ -119,6 +120,20 @@ static void __init __e820_add_region(struct e820map *e820x, u64 start, u64 size,
return;
}
+ if (start >= mem_limit) {
+ printk(KERN_ERR "e820: ignoring [mem %#010llx-%#010llx]\n",
+ (unsigned long long)start,
+ (unsigned long long)(start + size - 1));
+ return;
+ }
+
+ if (mem_limit - start < size) {
+ printk(KERN_ERR "e820: ignoring [mem %#010llx-%#010llx]\n",
+ (unsigned long long)mem_limit,
+ (unsigned long long)(start + size - 1));
+ size = mem_limit - start;
+ }
+
e820x->map[x].addr = start;
e820x->map[x].size = size;
e820x->map[x].type = type;
@@ -809,7 +824,7 @@ static int userdef __initdata;
/* "mem=nopentium" disables the 4MB page tables. */
static int __init parse_memopt(char *p)
{
- u64 mem_size;
+ char *oldp;
if (!p)
return -EINVAL;
@@ -825,11 +840,11 @@ static int __init parse_memopt(char *p)
}
userdef = 1;
- mem_size = memparse(p, &p);
+ oldp = p;
+ mem_limit = memparse(p, &p);
/* don't remove all of memory when handling "mem={invalid}" param */
- if (mem_size == 0)
+ if (mem_limit == 0 || p == oldp)
return -EINVAL;
- e820_remove_range(mem_size, ULLONG_MAX - mem_size, E820_RAM, 1);
return 0;
}
@@ -881,6 +896,12 @@ early_param("memmap", parse_memmap_opt);
void __init finish_e820_parsing(void)
{
+ if (mem_limit != ~0ULL) {
+ userdef = 1;
+ e820_remove_range(mem_limit, ULLONG_MAX - mem_limit,
+ E820_RAM, 1);
+ }
+
if (userdef) {
u32 nr = e820.nr_map;
--
1.7.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v2 2/2] x86: reimplement mem boot option
2012-08-21 8:11 ` [PATCH v2 " Wen Congyang
@ 2012-09-05 9:28 ` Wen Congyang
0 siblings, 0 replies; 9+ messages in thread
From: Wen Congyang @ 2012-09-05 9:28 UTC (permalink / raw)
To: Ingo Molnar, H. Peter Anvin; +Cc: rob, tglx, x86, linux-kernel, bhelgaas
Hi, H. Peter Anvin
Do you have time to review this patch?
Thanks
Wen Congyang
At 08/21/2012 04:11 PM, Wen Congyang Wrote:
> Current mem boot option only can work for non efi environment. If the user
> specifies add_efi_memmap, it cannot work for efi environment. In
> the efi environment, we call e820_add_region() to add the memory map. So
> we can modify __e820_add_region() and the mem boot option can work for
> efi environment.
>
> Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
> ---
> arch/x86/kernel/e820.c | 29 +++++++++++++++++++++++++----
> 1 files changed, 25 insertions(+), 4 deletions(-)
>
> diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
> index 4185797..20bc467 100644
> --- a/arch/x86/kernel/e820.c
> +++ b/arch/x86/kernel/e820.c
> @@ -47,6 +47,7 @@ unsigned long pci_mem_start = 0xaeedbabe;
> #ifdef CONFIG_PCI
> EXPORT_SYMBOL(pci_mem_start);
> #endif
> +static u64 mem_limit = ~0ULL;
>
> /*
> * This function checks if any part of the range <start,end> is mapped
> @@ -119,6 +120,20 @@ static void __init __e820_add_region(struct e820map *e820x, u64 start, u64 size,
> return;
> }
>
> + if (start >= mem_limit) {
> + printk(KERN_ERR "e820: ignoring [mem %#010llx-%#010llx]\n",
> + (unsigned long long)start,
> + (unsigned long long)(start + size - 1));
> + return;
> + }
> +
> + if (mem_limit - start < size) {
> + printk(KERN_ERR "e820: ignoring [mem %#010llx-%#010llx]\n",
> + (unsigned long long)mem_limit,
> + (unsigned long long)(start + size - 1));
> + size = mem_limit - start;
> + }
> +
> e820x->map[x].addr = start;
> e820x->map[x].size = size;
> e820x->map[x].type = type;
> @@ -809,7 +824,7 @@ static int userdef __initdata;
> /* "mem=nopentium" disables the 4MB page tables. */
> static int __init parse_memopt(char *p)
> {
> - u64 mem_size;
> + char *oldp;
>
> if (!p)
> return -EINVAL;
> @@ -825,11 +840,11 @@ static int __init parse_memopt(char *p)
> }
>
> userdef = 1;
> - mem_size = memparse(p, &p);
> + oldp = p;
> + mem_limit = memparse(p, &p);
> /* don't remove all of memory when handling "mem={invalid}" param */
> - if (mem_size == 0)
> + if (mem_limit == 0 || p == oldp)
> return -EINVAL;
> - e820_remove_range(mem_size, ULLONG_MAX - mem_size, E820_RAM, 1);
>
> return 0;
> }
> @@ -881,6 +896,12 @@ early_param("memmap", parse_memmap_opt);
>
> void __init finish_e820_parsing(void)
> {
> + if (mem_limit != ~0ULL) {
> + userdef = 1;
> + e820_remove_range(mem_limit, ULLONG_MAX - mem_limit,
> + E820_RAM, 1);
> + }
> +
> if (userdef) {
> u32 nr = e820.nr_map;
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] doc: update mem= option's spec
2012-06-14 8:10 [PATCH 1/2] doc: update mem= option's spec Wen Congyang
2012-06-14 8:12 ` [PATCH 2/2] x86: reimplement mem boot option Wen Congyang
@ 2012-06-14 20:22 ` Rob Landley
1 sibling, 0 replies; 9+ messages in thread
From: Rob Landley @ 2012-06-14 20:22 UTC (permalink / raw)
To: Wen Congyang
Cc: tglx, Ingo Molnar, x86, linux-kernel, bhelgaas, H. Peter Anvin
On 06/14/2012 03:10 AM, Wen Congyang wrote:
> Current mem= implementation seems buggy because specification and
> implementation doesn't match. Current mem= has been working
> for many years and it's not buggy, it works as expected. So
> we should update the specification.
>
> Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
> ---
> Documentation/kernel-parameters.txt | 7 ++++---
> 1 files changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
> index a92c5eb..924b1a4 100644
> --- a/Documentation/kernel-parameters.txt
> +++ b/Documentation/kernel-parameters.txt
> @@ -1471,9 +1471,10 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
> mem=nn[KMG] [KNL,BOOT] Force usage of a specific amount of memory
> Amount of memory to be used when the kernel is not able
> to see the whole system memory or for test.
> - [X86-32] Use together with memmap= to avoid physical
> - address space collisions. Without memmap= PCI devices
> - could be placed at addresses belonging to unused RAM.
> + [X86-32] Work as limiting max address. Use together
> + with memmap= to avoid physical address space collisions.
> + Without memmap= PCI devices could be placed at addresses
> + belonging to unused RAM.
>
> mem=nopentium [BUGS=X86-32] Disable usage of 4MB pages for kernel
> memory.
I have no objection to this but can't confirm it's true or not without
an awful lot more digging through the code I don't have time for right
now. (All the x86-32 machines I've used just had the 640k->1m hole and
the rest was contiguous memory, so the behavior would be the same either
way...)
Sort-of-tentatively-acked-by: Rob Landley <rob@landley.net>
Rob
--
GNU/Linux isn't: Linux=GPLv2, GNU=GPLv3+, they can't share code.
Either it's "mere aggregation", or a license violation. Pick one.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/2] x86: add max_addr boot option
@ 2012-05-22 7:02 Wen Congyang
2012-05-22 7:05 ` [PATCH 2/2] x86: reimplement mem " Wen Congyang
0 siblings, 1 reply; 9+ messages in thread
From: Wen Congyang @ 2012-05-22 7:02 UTC (permalink / raw)
To: rob, tglx, Ingo Molnar, x86, linux-kernel
Currently, the boot option max_addr is only supported on ia64 platform.
We also need it on x86 platform.
For example:
There are two nodes:
NODE#0 address range 0x00000000 00000000 - 0x00010000 00000000
NODE#1 address range 0x00010000 00000000 - 0x00020000 00000000
If we only want to use node0, we can specify the max_addr. The boot
option "mem=" can do the same thing now. But the boot option "mem="
means the total memory used by the system. If we tell the user
that the boot option "mem=" can do this, it will confuse the user.
So we need an new boot option "max_addr" on x86 platform.
Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
---
Documentation/kernel-parameters.txt | 2 +-
arch/x86/kernel/e820.c | 36 +++++++++++++++++++++++++++++++++++
2 files changed, 37 insertions(+), 1 deletions(-)
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index c1601e5..fe80e58 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -1409,7 +1409,7 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
yeeloong laptop.
Example: machtype=lemote-yeeloong-2f-7inch
- max_addr=nn[KMG] [KNL,BOOT,ia64] All physical memory greater
+ max_addr=nn[KMG] [KNL,BOOT,ia64,X86] All physical memory greater
than or equal to this physical address is ignored.
maxcpus= [SMP] Maximum number of processors that an SMP kernel
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index 62d61e9..2a6bec7 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -47,6 +47,7 @@ unsigned long pci_mem_start = 0xaeedbabe;
#ifdef CONFIG_PCI
EXPORT_SYMBOL(pci_mem_start);
#endif
+static u64 max_addr = ~0ULL;
/*
* This function checks if any part of the range <start,end> is mapped
@@ -117,6 +118,20 @@ static void __init __e820_add_region(struct e820map *e820x, u64 start, u64 size,
return;
}
+ if (start >= max_addr) {
+ printk(KERN_INFO "Ingoring memory: %016Lx - %016Lx\n",
+ (unsigned long long)start,
+ (unsigned long long)(start + size));
+ return;
+ }
+
+ if (max_addr - start < size) {
+ printk(KERN_INFO "Ingoring memory: %016Lx - %016Lx\n",
+ (unsigned long long)max_addr,
+ (unsigned long long)(start + size));
+ size = max_addr - start;
+ }
+
e820x->map[x].addr = start;
e820x->map[x].size = size;
e820x->map[x].type = type;
@@ -835,6 +850,22 @@ static int __init parse_memopt(char *p)
}
early_param("mem", parse_memopt);
+static int __init parse_memmax_opt(char *p)
+{
+ char *oldp;
+
+ if (!p)
+ return -EINVAL;
+
+ oldp = p;
+ max_addr = memparse(p, &p);
+ if (p == oldp)
+ return -EINVAL;
+
+ return 0;
+}
+early_param("max_addr", parse_memmax_opt);
+
static int __init parse_memmap_opt(char *p)
{
char *oldp;
@@ -881,6 +912,11 @@ early_param("memmap", parse_memmap_opt);
void __init finish_e820_parsing(void)
{
+ if (max_addr != ~0ULL) {
+ userdef = 1;
+ e820_remove_range(max_addr, ULLONG_MAX - max_addr, E820_RAM, 1);
+ }
+
if (userdef) {
u32 nr = e820.nr_map;
--
1.7.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/2] x86: reimplement mem boot option
2012-05-22 7:02 [PATCH 1/2] x86: add max_addr boot option Wen Congyang
@ 2012-05-22 7:05 ` Wen Congyang
0 siblings, 0 replies; 9+ messages in thread
From: Wen Congyang @ 2012-05-22 7:05 UTC (permalink / raw)
To: rob, tglx, Ingo Molnar, x86, linux-kernel
The boot option "mem=" specifies the total memory that the system can
use. But we implement it as max_addr.
The x86 system can be booted by EFI. If the user specify the boot
option "add_efi_memmap", we add all memory map from EFI, but we
donot handle the memory map according to the boot option "mem=".
This patch reimplement the boot option "mem=", and handle the memory
map after calling efi_init().
Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
---
arch/x86/include/asm/e820.h | 1 +
arch/x86/kernel/e820.c | 36 +++++++++++++++++++++++++++++++-----
arch/x86/kernel/setup.c | 1 +
3 files changed, 33 insertions(+), 5 deletions(-)
diff --git a/arch/x86/include/asm/e820.h b/arch/x86/include/asm/e820.h
index 3778256..d1bb772 100644
--- a/arch/x86/include/asm/e820.h
+++ b/arch/x86/include/asm/e820.h
@@ -127,6 +127,7 @@ extern void e820_reserve_resources(void);
extern void e820_reserve_resources_late(void);
extern void setup_memory_map(void);
extern char *default_machine_specific_memory_setup(void);
+extern void set_memlimit(void);
/*
* Returns true iff the specified range [s,e) is completely contained inside
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index 2a6bec7..0148944 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -48,6 +48,7 @@ unsigned long pci_mem_start = 0xaeedbabe;
EXPORT_SYMBOL(pci_mem_start);
#endif
static u64 max_addr = ~0ULL;
+static u64 mem_limit = ~0ULL;
/*
* This function checks if any part of the range <start,end> is mapped
@@ -824,8 +825,6 @@ static int userdef __initdata;
/* "mem=nopentium" disables the 4MB page tables. */
static int __init parse_memopt(char *p)
{
- u64 mem_size;
-
if (!p)
return -EINVAL;
@@ -840,16 +839,43 @@ static int __init parse_memopt(char *p)
}
userdef = 1;
- mem_size = memparse(p, &p);
+ mem_limit = memparse(p, &p);
/* don't remove all of memory when handling "mem={invalid}" param */
- if (mem_size == 0)
+ if (mem_limit == 0)
return -EINVAL;
- e820_remove_range(mem_size, ULLONG_MAX - mem_size, E820_RAM, 1);
return 0;
}
early_param("mem", parse_memopt);
+void __init set_memlimit(void)
+{
+ u64 total_size = 0;
+ int i;
+
+ if (mem_limit == ~0ULL)
+ return;
+
+ for (i = 0; i < e820.nr_map; i++) {
+ struct e820entry *ei = &e820.map[i];
+
+ if (ei->type != E820_RAM)
+ continue;
+
+ if (total_size >= mem_limit) {
+ memset(ei, 0, sizeof(struct e820entry));
+ continue;
+ }
+
+ if (mem_limit - total_size <= ei->size)
+ ei->size = mem_limit - total_size;
+
+ total_size += ei->size;
+ }
+
+ sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
+}
+
static int __init parse_memmax_opt(char *p)
{
char *oldp;
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 1a29015..7938fae 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -823,6 +823,7 @@ void __init setup_arch(char **cmdline_p)
if (efi_enabled)
efi_init();
+ set_memlimit();
dmi_scan_machine();
--
1.7.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
end of thread, other threads:[~2012-09-05 9:22 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-14 8:10 [PATCH 1/2] doc: update mem= option's spec Wen Congyang
2012-06-14 8:12 ` [PATCH 2/2] x86: reimplement mem boot option Wen Congyang
2012-06-28 1:29 ` Wen Congyang
2012-07-17 5:22 ` Wen Congyang
2012-07-18 9:16 ` Ingo Molnar
2012-08-21 8:11 ` [PATCH v2 " Wen Congyang
2012-09-05 9:28 ` Wen Congyang
2012-06-14 20:22 ` [PATCH 1/2] doc: update mem= option's spec Rob Landley
-- strict thread matches above, loose matches on Subject: below --
2012-05-22 7:02 [PATCH 1/2] x86: add max_addr boot option Wen Congyang
2012-05-22 7:05 ` [PATCH 2/2] x86: reimplement mem " Wen Congyang
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.