Files
linux/include/linux/amlogic/vmap_stack.h
Tao Zeng ea094c64aa 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 <tao.zeng@amlogic.com>
2023-04-21 13:52:34 +09:00

90 lines
2.7 KiB
C

/*
* include/linux/amlogic/vmap_stack.h
*
* Copyright (C) 2017 Amlogic, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
*/
#ifndef __VMAP_STACK_H__
#define __VMAP_STACK_H__
#include <linux/seq_file.h>
#define STACK_SHRINK_THRESHOLD (PAGE_SIZE + 1024)
#define STACK_SHRINK_SLEEP (HZ)
#ifdef CONFIG_64BIT
#define VM_STACK_AREA_SIZE SZ_512M
#define VMAP_ADDR_START VMALLOC_START
#define VMAP_ADDR_END VMALLOC_END
#define VMAP_ALIGN VM_STACK_AREA_SIZE
#else
/* currently support max 6144 tasks on 32bit */
#define VM_STACK_AREA_SIZE (SZ_64M - SZ_16M)
#ifdef CONFIG_AMLOGIC_KASAN32 /* change place if open kasan */
#define VMAP_ADDR_START VMALLOC_START
#define VMAP_ADDR_END (VMALLOC_START + VM_STACK_AREA_SIZE)
#else
#define VMAP_ADDR_START MODULES_VADDR
#define VMAP_ADDR_END MODULES_END
#endif /* CONFIG_AMLOGIC_KASAN32 */
#define VMAP_ALIGN SZ_64M
#endif
#define STACK_TOP_PAGE_OFF (THREAD_SIZE - PAGE_SIZE)
#define MAX_TASKS (VM_STACK_AREA_SIZE / THREAD_SIZE)
#define VMAP_PAGE_FLAG (__GFP_ZERO | __GFP_HIGH |\
__GFP_ATOMIC | __GFP_REPEAT)
#ifdef CONFIG_KASAN
#define VMAP_CACHE_PAGE_ORDER 7
#else
#define VMAP_CACHE_PAGE_ORDER 5
#endif
#define VMAP_CACHE_PAGE (1 << VMAP_CACHE_PAGE_ORDER)
#define CACHE_MAINTAIN_DELAY (HZ / 2)
struct aml_vmap {
spinlock_t vmap_lock;
unsigned int start_bit;
int cached_pages;
struct vm_struct *root_vm;
unsigned long *bitmap;
struct list_head list;
struct delayed_work mwork;
spinlock_t page_lock;
};
#ifndef CONFIG_ARM64
extern void *irq_stack[NR_CPUS];
#endif
extern int handle_vmap_fault(unsigned long addr,
unsigned int esr, struct pt_regs *regs);
extern bool on_vmap_stack(unsigned long sp, int cpu);
extern void __setup_vmap_stack(unsigned long off);
extern void update_vmap_stack(int diff);
extern int get_vmap_stack_size(void);
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
extern struct page *check_pte_exist(unsigned long addr);
#endif /* __VMAP_STACK_H__ */