Hi Wonhyuk, Thank you for the reply (I found it this morning :)) Yes, I saw your blog and it helped. And I later found in a book that this memblock puts the kernel image, initrd, page tables, dtb,.. and the "reserved-memory" regions from the dtb in its memblock.reserved regions. Have a nice day! Chan Kim
-----Original Message----- From: Wonhyuk Yang <vvghjk1234@gmail.com> Sent: Friday, June 24, 2022 3:41 PM To: Chan Kim <ckim@etri.re.kr> Cc: kernelnewbies <kernelnewbies@kernelnewbies.org> Subject: Re: A question about memblock.reserved
On Thu, Jun 23, 2022 at 2:25 PM Chan Kim <ckim@etri.re.kr> wrote:
I mm/memblock.c I see this struct memblock memblock which is initialized
with empty list.
static struct memblock_region memblock_memory_init_regions[INIT_MEMBLOCK_REGIONS] __initdata_memblock; static struct memblock_region memblock_reserved_init_regions[INIT_MEMBLOCK_RESERVED_REGIONS] __initdata_memblock;
struct memblock memblock __initdata_memblock = { .memory.regions = memblock_memory_init_regions, .memory.cnt = 1, /* empty dummy entry */ .memory.max = INIT_MEMBLOCK_REGIONS, .memory.name = "memory", .reserved.regions = memblock_reserved_init_regions, .reserved.cnt = 1, /* empty dummy entry */ .reserved.max = INIT_MEMBLOCK_RESERVED_REGIONS, .reserved.name = "reserved", .bottom_up = false, .current_limit = MEMBLOCK_ALLOC_ANYWHERE, };
My question is : we can speicify "reserved-memory" in the device tree.
Some drivers use the reserved memory for its own use.
Then, are the 'reserved-memory' regions are put into this memblock.reserved regions during the boot process?(I mean during dtb parsing).
Yes, reserved memblock is initialized while scanning the fdt. I'll attach some call graph below and I hope it helps you.
setup_arch () arm64_memblock_init () early_init_fdt_scan_reserved_mem () fdt_init_reserved_mem () fdt_scan_reserved_mem () __reserved_mem_reserve_reg () early_init_dt_reserve_memory_arch () memblock_reserve ()
Plus, I written some *scribbled* notes about this in Korean. I don't know if it will help, but I will attach it below.