From ea094c64aa534e3e3e692fe83fea6b26ab58c53d Mon Sep 17 00:00:00 2001 From: Tao Zeng Date: Mon, 25 Nov 2019 10:26:51 +0800 Subject: [PATCH] mm: fix Lost RAM too large problem when playing 4k [1/2] PD#SWPL-16990 Problem: Lost RAM will be over 200MB when playing 4K. Solution: Add cma pages in /proc/meminfo and give a information for android layer to count them. Verify: x301 Change-Id: I99d1ded53ed351a5cb0d24f0e03850a55ef0d272 Signed-off-by: Tao Zeng --- drivers/amlogic/memory_ext/aml_cma.c | 1 - drivers/amlogic/memory_ext/page_trace.c | 17 +++++++++++++++++ drivers/amlogic/memory_ext/vmap_stack.c | 2 +- include/linux/amlogic/vmap_stack.h | 3 +++ 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/drivers/amlogic/memory_ext/aml_cma.c b/drivers/amlogic/memory_ext/aml_cma.c index 3f82e3bb5b25..9a7d3289d96c 100644 --- a/drivers/amlogic/memory_ext/aml_cma.c +++ b/drivers/amlogic/memory_ext/aml_cma.c @@ -817,7 +817,6 @@ static const struct file_operations cma_dbg_file_ops = { static int __init aml_cma_init(void) { atomic_set(&cma_allocate, 0); - atomic_long_set(&nr_cma_allocated, 0); dentry = proc_create("cma_debug", 0644, NULL, &cma_dbg_file_ops); if (IS_ERR_OR_NULL(dentry)) { diff --git a/drivers/amlogic/memory_ext/page_trace.c b/drivers/amlogic/memory_ext/page_trace.c index 658441205bcf..e23c414adee0 100644 --- a/drivers/amlogic/memory_ext/page_trace.c +++ b/drivers/amlogic/memory_ext/page_trace.c @@ -30,6 +30,12 @@ #include #include #include +#ifdef CONFIG_AMLOGIC_VMAP +#include +#endif +#ifdef CONFIG_AMLOGIC_CMA +#include +#endif #include #include @@ -1703,3 +1709,14 @@ void __init page_trace_mem_init(void) #endif } +void arch_report_meminfo(struct seq_file *m) +{ +#ifdef CONFIG_AMLOGIC_CMA + seq_printf(m, "DriverCma: %8ld kB\n", + get_cma_allocated() * (1 << (PAGE_SHIFT - 10))); +#endif +#ifdef CONFIG_AMLOGIC_VMAP + vmap_report_meminfo(m); +#endif +} + diff --git a/drivers/amlogic/memory_ext/vmap_stack.c b/drivers/amlogic/memory_ext/vmap_stack.c index 59b64ff02cf8..269f0932d123 100644 --- a/drivers/amlogic/memory_ext/vmap_stack.c +++ b/drivers/amlogic/memory_ext/vmap_stack.c @@ -602,7 +602,7 @@ static int shrink_vm_stack(unsigned long low, unsigned long high) return pages; } -void arch_report_meminfo(struct seq_file *m) +void vmap_report_meminfo(struct seq_file *m) { unsigned long kb = 1 << (PAGE_SHIFT - 10); unsigned long tmp1, tmp2, tmp3; diff --git a/include/linux/amlogic/vmap_stack.h b/include/linux/amlogic/vmap_stack.h index 1004a09d9b07..330011257d7f 100644 --- a/include/linux/amlogic/vmap_stack.h +++ b/include/linux/amlogic/vmap_stack.h @@ -18,6 +18,8 @@ #ifndef __VMAP_STACK_H__ #define __VMAP_STACK_H__ +#include + #define STACK_SHRINK_THRESHOLD (PAGE_SIZE + 1024) #define STACK_SHRINK_SLEEP (HZ) #ifdef CONFIG_64BIT @@ -79,6 +81,7 @@ extern int is_vmap_addr(unsigned long addr); extern void aml_stack_free(struct task_struct *tsk); extern void *aml_stack_alloc(int node, struct task_struct *tsk); extern void aml_account_task_stack(struct task_struct *tsk, int account); +void vmap_report_meminfo(struct seq_file *m); #ifdef CONFIG_ARM extern int on_irq_stack(unsigned long sp, int cpu); #endif