Hi tj, I have resent the v2 patch-set. Would you please give some more comments about the memblock and x86 booting code modification ?
And I'm also discussing with the ACPICA guys about the implementation on ACPI side. I hope we can catch up with 3.12 this time. Thanks. On 08/02/2013 05:14 PM, Tang Chen wrote:
At early time, memblock will reserve some memory for the kernel, such as the kernel code and data segments, initrd file, and so on, which means the kernel resides in these memory regions. Even if these memory regions are hotpluggable, we should not mark them as hotpluggable. Otherwise the kernel won't have enough memory to boot. This patch finds out which memory regions the kernel resides in, and skip them when finding all hotpluggable memory regions. Signed-off-by: Tang Chen<tangc...@cn.fujitsu.com> Reviewed-by: Zhang Yanfei<zhangyan...@cn.fujitsu.com> --- mm/memory_hotplug.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 45 insertions(+), 0 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index ef9ccf8..10a30ef 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -31,6 +31,7 @@ #include<linux/firmware-map.h> #include<linux/stop_machine.h> #include<linux/acpi.h> +#include<linux/memblock.h> #include<asm/tlbflush.h> @@ -93,6 +94,40 @@ static void release_memory_resource(struct resource *res) #ifdef CONFIG_ACPI_NUMA /** + * kernel_resides_in_range - Check if kernel resides in a memory region. + * @base: The base address of the memory region. + * @length: The length of the memory region. + * + * This function is used at early time. It iterates memblock.reserved and check + * if the kernel has used any memory in [@base, @base + @length). + * + * Return true if the kernel resides in the memory region, false otherwise. + */ +static bool __init kernel_resides_in_region(phys_addr_t base, u64 length) +{ + int i; + phys_addr_t start, end; + struct memblock_region *region; + struct memblock_type *reserved =&memblock.reserved; + + for (i = 0; i< reserved->cnt; i++) { + region =&reserved->regions[i]; + + if (region->flags != MEMBLOCK_HOTPLUG) + continue; + + start = region->base; + end = region->base + region->size; + if (end<= base || start>= base + length) + continue; + + return true; + } + + return false; +} + +/** * find_hotpluggable_memory - Find out hotpluggable memory from ACPI SRAT. * * This function did the following: @@ -129,6 +164,16 @@ void __init find_hotpluggable_memory(void) while (ACPI_SUCCESS(acpi_hotplug_mem_affinity(srat_vaddr,&base, &size,&offset))) { + /* + * At early time, memblock will reserve some memory for the + * kernel, such as the kernel code and data segments, initrd + * file, and so on,which means the kernel resides in these + * memory regions. These regions should not be hotpluggable. + * So do not mark them as hotpluggable. + */ + if (kernel_resides_in_region(base, size)) + continue; + /* Will mark hotpluggable memory regions here */ }
-- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/