linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] memcg/hugetlb: Rework memcg hugetlb charging
@ 2024-11-08 21:29 Joshua Hahn
  2024-11-08 21:29 ` [PATCH 1/3] memcg/hugetlb: Introduce memcg_accounts_hugetlb Joshua Hahn
                   ` (2 more replies)
  0 siblings, 3 replies; 18+ messages in thread
From: Joshua Hahn @ 2024-11-08 21:29 UTC (permalink / raw)
  To: shakeel.butt
  Cc: hannes, mhocko, roman.gushchin, muchun.song, akpm, cgroups,
	linux-mm, linux-kernel, kernel-team

This series cleans up memcg's hugetlb charging logic by deprecating the
current memcg hugetlb try-charge + {commit, cancel} logic present in
alloc_hugetlb_folio. A single function mem_cgroup_charge_hugetlb takes
its place instead. This makes the code more maintainable by simplifying
the error path and reduces memcg's footprint in hugetlb logic.

This patch introduces a few changes in the hugetlb folio allocation
error path:
(a) Instead of having multiple return points, we consolidate them to
    two: one for reaching the memcg limit or running out of memory
    (-ENOMEM) and one for hugetlb allocation fails / limit being
    reached (-ENOSPC).
(b) Previously, the memcg limit was checked before the folio is acquired,
    meaning the hugeTLB folio isn't acquired if the limit is reached.
    This patch performs the charging after the folio is reached, meaning
    if memcg's limit is reached, the acquired folio is freed right away.

This patch builds on two earlier patch series: [2] which adds memcg
hugeTLB counters, and [3] which deprecates charge moving and removes the
last references to mem_cgroup_cancel_charge. The request for this cleanup
can be found in [2].

Suggested-by: Shakeel Butt <shakeel.butt@linux.dev>
Signed-off-by: Joshua Hahn <joshua.hahnjy@gmail.com>

[1] https://lore.kernel.org/all/20231006184629.155543-1-nphamcs@gmail.com/
[2] https://lore.kernel.org/all/20241101204402.1885383-1-joshua.hahnjy@gmail.com/
[3] https://lore.kernel.org/linux-mm/20241025012304.2473312-1-shakeel.butt@linux.dev/

---
Changelog
v2:
  * Removed declaration of memcg_accounts_hugetlb from memcontrol.h
  * Moved second call to memcg_accounts_hugetlb from 2nd patch to 1st
  * Changed error behavior in alloc_hugetlb_folio: v1 included a bug
    that uncharged hugetlb_cgroup twice when memecg's limit was reached
  * mem_cgroup_charge_hugetlb no longer called with hugetlb_lock held
  * Moved mem_cgroup_hugetlb_{try, charge} deprecation to patch 3
  * mem_cgroup_charge_hugetlb always decrements memcg's refcount
  * Fully cleaned up mem_cgroup_{cancel,commit}_charge
  * Fixed typos
Joshua Hahn (3):
  memcg/hugetlb: Introduce memcg_accounts_hugetlb
  memcg/hugetlb: Introduce mem_cgroup_charge_hugetlb
  memcg/hugetlb: Deprecate memcg hugetlb try-commit-cancel protocol

 include/linux/memcontrol.h | 22 +---------
 mm/hugetlb.c               | 34 +++++----------
 mm/memcontrol.c            | 89 +++++++++++++-------------------------
 3 files changed, 43 insertions(+), 102 deletions(-)

-- 
2.43.5



^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2024-11-11  6:33 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-08 21:29 [PATCH 0/3] memcg/hugetlb: Rework memcg hugetlb charging Joshua Hahn
2024-11-08 21:29 ` [PATCH 1/3] memcg/hugetlb: Introduce memcg_accounts_hugetlb Joshua Hahn
2024-11-08 22:21   ` Shakeel Butt
2024-11-08 23:03     ` Yosry Ahmed
2024-11-09 18:31       ` Joshua Hahn
2024-11-08 21:29 ` [PATCH 2/3] memcg/hugetlb: Introduce mem_cgroup_charge_hugetlb Joshua Hahn
2024-11-08 22:42   ` Shakeel Butt
2024-11-09 18:58     ` Joshua Hahn
2024-11-11  6:33       ` Shakeel Butt
2024-11-09  1:03   ` SeongJae Park
2024-11-09 18:41     ` Joshua Hahn
2024-11-09 20:52       ` SeongJae Park
2024-11-09  3:42   ` kernel test robot
2024-11-09  5:24   ` kernel test robot
2024-11-08 21:29 ` [PATCH 3/3] memcg/hugetlb: Deprecate memcg hugetlb try-commit-cancel protocol Joshua Hahn
2024-11-08 22:43   ` Shakeel Butt
2024-11-08 23:07   ` Yosry Ahmed
2024-11-09 18:34     ` Joshua Hahn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox