ANDROID: memblock: track kernel size on memsize

Some memory regions are already being tracked by previous patches. But
there are many memory allocations from memblock and frees to memblock
during the boot time.

This patch tracks the memblock size used for the common kernel. To to
this, tracking memblock size is disabled for some memory handling logics
like early param, device tree, and default cma size.

For precise kernel size, this patch counts not actually freed size to
buddy at boot time, and does not count freed size from ramdisk and init
section.

Additionally this patch does one important thing. This patch blocks
memblock_add_range of memblock_remove_range not to update memsize if
free pages were already released to the buddy allocator.

This is an example. The kernel size is newly added by this patch.

 .kernel    :  135137 KB
 .unusable  :  788073 KB
 .reusable  :  294912 KB

Bug: 340432773
Signed-off-by: Jaewon Kim <jaewon31.kim@samsung.com>
Link: https://lore.kernel.org/linux-mm/20240521023957.2587005-8-jaewon31.kim@samsung.com/
Change-Id: Ice0c2aa568385490a3468f7567b4b8c083e043ec
This commit is contained in:
Jaewon Kim
2020-06-30 10:32:13 +09:00
committed by Suren Baghdasaryan
parent e8e18b40c0
commit 75fe456d4e
5 changed files with 79 additions and 4 deletions
+5 -2
View File
@@ -278,10 +278,11 @@ int __init dma_contiguous_reserve_area(phys_addr_t size, phys_addr_t base,
{
int ret;
memblock_memsize_disable_tracking();
ret = cma_declare_contiguous(base, size, limit, 0, 0, fixed,
"reserved", res_cma);
if (ret)
return ret;
goto out;
/* Architecture specific contiguous memory fixup. */
dma_contiguous_early_fixup(cma_get_base(*res_cma),
@@ -289,7 +290,9 @@ int __init dma_contiguous_reserve_area(phys_addr_t size, phys_addr_t base,
memblock_memsize_record("dma_cma", cma_get_base(*res_cma),
cma_get_size(*res_cma), false, true);
return 0;
out:
memblock_memsize_enable_tracking();
return ret;
}
/**