linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] memcg/hugetlb: Rework memcg hugetlb charging
@ 2024-11-06 22:14 Joshua Hahn
  2024-11-06 22:14 ` [PATCH 1/2] memcg/hugetlb: Introduce memcg_accounts_hugetlb Joshua Hahn
  2024-11-06 22:14 ` [PATCH 2/2] memcg/hugetlb: Deprecate hugetlb memcg try-commit-cancel charging Joshua Hahn
  0 siblings, 2 replies; 11+ messages in thread
From: Joshua Hahn @ 2024-11-06 22:14 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 allocation error path:
(a) Instead of having multiple return paths, we consolidate them into
    a single error path. Failing when memcg's limit is reached no longer
    returns -ENOMEM, but -ENOSPEC like the other errors as well. This
    makes the memory controller error behavior the same as hugeTLB's.
    With this said, no callers handle -ENOMEM separately, so no existing
    behavior is affected by this change.
(b) Previously, the memcg limit is 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. 

In the first patch, a check for whether memcg accounts hugetlb [1] is
introduced. In the second patch, the charging mechanism is reworked.

This patch builds on earlier work [2] which adds memcg hugeTLB counters.
The request for this rework is also part of the original thread.

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/

Joshua Hahn (2):
  Introduce memcg_accounts_hugetlb
  Deprecate hugetlb memcg try-commit-cancel charging

 include/linux/memcontrol.h |  5 ++--
 mm/hugetlb.c               | 35 ++++++++++------------------
 mm/memcontrol.c            | 47 +++++++++++++++-----------------------
 3 files changed, 33 insertions(+), 54 deletions(-)


base-commit: 34d664f9c954f4bce85be506bd81024f64dd5fda
-- 
2.43.5



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

end of thread, other threads:[~2024-11-07 19:28 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-06 22:14 [PATCH 0/2] memcg/hugetlb: Rework memcg hugetlb charging Joshua Hahn
2024-11-06 22:14 ` [PATCH 1/2] memcg/hugetlb: Introduce memcg_accounts_hugetlb Joshua Hahn
2024-11-06 23:17   ` Shakeel Butt
2024-11-07  0:21   ` SeongJae Park
2024-11-07 15:07     ` Joshua Hahn
2024-11-06 22:14 ` [PATCH 2/2] memcg/hugetlb: Deprecate hugetlb memcg try-commit-cancel charging Joshua Hahn
2024-11-06 23:50   ` Shakeel Butt
2024-11-07 15:07     ` Joshua Hahn
2024-11-07 18:27     ` Joshua Hahn
2024-11-07 18:58       ` Shakeel Butt
2024-11-07 19:28         ` Joshua Hahn

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