Skip to contentSkip to conversation

Add support for soft reserved memory range

PATCH In review Jacek Tomaka 3 participants 5 messages Aug 14, 2024 – Sep 4, 2024 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 Add support for soft reserved memory range

Essentially catch up with e820 related changes in the kernel. Intel Sapphire Rappids MAX has high bandwidth memory which is precious resource that is better not allocated by the kernel.

Userspace later can enable soft reserved range using daxctl.

---
 include/x86/x86-linux.h               | 2 ++
 kexec/arch/i386/crashdump-x86.c       | 7 +++++++
 kexec/arch/i386/kexec-multiboot-x86.c | 1 +
 kexec/arch/i386/kexec-x86-common.c    | 5 +++++
 kexec/arch/i386/x86-linux-setup.c     | 3 +++
 kexec/firmware_memmap.c               | 2 ++
 kexec/kexec.h                         | 1 +
 7 files changed, 21 insertions(+)
include/x86/x86-linux.h +2 -0
index 9646102835..fbde93df94 100644
@@ -23,6 +23,8 @@ struct e820entry {
 #define E820_NVS	4
 #define E820_PMEM       7
 #define E820_PRAM       12
+#define E820_SOFT_RESERVED 0xefffffff
+
 } __attribute__((packed));
 #endif
 
