> On Fri, 13 Mar 2020 12:06:37 +0900, <kjhg4321@xxxxxxxxx> said: > > > In the __reserved_mem_reserve_reg() function, I found something that > > I couldn't easily understand. > > > > To get help, I sent an e-mail to this mailing list. > > > > if (first) { > > fdt_reserved_mem_save_node(node, uname, base, size); > > first = 0; > > } > > > > I found that fdt_reserved_mem_save_node() is called the regardless of > > memblock remove/reserve success. > > > > I think early_init_dt_reserve_memory_arch() can fail.(ex. for the lack > > of memblock's region) > > > > So I wonder there will be a situation where reserved_mem > > initialization will be executed without memory reservation. > > What you probably missed is that function is wrapped in a #ifdef > CONFIG_OF_EARLY_FLATTREE - and is called to read in the OF devicetree data and > save it in a form the kernel can use. > > So there usually shouldn't be a problem in reserving memory early in boot, > unless of course somebody bollixed up a devicetree entry and put in bad values > for base, size, and nomap. But, This is when the early memory allocation is not active. Therefore, if memblock's region[128] is full, memblock_reserve/remove() can fail.(Of course, there should be more than 128 reserved memory.) >However, fdt_reserved_mem_save_node() needs to happen anyhow, because that's >not initialiing the memory that wasn't actually reserved, it's recording the >fact that the devicetree had a reserved memory request in it, and that needs to >be remembered because there's a second pass over the devicetree data later on >(or so the comments in drivers/of/of_reserved_mem.c tell me). Yes, fdt_reserved_mem_save_node() just register the reseved memory in the reserve_mem. then, reserved_mem is passed to _reserved_mem_init_node(). But In this function, If the node is "cma", it will call rmem_cma_setup() and it will initializing the cma struct, So what I was wondering was wouldn't the cma structure be initialized without memory being reserved? _______________________________________________ Kernelnewbies mailing list Kernelnewbies@xxxxxxxxxxxxxxxxx https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies _______________________________________________ Kernelnewbies mailing list Kernelnewbies@xxxxxxxxxxxxxxxxx https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies