From c0b27cdcc74fbd4b9809d0d9dfcbf46014eb6af8 Mon Sep 17 00:00:00 2001 From: Jianan Huang Date: Tue, 15 Oct 2024 15:13:31 +0800 Subject: [PATCH] ANDROID: mm: export mem_cgroup_move_account Export mem_cgroup_move_account to migrate folios between different memcgs. This is to achieve more accurate memory reclamation. Bug: 373540729 Change-Id: I77ac12fdc25bae90f37f725be1a168da52f02abd Signed-off-by: Jianan Huang (cherry picked from commit c031476ae982c66d0f0674eb0a5c1ee03e825fd7) --- include/linux/memcontrol.h | 13 +++++++++++++ mm/memcontrol.c | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index a0e507337acc..67c055298914 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -357,6 +357,11 @@ enum page_memcg_data_flags { static inline bool folio_memcg_kmem(struct folio *folio); +int mem_cgroup_move_account(struct page *page, + bool compound, + struct mem_cgroup *from, + struct mem_cgroup *to); + /* * After the initialization objcg->memcg is always pointing at * a valid memcg, but can be atomically swapped to the parent memcg. @@ -1188,6 +1193,14 @@ static inline bool PageMemcgKmem(struct page *page) return false; } +static inline int mem_cgroup_move_account(struct page *page, + bool compound, + struct mem_cgroup *from, + struct mem_cgroup *to) +{ + return 0; +} + static inline bool mem_cgroup_is_root(struct mem_cgroup *memcg) { return true; diff --git a/mm/memcontrol.c b/mm/memcontrol.c index ee5e370de64f..f07b1e135fd2 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -5750,7 +5750,7 @@ static struct page *mc_handle_file_pte(struct vm_area_struct *vma, * This function doesn't do "charge" to new cgroup and doesn't do "uncharge" * from old cgroup. */ -static int mem_cgroup_move_account(struct page *page, +int mem_cgroup_move_account(struct page *page, bool compound, struct mem_cgroup *from, struct mem_cgroup *to) @@ -5861,6 +5861,7 @@ out_unlock: out: return ret; } +EXPORT_SYMBOL_GPL(mem_cgroup_move_account); /** * get_mctgt_type - get target type of moving charge