ANDROID: memblock: support memsize reusable to consider as reusable
Sometimes we'd like to include some memory region as reusable even though it is actually not CMA type. This could be applied to cleancache memory. If we want the cleancache memory to be considered as reusable, add reusable in its device tree description, then memsize will say it is reusuable and this commit will add its size to the system total memory size. Bug: 340432773 Signed-off-by: Jaewon Kim <jaewon31.kim@samsung.com> Link: https://lore.kernel.org/linux-mm/20240521023957.2587005-11-jaewon31.kim@samsung.com/ Change-Id: I0bf8006a397ae7a7f136281c9712dde9dffe38b2
This commit is contained in:
committed by
Suren Baghdasaryan
parent
08e2d09578
commit
99b134ba86
@@ -542,6 +542,8 @@ static void __init fdt_init_reserved_mem_node(struct reserved_mem *rmem)
|
||||
|
||||
memblock_memsize_record(rmem->name, rmem->base,
|
||||
rmem->size, nomap, reusable);
|
||||
if (reusable && !of_flat_dt_is_compatible(node, "shared-dma-pool"))
|
||||
memblock_memsize_mod_reusable_size(rmem->size);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -603,6 +603,7 @@ extern void memblock_memsize_mod_kernel_size(long size);
|
||||
extern void __init memblock_memsize_mod_memmap_size(long size);
|
||||
extern void __init memblock_memsize_kernel_code_data(unsigned long code,
|
||||
unsigned long data, unsigned long ro, unsigned long bss);
|
||||
extern void memblock_memsize_mod_reusable_size(long size);
|
||||
#else
|
||||
static inline void __init_memblock memblock_memsize_record(const char *name,
|
||||
phys_addr_t base, phys_addr_t size, bool nomap, bool reusable) { }
|
||||
@@ -613,6 +614,7 @@ static inline void memblock_memsize_mod_kernel_size(long size) { }
|
||||
static inline void __init memblock_memsize_mod_memmap_size(long size) { }
|
||||
static inline void __init memblock_memsize_kernel_code_data(unsigned long code,
|
||||
unsigned long data, unsigned long ro, unsigned long bss) { }
|
||||
static inline void memblock_memsize_mod_reusable_size(long size) { }
|
||||
#endif
|
||||
|
||||
#endif /* _LINUX_MEMBLOCK_H */
|
||||
|
||||
@@ -2084,6 +2084,7 @@ static unsigned long memsize_code __initdata_memblock;
|
||||
static unsigned long memsize_data __initdata_memblock;
|
||||
static unsigned long memsize_ro __initdata_memblock;
|
||||
static unsigned long memsize_bss __initdata_memblock;
|
||||
static long memsize_reusable_size;
|
||||
|
||||
void __init memblock_memsize_enable_tracking(void)
|
||||
{
|
||||
@@ -2133,6 +2134,11 @@ static void __init_memblock memsize_get_valid_name(char *valid_name, const char
|
||||
strscpy(valid_name, head, valid_size);
|
||||
}
|
||||
|
||||
void memblock_memsize_mod_reusable_size(long size)
|
||||
{
|
||||
memsize_reusable_size += size;
|
||||
}
|
||||
|
||||
static inline struct memsize_rgn_struct * __init_memblock memsize_get_new_rgn(void)
|
||||
{
|
||||
if (memsize_rgn_count == ARRAY_SIZE(memsize_rgn)) {
|
||||
@@ -2802,6 +2808,7 @@ static int memblock_memsize_show(struct seq_file *m, void *private)
|
||||
etc -= memsize_code + memsize_data + memsize_ro + memsize_bss +
|
||||
memsize_memmap;
|
||||
|
||||
system += memsize_reusable_size;
|
||||
sort(memsize_rgn, memsize_rgn_count,
|
||||
sizeof(memsize_rgn[0]), memsize_rgn_cmp, NULL);
|
||||
for (i = 0; i < memsize_rgn_count; i++) {
|
||||
|
||||
Reference in New Issue
Block a user