kexec/arch/i386/crashdump-x86.c +7 -0
index a01031e570..49108b2032 100644
@@ -288,6 +288,10 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges,
 			type = RANGE_RESERVED;
 		} else if (memcmp(str, "Reserved\n", 9) == 0) {
 			type = RANGE_RESERVED;
+		} else if (memcmp(str, "soft reserved\n", 14) == 0 ) {
+			type = RANGE_SOFT_RESERVED;
+		} else if (memcmp(str, "Soft Reserved\n", 14) == 0 ) {
+			type = RANGE_SOFT_RESERVED;
 		} else if (memcmp(str, "GART\n", 5) == 0) {
 			gart_start = start;
 			gart_end = end;
@@ -615,6 +619,8 @@ static void cmdline_add_memmap_internal(char *cmdline, unsigned long startk,
 		strcat (str_mmap, "K@");
 	else if (type == RANGE_RESERVED)
 		strcat (str_mmap, "K$");
+	else if (type == RANGE_SOFT_RESERVED)
+		strcat (str_mmap, "K*");
 	else if (type == RANGE_ACPI || type == RANGE_ACPI_NVS)
 		strcat (str_mmap, "K#");
 	else if (type == RANGE_PRAM)
@@ -985,6 +991,7 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,
 		if ( !( mem_range[i].type == RANGE_ACPI
 			|| mem_range[i].type == RANGE_ACPI_NVS
 			|| mem_range[i].type == RANGE_RESERVED
+			|| mem_range[i].type == RANGE_SOFT_RESERVED
 			|| mem_range[i].type == RANGE_PMEM
 			|| mem_range[i].type == RANGE_PRAM))
 			continue;
kexec/arch/i386/kexec-multiboot-x86.c +1 -0
index 33c885a2fa..49d57cb5ae 100644
@@ -379,6 +379,7 @@ int multiboot_x86_load(int argc, char **argv, const char *buf, off_t len,
 			mmap[i].Type = 4;
 			break;
 		case RANGE_RESERVED:
+		case RANGE_SOFT_RESERVED:
 		default:
 			mmap[i].Type = 2;  /* Not RAM (reserved) */
 		}
kexec/arch/i386/kexec-x86-common.c +5 -0
index ffc95a9e43..116c4f4fd3 100644
@@ -99,6 +99,9 @@ static int get_memory_ranges_proc_iomem(struct memory_range **range, int *ranges
 		else if (strncasecmp(str, "reserved\n", 9) == 0) {
 			type = RANGE_RESERVED;
 		}
+		else if (strncasecmp(str, "soft reserved\n", 9) == 0) {
+			type = RANGE_SOFT_RESERVED;
+		}
 		else if (memcmp(str, "ACPI Tables\n", 12) == 0) {
 			type = RANGE_ACPI;
 		}
@@ -170,6 +173,8 @@ unsigned xen_e820_to_kexec_type(uint32_t type)
 			return RANGE_PMEM;
 		case E820_PRAM:
 			return RANGE_PRAM;
+		case E820_SOFT_RESERVED;
+			return RANGE_SOFT_RESERVED;
 		case E820_RESERVED:
 		default:
 			return RANGE_RESERVED;
kexec/arch/i386/x86-linux-setup.c +3 -0
index 73251b9339..afc83fe729 100644
@@ -755,6 +755,9 @@ static void add_e820_map_from_mr(struct x86_linux_param_header *real_mode,
 			case RANGE_PRAM:
 				e820[i].type = E820_PRAM;
 				break;
+			case RANGE_SOFT_RESERVED:
+				e820[i].type = E820_SOFT_RESERVED;
+				break;
 			default:
 			case RANGE_RESERVED:
 				e820[i].type = E820_RESERVED;
kexec/firmware_memmap.c +2 -0
index 457c3dc9a6..fa0c22140a 100644
@@ -182,6 +182,8 @@ static int parse_memmap_entry(const char *entry, struct memory_range *range)
 		range->type = RANGE_RESERVED;
 	else if (strcmp(type, "Reserved") == 0)
 		range->type = RANGE_RESERVED;
+        else if (strcmp(type, "Soft Reserved") == 0)
+                range->type = RANGE_SOFT_RESERVED;
 	else if (strcmp(type, "Unknown E820 type") == 0)
 		range->type = RANGE_RESERVED;
 	else if (strcmp(type, "ACPI Non-volatile Storage") == 0)
kexec/kexec.h +1 -0
index 31c323f674..dbb27a7607 100644
@@ -139,6 +139,7 @@ struct memory_range {
 #define RANGE_UNCACHED	4
 #define RANGE_PMEM		6
 #define RANGE_PRAM		11
+#define RANGE_SOFT_RESERVED 0xefffffff
 };
 
 struct memory_ranges {
Signature · 7 lines
2.17.0


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

A friendly ping.

Quoted 140 lines · Jacek Tomaka

Essentially catch up with e820 related changes in the kernel. Intel Sapphire Rappids MAX has high bandwidth memory which is precious resource that is better not allocated by the kernel.

Userspace later can enable soft reserved range using daxctl.

---
 include/x86/x86-linux.h               | 2 ++
 kexec/arch/i386/crashdump-x86.c       | 7 +++++++
 kexec/arch/i386/kexec-multiboot-x86.c | 1 +
 kexec/arch/i386/kexec-x86-common.c    | 5 +++++
 kexec/arch/i386/x86-linux-setup.c     | 3 +++
 kexec/firmware_memmap.c               | 2 ++
 kexec/kexec.h                         | 1 +
 7 files changed, 21 insertions(+)
include/x86/x86-linux.h +2 -0
index 9646102835..fbde93df94 100644
@@ -23,6 +23,8 @@ struct e820entry {
 #define E820_NVS       4
 #define E820_PMEM       7
 #define E820_PRAM       12
+#define E820_SOFT_RESERVED 0xefffffff
+
 } __attribute__((packed));
 #endif
 
kexec/arch/i386/crashdump-x86.c +7 -0
index a01031e570..49108b2032 100644
@@ -288,6 +288,10 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges,
                        type = RANGE_RESERVED;
                } else if (memcmp(str, "Reserved\n", 9) == 0) {
                        type = RANGE_RESERVED;
+               } else if (memcmp(str, "soft reserved\n", 14) == 0 ) {
+                       type = RANGE_SOFT_RESERVED;
+               } else if (memcmp(str, "Soft Reserved\n", 14) == 0 ) {
+                       type = RANGE_SOFT_RESERVED;
                } else if (memcmp(str, "GART\n", 5) == 0) {
                        gart_start = start;
                        gart_end = end;
@@ -615,6 +619,8 @@ static void cmdline_add_memmap_internal(char *cmdline, unsigned long startk,
                strcat (str_mmap, "K@");
        else if (type == RANGE_RESERVED)
                strcat (str_mmap, "K$");
+       else if (type == RANGE_SOFT_RESERVED)
+               strcat (str_mmap, "K*");
        else if (type == RANGE_ACPI || type == RANGE_ACPI_NVS)
                strcat (str_mmap, "K#");
        else if (type == RANGE_PRAM)
@@ -985,6 +991,7 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,
                if ( !( mem_range[i].type == RANGE_ACPI
                        || mem_range[i].type == RANGE_ACPI_NVS
                        || mem_range[i].type == RANGE_RESERVED
+                       || mem_range[i].type == RANGE_SOFT_RESERVED
                        || mem_range[i].type == RANGE_PMEM
                        || mem_range[i].type == RANGE_PRAM))
                        continue;
kexec/arch/i386/kexec-multiboot-x86.c +1 -0
index 33c885a2fa..49d57cb5ae 100644
@@ -379,6 +379,7 @@ int multiboot_x86_load(int argc, char **argv, const char *buf, off_t len,
                        mmap[i].Type = 4;
                        break;
                case RANGE_RESERVED:
+               case RANGE_SOFT_RESERVED:
                default:
                        mmap[i].Type = 2;  /* Not RAM (reserved) */
                }
kexec/arch/i386/kexec-x86-common.c +5 -0
index ffc95a9e43..116c4f4fd3 100644
@@ -99,6 +99,9 @@ static int get_memory_ranges_proc_iomem(struct memory_range **range, int *ranges
                else if (strncasecmp(str, "reserved\n", 9) == 0) {
                        type = RANGE_RESERVED;
                }
+               else if (strncasecmp(str, "soft reserved\n", 9) == 0) {
+                       type = RANGE_SOFT_RESERVED;
+               }
                else if (memcmp(str, "ACPI Tables\n", 12) == 0) {
                        type = RANGE_ACPI;
                }
@@ -170,6 +173,8 @@ unsigned xen_e820_to_kexec_type(uint32_t type)
                        return RANGE_PMEM;
                case E820_PRAM:
                        return RANGE_PRAM;
+               case E820_SOFT_RESERVED;
+                       return RANGE_SOFT_RESERVED;
                case E820_RESERVED:
                default:
                        return RANGE_RESERVED;
kexec/arch/i386/x86-linux-setup.c +3 -0
index 73251b9339..afc83fe729 100644
@@ -755,6 +755,9 @@ static void add_e820_map_from_mr(struct x86_linux_param_header *real_mode,
                        case RANGE_PRAM:
                                e820[i].type = E820_PRAM;
                                break;
+                       case RANGE_SOFT_RESERVED:
+                               e820[i].type = E820_SOFT_RESERVED;
+                               break;
                        default:
                        case RANGE_RESERVED:
                                e820[i].type = E820_RESERVED;
kexec/firmware_memmap.c +2 -0
index 457c3dc9a6..fa0c22140a 100644
@@ -182,6 +182,8 @@ static int parse_memmap_entry(const char *entry, struct memory_range *range)
                range->type = RANGE_RESERVED;
        else if (strcmp(type, "Reserved") == 0)
                range->type = RANGE_RESERVED;
+        else if (strcmp(type, "Soft Reserved") == 0)
+                range->type = RANGE_SOFT_RESERVED;
        else if (strcmp(type, "Unknown E820 type") == 0)
                range->type = RANGE_RESERVED;
        else if (strcmp(type, "ACPI Non-volatile Storage") == 0)
kexec/kexec.h +1 -1
index 31c323f674..dbb27a7607 100644
@@ -139,6 +139,7 @@ struct memory_range {
 #define RANGE_UNCACHED 4
 #define RANGE_PMEM             6
 #define RANGE_PRAM             11
+#define RANGE_SOFT_RESERVED 0xefffffff
 };
 
 struct memory_ranges {
--

2.17.0

Signature · 14 lines
Jacek Tomaka
Principal Software Engineer

76 Kings Park Road
West Perth 6005 WA, Australia
tel +61 8 9287 4143
[email protected]
www.dug.com
www.dug.comwww.dug.com

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#3 lore raw
In reply to Jacek Tomaka

Hi,

Quoted 3 lines · Jacek Tomaka

Essentially catch up with e820 related changes in the kernel. Intel Sapphire Rappids MAX has high bandwidth memory which is precious resource that is better not allocated by the kernel.

Wondering what use cases you have encountered and want to use this patch to resolve. Could you say more about it?

Quoted 142 lines

Userspace later can enable soft reserved range using daxctl.

---
 include/x86/x86-linux.h               | 2 ++
 kexec/arch/i386/crashdump-x86.c       | 7 +++++++
 kexec/arch/i386/kexec-multiboot-x86.c | 1 +
 kexec/arch/i386/kexec-x86-common.c    | 5 +++++
 kexec/arch/i386/x86-linux-setup.c     | 3 +++
 kexec/firmware_memmap.c               | 2 ++
 kexec/kexec.h                         | 1 +
 7 files changed, 21 insertions(+)
include/x86/x86-linux.h +2 -0
index 9646102835..fbde93df94 100644
@@ -23,6 +23,8 @@ struct e820entry {
 #define E820_NVS	4
 #define E820_PMEM       7
 #define E820_PRAM       12
+#define E820_SOFT_RESERVED 0xefffffff
+
 } __attribute__((packed));
 #endif
 
kexec/arch/i386/crashdump-x86.c +7 -0
index a01031e570..49108b2032 100644
@@ -288,6 +288,10 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges,
 			type = RANGE_RESERVED;
 		} else if (memcmp(str, "Reserved\n", 9) == 0) {
 			type = RANGE_RESERVED;
+		} else if (memcmp(str, "soft reserved\n", 14) == 0 ) {
+			type = RANGE_SOFT_RESERVED;
+		} else if (memcmp(str, "Soft Reserved\n", 14) == 0 ) {
+			type = RANGE_SOFT_RESERVED;
 		} else if (memcmp(str, "GART\n", 5) == 0) {
 			gart_start = start;
 			gart_end = end;
@@ -615,6 +619,8 @@ static void cmdline_add_memmap_internal(char *cmdline, unsigned long startk,
 		strcat (str_mmap, "K@");
 	else if (type == RANGE_RESERVED)
 		strcat (str_mmap, "K$");
+	else if (type == RANGE_SOFT_RESERVED)
+		strcat (str_mmap, "K*");
 	else if (type == RANGE_ACPI || type == RANGE_ACPI_NVS)
 		strcat (str_mmap, "K#");
 	else if (type == RANGE_PRAM)
@@ -985,6 +991,7 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,
 		if ( !( mem_range[i].type == RANGE_ACPI
 			|| mem_range[i].type == RANGE_ACPI_NVS
 			|| mem_range[i].type == RANGE_RESERVED
+			|| mem_range[i].type == RANGE_SOFT_RESERVED
 			|| mem_range[i].type == RANGE_PMEM
 			|| mem_range[i].type == RANGE_PRAM))
 			continue;
kexec/arch/i386/kexec-multiboot-x86.c +1 -0
index 33c885a2fa..49d57cb5ae 100644
@@ -379,6 +379,7 @@ int multiboot_x86_load(int argc, char **argv, const char *buf, off_t len,
 			mmap[i].Type = 4;
 			break;
 		case RANGE_RESERVED:
+		case RANGE_SOFT_RESERVED:
 		default:
 			mmap[i].Type = 2;  /* Not RAM (reserved) */
 		}
kexec/arch/i386/kexec-x86-common.c +5 -0
index ffc95a9e43..116c4f4fd3 100644
@@ -99,6 +99,9 @@ static int get_memory_ranges_proc_iomem(struct memory_range **range, int *ranges
 		else if (strncasecmp(str, "reserved\n", 9) == 0) {
 			type = RANGE_RESERVED;
 		}
+		else if (strncasecmp(str, "soft reserved\n", 9) == 0) {
+			type = RANGE_SOFT_RESERVED;
+		}
 		else if (memcmp(str, "ACPI Tables\n", 12) == 0) {
 			type = RANGE_ACPI;
 		}
@@ -170,6 +173,8 @@ unsigned xen_e820_to_kexec_type(uint32_t type)
 			return RANGE_PMEM;
 		case E820_PRAM:
 			return RANGE_PRAM;
+		case E820_SOFT_RESERVED;
+			return RANGE_SOFT_RESERVED;
 		case E820_RESERVED:
 		default:
 			return RANGE_RESERVED;
kexec/arch/i386/x86-linux-setup.c +3 -0
index 73251b9339..afc83fe729 100644
@@ -755,6 +755,9 @@ static void add_e820_map_from_mr(struct x86_linux_param_header *real_mode,
 			case RANGE_PRAM:
 				e820[i].type = E820_PRAM;
 				break;
+			case RANGE_SOFT_RESERVED:
+				e820[i].type = E820_SOFT_RESERVED;
+				break;
 			default:
 			case RANGE_RESERVED:
 				e820[i].type = E820_RESERVED;
kexec/firmware_memmap.c +2 -0
index 457c3dc9a6..fa0c22140a 100644
@@ -182,6 +182,8 @@ static int parse_memmap_entry(const char *entry, struct memory_range *range)
 		range->type = RANGE_RESERVED;
 	else if (strcmp(type, "Reserved") == 0)
 		range->type = RANGE_RESERVED;
+        else if (strcmp(type, "Soft Reserved") == 0)
+                range->type = RANGE_SOFT_RESERVED;
 	else if (strcmp(type, "Unknown E820 type") == 0)
 		range->type = RANGE_RESERVED;
 	else if (strcmp(type, "ACPI Non-volatile Storage") == 0)
kexec/kexec.h +1 -0
index 31c323f674..dbb27a7607 100644
@@ -139,6 +139,7 @@ struct memory_range {
 #define RANGE_UNCACHED	4
 #define RANGE_PMEM		6
 #define RANGE_PRAM		11
+#define RANGE_SOFT_RESERVED 0xefffffff
 };
 
 struct memory_ranges {
Signature · 7 lines
2.17.0


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

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

#4 lore raw

Hi Boaquan,

Quoted 2 lines

Wondering what use cases you have encountered and want to use this patch to resolve. Could you say more about it?

Sure, we are using genders to store kernel arguments for each machine so that they are version controlled.
In order to apply them we boot buildroot kernel, download destination kernel, read arguments to be passed,
then kexec.

In general it works fine, but some of our machines are Sapphire Rapids Max and without kexec understanding soft
reservations we end up with 2GB less total memory, which in general would not be a big deal but I think it is the
HBM memory that is wasted.

Regards.
Jacek Tomaka

Quoted 154 lines · Baoquan He

Hi,

Quoted 3 lines · Jacek Tomaka

Essentially catch up with e820 related changes in the kernel. Intel Sapphire Rappids MAX has high bandwidth memory which is precious resource that is better not allocated by the kernel.

Wondering what use cases you have encountered and want to use this patch to resolve. Could you say more about it?

Quoted 142 lines

Userspace later can enable soft reserved range using daxctl.

---
 include/x86/x86-linux.h               | 2 ++
 kexec/arch/i386/crashdump-x86.c       | 7 +++++++
 kexec/arch/i386/kexec-multiboot-x86.c | 1 +
 kexec/arch/i386/kexec-x86-common.c    | 5 +++++
 kexec/arch/i386/x86-linux-setup.c     | 3 +++
 kexec/firmware_memmap.c               | 2 ++
 kexec/kexec.h                         | 1 +
 7 files changed, 21 insertions(+)
include/x86/x86-linux.h +2 -0
index 9646102835..fbde93df94 100644
@@ -23,6 +23,8 @@ struct e820entry {
 #define E820_NVS     4
 #define E820_PMEM       7
 #define E820_PRAM       12
+#define E820_SOFT_RESERVED 0xefffffff
+
 } __attribute__((packed));
 #endif
 
kexec/arch/i386/crashdump-x86.c +7 -0
index a01031e570..49108b2032 100644
@@ -288,6 +288,10 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges,
                      type = RANGE_RESERVED;
              } else if (memcmp(str, "Reserved\n", 9) == 0) {
                      type = RANGE_RESERVED;
+             } else if (memcmp(str, "soft reserved\n", 14) == 0 ) {
+                     type = RANGE_SOFT_RESERVED;
+             } else if (memcmp(str, "Soft Reserved\n", 14) == 0 ) {
+                     type = RANGE_SOFT_RESERVED;
              } else if (memcmp(str, "GART\n", 5) == 0) {
                      gart_start = start;
                      gart_end = end;
@@ -615,6 +619,8 @@ static void cmdline_add_memmap_internal(char *cmdline, unsigned long startk,
              strcat (str_mmap, "K@");
      else if (type == RANGE_RESERVED)
              strcat (str_mmap, "K$");
+     else if (type == RANGE_SOFT_RESERVED)
+             strcat (str_mmap, "K*");
      else if (type == RANGE_ACPI || type == RANGE_ACPI_NVS)
              strcat (str_mmap, "K#");
      else if (type == RANGE_PRAM)
@@ -985,6 +991,7 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,
              if ( !( mem_range[i].type == RANGE_ACPI
                      || mem_range[i].type == RANGE_ACPI_NVS
                      || mem_range[i].type == RANGE_RESERVED
+                     || mem_range[i].type == RANGE_SOFT_RESERVED
                      || mem_range[i].type == RANGE_PMEM
                      || mem_range[i].type == RANGE_PRAM))
                      continue;
kexec/arch/i386/kexec-multiboot-x86.c +1 -0
index 33c885a2fa..49d57cb5ae 100644
@@ -379,6 +379,7 @@ int multiboot_x86_load(int argc, char **argv, const char *buf, off_t len,
                      mmap[i].Type = 4;
                      break;
              case RANGE_RESERVED:
+             case RANGE_SOFT_RESERVED:
              default:
                      mmap[i].Type = 2;  /* Not RAM (reserved) */
              }
kexec/arch/i386/kexec-x86-common.c +5 -0
index ffc95a9e43..116c4f4fd3 100644
@@ -99,6 +99,9 @@ static int get_memory_ranges_proc_iomem(struct memory_range **range, int *ranges
              else if (strncasecmp(str, "reserved\n", 9) == 0) {
                      type = RANGE_RESERVED;
              }
+             else if (strncasecmp(str, "soft reserved\n", 9) == 0) {
+                     type = RANGE_SOFT_RESERVED;
+             }
              else if (memcmp(str, "ACPI Tables\n", 12) == 0) {
                      type = RANGE_ACPI;
              }
@@ -170,6 +173,8 @@ unsigned xen_e820_to_kexec_type(uint32_t type)
                      return RANGE_PMEM;
              case E820_PRAM:
                      return RANGE_PRAM;
+             case E820_SOFT_RESERVED;
+                     return RANGE_SOFT_RESERVED;
              case E820_RESERVED:
              default:
                      return RANGE_RESERVED;
kexec/arch/i386/x86-linux-setup.c +3 -0
index 73251b9339..afc83fe729 100644
@@ -755,6 +755,9 @@ static void add_e820_map_from_mr(struct x86_linux_param_header *real_mode,
                      case RANGE_PRAM:
                              e820[i].type = E820_PRAM;
                              break;
+                     case RANGE_SOFT_RESERVED:
+                             e820[i].type = E820_SOFT_RESERVED;
+                             break;
                      default:
                      case RANGE_RESERVED:
                              e820[i].type = E820_RESERVED;
kexec/firmware_memmap.c +2 -0
index 457c3dc9a6..fa0c22140a 100644
@@ -182,6 +182,8 @@ static int parse_memmap_entry(const char *entry, struct memory_range *range)
              range->type = RANGE_RESERVED;
      else if (strcmp(type, "Reserved") == 0)
              range->type = RANGE_RESERVED;
+        else if (strcmp(type, "Soft Reserved") == 0)
+                range->type = RANGE_SOFT_RESERVED;
      else if (strcmp(type, "Unknown E820 type") == 0)
              range->type = RANGE_RESERVED;
      else if (strcmp(type, "ACPI Non-volatile Storage") == 0)
kexec/kexec.h +1 -1
index 31c323f674..dbb27a7607 100644
@@ -139,6 +139,7 @@ struct memory_range {
 #define RANGE_UNCACHED       4
 #define RANGE_PMEM           6
 #define RANGE_PRAM           11
+#define RANGE_SOFT_RESERVED 0xefffffff
 };
 
 struct memory_ranges {
--

2.17.0

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

Signature · 14 lines
Jacek Tomaka
Principal Software Engineer

76 Kings Park Road
West Perth 6005 WA, Australia
tel +61 8 9287 4143
[email protected]
www.dug.com
www.dug.comwww.dug.com

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#5 lore raw
Quoted 11 lines · Jacek Tomaka

Hi Boaquan,

Quoted 2 lines

Wondering what use cases you have encountered and want to use this patch to resolve. Could you say more about it?

Sure, we are using genders to store kernel arguments for each machine so that they are version controlled.
In order to apply them we boot buildroot kernel, download destination kernel, read arguments to be passed,
then kexec.

Quoted 5 lines

In general it works fine, but some of our machines are Sapphire Rapids Max and without kexec understanding soft
reservations we end up with 2GB less total memory, which in general would not be a big deal but I think it is the
HBM memory that is wasted.

Ok, thanks for these details.

So you are using kexec_load interface, does kexec_file_load interface work well in this case?

Quoted 151 lines · Baoquan He
Quoted 148 lines

Hi,

Quoted 3 lines · Jacek Tomaka

Essentially catch up with e820 related changes in the kernel. Intel Sapphire Rappids MAX has high bandwidth memory which is precious resource that is better not allocated by the kernel.

Wondering what use cases you have encountered and want to use this patch to resolve. Could you say more about it?

Quoted 137 lines

Userspace later can enable soft reserved range using daxctl.

---
 include/x86/x86-linux.h               | 2 ++
 kexec/arch/i386/crashdump-x86.c       | 7 +++++++
 kexec/arch/i386/kexec-multiboot-x86.c | 1 +
 kexec/arch/i386/kexec-x86-common.c    | 5 +++++
 kexec/arch/i386/x86-linux-setup.c     | 3 +++
 kexec/firmware_memmap.c               | 2 ++
 kexec/kexec.h                         | 1 +
 7 files changed, 21 insertions(+)
include/x86/x86-linux.h +2 -0
index 9646102835..fbde93df94 100644
@@ -23,6 +23,8 @@ struct e820entry {
 #define E820_NVS     4
 #define E820_PMEM       7
 #define E820_PRAM       12
+#define E820_SOFT_RESERVED 0xefffffff
+
 } __attribute__((packed));
 #endif
 
kexec/arch/i386/crashdump-x86.c +7 -0
index a01031e570..49108b2032 100644
@@ -288,6 +288,10 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges,
                      type = RANGE_RESERVED;
              } else if (memcmp(str, "Reserved\n", 9) == 0) {
                      type = RANGE_RESERVED;
+             } else if (memcmp(str, "soft reserved\n", 14) == 0 ) {
+                     type = RANGE_SOFT_RESERVED;
+             } else if (memcmp(str, "Soft Reserved\n", 14) == 0 ) {
+                     type = RANGE_SOFT_RESERVED;
              } else if (memcmp(str, "GART\n", 5) == 0) {
                      gart_start = start;
                      gart_end = end;
@@ -615,6 +619,8 @@ static void cmdline_add_memmap_internal(char *cmdline, unsigned long startk,
              strcat (str_mmap, "K@");
      else if (type == RANGE_RESERVED)
              strcat (str_mmap, "K$");
+     else if (type == RANGE_SOFT_RESERVED)
+             strcat (str_mmap, "K*");
      else if (type == RANGE_ACPI || type == RANGE_ACPI_NVS)
              strcat (str_mmap, "K#");
      else if (type == RANGE_PRAM)
@@ -985,6 +991,7 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,
              if ( !( mem_range[i].type == RANGE_ACPI
                      || mem_range[i].type == RANGE_ACPI_NVS
                      || mem_range[i].type == RANGE_RESERVED
+                     || mem_range[i].type == RANGE_SOFT_RESERVED
                      || mem_range[i].type == RANGE_PMEM
                      || mem_range[i].type == RANGE_PRAM))
                      continue;
kexec/arch/i386/kexec-multiboot-x86.c +1 -0
index 33c885a2fa..49d57cb5ae 100644
@@ -379,6 +379,7 @@ int multiboot_x86_load(int argc, char **argv, const char *buf, off_t len,
                      mmap[i].Type = 4;
                      break;
              case RANGE_RESERVED:
+             case RANGE_SOFT_RESERVED:
              default:
                      mmap[i].Type = 2;  /* Not RAM (reserved) */
              }
kexec/arch/i386/kexec-x86-common.c +5 -0
index ffc95a9e43..116c4f4fd3 100644
@@ -99,6 +99,9 @@ static int get_memory_ranges_proc_iomem(struct memory_range **range, int *ranges
              else if (strncasecmp(str, "reserved\n", 9) == 0) {
                      type = RANGE_RESERVED;
              }
+             else if (strncasecmp(str, "soft reserved\n", 9) == 0) {
+                     type = RANGE_SOFT_RESERVED;
+             }
              else if (memcmp(str, "ACPI Tables\n", 12) == 0) {
                      type = RANGE_ACPI;
              }
@@ -170,6 +173,8 @@ unsigned xen_e820_to_kexec_type(uint32_t type)
                      return RANGE_PMEM;
              case E820_PRAM:
                      return RANGE_PRAM;
+             case E820_SOFT_RESERVED;
+                     return RANGE_SOFT_RESERVED;
              case E820_RESERVED:
              default:
                      return RANGE_RESERVED;
kexec/arch/i386/x86-linux-setup.c +3 -0
index 73251b9339..afc83fe729 100644
@@ -755,6 +755,9 @@ static void add_e820_map_from_mr(struct x86_linux_param_header *real_mode,
                      case RANGE_PRAM:
                              e820[i].type = E820_PRAM;
                              break;
+                     case RANGE_SOFT_RESERVED:
+                             e820[i].type = E820_SOFT_RESERVED;
+                             break;
                      default:
                      case RANGE_RESERVED:
                              e820[i].type = E820_RESERVED;
kexec/firmware_memmap.c +2 -0
index 457c3dc9a6..fa0c22140a 100644
@@ -182,6 +182,8 @@ static int parse_memmap_entry(const char *entry, struct memory_range *range)
              range->type = RANGE_RESERVED;
      else if (strcmp(type, "Reserved") == 0)
              range->type = RANGE_RESERVED;
+        else if (strcmp(type, "Soft Reserved") == 0)
+                range->type = RANGE_SOFT_RESERVED;
      else if (strcmp(type, "Unknown E820 type") == 0)
              range->type = RANGE_RESERVED;
      else if (strcmp(type, "ACPI Non-volatile Storage") == 0)
kexec/kexec.h +1 -1
index 31c323f674..dbb27a7607 100644
@@ -139,6 +139,7 @@ struct memory_range {
 #define RANGE_UNCACHED       4
 #define RANGE_PMEM           6
 #define RANGE_PRAM           11
+#define RANGE_SOFT_RESERVED 0xefffffff
 };
 
 struct memory_ranges {
--

2.17.0

Quoted 19 lines
Quoted 6 lines
Quoted 5 lines

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

Signature · 9 lines
Jacek Tomaka
Principal Software Engineer

76 Kings Park Road
West Perth 6005 WA, Australia
tel +61 8 9287 4143
[email protected]
www.dug.com
www.dug.comwww.dug.com

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