Skip to contentSkip to conversation

Only parse exactmap once, introduce memmap=resetusablemap

PATCH In review Thomas Renninger 3 participants 21 messages Jan 22, 2013 – Jan 29, 2013

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover Only parse exactmap once, introduce memmap=resetusablemap

this is a clean resend of Yinghai's memmap= extensions.
They were discussed on lkml in a thread with subject:
[PATCH] x86 e820: only void usable memory areas in memmap=exactmap case

The patches are based on origin/x86/mm2 where another memmap= enhancement from Yinghai is already queued.

Would be great if these can be queued there as well.

Thanks,

Thomas

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#1 lore raw

PATCH 1/2 x86 e820: Check for exactmap appearance when parsing first memmap option

From: Yinghai Lu <[email protected]>

memmap=exactmap will throw away all original, but also until then user defined (through other provided memmap= parameters) areas. That means all memmap= boot parameters passed before a memmap=exactmap parameter are not recognized.
Without this fix:
memmap=x@y memmap=exactmap memmap=i#k
only i#k would get recognized.

This is wrong, this fix will only throw away all original e820 areas once when memmap=exactmap is found in the whole boot command line and before any other memmap= option is parsed.

---
 arch/x86/kernel/e820.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
arch/x86/kernel/e820.c +12 -0
index d32abea..dc0b9f0 100644
@@ -835,6 +835,8 @@ static int __init parse_memopt(char *p)
 }
 early_param("mem", parse_memopt);
 
