Skip to contentSkip to conversation

memory: exit when hugepage allocation fails if mem-prealloc

PATCH In review Luiz Capitulino 2 participants 2 messages Jan 22, 2016 – Jan 26, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 memory: exit when hugepage allocation fails if mem-prealloc

When -mem-prealloc is passed on the command-line, the expected behavior is to exit if the hugepage allocation fails. However, this behavior is broken since commit cc57501dee which made hugepage allocation fall back to regular ram in case of faliure.

This commit restores the expected behavior for -mem-prealloc.

---
 numa.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
numa.c +5 -4
index 425ef8d..0e1638d 100644
@@ -418,12 +418,13 @@ static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner,
         Error *err = NULL;
         memory_region_init_ram_from_file(mr, owner, name, ram_size, false,
                                          mem_path, &err);
-
-        /* Legacy behavior: if allocation failed, fall back to
-         * regular RAM allocation.
-         */
         if (err) {
             error_report_err(err);
+            if (mem_prealloc)
+                exit(1);
+            /* Legacy behavior: if allocation failed, fall back to
+             * regular RAM allocation.
+             */
             memory_region_init_ram(mr, owner, name, ram_size, &error_fatal);
         }
 #else
Signature · 1 line
2.1.0
#1 lore raw
Quoted 25 lines · Luiz Capitulino

When -mem-prealloc is passed on the command-line, the expected behavior is to exit if the hugepage allocation fails. However, this behavior is broken since commit cc57501dee which made hugepage allocation fall back to regular ram in case of faliure.

This commit restores the expected behavior for -mem-prealloc.

---
 numa.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
numa.c +0 -4
index 425ef8d..0e1638d 100644
@@ -418,12 +418,13 @@ static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner,
         Error *err = NULL;
         memory_region_init_ram_from_file(mr, owner, name, ram_size, false,
                                          mem_path, &err);
-
-        /* Legacy behavior: if allocation failed, fall back to
-         * regular RAM allocation.
-         */

numa.c static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner, · line 430

Quoted 10 lines
numa.c +5 -0
         if (err) {
             error_report_err(err);
+            if (mem_prealloc)
+                exit(1);
+            /* Legacy behavior: if allocation failed, fall back to
+             * regular RAM allocation.
+             */
             memory_region_init_ram(mr, owner, name, ram_size, &error_fatal);
         }
 #else

Right, patch cc57501dee did the correct change but it was insufficient.
I'll add the braces for you and queue the patch.

Paolo