Skip to content

Commit

Permalink
init: Add CONFIG_ROCKCHIP_THUNDER_BOOT_DEFER_FREE_MEMBLOCK
Browse files Browse the repository at this point in the history
Allow defer free large memblock to Buddy allocator work on
!CONFIG_ROCKCHIP_THUNDER_BOOT.

Change-Id: I30f851f648b007d1629eed27ba464ad2d7425577
Signed-off-by: Tao Huang <huangtao@rock-chips.com>
  • Loading branch information
rkhuangtao committed Mar 1, 2024
1 parent 286ef81 commit 8ca3ffc
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
15 changes: 15 additions & 0 deletions drivers/soc/rockchip/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion include/linux/memblock.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion init/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions mm/memblock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 8ca3ffc

Please sign in to comment.