+static bool __initdata exactmap_parsed;
+
 static int __init parse_memmap_one(char *p)
 {
 	char *oldp;
@@ -844,6 +846,10 @@ static int __init parse_memmap_one(char *p)
 		return -EINVAL;
 
 	if (!strncmp(p, "exactmap", 8)) {
+		if (exactmap_parsed)
+			return 0;
+
+		exactmap_parsed = true;
 #ifdef CONFIG_CRASH_DUMP
 		/*
 		 * If we are doing a crash dump, we still need to know
@@ -879,6 +885,12 @@ static int __init parse_memmap_one(char *p)
 }
 static int __init parse_memmap_opt(char *str)
 {
+	char *p = boot_command_line;
+
+	p = strstr(p, "exactmap");
+	if (p)
+		parse_memmap_one("exactmap");
+
 	while (str) {
 		char *k = strchr(str, ',');
 
Signature · 7 lines
1.7.6.1


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Reviewed-by Thomas Renninger on v1 1/2
#2 lore raw

Re: [PATCH 1/2] x86 e820: Check for exactmap appearance when parsing first memmap option

Quoted 9 lines · Thomas Renninger

memmap=exactmap will throw away all original, but also until then user defined (through other provided memmap= parameters) areas. That means all memmap= boot parameters passed before a memmap=exactmap parameter are not recognized.
Without this fix:
memmap=x@y memmap=exactmap memmap=i#k
only i#k would get recognized.

Quoted 3 lines

This is wrong, this fix will only throw away all original e820 areas once when memmap=exactmap is found in the whole boot command line and before any other memmap= option is parsed.

Actually I put this patch already in for-x86-boot branch.

http://git.kernel.org/?p=linux/kernel/git/yinghai/linux-yinghai.git;a=commit;h=bd40ee79abf2351109ebd469b0b9ba6a8f3b0872

And will update change log to following to merge two change log.

---
Subject: [PATCH] x86: Handle multiple exactmaps and out of order exactmap

Current code expect that we only have one exactmap and exactmap need to first one in memmap=.

memmap=exactmap will throw away all original entries, but also until then user defined (through other provided memmap= parameters) areas. That means all memmap= boot parameters passed before a memmap=exactmap parameter are not recognized.

Without this fix:
memmap=x@y memmap=exactmap memmap=i#k
only i#k would get recognized. This is wrong.

This fix will scan the boot_command_line to find if there is exactmap at first and only throw away all original e820 entries once, and then parse other memmap= option.

-v2: incorporate change log from Thomas Renninger.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#3 lore raw

Re: [PATCH 1/2] x86 e820: Check for exactmap appearance when parsing first memmap option

In reply to Thomas Renninger
Quoted 10 lines · Thomas Renninger

From: Yinghai Lu <[email protected]>

memmap=exactmap will throw away all original, but also until then user defined (through other provided memmap= parameters) areas. That means all memmap= boot parameters passed before a memmap=exactmap parameter are not recognized.
Without this fix:
memmap=x@y memmap=exactmap memmap=i#k
only i#k would get recognized.

Quoted 4 lines

This is wrong, this fix will only throw away all original e820 areas once when memmap=exactmap is found in the whole boot command line and before any other memmap= option is parsed.

I don't understand why this is wrong. The kernel command line is always parsed from left to right, and I don't see anything inherently problematic with that with something like a big hammer like exactmap.

-hpa

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#4 lore raw

Re: [PATCH 1/2] x86 e820: Check for exactmap appearance when parsing first memmap option

Quoted 11 lines · H. Peter Anvin
Quoted 10 lines · Thomas Renninger

From: Yinghai Lu <[email protected]>

memmap=exactmap will throw away all original, but also until then user defined (through other provided memmap= parameters) areas. That means all memmap= boot parameters passed before a memmap=exactmap parameter are not recognized.
Without this fix:
memmap=x@y memmap=exactmap memmap=i#k
only i#k would get recognized.

Quoted 8 lines
Quoted 4 lines

This is wrong, this fix will only throw away all original e820 areas once when memmap=exactmap is found in the whole boot command line and before any other memmap= option is parsed.

I don't understand why this is wrong. The kernel command line is always parsed from left to right, and I don't see anything inherently problematic with that with something like a big hammer like exactmap.

Ok, let's drop it.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#5 lore raw

PATCH 2/2 x86 e820: Introduce memmap=resetusablemap for kdump usage

In reply to Thomas Renninger

From: Yinghai Lu <[email protected]>

kdump voided the whole original e820 map and half way made it up via memmap= options passed via kdump boot params again.

But this is conceptionally wrong. The whole original memory ranges which are declared reserved, ACPI data/nvs or however are not usable must stay the same and get honored by the kdump kernel.

Therefore memmap=resetusablemap gets introduced.
kdump passes this one and only the usable e820 ranges are removed. kdump passes the usable ranges to use via memmap=x@y parameter(s). The not usable e820 ranges are preserved.

This for example fixes mmconf (extended PCI config access) and possibly other kernel parts which rely on remapped memory to be in reserved or ACPI (data/nvs) declared e820 memory areas.

---
 Documentation/kernel-parameters.txt |    9 +++++++++
 arch/x86/kernel/e820.c              |   13 +++++++++++--
 2 files changed, 20 insertions(+), 2 deletions(-)
Documentation/kernel-parameters.txt +9 -0
index 9776f06..fe2f677 100644
@@ -1498,6 +1498,15 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
 			BIOS output or other requirements. See the memmap=nn@ss
 			option description.
 
+	memmap=resetusablemap
+			[KNL,X86] Similar to exactmap, but instead of discarding
+			the whole original e820 map, only the usable memory
+			areas are ignored.
+			Those must be passed via memmap=X@Y parameters,
+			reserved, ACPI and ACPI NVS areas are preserved.
+			This boot parameter is intended for kdump usage.
+			Also passing exactmap overrules resetusablemap.
+
 	memmap=nn[KMG]@ss[KMG]
 			[KNL] Force usage of a specific region of memory
 			Region of memory to be used, from ss to ss+nn.
arch/x86/kernel/e820.c +11 -2
index dc0b9f0..4e0ef9d 100644
@@ -845,7 +845,7 @@ static int __init parse_memmap_one(char *p)
 	if (!p)
 		return -EINVAL;
 
-	if (!strncmp(p, "exactmap", 8)) {
+	if (!strncmp(p, "exactmap", 8) || !strncmp(p, "resetusablemap", 14)) {
 		if (exactmap_parsed)
 			return 0;
 
@@ -858,7 +858,11 @@ static int __init parse_memmap_one(char *p)
 		 */
 		saved_max_pfn = e820_end_of_ram_pfn();
 #endif
-		e820.nr_map = 0;
+		if (!strncmp(p, "resetusablemap", 14)) {
+			/* remove all old E820_RAM ranges */
+			e820_remove_range(0, ULLONG_MAX, E820_RAM, 1);
+		} else
+			e820.nr_map = 0;
 		userdef = 1;
 		return 0;
 	}
@@ -890,6 +894,11 @@ static int __init parse_memmap_opt(char *str)
 	p = strstr(p, "exactmap");
 	if (p)
 		parse_memmap_one("exactmap");
+	else {
+		p = strstr(boot_command_line, "resetusablemap");
+		if (p)
+			parse_memmap_one("resetusablemap");
+	}
 
 	while (str) {
 		char *k = strchr(str, ',');
Signature · 7 lines
1.7.6.1


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#6 lore raw

Re: [PATCH 2/2] x86 e820: Introduce memmap=resetusablemap for kdump usage

Quoted 14 lines · Thomas Renninger

From: Yinghai Lu <[email protected]>

kdump voided the whole original e820 map and half way made it up via memmap= options passed via kdump boot params again.

But this is conceptionally wrong. The whole original memory ranges which are declared reserved, ACPI data/nvs or however are not usable must stay the same and get honored by the kdump kernel.

Therefore memmap=resetusablemap gets introduced.
kdump passes this one and only the usable e820 ranges are removed. kdump passes the usable ranges to use via memmap=x@y parameter(s). The not usable e820 ranges are preserved.

Quoted 7 lines

This for example fixes mmconf (extended PCI config access) and possibly other kernel parts which rely on remapped memory to be in reserved or ACPI (data/nvs) declared e820 memory areas.

Tested-by: and Reviewed-by: are rather redundant with Signed-off-by:. Also, you should have a Signed-off-by: from the author (Yinghai).

However, when thinking about it this really doesn't seem to be the right interface, either. Something like "memmap=reserveram" which turns all RAM areas into reserved areas, which can then be overridden by memmap= options would make more sense.

Even more sense would be to pass the modified memmap to kexec...

-hpa

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#7 lore raw

Re: [PATCH 2/2] x86 e820: Introduce memmap=resetusablemap for kdump usage

Quoted 19 lines · H. Peter Anvin
Quoted 18 lines · Thomas Renninger

From: Yinghai Lu <[email protected]>

kdump voided the whole original e820 map and half way made it up via memmap= options passed via kdump boot params again.

But this is conceptionally wrong. The whole original memory ranges which are declared reserved, ACPI data/nvs or however are not usable must stay the same and get honored by the kdump kernel.

Therefore memmap=resetusablemap gets introduced.
kdump passes this one and only the usable e820 ranges are removed. kdump passes the usable ranges to use via memmap=x@y parameter(s). The not usable e820 ranges are preserved.

This for example fixes mmconf (extended PCI config access) and possibly other kernel parts which rely on remapped memory to be in reserved or ACPI (data/nvs) declared e820 memory areas.

Quoted 5 lines
Quoted 3 lines
Tested-by and Reviewed-by: are rather redundant with Signed-off-by:.

Yes, the Signed-off-by slipped in.

Quoted 1 line

Also, you should have a Signed-off-by: from the author (Yinghai).

From: and Signed-off-by: are also redundant?

Quoted 2 lines

However, when thinking about it this really doesn't seem to be the right interface, either.

Why?

Quoted 3 lines

Something like "memmap=reserveram" which turns all
RAM areas into reserved areas, which can then be overridden by memmap= options would make more sense.

What for?
This would be wrong. If kexec tries to declare usable memory via memmap= which is set to reserved by the BIOS, a WARN_ON() or even better BUG_ON() can/should be issued. This is then not possible anymore.

Your suggestion would again make the e820 data useless. One would again not know whether an area which is reserved really is meant for BIOS/HW communication. And for example broken mmconf platforms for which the check "is mmconf area is in reserved space" returns false, would now try to setup mmconf in kdump case. Do you want to introduce another e820 type: KDUMP_RESERVED which formerly was usable? This would preserve e820 info, but I cannot see for what this should be good for.

Quoted 1 line

Even more sense would be to pass the modified memmap to kexec...

Not sure what you mean with this. When kexec is called, you are in a kernel which does not have a modified memmap. How can a modified map get passed to kexec?

Again: Please explain what is bad with this solution.
I cannot see a better and more robust way for kdump other than reserving the original reserved memory areas as declared by the BIOS.

Thomas

#8 lore raw

Re: [PATCH 2/2] x86 e820: Introduce memmap=resetusablemap for kdump usage

Quoted 3 lines · Thomas Renninger

This would be wrong. If kexec tries to declare usable memory via memmap= which is set to reserved by the BIOS, a WARN_ON() or even better BUG_ON() can/should be issued. This is then not possible anymore.

You can't do that anyway, because memmap= is not kexec-specific.

Quoted 7 lines

Your suggestion would again make the e820 data useless. One would again not know whether an area which is reserved really is meant for BIOS/HW communication. And for example broken mmconf platforms for which the check "is mmconf area is in reserved space" returns false, would now try to setup mmconf in kdump case. Do you want to introduce another e820 type: KDUMP_RESERVED which formerly was usable? This would preserve e820 info, but I cannot see for what this should be good for.

You just answered your own question. Yes, we already have such "kernel reserved" types, and we could make a "memmap reserved"

Quoted 4 lines
Quoted 1 line

Even more sense would be to pass the modified memmap to kexec...

Not sure what you mean with this. When kexec is called, you are in a kernel which does not have a modified memmap. How can a modified map get passed to kexec?

The memory map is simply a data structure which is passed by kexec. It can be modified at will by the kexec tools. This is the Right Way to do any of this; using the command line is just a horribly fscked up hack in the first place.

Quoted 3 lines

Again: Please explain what is bad with this solution.
I cannot see a better and more robust way for kdump other than reserving the original reserved memory areas as declared by the BIOS.

It is bad because it creates more complexity than is needed.

The whole point is that what we want is simply to switch type 1 to type X, with the sole exceptions being the areas explicitly reserved for the kdump kernel.

-hpa

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#9 lore raw

Re: [PATCH 2/2] x86 e820: Introduce memmap=resetusablemap for kdump usage

Quoted 9 lines · H. Peter Anvin
Quoted 3 lines

Again: Please explain what is bad with this solution.
I cannot see a better and more robust way for kdump other than reserving the original reserved memory areas as declared by the BIOS.

It is bad because it creates more complexity than is needed.

The whole point is that what we want is simply to switch type 1 to type X, with the sole exceptions being the areas explicitly reserved for the kdump kernel.

Do you prefer to "reserveram" way in attached patch?

Thanks

Yinghai

---
 arch/x86/kernel/e820.c |   18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
arch/x86/kernel/e820.c +16 -2
Index: linux-2.6/arch/x86/kernel/e820.c
===================================================================
@@ -836,6 +836,7 @@ static int __init parse_memopt(char *p)
 early_param("mem", parse_memopt);
 
 static bool __initdata exactmap_parsed;
+static bool __initdata reserveram_parsed;
 
 static int __init parse_memmap_one(char *p)
 {
@@ -845,7 +846,7 @@ static int __init parse_memmap_one(char
 	if (!p)
 		return -EINVAL;
 
-	if (!strncmp(p, "exactmap", 8)) {
+	if (!strncmp(p, "exactmap", 8) || !strncmp(p, "reserveram", 10)) {
 		if (exactmap_parsed)
 			return 0;
 
@@ -858,7 +859,11 @@ static int __init parse_memmap_one(char
 		 */
 		saved_max_pfn = e820_end_of_ram_pfn();
 #endif
-		e820.nr_map = 0;
+		if (!strncmp(p, "reserveram", 10)) {
+			e820_update_range(0, ULLONG_MAX, E820_RAM, E820_RESERVED);
+			reserveram_parsed = true;
+		} else
+			e820.nr_map = 0;
 		userdef = 1;
 		return 0;
 	}
@@ -871,6 +876,10 @@ static int __init parse_memmap_one(char
 	userdef = 1;
 	if (*p == '@') {
 		start_at = memparse(p+1, &p);
+		if (reserveram_parsed) {
+			/* remove old reserved so new ram could take over */
+			e820_remove_range(start_at, mem_size, E820_RESERVED, 0);
+		}
 		e820_add_region(start_at, mem_size, E820_RAM);
 	} else if (*p == '#') {
 		start_at = memparse(p+1, &p);
@@ -890,6 +899,11 @@ static int __init parse_memmap_opt(char
 	p = strstr(p, "exactmap");
 	if (p)
 		parse_memmap_one("exactmap");
+	else {
+		p = strstr(boot_command_line, "reserveram");
+		if (p)
+			parse_memmap_one("reserveram");
+	}
 
 	while (str) {
 		char *k = strchr(str, ',');
#10 lore raw

Re: [PATCH 2/2] x86 e820: Introduce memmap=resetusablemap for kdump usage

Quoted 5 lines · Yinghai Lu
Quoted 4 lines · H. Peter Anvin
Quoted 3 lines

Again: Please explain what is bad with this solution.
I cannot see a better and more robust way for kdump other than reserving the original reserved memory areas as declared by the BIOS.

Quoted 7 lines
Quoted 5 lines

It is bad because it creates more complexity than is needed.

The whole point is that what we want is simply to switch type 1 to type X, with the sole exceptions being the areas explicitly reserved for the kdump kernel.

Do you prefer to "reserveram" way in attached patch?

Hi, Thomas,

Can you please check attached reserveram version on your setup?

If it is ok, i will put it in for-x86-boot patchset and send it to Peter for v3.9.

Thanks

Yinghai

Subject: [PATCH] x86, mm: Introduce memmap=reserveram

kdump voided the whole original e820 map and half way made it up via memmap= options passed via kdump boot params again.

But this is conceptionally wrong. The whole original memory ranges which are declared reserved, ACPI data/nvs or however are not usable must stay the same and get honored by the kdump kernel.

Therefore memmap=reserveram gets introduced.
kdump passes this one and only the usable e820 ranges are updated to reserved at first by kernel, then when kdump passes the usable ranges to use via memmap=x@y parameter(s), kernel will remove reserved range and add usable range accordingly.

This for example fixes mmconf (extended PCI config access) and possibly other kernel parts which rely on remapped memory to be in reserved or ACPI (data/nvs) declared e820 memory areas.

Changelog is from Thomas Renninger, and updated to reserveram

-v2: According to HPA, use reserveram instead of resetusablemap.

---
 arch/x86/kernel/e820.c |   19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
arch/x86/kernel/e820.c +17 -2
Index: linux-2.6/arch/x86/kernel/e820.c
===================================================================
@@ -836,6 +836,7 @@ static int __init parse_memopt(char *p)
 early_param("mem", parse_memopt);
 
 static bool __initdata exactmap_parsed;
+static bool __initdata reserveram_parsed;
 
 static int __init parse_memmap_one(char *p)
 {
@@ -845,7 +846,7 @@ static int __init parse_memmap_one(char
 	if (!p)
 		return -EINVAL;
 
-	if (!strncmp(p, "exactmap", 8)) {
+	if (!strncmp(p, "exactmap", 8) || !strncmp(p, "reserveram", 10)) {
 		if (exactmap_parsed)
 			return 0;
 
@@ -858,7 +859,12 @@ static int __init parse_memmap_one(char
 		 */
 		saved_max_pfn = e820_end_of_ram_pfn();
 #endif
-		e820.nr_map = 0;
+		if (!strncmp(p, "reserveram", 10)) {
+			e820_update_range(0, ULLONG_MAX, E820_RAM,
+					  E820_RESERVED);
+			reserveram_parsed = true;
+		} else
+			e820.nr_map = 0;
 		userdef = 1;
 		return 0;
 	}
@@ -871,6 +877,10 @@ static int __init parse_memmap_one(char
 	userdef = 1;
 	if (*p == '@') {
 		start_at = memparse(p+1, &p);
+		if (reserveram_parsed) {
+			/* Remove old reserved so new ram could take over. */
+			e820_remove_range(start_at, mem_size, E820_RESERVED, 0);
+		}
 		e820_add_region(start_at, mem_size, E820_RAM);
 	} else if (*p == '#') {
 		start_at = memparse(p+1, &p);
@@ -890,6 +900,11 @@ static int __init parse_memmap_opt(char
 	p = strstr(p, "exactmap");
 	if (p)
 		parse_memmap_one("exactmap");
+	else {
+		p = strstr(boot_command_line, "reserveram");
+		if (p)
+			parse_memmap_one("reserveram");
+	}
 
 	while (str) {
 		char *k = strchr(str, ',');

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#11 lore raw

Re: [PATCH 2/2] x86 e820: Introduce memmap=resetusablemap for kdump usage

Quoted 12 lines · Yinghai Lu
Quoted 11 lines · Yinghai Lu
Quoted 9 lines · H. Peter Anvin
Quoted 3 lines

Again: Please explain what is bad with this solution.
I cannot see a better and more robust way for kdump other than reserving the original reserved memory areas as declared by the BIOS.

It is bad because it creates more complexity than is needed.

The whole point is that what we want is simply to switch type 1 to type X, with the sole exceptions being the areas explicitly reserved for the kdump kernel.

Quoted 8 lines
Quoted 1 line

Do you prefer to "reserveram" way in attached patch?

Hi, Thomas,

Can you please check attached reserveram version on your setup?

If it is ok, i will put it in for-x86-boot patchset and send it to Peter for v3.9.

But this (converting usable memory to reserved one before usable kdump memory is added) will let machines run into problems again for which the check:
"mmconf area must be in reserved memory" got added?

If, then memory which was usable before has to be converted to a special E820_KUMP (or whatever type) to make sure existing checks which look for "is reserved memory" still work the same way as in a productive kernel.

Advantage of this would be that the info what originally was usable memory is preserved and can be used in future kdump related patches.

So I guess the final patch should be:
- Add a new e820 type:
E820_KDUMP_RESERVED /* Originally usable memory where the crashed
kernel kernel resided in */
- Use Yinghai's last posted patch, but instead of:
+ e820_update_range(0, ULLONG_MAX, E820_RAM,
+ E820_RESERVED);
...
+ e820_remove_range(start_at, mem_size, E820_RESERVED, 0);
do:
+ e820_update_range(0, ULLONG_MAX, E820_RAM,
+ E820_KDUMP_RESERVED);
...
+ e820_remove_range(start_at, mem_size, E820_KDUMP_RESERVED, 0);

- Come up with another memmap=kdump_reserve_ram memmap option name or however it should get named...

If this proposal gets accepted, I can send a tested patch...

Thomas

#12 lore raw

Re: [PATCH 2/2] x86 e820: Introduce memmap=resetusablemap for kdump usage

Quoted 30 lines · Thomas Renninger

But this (converting usable memory to reserved one before usable kdump memory is added) will let machines run into problems again for which the check:
"mmconf area must be in reserved memory" got added?

If, then memory which was usable before has to be converted to a special E820_KUMP (or whatever type) to make sure existing checks which look for "is reserved memory" still work the same way as in a productive kernel.

Advantage of this would be that the info what originally was usable memory is preserved and can be used in future kdump related patches.

So I guess the final patch should be:
- Add a new e820 type:
E820_KDUMP_RESERVED /* Originally usable memory where the crashed
kernel kernel resided in */
- Use Yinghai's last posted patch, but instead of:

arch/x86/kernel/e820.c +3 -0
+			e820_update_range(0, ULLONG_MAX, E820_RAM,
+					  E820_RESERVED);
...
+			e820_remove_range(start_at, mem_size, E820_RESERVED, 0);

do:

(quoted diff) +3 -0
+			e820_update_range(0, ULLONG_MAX, E820_RAM,
+					  E820_KDUMP_RESERVED);
...
+			e820_remove_range(start_at, mem_size, E820_KDUMP_RESERVED, 0);
 
  - Come up with another memmap=kdump_reserve_ram memmap option name
    or however it should get named...
Quoted 2 lines

If this proposal gets accepted, I can send a tested patch...

Yes, this is much saner. There really shouldn't need to be an option, even; since the tools need to be modified anyway, just modify the actual memory map data structure itself.

-hpa

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#13 lore raw

Re: [PATCH 2/2] x86 e820: Introduce memmap=resetusablemap for kdump usage

Quoted 18 lines · H. Peter Anvin
Quoted 18 lines

So I guess the final patch should be:
- Add a new e820 type:
E820_KDUMP_RESERVED /* Originally usable memory where the crashed
kernel kernel resided in */
- Use Yinghai's last posted patch, but instead of:

arch/x86/kernel/e820.c +3 -0
+                     e820_update_range(0, ULLONG_MAX, E820_RAM,
+                                       E820_RESERVED);
...
+                     e820_remove_range(start_at, mem_size, E820_RESERVED, 0);

do:

(quoted diff) +3 -0
+                     e820_update_range(0, ULLONG_MAX, E820_RAM,
+                                       E820_KDUMP_RESERVED);
...
+                     e820_remove_range(start_at, mem_size, E820_KDUMP_RESERVED, 0);
 
  - Come up with another memmap=kdump_reserve_ram memmap option name
    or however it should get named...
Quoted 6 lines
Quoted 2 lines

If this proposal gets accepted, I can send a tested patch...

Yes, this is much saner. There really shouldn't need to be an option, even; since the tools need to be modified anyway, just modify the actual memory map data structure itself.

yes,

kexec-tools will change that to E820_KDUMP_RESERVED (or other good name).

We only need to update kernel to get old max_pfn by checking E820_KDUMP_RESERVED.

Yinghai

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#14 lore raw

Re: [PATCH 2/2] x86 e820: Introduce memmap=resetusablemap for kdump usage

Quoted 6 lines · Yinghai Lu

kexec-tools will change that to E820_KDUMP_RESERVED (or other good name).

We only need to update kernel to get old max_pfn by checking E820_KDUMP_RESERVED.

OK, I have asked this before, but I still have not gotten any acceptable answer:

Why do we still have max_*_pfn at all? Shouldn't it all be based on memblocks by now?

-hpa

Signature · 8 lines
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#15 lore raw

Re: [PATCH 2/2] x86 e820: Introduce memmap=resetusablemap for kdump usage

Quoted 9 lines · H. Peter Anvin
Quoted 7 lines · Yinghai Lu

kexec-tools will change that to E820_KDUMP_RESERVED (or other good name).

We only need to update kernel to get old max_pfn by checking E820_KDUMP_RESERVED.

Quoted 5 lines

OK, I have asked this before, but I still have not gotten any acceptable answer:

Why do we still have max_*_pfn at all? Shouldn't it all be based on memblocks by now?

saved_max_pfn is used for kdump:
drivers/char/mem.c::read_oldmem will stop there.
...

        while (count) {
                pfn = *ppos / PAGE_SIZE;
                if (pfn > saved_max_pfn)
                        return read;

...

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#16 lore raw

Re: [PATCH 2/2] x86 e820: Introduce memmap=resetusablemap for kdump usage

Quoted 16 lines · Yinghai Lu
Quoted 9 lines · H. Peter Anvin
Quoted 7 lines · Yinghai Lu

kexec-tools will change that to E820_KDUMP_RESERVED (or other good name).

We only need to update kernel to get old max_pfn by checking E820_KDUMP_RESERVED.

Quoted 5 lines

OK, I have asked this before, but I still have not gotten any acceptable answer:

Why do we still have max_*_pfn at all? Shouldn't it all be based on memblocks by now?

Quoted 8 lines

saved_max_pfn is used for kdump:
drivers/char/mem.c::read_oldmem will stop there.
...

         while (count) {
                 pfn = *ppos / PAGE_SIZE;
                 if (pfn > saved_max_pfn)
                         return read;

...

That is a non-answer.

Why do we have *any* instances of max_pfn or max_low_pfn in the kernel anymore?

-hpa

Signature · 8 lines
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#17 lore raw

Re: [PATCH 2/2] x86 e820: Introduce memmap=resetusablemap for kdump usage

In reply to Yinghai Lu

To be more clear: the max_pfn stuff seems like a relic of the past, and I am wondering what it would take to get rid of it.

It clearly has the wrong semantics, except perhaps in the most trivial allocator models.

Quoted 26 lines · Yinghai Lu
Quoted 4 lines · H. Peter Anvin
Quoted 3 lines · Yinghai Lu

kexec-tools will change that to E820_KDUMP_RESERVED (or other good

name).

Quoted 6 lines
Quoted 4 lines

We only need to update kernel to get old max_pfn by checking E820_KDUMP_RESERVED.

OK, I have asked this before, but I still have not gotten any

acceptable

Quoted 4 lines

answer:

Why do we still have max_*_pfn at all? Shouldn't it all be based on memblocks by now?

saved_max_pfn is used for kdump:
drivers/char/mem.c::read_oldmem will stop there.
...

       while (count) {
               pfn = *ppos / PAGE_SIZE;
               if (pfn > saved_max_pfn)
                       return read;

...

Signature · 6 lines
Sent from my mobile phone. Please excuse brevity and lack of formatting.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#18 lore raw

Re: [PATCH 2/2] x86 e820: Introduce memmap=resetusablemap for kdump usage

Quoted 4 lines · H. Peter Anvin

To be more clear: the max_pfn stuff seems like a relic of the past, and I am wondering what it would take to get rid of it.

It clearly has the wrong semantics, except perhaps in the most trivial allocator models.

one thing i think could be : use that decide if we need iommu/swiotlb. like in
arch/x86/kernel/amd_gart_64.c
arch/x86/kernel/pci-swiotlb.c
drivers/iommu/amd_iommu.c
...

Yinghai

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#19 lore raw

Re: [PATCH 2/2] x86 e820: Introduce memmap=resetusablemap for kdump usage

I guess that very limited use might make sense.

Quoted 15 lines · Yinghai Lu
Quoted 1 line · H. Peter Anvin

To be more clear: the max_pfn stuff seems like a relic of the past,

and I am wondering what it would take to get rid of it.

Quoted 2 lines

It clearly has the wrong semantics, except perhaps in the most

trivial allocator models.

Quoted 1 line

one thing i think could be : use that decide if we need iommu/swiotlb. like in
arch/x86/kernel/amd_gart_64.c
arch/x86/kernel/pci-swiotlb.c
drivers/iommu/amd_iommu.c
...

Yinghai

Signature · 6 lines
Sent from my mobile phone. Please excuse brevity and lack of formatting.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#20 lore raw

Re: [PATCH 2/2] x86 e820: Introduce memmap=resetusablemap for kdump usage

In reply to Yinghai Lu
Quoted 26 lines · Yinghai Lu
Quoted 18 lines · H. Peter Anvin
Quoted 18 lines

So I guess the final patch should be:
- Add a new e820 type:
E820_KDUMP_RESERVED /* Originally usable memory where the crashed
kernel kernel resided in */
- Use Yinghai's last posted patch, but instead of:

arch/x86/kernel/e820.c +3 -0
+                     e820_update_range(0, ULLONG_MAX, E820_RAM,
+                                       E820_RESERVED);
...
+                     e820_remove_range(start_at, mem_size, E820_RESERVED, 0);

do:

(quoted diff) +3 -0
+                     e820_update_range(0, ULLONG_MAX, E820_RAM,
+                                       E820_KDUMP_RESERVED);
...
+                     e820_remove_range(start_at, mem_size, E820_KDUMP_RESERVED, 0);
 
  - Come up with another memmap=kdump_reserve_ram memmap option name
    or however it should get named...
Quoted 6 lines
Quoted 2 lines

If this proposal gets accepted, I can send a tested patch...

Yes, this is much saner. There really shouldn't need to be an option, even; since the tools need to be modified anyway, just modify the actual memory map data structure itself.

Quoted 6 lines

yes,

kexec-tools will change that to E820_KDUMP_RESERVED (or other good name).

We only need to update kernel to get old max_pfn by checking E820_KDUMP_RESERVED.

Wait, above proposal does not include kexec-tools mangling of the e820 table, for several reasons:

- Keep the boot interface clean and pass the original table
- Only one possible error source on e820 table modifications
- While hpa proposed kexec-tools to pass a modified e820 table to make things easier, exactly the opposite is the case:
If kexec-tools and the kernel modify the table, things are more complex and hard to understand in case of debugging where things went wrong
- It's really easy to do that in the kernel. As shown above it should simply be this line to change usable areas into E820_KDUMP_RESERVED ones:
e820_update_range(0, ULLONG_MAX, E820_RAM, E820_KDUMP_RESERVED); and possibly slight adjusting when the memmap=X#Y memory the kdump kernel uses is added (has to override E820_KDUMP_RESERVED areas with usable memory again)

My previously posted kexec-tools patches should simply work, it's just that the memmap option name changes to:
memmap=kdump_reserve_ram

This is what I proposed and is IMO the best and less complex way to go. I guess I still wait another day for comments and will send something if you agree.

Thomas

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec