With the (re)introduction of the try-commit-cancel charging protocol for HugeTLB's use, mem_cgroup_charge_hugetlb() is now redundant. Remove the function's implementation from mm/memcontrol.c and its declaration from include/linux/memcontrol.h No functional change intended. Signed-off-by: Ackerley Tng --- include/linux/memcontrol.h | 7 ------- mm/memcontrol.c | 34 ---------------------------------- 2 files changed, 41 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 59eab4caa01fa..572ad695afa40 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -668,8 +668,6 @@ static inline int mem_cgroup_charge(struct folio *folio, struct mm_struct *mm, int mem_cgroup_hugetlb_try_charge(struct mem_cgroup *memcg, gfp_t gfp, long nr_pages); -int mem_cgroup_charge_hugetlb(struct folio* folio, gfp_t gfp); - int mem_cgroup_swapin_charge_folio(struct folio *folio, struct mm_struct *mm, gfp_t gfp, swp_entry_t entry); @@ -1158,11 +1156,6 @@ static inline int mem_cgroup_hugetlb_try_charge(struct mem_cgroup *memcg, return 0; } -static inline int mem_cgroup_charge_hugetlb(struct folio* folio, gfp_t gfp) -{ - return 0; -} - static inline int mem_cgroup_swapin_charge_folio(struct folio *folio, struct mm_struct *mm, gfp_t gfp, swp_entry_t entry) { diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 70d762ba465b1..87d22db5a4bd3 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -4855,40 +4855,6 @@ int mem_cgroup_hugetlb_try_charge(struct mem_cgroup *memcg, gfp_t gfp, return 0; } -/** - * mem_cgroup_charge_hugetlb - charge the memcg for a hugetlb folio - * @folio: folio being charged - * @gfp: reclaim mode - * - * This function is called when allocating a huge page folio, after the page has - * already been obtained and charged to the appropriate hugetlb cgroup - * controller (if it is enabled). - * - * Returns ENOMEM if the memcg is already full. - * Returns 0 if either the charge was successful, or if we skip the charging. - */ -int mem_cgroup_charge_hugetlb(struct folio *folio, gfp_t gfp) -{ - struct mem_cgroup *memcg = get_mem_cgroup_from_current(); - int ret = 0; - - /* - * Even memcg does not account for hugetlb, we still want to update - * system-level stats via lruvec_stat_mod_folio. Return 0, and skip - * charging the memcg. - */ - if (mem_cgroup_disabled() || !memcg_accounts_hugetlb() || - !memcg || !cgroup_subsys_on_dfl(memory_cgrp_subsys)) - goto out; - - if (charge_memcg(folio, memcg, gfp)) - ret = -ENOMEM; - -out: - mem_cgroup_put(memcg); - return ret; -} - /** * mem_cgroup_swapin_charge_folio - Charge a newly allocated folio for swapin. * @folio: folio to charge. -- 2.53.0.310.g728cabbaf7-goog