From 8ca3ffc967acded5184a1f4338f32aedaafef5e1 Mon Sep 17 00:00:00 2001 From: Tao Huang Date: Wed, 28 Feb 2024 17:04:57 +0800 Subject: [PATCH] init: Add CONFIG_ROCKCHIP_THUNDER_BOOT_DEFER_FREE_MEMBLOCK Allow defer free large memblock to Buddy allocator work on !CONFIG_ROCKCHIP_THUNDER_BOOT. Change-Id: I30f851f648b007d1629eed27ba464ad2d7425577 Signed-off-by: Tao Huang --- drivers/soc/rockchip/Kconfig | 15 +++++++++++++++ include/linux/memblock.h | 2 +- init/main.c | 2 +- mm/memblock.c | 6 +++--- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/drivers/soc/rockchip/Kconfig b/drivers/soc/rockchip/Kconfig index c3f7a24942a8..2f284f17602e 100644 --- a/drivers/soc/rockchip/Kconfig +++ b/drivers/soc/rockchip/Kconfig @@ -250,10 +250,25 @@ config ROCKCHIP_MINI_KERNEL config ROCKCHIP_THUNDER_BOOT bool "Rockchip Thunder Boot support" depends on NO_GKI + select ROCKCHIP_THUNDER_BOOT_DEFER_FREE_MEMBLOCK if SMP help Say y here to enable Rockchip thunder boot support. This option make the kernel boot faster. +config ROCKCHIP_THUNDER_BOOT_DEFER_FREE_MEMBLOCK + bool "Defer free large memblock to Buddy allocator" + depends on SMP + depends on NO_GKI + help + The physical memory of a system is divided into several types, like + memory reserved for device, for kernel pagetable, etc. The remaining + area is for Buddy allocator. Normally, The memory for Buddy is consist + of different size blocks, so, under meeting the memory request of kernel + booting, we can defer free the large block size to Buddy which can be + done later in work queue in parallel to other kernel threads, and the + size of the large block can be defined in kernel command line + by "defer_free_block_size" boot parameter. + config ROCKCHIP_THUNDER_BOOT_MMC bool "Rockchip Thunder Boot from MMC" depends on ROCKCHIP_THUNDER_BOOT diff --git a/include/linux/memblock.h b/include/linux/memblock.h index a3eb462a4032..758a063f9b8f 100644 --- a/include/linux/memblock.h +++ b/include/linux/memblock.h @@ -24,7 +24,7 @@ extern unsigned long max_pfn; */ extern unsigned long long max_possible_pfn; -#ifdef CONFIG_ROCKCHIP_THUNDER_BOOT +#ifdef CONFIG_ROCKCHIP_THUNDER_BOOT_DEFER_FREE_MEMBLOCK extern int defer_free_memblock(void *unused); #endif diff --git a/init/main.c b/init/main.c index 396246088c63..fc86c67eeb57 100644 --- a/init/main.c +++ b/init/main.c @@ -1819,7 +1819,7 @@ static noinline void __init kernel_init_freeable(void) smp_init(); sched_init_smp(); -#if defined(CONFIG_ROCKCHIP_THUNDER_BOOT) && defined(CONFIG_SMP) +#ifdef CONFIG_ROCKCHIP_THUNDER_BOOT_DEFER_FREE_MEMBLOCK kthread_run(defer_free_memblock, NULL, "defer_mem"); #endif diff --git a/mm/memblock.c b/mm/memblock.c index 1ee24945bf31..f71c8b0f8ac7 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -101,7 +101,7 @@ struct pglist_data __refdata contig_page_data; EXPORT_SYMBOL(contig_page_data); #endif -#if defined(CONFIG_ROCKCHIP_THUNDER_BOOT) && defined(CONFIG_SMP) +#ifdef CONFIG_ROCKCHIP_THUNDER_BOOT_DEFER_FREE_MEMBLOCK static int db_count __initdata; #define DB_COUNT_MAX 4 @@ -2066,7 +2066,7 @@ static void __init __free_pages_memory(unsigned long start, unsigned long end) } } -#if defined(CONFIG_ROCKCHIP_THUNDER_BOOT) && defined(CONFIG_SMP) +#ifdef CONFIG_ROCKCHIP_THUNDER_BOOT_DEFER_FREE_MEMBLOCK int __init defer_free_memblock(void *unused) { int i; @@ -2100,7 +2100,7 @@ static unsigned long __init __free_memory_core(phys_addr_t start, if (start_pfn >= end_pfn) return 0; -#if defined(CONFIG_ROCKCHIP_THUNDER_BOOT) && defined(CONFIG_SMP) +#ifdef CONFIG_ROCKCHIP_THUNDER_BOOT_DEFER_FREE_MEMBLOCK pr_debug("%s, start = %pa, end = %pa\n", __func__, &start, &end); if ((end - start) > defer_free_block_size && (db_count < ARRAY_SIZE(db))) { db[db_count].defer_start = start_pfn;