Patch "mm/memory_hotplug: handle memblock_add_node() failures in add_memory_resource()" has been added to the 5.15-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    mm/memory_hotplug: handle memblock_add_node() failures in add_memory_resource()

to the 5.15-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     mm-memory_hotplug-handle-memblock_add_node-failures-.patch
and it can be found in the queue-5.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit d23ca92bf201f0e24e446dba77aca242c2e41e45
Author: David Hildenbrand <david@xxxxxxxxxx>
Date:   Fri Nov 5 13:44:42 2021 -0700

    mm/memory_hotplug: handle memblock_add_node() failures in add_memory_resource()
    
    [ Upstream commit 53d38316ab2017a7c0d733765b521700aa357ec9 ]
    
    Patch series "mm/memory_hotplug: full support for add_memory_driver_managed() with CONFIG_ARCH_KEEP_MEMBLOCK", v2.
    
    Architectures that require CONFIG_ARCH_KEEP_MEMBLOCK=y, such as arm64,
    don't cleanly support add_memory_driver_managed() yet.  Most
    prominently, kexec_file can still end up placing kexec images on such
    driver-managed memory, resulting in undesired behavior, for example,
    having kexec images located on memory not part of the firmware-provided
    memory map.
    
    Teaching kexec to not place images on driver-managed memory is
    especially relevant for virtio-mem.  Details can be found in commit
    7b7b27214bba ("mm/memory_hotplug: introduce
    add_memory_driver_managed()").
    
    Extend memblock with a new flag and set it from memory hotplug code when
    applicable.  This is required to fully support virtio-mem on arm64,
    making also kexec_file behave like on x86-64.
    
    This patch (of 2):
    
    If memblock_add_node() fails, we're most probably running out of memory.
    While this is unlikely to happen, it can happen and having memory added
    without a memblock can be problematic for architectures that use
    memblock to detect valid memory.  Let's fail in a nice way instead of
    silently ignoring the error.
    
    Link: https://lkml.kernel.org/r/20211004093605.5830-1-david@xxxxxxxxxx
    Link: https://lkml.kernel.org/r/20211004093605.5830-2-david@xxxxxxxxxx
    Signed-off-by: David Hildenbrand <david@xxxxxxxxxx>
    Cc: Mike Rapoport <rppt@xxxxxxxxxx>
    Cc: Michal Hocko <mhocko@xxxxxxxx>
    Cc: Oscar Salvador <osalvador@xxxxxxx>
    Cc: Jianyong Wu <Jianyong.Wu@xxxxxxx>
    Cc: "Aneesh Kumar K . V" <aneesh.kumar@xxxxxxxxxxxxx>
    Cc: Vineet Gupta <vgupta@xxxxxxxxxx>
    Cc: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>
    Cc: Huacai Chen <chenhuacai@xxxxxxxxxx>
    Cc: Jiaxun Yang <jiaxun.yang@xxxxxxxxxxx>
    Cc: Thomas Bogendoerfer <tsbogend@xxxxxxxxxxxxxxxx>
    Cc: Heiko Carstens <hca@xxxxxxxxxxxxx>
    Cc: Vasily Gorbik <gor@xxxxxxxxxxxxx>
    Cc: Christian Borntraeger <borntraeger@xxxxxxxxxx>
    Cc: Eric Biederman <ebiederm@xxxxxxxxxxxx>
    Cc: Arnd Bergmann <arnd@xxxxxxxx>
    Cc: Shahab Vahedi <shahab@xxxxxxxxxxxx>
    Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
    Stable-dep-of: c7206e7bd214 ("MIPS: Loongson64: Handle more memory types passed from firmware")
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index bf611c55fc66b..bc52a9d201ea6 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -1384,8 +1384,11 @@ int __ref add_memory_resource(int nid, struct resource *res, mhp_t mhp_flags)
 
 	mem_hotplug_begin();
 
-	if (IS_ENABLED(CONFIG_ARCH_KEEP_MEMBLOCK))
-		memblock_add_node(start, size, nid);
+	if (IS_ENABLED(CONFIG_ARCH_KEEP_MEMBLOCK)) {
+		ret = memblock_add_node(start, size, nid);
+		if (ret)
+			goto error_mem_hotplug_end;
+	}
 
 	ret = __try_online_node(nid, false);
 	if (ret < 0)
@@ -1458,6 +1461,7 @@ int __ref add_memory_resource(int nid, struct resource *res, mhp_t mhp_flags)
 		rollback_node_hotadd(nid);
 	if (IS_ENABLED(CONFIG_ARCH_KEEP_MEMBLOCK))
 		memblock_remove(start, size);
+error_mem_hotplug_end:
 	mem_hotplug_done();
 	return ret;
 }




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux